public static function run($r)
 {
     $missing_titles = pts_external_dependencies::missing_dependency_titles();
     pts_client::$display->generic_heading(count($missing_titles) . ' of ' . count(pts_external_dependencies::all_dependency_names()) . ' External Dependencies Missing');
     echo pts_user_io::display_text_list($missing_titles);
     echo PHP_EOL;
 }
 public static function run($r)
 {
     $all_dependencies = pts_external_dependencies::all_dependency_titles();
     pts_client::$display->generic_heading(count($all_dependencies) . ' External Dependencies Available');
     echo pts_user_io::display_text_list($all_dependencies);
     echo PHP_EOL;
 }
 private static function install_packages_on_system($os_packages_to_install)
 {
     // Do the actual installing process of packages using the distribution's package management system
     $vendor_install_file = PTS_EXDEP_PATH . 'scripts/install-' . self::vendor_identifier('installer') . '-packages.sh';
     // Rebuild the array index since some OS package XML tags provide multiple package names in a single string
     $os_packages_to_install = explode(' ', implode(' ', $os_packages_to_install));
     if (is_file($vendor_install_file)) {
         // hook into pts_client::$display here if it's desired
         echo PHP_EOL . 'The following dependencies are needed and will be installed: ' . PHP_EOL . PHP_EOL;
         echo pts_user_io::display_text_list($os_packages_to_install);
         echo PHP_EOL . 'This process may take several minutes.' . PHP_EOL;
         echo shell_exec('sh ' . $vendor_install_file . ' ' . implode(' ', $os_packages_to_install));
     } else {
         if (phodevi::is_macosx() == false) {
             echo 'Distribution install script not found!';
         }
     }
 }
 public static function cleanup_tests_to_run(&$to_run_objects)
 {
     $skip_tests = ($e = pts_client::read_env('SKIP_TESTS')) ? pts_strings::comma_explode($e) : false;
     $tests_verified = array();
     $tests_missing = array();
     foreach ($to_run_objects as &$run_object) {
         if ($skip_tests && (in_array($run_object->get_identifier(false), $skip_tests) || $run_object instanceof pts_test_profile && in_array($run_object->get_identifier_base_name(), $skip_tests))) {
             pts_client::$display->generic_sub_heading('Skipping: ' . $run_object->get_identifier());
             continue;
         } else {
             if ($run_object instanceof pts_test_profile) {
                 if ($run_object->get_title() == null) {
                     pts_client::$display->generic_sub_heading('Not A Test: ' . $run_object);
                     continue;
                 } else {
                     if ($run_object->is_supported(false) == false) {
                         continue;
                     }
                     if ($run_object->is_test_installed() == false) {
                         // Check to see if older version of test is currently installed
                         // TODO: show change-log between installed versions and upstream
                         array_push($tests_missing, $run_object);
                         continue;
                     }
                 }
             } else {
                 if ($run_object instanceof pts_result_file) {
                     $num_installed = 0;
                     foreach ($run_object->get_contained_test_profiles() as $test_profile) {
                         if ($test_profile == null || $test_profile->get_identifier() == null || $test_profile->is_supported(false) == false) {
                             continue;
                         } else {
                             if ($test_profile->is_test_installed() == false) {
                                 array_push($tests_missing, $test_profile);
                             } else {
                                 $num_installed++;
                             }
                         }
                     }
                     if ($num_installed == 0) {
                         continue;
                     }
                 } else {
                     if ($run_object instanceof pts_test_suite || $run_object instanceof pts_virtual_test_suite || $run_object instanceof pts_virtual_test_queue) {
                         if ($run_object->is_core_version_supported() == false) {
                             pts_client::$display->generic_sub_heading($run_object->get_title() . ' is a suite not supported by this version of the Phoronix Test Suite.');
                             continue;
                         }
                         $num_installed = 0;
                         foreach ($run_object->get_contained_test_profiles() as $test_profile) {
                             if ($test_profile == null || $test_profile->get_identifier() == null || $test_profile->is_supported(false) == false) {
                                 continue;
                             }
                             if ($test_profile->is_test_installed() == false) {
                                 array_push($tests_missing, $test_profile);
                             } else {
                                 $num_installed++;
                             }
                         }
                         if ($num_installed == 0) {
                             continue;
                         }
                     } else {
                         pts_client::$display->generic_sub_heading('Not Recognized: ' . $run_object);
                         continue;
                     }
                 }
             }
         }
         array_push($tests_verified, $run_object);
     }
     $to_run_objects = $tests_verified;
     if (count($tests_missing) > 0 && !defined('PHOROMATIC_PROCESS')) {
         $tests_missing = array_unique($tests_missing);
         if (count($tests_missing) == 1) {
             trigger_error($tests_missing[0] . ' is not installed.', E_USER_ERROR);
             // PHP_EOL . 'To install, run: phoronix-test-suite install ' . $tests_missing[0]
         } else {
             $message = PHP_EOL . PHP_EOL . 'Multiple tests are not installed:' . PHP_EOL . PHP_EOL;
             $message .= pts_user_io::display_text_list($tests_missing);
             //$message .= PHP_EOL . 'To install, run: phoronix-test-suite install ' . implode(' ', $tests_missing) . PHP_EOL . PHP_EOL;
             echo $message;
         }
         if (!$this->batch_mode && !$this->auto_mode && pts_client::current_command() != 'benchmark') {
             $stop_and_install = pts_user_io::prompt_bool_input('Would you like to stop and install these tests now', true);
             if ($stop_and_install) {
                 pts_test_installer::standard_install($tests_missing);
                 self::cleanup_tests_to_run($to_run_objects);
             }
         }
     }
     return true;
 }
 public static function recently_saved_results()
 {
     $recent_results = pts_tests::test_results_by_date();
     if (count($recent_results) > 0) {
         $recent_results = array_slice($recent_results, 0, 5, true);
         $res_length = strlen(pts_strings::find_longest_string($recent_results)) + 2;
         $current_time = time();
         foreach ($recent_results as $m_time => &$recent_result) {
             $days = floor(($current_time - $m_time) / 86400);
             $recent_result = sprintf('%-' . $res_length . 'ls [%-ls]', $recent_result, $days == 0 ? 'Today' : pts_strings::days_ago_format_string($days) . ' old');
         }
         echo PHP_EOL . 'Recently Saved Test Results:' . PHP_EOL;
         echo pts_user_io::display_text_list($recent_results) . PHP_EOL;
         return true;
     }
     return false;
 }
 public static function run($args)
 {
     echo PHP_EOL;
     if ($args[0] == 'pts/all') {
         $args = pts_openbenchmarking::available_tests(false);
     }
     foreach ($args as $arg) {
         $o = pts_types::identifier_to_object($arg);
         if ($o instanceof pts_test_suite) {
             pts_client::$display->generic_heading($o->get_title());
             echo 'Run Identifier: ' . $o->get_identifier() . PHP_EOL;
             echo 'Suite Version: ' . $o->get_version() . PHP_EOL;
             echo 'Maintainer: ' . $o->get_maintainer() . PHP_EOL;
             echo 'Suite Type: ' . $o->get_suite_type() . PHP_EOL;
             echo 'Unique Tests: ' . $o->get_unique_test_count() . PHP_EOL;
             echo 'Suite Description: ' . $o->get_description() . PHP_EOL;
             echo PHP_EOL;
             echo $o->pts_format_contained_tests_string();
             echo PHP_EOL;
         } else {
             if ($o instanceof pts_test_profile) {
                 $test_title = $o->get_title();
                 $test_version = $o->get_app_version();
                 if (!empty($test_version)) {
                     $test_title .= ' ' . $test_version;
                 }
                 pts_client::$display->generic_heading($test_title);
                 echo 'Run Identifier: ' . $o->get_identifier() . PHP_EOL;
                 echo 'Profile Version: ' . $o->get_test_profile_version() . PHP_EOL;
                 echo 'Maintainer: ' . $o->get_maintainer() . PHP_EOL;
                 echo 'Test Type: ' . $o->get_test_hardware_type() . PHP_EOL;
                 echo 'Software Type: ' . $o->get_test_software_type() . PHP_EOL;
                 echo 'License Type: ' . $o->get_license() . PHP_EOL;
                 echo 'Test Status: ' . $o->get_status() . PHP_EOL;
                 echo 'Project Web-Site: ' . $o->get_project_url() . PHP_EOL;
                 if ($o->get_estimated_run_time() > 1) {
                     echo 'Estimated Run-Time: ' . $o->get_estimated_run_time() . ' Seconds' . PHP_EOL;
                 }
                 $download_size = $o->get_download_size();
                 if (!empty($download_size)) {
                     echo 'Download Size: ' . $download_size . ' MB' . PHP_EOL;
                 }
                 $environment_size = $o->get_environment_size();
                 if (!empty($environment_size)) {
                     echo 'Environment Size: ' . $environment_size . ' MB' . PHP_EOL;
                 }
                 echo PHP_EOL . 'Description: ' . $o->get_description() . PHP_EOL;
                 if ($o->test_installation != false) {
                     $last_run = $o->test_installation->get_last_run_date();
                     $last_run = $last_run == '0000-00-00' ? 'Never' : $last_run;
                     $avg_time = $o->test_installation->get_average_run_time();
                     $avg_time = !empty($avg_time) ? pts_strings::format_time($avg_time, 'SECONDS') : 'N/A';
                     $latest_time = $o->test_installation->get_latest_run_time();
                     $latest_time = !empty($latest_time) ? pts_strings::format_time($latest_time, 'SECONDS') : 'N/A';
                     echo PHP_EOL . 'Test Installed: Yes' . PHP_EOL;
                     echo 'Last Run: ' . $last_run . PHP_EOL;
                     if ($last_run != 'Never') {
                         if ($o->test_installation->get_run_count() > 1) {
                             echo 'Average Run-Time: ' . $avg_time . PHP_EOL;
                         }
                         echo 'Latest Run-Time: ' . $latest_time . PHP_EOL;
                         echo 'Times Run: ' . $o->test_installation->get_run_count() . PHP_EOL;
                     }
                 } else {
                     echo PHP_EOL . 'Test Installed: No' . PHP_EOL;
                 }
                 $dependencies = $o->get_external_dependencies();
                 if (!empty($dependencies) && !empty($dependencies[0])) {
                     echo PHP_EOL . 'Software Dependencies:' . PHP_EOL;
                     echo pts_user_io::display_text_list($o->get_dependency_names());
                 }
                 echo PHP_EOL;
             } else {
                 if ($o instanceof pts_result_file) {
                     echo 'Title: ' . $o->get_title() . PHP_EOL . 'Identifier: ' . $o->get_identifier() . PHP_EOL;
                     echo PHP_EOL . 'Test Result Identifiers:' . PHP_EOL;
                     echo pts_user_io::display_text_list($o->get_system_identifiers());
                     $test_titles = array();
                     foreach ($o->get_result_objects() as $result_object) {
                         if ($result_object->test_profile->get_display_format() == 'BAR_GRAPH') {
                             array_push($test_titles, $result_object->test_profile->get_title());
                         }
                     }
                     if (count($test_titles) > 0) {
                         echo PHP_EOL . 'Contained Tests:' . PHP_EOL;
                         echo pts_user_io::display_text_list(array_unique($test_titles));
                     }
                     echo PHP_EOL;
                 } else {
                     if ($o instanceof pts_virtual_test_suite) {
                         pts_client::$display->generic_heading($o->get_title());
                         echo 'Virtual Suite Description: ' . $o->get_description() . PHP_EOL . PHP_EOL;
                         foreach ($o->get_contained_test_profiles() as $test_profile) {
                             echo '- ' . $test_profile . PHP_EOL;
                         }
                         echo PHP_EOL;
                     }
                 }
             }
         }
     }
 }
 public static function run($r)
 {
     $installed_titles = pts_external_dependencies::installed_dependency_titles();
     pts_client::$display->generic_heading(count($installed_titles) . ' of ' . count(pts_external_dependencies::all_dependency_names()) . ' External Dependencies Installed');
     echo pts_user_io::display_text_list($installed_titles);
 }