Esempio n. 1
0
 public static function upload_unscheduled_result($args)
 {
     $server_setup = self::setup_server_addressing($args);
     if (!$server_setup) {
         return false;
     }
     $uploads = 0;
     foreach ($args as $arg) {
         if (pts_types::is_result_file($arg)) {
             $uploads++;
             echo PHP_EOL . 'Uploading: ' . $arg . PHP_EOL;
             $result_file = pts_types::identifier_to_object($arg);
             $server_response = self::upload_test_result($result_file);
             $server_response = json_decode($server_response, true);
             if (isset($server_response['phoromatic']['response'])) {
                 echo '   Result Uploaded' . PHP_EOL;
             } else {
                 echo '   Upload Failed' . PHP_EOL;
             }
         }
     }
     if ($uploads == 0) {
         echo PHP_EOL . 'No Result Files Found To Upload.' . PHP_EOL;
     }
 }
 public static function run($r)
 {
     $result_file = false;
     if (count($r) != 0) {
         $result_file = $r[0];
     }
     $suite_name = pts_user_io::prompt_user_input('Enter name of suite');
     $suite_test_type = pts_user_io::prompt_text_menu('Select test type', pts_types::subsystem_targets());
     $suite_maintainer = pts_user_io::prompt_user_input('Enter suite maintainer name');
     $suite_description = pts_user_io::prompt_user_input('Enter suite description');
     $suite_writer = new pts_test_suite_writer();
     $suite_writer->add_suite_information($suite_name, '1.0.0', $suite_maintainer, $suite_test_type, $suite_description);
     // Read results file
     $result_file = new pts_result_file($result_file);
     foreach ($result_file->get_result_objects() as $result_object) {
         $suite_writer->add_to_suite_from_result_object($result_object);
     }
     // Finish it off
     $suite_identifier = pts_test_run_manager::clean_save_name($suite_name);
     mkdir(PTS_TEST_SUITE_PATH . 'local/' . $suite_identifier);
     $save_to = PTS_TEST_SUITE_PATH . 'local/' . $suite_identifier . '/suite-definition.xml';
     if ($suite_writer->save_xml($save_to) != false) {
         echo PHP_EOL . PHP_EOL . 'Saved To: ' . $save_to . PHP_EOL . 'To run this suite, type: phoronix-test-suite benchmark ' . $suite_identifier . PHP_EOL . PHP_EOL;
     }
 }
 public static function run($r)
 {
     if (($test_suite = pts_types::identifier_to_object($r[0])) != false) {
         pts_client::$display->generic_heading($r[0]);
         pts_validation::validate_test_suite($test_suite);
     }
 }
 public static function run($r)
 {
     foreach (pts_types::identifiers_to_test_profile_objects($r, true, true) as $test_profile) {
         pts_client::$display->generic_heading($test_profile);
         pts_validation::validate_test_profile($test_profile);
     }
 }
 public static function run($r)
 {
     $to_run = array();
     foreach (pts_types::identifiers_to_test_profile_objects($r, false, true) as $test_profile) {
         pts_arrays::unique_push($to_run, $test_profile);
     }
     pts_test_run_manager::standard_run($to_run);
 }
 public static function run($r)
 {
     $result_file = pts_types::identifier_to_object($r[0]);
     $upload_url = pts_openbenchmarking::upload_test_result($result_file);
     if ($upload_url) {
         pts_client::display_web_page($upload_url, 'Do you want to view the results on OpenBenchmarking.org', true);
     } else {
         echo PHP_EOL . 'Results Failed To Upload.' . PHP_EOL;
     }
 }
 public static function run($r)
 {
     $test_profiles = pts_types::identifiers_to_test_profile_objects($r, true, true);
     if (count($test_profiles) > 0) {
         echo PHP_EOL . 'Downloading Test Files For: ' . implode(' ', $test_profiles);
         pts_test_installer::only_download_test_files($test_profiles, pts_client::read_env('DOWNLOAD_CACHE_LOCATION'));
     } else {
         echo PHP_EOL . 'Nothing found to download.' . PHP_EOL;
     }
 }
 public static function test_profile_permitted_files()
 {
     $allowed_files = array('downloads.xml', 'test-definition.xml', 'results-definition.xml', 'install.sh', 'support-check.sh', 'pre.sh', 'post.sh', 'interim.sh', 'post-cache-share.sh');
     foreach (pts_types::operating_systems() as $os) {
         $os = strtolower($os[0]);
         array_push($allowed_files, 'support-check_' . $os . '.sh');
         array_push($allowed_files, 'install_' . $os . '.sh');
         array_push($allowed_files, 'pre_' . $os . '.sh');
         array_push($allowed_files, 'post_' . $os . '.sh');
         array_push($allowed_files, 'interim_' . $os . '.sh');
     }
     return $allowed_files;
 }
 public function get_contained_test_result_objects()
 {
     $test_result_objects = array();
     $test_names = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/Test');
     $sub_modes = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/Mode');
     $sub_arguments = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/Arguments');
     $sub_arguments_description = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/Description');
     $override_test_options = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/OverrideTestOptions');
     for ($i = 0; $i < count($test_names); $i++) {
         $obj = pts_types::identifier_to_object($test_names[$i]);
         if ($obj instanceof pts_test_profile) {
             // Check for test profile values to override
             $override_options = array();
             if (!empty($override_test_options[$i])) {
                 foreach (explode(';', $override_test_options[$i]) as $override_string) {
                     $override_segments = pts_strings::trim_explode('=', $override_string);
                     if (count($override_segments) == 2 && !empty($override_segments[0]) && !empty($override_segments[1])) {
                         $override_options[$override_segments[0]] = $override_segments[1];
                     }
                 }
             }
             switch ($sub_modes[$i]) {
                 case 'BATCH':
                     $option_output = pts_test_run_options::batch_user_options($obj);
                     break;
                 case 'DEFAULTS':
                     $option_output = pts_test_run_options::default_user_options($obj);
                     break;
                 default:
                     $option_output = array(array($sub_arguments[$i]), array($sub_arguments_description[$i]));
                     break;
             }
             foreach (array_keys($option_output[0]) as $x) {
                 if ($override_options != null) {
                     $test_profile->set_override_values($override_options);
                 }
                 $test_result = new pts_test_result($obj);
                 $test_result->set_used_arguments($option_output[0][$x]);
                 $test_result->set_used_arguments_description($option_output[1][$x]);
                 array_push($test_result_objects, $test_result);
             }
         } else {
             if ($obj instanceof pts_test_suite) {
                 foreach ($obj->get_contained_test_result_objects() as $test_result) {
                     array_push($test_result_objects, $test_result);
                 }
             }
         }
     }
     return $test_result_objects;
 }
 public static function run($r)
 {
     pts_client::$display->generic_heading('Test Suite Creation');
     $suite_name = pts_user_io::prompt_user_input('Enter name of suite');
     $suite_test_type = pts_user_io::prompt_text_menu('Select test type', pts_types::subsystem_targets());
     $suite_maintainer = pts_user_io::prompt_user_input('Enter suite maintainer name');
     $suite_description = pts_user_io::prompt_user_input('Enter suite description');
     $possible_suites = pts_openbenchmarking::available_suites();
     $possible_tests = pts_openbenchmarking::available_tests();
     $suite_writer = new pts_test_suite_writer();
     $suite_writer->add_suite_information($suite_name, '1.0.0', $suite_maintainer, $suite_test_type, $suite_description);
     foreach ($r as $test_object) {
         $test_object = pts_types::identifier_to_object($test_object);
         if ($test_object instanceof pts_test_profile) {
             list($args, $description) = pts_test_run_options::prompt_user_options($test_object);
             for ($i = 0; $i < count($args); $i++) {
                 // Not binding the test profile version to this suite, otherwise change false to true
                 $suite_writer->add_to_suite($test_object->get_identifier(false), $args[$i], $description[$i]);
             }
         } else {
             if ($test_object instanceof pts_test_suite) {
                 $suite_writer->add_to_suite($test_object->get_identifier(), null, null);
             }
         }
     }
     $input_option = null;
     do {
         switch ($input_option) {
             case 'Add Test':
                 $test_to_add = pts_user_io::prompt_text_menu('Enter test name', $possible_tests);
                 $test_profile = new pts_test_profile($test_to_add);
                 list($args, $description) = pts_test_run_options::prompt_user_options($test_profile);
                 for ($i = 0; $i < count($args); $i++) {
                     $suite_writer->add_to_suite($test_to_add, $args[$i], $description[$i]);
                 }
                 break;
             case 'Add Sub-Suite':
                 $suite_to_add = pts_user_io::prompt_text_menu('Enter test suite', $possible_suites);
                 $suite_writer->add_to_suite($suite_to_add, null, null);
                 break;
         }
         echo PHP_EOL . 'Available Options:' . PHP_EOL;
         $input_option = pts_user_io::prompt_text_menu('Select next operation', array('Add Test', 'Add Sub-Suite', 'Save & Exit'));
     } while ($input_option != 'Save & Exit');
     $suite_identifier = $suite_writer->clean_save_name_string($suite_name);
     $save_to = PTS_TEST_SUITE_PATH . 'local/' . $suite_identifier . '/suite-definition.xml';
     mkdir(dirname($save_to));
     if ($suite_writer->save_xml($save_to) != false) {
         echo PHP_EOL . PHP_EOL . 'Saved To: ' . $save_to . PHP_EOL . 'To run this suite, type: phoronix-test-suite benchmark ' . $suite_identifier . PHP_EOL . PHP_EOL;
     }
 }
 public function get_contained_test_result_objects()
 {
     $test_result_objects = array();
     foreach ($this->tests as $test) {
         $obj = pts_types::identifier_to_object($test['test']);
         if ($obj instanceof pts_test_profile) {
             $test_result = new pts_test_result($obj);
             $test_result->set_used_arguments_description($test['option']);
             $test_result->set_used_arguments($test['option_value']);
             array_push($test_result_objects, $test_result);
         }
     }
     return $test_result_objects;
 }
 public static function run($r)
 {
     foreach (pts_types::identifiers_to_test_profile_objects($r, true, true) as $test_profile) {
         echo 'Checking: ' . $test_profile . PHP_EOL;
         foreach (pts_test_install_request::read_download_object_list($test_profile) as $test_file_download) {
             foreach ($test_file_download->get_download_url_array() as $url) {
                 $stream_context = pts_network::stream_context_create();
                 stream_context_set_params($stream_context, array('notification' => 'pts_stream_status_callback'));
                 $file_pointer = @fopen($url, 'r', false, $stream_context);
                 //fread($file_pointer, 1024);
                 if ($file_pointer == false) {
                     echo PHP_EOL . 'BAD URL: ' . $test_file_download->get_filename() . ' / ' . $url . PHP_EOL;
                 } else {
                     @fclose($file_pointer);
                 }
             }
         }
     }
 }
 public static function run($r)
 {
     if (pts_openbenchmarking_client::user_name() == false) {
         echo PHP_EOL . 'You must first be logged into an OpenBenchmarking.org account.' . PHP_EOL;
         echo PHP_EOL . 'Create An Account: http://openbenchmarking.org/';
         echo PHP_EOL . 'Log-In Command: phoronix-test-suite openbenchmarking-setup' . PHP_EOL . PHP_EOL;
         return false;
     }
     foreach (pts_types::identifiers_to_test_profile_objects($r, true, true) as $test_profile) {
         // validate_test_profile
         if (pts_validation::validate_test_profile($test_profile)) {
             pts_client::$display->generic_heading($test_profile);
             $zip_file = PTS_OPENBENCHMARKING_SCRATCH_PATH . $test_profile->get_identifier_base_name() . '-' . $test_profile->get_test_profile_version() . '.zip';
             $zip_created = pts_compression::zip_archive_create($zip_file, pts_file_io::glob($test_profile->get_resource_dir() . '*'));
             if ($zip_created == false) {
                 echo PHP_EOL . 'Failed to create zip file.' . PHP_EOL;
                 return false;
             }
             if (filesize($zip_file) > 104857) {
                 echo PHP_EOL . 'The test profile package is too big.' . PHP_EOL;
                 return false;
             }
             $commit_description = pts_user_io::prompt_user_input('Enter a test commit description', false);
             echo PHP_EOL;
             $server_response = pts_openbenchmarking::make_openbenchmarking_request('upload_test_profile', array('tp_identifier' => $test_profile->get_identifier_base_name(), 'tp_sha1' => sha1_file($zip_file), 'tp_zip' => base64_encode(file_get_contents($zip_file)), 'tp_zip_name' => basename($zip_file), 'commit_description' => $commit_description));
             echo PHP_EOL;
             $json = json_decode($server_response, true);
             if (isset($json['openbenchmarking']['upload']['error']) && !empty($json['openbenchmarking']['upload']['error'])) {
                 echo 'ERROR: ' . $json['openbenchmarking']['upload']['error'] . PHP_EOL;
             }
             if (isset($json['openbenchmarking']['upload']['id']) && !empty($json['openbenchmarking']['upload']['id'])) {
                 echo 'Command: phoronix-test-suite benchmark ' . $json['openbenchmarking']['upload']['id'] . PHP_EOL;
             }
             if (isset($json['openbenchmarking']['upload']['url']) && !empty($json['openbenchmarking']['upload']['url'])) {
                 pts_openbenchmarking::refresh_repository_lists(null, true);
                 echo 'URL: ' . $json['openbenchmarking']['upload']['url'] . PHP_EOL;
             }
             echo PHP_EOL;
             // TODO: chmod +x the .sh files, appropriate permissions elsewhere
             unlink($zip_file);
         }
     }
 }
 public static function run($r)
 {
     if (pts_openbenchmarking_client::user_name() == false) {
         echo PHP_EOL . 'You must first be logged into an OpenBenchmarking.org account.' . PHP_EOL;
         echo PHP_EOL . 'Create An Account: http://openbenchmarking.org/';
         echo PHP_EOL . 'Log-In Command: phoronix-test-suite openbenchmarking-setup' . PHP_EOL . PHP_EOL;
         return false;
     }
     if (($test_suite = pts_types::identifier_to_object($r[0])) != false) {
         pts_client::$display->generic_heading($r[0]);
         if (pts_validation::validate_test_suite($test_suite)) {
             $zip_file = PTS_OPENBENCHMARKING_SCRATCH_PATH . $test_suite->get_identifier(false) . '-' . $test_suite->get_version() . '.zip';
             $zip_created = pts_compression::zip_archive_create($zip_file, $test_suite->xml_parser->getFileLocation());
             if ($zip_created == false) {
                 echo PHP_EOL . 'Failed to create zip file.' . PHP_EOL;
                 return false;
             }
             $zip = new ZipArchive();
             $zip->open($zip_file);
             $zip->renameName(basename($test_suite->xml_parser->getFileLocation()), 'suite-definition.xml');
             $zip->close();
             $commit_description = pts_user_io::prompt_user_input('Enter a test commit description', false);
             echo PHP_EOL;
             $server_response = pts_openbenchmarking::make_openbenchmarking_request('upload_test_suite', array('ts_identifier' => $test_suite->get_identifier_base_name(), 'ts_sha1' => sha1_file($zip_file), 'ts_zip' => base64_encode(file_get_contents($zip_file)), 'ts_zip_name' => basename($zip_file), 'commit_description' => $commit_description));
             echo PHP_EOL;
             $json = json_decode($server_response, true);
             if (isset($json['openbenchmarking']['upload']['error']) && !empty($json['openbenchmarking']['upload']['error'])) {
                 echo 'ERROR: ' . $json['openbenchmarking']['upload']['error'] . PHP_EOL;
             }
             if (isset($json['openbenchmarking']['upload']['id']) && !empty($json['openbenchmarking']['upload']['id'])) {
                 echo 'Command: phoronix-test-suite benchmark ' . $json['openbenchmarking']['upload']['id'] . PHP_EOL;
             }
             if (isset($json['openbenchmarking']['upload']['url']) && !empty($json['openbenchmarking']['upload']['url'])) {
                 pts_openbenchmarking::refresh_repository_lists(null, true);
                 echo 'URL: ' . $json['openbenchmarking']['upload']['url'] . PHP_EOL;
             }
             echo PHP_EOL;
             unlink($zip_file);
         }
     }
 }
 public static function run($r)
 {
     $result_files_to_merge = array();
     foreach ($r as $result_file) {
         if (pts_types::is_result_file($result_file)) {
             array_push($result_files_to_merge, $result_file);
         }
     }
     if (count($result_files_to_merge) < 2) {
         echo PHP_EOL . 'At least two saved result names must be supplied.';
         return false;
     }
     do {
         $rand_file = rand(1000, 9999);
         $merge_to_file = 'merge-' . $rand_file . '/';
     } while (is_dir(PTS_SAVE_RESULTS_PATH . $merge_to_file));
     $merge_to_file .= 'composite.xml';
     // Merge Results
     $merged_results = call_user_func(array('pts_merge', 'merge_test_results_array'), $result_files_to_merge);
     pts_client::save_test_result($merge_to_file, $merged_results);
     echo 'Merged Results Saved To: ' . PTS_SAVE_RESULTS_PATH . $merge_to_file . PHP_EOL . PHP_EOL;
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . dirname($merge_to_file) . '/index.html');
 }
 public static function standard_install($items_to_install, $force_install = false, $no_prompts = false, $skip_tests_with_missing_dependencies = false)
 {
     // Refresh the pts_client::$display in case we need to run in debug mode
     if (pts_client::$display == false || !pts_client::$display instanceof pts_websocket_display_mode) {
         pts_client::init_display_mode();
     }
     // Create a lock
     $lock_path = pts_client::temporary_directory() . '/phoronix-test-suite.active';
     pts_client::create_lock($lock_path);
     // Get the test profiles
     $unknown_tests = array();
     $test_profiles = pts_types::identifiers_to_test_profile_objects($items_to_install, true, true, $unknown_tests);
     // Any external dependencies?
     pts_external_dependencies::install_dependencies($test_profiles, $no_prompts, $skip_tests_with_missing_dependencies);
     // Install tests
     if (!is_writable(pts_client::test_install_root_path())) {
         trigger_error('The test installation directory is not writable.' . PHP_EOL . 'Location: ' . pts_client::test_install_root_path(), E_USER_ERROR);
         return false;
     }
     pts_test_installer::start_install($test_profiles, $unknown_tests, $force_install, $no_prompts);
     pts_client::release_lock($lock_path);
     return $test_profiles;
 }
 public static function run($r)
 {
     // Force refresh of OB repository to ensure the latest profiles
     pts_openbenchmarking::refresh_repository_lists(null, true);
     // Determine cache location
     $dc_write_directory = pts_strings::add_trailing_slash(pts_strings::parse_for_home_directory(pts_config::read_user_config('PhoronixTestSuite/Options/Installation/CacheDirectory', PTS_DOWNLOAD_CACHE_PATH)));
     echo PHP_EOL . 'Download Cache Directory: ' . $dc_write_directory . PHP_EOL;
     if ($dc_write_directory == null || !is_writable($dc_write_directory)) {
         echo 'No writable download cache directory was found. A download cache cannot be created.' . PHP_EOL . PHP_EOL;
         return false;
     }
     if (!empty($r)) {
         $test_profiles = pts_types::identifiers_to_test_profile_objects($r, true, true);
         if (count($test_profiles) > 0) {
             echo PHP_EOL . 'Downloading Test Files For: ' . implode(' ', $test_profiles);
             pts_test_installer::only_download_test_files($test_profiles, $dc_write_directory);
         }
     }
     $json_download_cache = array('phoronix-test-suite' => array('main' => array('generated' => time()), 'download-cache' => array()));
     foreach (pts_tests::partially_installed_tests() as $test) {
         $test_profile = new pts_test_profile($test);
         echo PHP_EOL . 'Checking Downloads For: ' . $test . PHP_EOL;
         foreach (pts_test_install_request::read_download_object_list($test_profile, false) as $file) {
             $cached_valid = false;
             if (is_file($dc_write_directory . $file->get_filename()) && $file->check_file_hash($dc_write_directory . $file->get_filename())) {
                 echo '   Previously Cached: ' . $file->get_filename() . PHP_EOL;
                 $cached_valid = true;
             } else {
                 if (is_dir($test_profile->get_install_dir())) {
                     if (is_file($test_profile->get_install_dir() . $file->get_filename()) && $file->check_file_hash($test_profile->get_install_dir() . $file->get_filename())) {
                         echo '   Caching: ' . $file->get_filename() . PHP_EOL;
                         if (copy($test_profile->get_install_dir() . $file->get_filename(), $dc_write_directory . $file->get_filename())) {
                             $cached_valid = true;
                         }
                     }
                 }
             }
             if ($cached_valid) {
                 if (!isset($json_download_cache['phoronix-test-suite']['download-cache'][$file->get_filename()])) {
                     $json_download_cache['phoronix-test-suite']['download-cache'][$file->get_filename()] = array('file_name' => $file->get_filename(), 'file_size' => $file->get_filesize(), 'associated_tests' => array($test_profile->get_identifier()), 'md5' => $file->get_md5(), 'sha256' => $file->get_sha256());
                 } else {
                     if ($file->get_md5() == $json_download_cache['phoronix-test-suite']['download-cache'][$file->get_filename()]['md5'] && $file->get_sha256() == $json_download_cache['phoronix-test-suite']['download-cache'][$file->get_filename()]['sha256']) {
                         array_push($json_download_cache['phoronix-test-suite']['download-cache'][$file->get_filename()]['associated_tests'], $test_profile->get_identifier());
                     }
                 }
             }
         }
     }
     // Find files in download-cache/ that weren't part of an installed test (but could have just been tossed in there) to cache
     foreach (glob($dc_write_directory . '/*') as $cached_file) {
         $file_name = basename($cached_file);
         if (!isset($json_download_cache['phoronix-test-suite']['download-cache'][$file_name]) && $file_name != 'pts-download-cache.json') {
             $json_download_cache['phoronix-test-suite']['download-cache'][$file_name] = array('file_name' => $file_name, 'file_size' => filesize($cached_file), 'associated_tests' => array(), 'md5' => md5_file($cached_file), 'sha256' => hash_file('sha256', $cached_file));
         }
     }
     $cached_tests = array();
     foreach (pts_openbenchmarking::available_tests(true, true) as $test) {
         if (pts_test_install_request::test_files_in_cache($test, true, true) == false) {
             continue;
         }
         array_push($cached_tests, $test);
     }
     $json_download_cache['phoronix-test-suite']['cached-tests'] = $cached_tests;
     file_put_contents($dc_write_directory . 'pts-download-cache.json', json_encode($json_download_cache, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 0));
     echo PHP_EOL;
 }
Esempio n. 18
0
 public static function is_result_file($identifier)
 {
     return pts_types::identifier_to_object($identifier) instanceof pts_result_file ? true : false;
 }
 public static function run($r)
 {
     $compare_tests = array();
     $compare_subsystems = array();
     foreach ($r as $test_object) {
         $test_object = pts_types::identifier_to_object($test_object);
         if ($test_object instanceof pts_test_profile) {
             array_push($compare_tests, $test_object->get_identifier(false));
             if (!isset($compare_subsystems[$test_object->get_test_hardware_type()])) {
                 $compare_subsystems[$test_object->get_test_hardware_type()] = 1;
             } else {
                 $compare_subsystems[$test_object->get_test_hardware_type()] += 1;
             }
         }
     }
     if (empty($compare_tests)) {
         $subsystem_under_test = pts_user_io::prompt_text_menu('Sub-System To Test', array('Processor', 'Graphics', 'Disk'));
     } else {
         arsort($compare_subsystems);
         $compare_subsystems = array_keys($compare_subsystems);
         $subsystem_under_test = array_shift($compare_subsystems);
     }
     $system_info = array_merge(phodevi::system_hardware(false), phodevi::system_software(false));
     $to_include = array();
     $to_exclude = array();
     if (isset($system_info[$subsystem_under_test])) {
         $compare_component = $system_info[$subsystem_under_test];
     } else {
         return;
     }
     switch ($subsystem_under_test) {
         case 'Processor':
             self::system_component_to_format($system_info, $to_include, array('OS', 'Compiler', 'Kernel', 'Motherboard'), true);
             break;
         case 'Graphics':
             self::system_component_to_format($system_info, $to_include, array('OS', 'Display Driver', 'OpenGL', 'Processor', 'Kernel', 'Desktop'), true);
             break;
         case 'OS':
             self::system_component_to_format($system_info, $to_include, array('Processor', 'Motherboard', 'Graphics', 'Disk'), true);
             self::system_component_to_format($system_info, $to_exclude, array('OS'));
             break;
         case 'Disk':
             self::system_component_to_format($system_info, $to_include, array('Processor', 'OS', 'Chipset', 'Motherboard', 'Kernel'), true);
             break;
     }
     $payload = array('subsystem_under_test' => $subsystem_under_test, 'component_under_test' => $compare_component, 'include_components' => implode(',', $to_include), 'exclude_components' => implode(',', $to_exclude), 'include_tests' => implode(',', $compare_tests));
     echo PHP_EOL . 'Querying test data from OpenBenchmarking.org...' . PHP_EOL;
     $json = pts_openbenchmarking::make_openbenchmarking_request('auto_generate_comparison', $payload);
     $json = json_decode($json, true);
     if (isset($json['auto_compare']['public_ids']) && isset($json['auto_compare']['count']) && $json['auto_compare']['count'] > 0) {
         echo 'Found ' . $json['auto_compare']['count'] . ' comparable results on OpenBenchmarking.org with a ' . $json['auto_compare']['accuracy'] . '% accuracy.' . PHP_EOL;
         $compare_results = array();
         foreach ($json['auto_compare']['public_ids'] as $public_id) {
             $result_xml = pts_openbenchmarking::clone_openbenchmarking_result($public_id, true);
             if ($result_xml) {
                 $result_file = new pts_result_file($result_xml);
                 $result_objects = $result_file->get_result_objects();
                 foreach ($result_objects as $i => &$result_object) {
                     if (!empty($compare_tests)) {
                         if (!in_array($result_object->test_profile->get_identifier(false), $compare_tests)) {
                             unset($result_objects[$i]);
                         }
                     } else {
                         if ($result_object->test_profile->get_test_hardware_type() != $subsystem_under_test) {
                             unset($result_objects[$i]);
                         }
                     }
                 }
                 if (count($result_objects) == 0) {
                     continue;
                 }
                 $result_file->override_result_objects($result_objects);
                 array_push($compare_results, $result_file);
             }
         }
         if (count($compare_results) > 0) {
             $result_xml = pts_merge::merge_test_results_array($compare_results);
             if (count($compare_results) > 2) {
                 $result_file = new pts_result_file($result_xml);
                 $result_objects = $result_file->get_result_objects();
                 $system_count = $result_file->get_system_count();
                 $result_count = count($result_objects);
                 $result_match_count = array();
                 if ($result_count > 3) {
                     foreach ($result_objects as $i => &$result_object) {
                         $result_match_count[$i] = $result_object->test_result_buffer->get_count();
                     }
                     arsort($result_match_count);
                     $biggest_size = pts_arrays::first_element($result_match_count);
                     if ($biggest_size == $system_count || $biggest_size > 3) {
                         foreach ($result_match_count as $key => $value) {
                             if ($value < 2) {
                                 unset($result_objects[$key]);
                             }
                         }
                     }
                     $result_file->override_result_objects($result_objects);
                     $result_xml = pts_merge::merge_test_results_array(array($result_file));
                 }
             }
             pts_client::save_test_result('auto-comparison/composite.xml', $result_xml);
         }
     }
     pts_test_installer::standard_install(array('auto-comparison'));
     pts_test_run_manager::standard_run(array('auto-comparison'));
 }
 private static function is_selector_software_type($id)
 {
     $yes = false;
     foreach (pts_types::test_profile_software_types() as $subsystem) {
         if (strtolower($subsystem) === $id && $subsystem != 'BaseTestProfile') {
             // virtual suite of all supported tests by a given SoftwareType
             $yes = $subsystem;
             break;
         }
     }
     return $yes;
 }
 public function get_contained_test_profiles()
 {
     $test_names = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/Test');
     $test_profiles = array();
     foreach (array_keys($test_names) as $i) {
         $obj = pts_types::identifier_to_object($test_names[$i]);
         if ($obj instanceof pts_test_profile) {
             $test_profiles[] = $obj;
         } else {
             if ($obj instanceof pts_test_suite) {
                 foreach ($obj->get_contained_test_profiles() as $obj) {
                     $test_profiles[] = $obj;
                 }
             }
         }
     }
     return $test_profiles;
 }
 public static function run($r)
 {
     $test_profiles = pts_types::identifiers_to_test_profile_objects($r, true, true);
     //pts_client::set_test_flags(pts_c::auto_mode);
     pts_external_dependencies::install_dependencies($test_profiles);
 }
Esempio n. 23
0
 public static function initial_setup()
 {
     // Operating System Detection
     $supported_operating_systems = pts_types::operating_systems();
     $uname_s = strtolower(php_uname('s'));
     foreach ($supported_operating_systems as $os_check) {
         for ($i = 0; $i < count($os_check); $i++) {
             if (strpos($uname_s, strtolower($os_check[$i])) !== false) {
                 self::$operating_system = $os_check[0];
                 self::$operating_systems[strtolower($os_check[0])] = true;
                 break;
             }
         }
         if (self::$operating_system != null) {
             break;
         }
     }
     if (self::operating_system() == false) {
         self::$operating_system = 'Unknown';
     }
     // OpenGL / graphics detection
     $graphics_detection = array('NVIDIA', array('ATI', 'AMD', 'fglrx'), array('Mesa', 'SGI'));
     $opengl_driver = phodevi::read_property('system', 'opengl-vendor') . ' ' . phodevi::read_property('system', 'opengl-driver') . ' ' . phodevi::read_property('system', 'dri-display-driver');
     $opengl_driver = trim(str_replace('Corporation', null, $opengl_driver));
     // Prevents a possible false positive for ATI being in CorporATIon
     foreach ($graphics_detection as $gpu_check) {
         if (!is_array($gpu_check)) {
             $gpu_check = array($gpu_check);
         }
         for ($i = 0; $i < count($gpu_check); $i++) {
             if (stripos($opengl_driver, $gpu_check[$i]) !== false) {
                 self::$graphics[strtolower($gpu_check[0])] = true;
                 break;
             }
         }
     }
     self::load_sensors();
 }
 public function initial_checks(&$to_run, $override_display_mode = false)
 {
     // Refresh the pts_client::$display in case we need to run in debug mode
     if (pts_client::$display == false || !pts_client::$display instanceof pts_websocket_display_mode) {
         pts_client::init_display_mode($override_display_mode);
     }
     $to_run = pts_types::identifiers_to_objects($to_run);
     if ($this->batch_mode && $this->batch_mode['Configured'] == false && !$this->auto_mode) {
         trigger_error('The batch mode must first be configured.' . PHP_EOL . 'To configure, run phoronix-test-suite batch-setup', E_USER_ERROR);
         return false;
     }
     if (!is_writable(pts_client::test_install_root_path())) {
         trigger_error('The test installation directory is not writable.' . PHP_EOL . 'Location: ' . pts_client::test_install_root_path(), E_USER_ERROR);
         return false;
     }
     // Cleanup tests to run
     if (pts_test_run_manager::cleanup_tests_to_run($to_run) == false) {
         return false;
     } else {
         if (count($to_run) == 0) {
             trigger_error('You must enter at least one test, suite, or result identifier to run.', E_USER_ERROR);
             return false;
         }
     }
     return true;
 }
Esempio n. 25
0
 public static function initial_setup()
 {
     // Operating System Detection
     $supported_operating_systems = pts_types::operating_systems();
     $uname_s = strtolower(php_uname('s'));
     foreach ($supported_operating_systems as $os_check) {
         for ($i = 0; $i < count($os_check); $i++) {
             if (strpos($uname_s, strtolower($os_check[$i])) !== false) {
                 self::$operating_system = $os_check[0];
                 self::$operating_systems[strtolower($os_check[0])] = true;
                 break;
             }
         }
         if (self::$operating_system != null) {
             break;
         }
     }
     if (self::operating_system() == false) {
         self::$operating_system = 'Unknown';
     }
     self::load_sensors();
 }
 public static function run($r)
 {
     if (pts_openbenchmarking_client::user_name() == false) {
         echo PHP_EOL . 'You must first be logged into an OpenBenchmarking.org account.' . PHP_EOL;
         echo PHP_EOL . 'Create An Account: http://openbenchmarking.org/';
         echo PHP_EOL . 'Log-In Command: phoronix-test-suite openbenchmarking-setup' . PHP_EOL . PHP_EOL;
         return false;
     }
     ini_set('memory_limit', '2048M');
     foreach (pts_types::identifiers_to_test_profile_objects($r, false, true) as $test_profile) {
         $qualified_identifier = $test_profile->get_identifier();
         // First make sure the test profile is already in the OpenBenchmarking.org database...
         $json = pts_openbenchmarking::make_openbenchmarking_request('is_test_profile', array('i' => $qualified_identifier));
         $json = json_decode($json, true);
         if (!isset($json['openbenchmarking']['test']['valid']) || $json['openbenchmarking']['test']['valid'] != 'TRUE') {
             echo PHP_EOL . $qualified_identifier . ' must first be uploaded to OpenBenchmarking.org.' . PHP_EOL;
             //	break;
         }
         // Set some other things...
         pts_client::pts_set_environment_variable('FORCE_TIMES_TO_RUN', 1);
         pts_client::pts_set_environment_variable('TEST_RESULTS_NAME', $test_profile->get_title() . ' Testing ' . date('Y-m-d'));
         pts_client::pts_set_environment_variable('TEST_RESULTS_IDENTIFIER', 'Sample Run');
         pts_client::pts_set_environment_variable('TEST_RESULTS_DESCRIPTION', 1);
         pts_openbenchmarking_client::override_client_setting('AutoUploadResults', true);
         pts_openbenchmarking_client::override_client_setting('UploadSystemLogsByDefault', true);
         // Take screenshots
         pts_client::pts_set_environment_variable('SCREENSHOT_INTERVAL', 9);
         pts_module_manager::attach_module('timed_screenshot');
         $force_ss = true;
         $reference_ss_file = pts_module_manager::module_call('timed_screenshot', 'take_screenshot', $force_ss);
         sleep(2);
         $apitrace = pts_file_io::glob('/usr/local/lib/*/apitrace/wrappers/glxtrace.so');
         if (!empty($apitrace) && pts_client::executable_in_path('apitrace')) {
             $apitrace = array_shift($apitrace);
             putenv('LD_PRELOAD=' . $apitrace);
         } else {
             $apitrace = false;
         }
         // So for any compiling tasks they will try to use the most aggressive instructions possible
         putenv('CFLAGS=-march=native -O3');
         putenv('CXXFLAGS=-march=native -O3');
         pts_test_installer::standard_install($qualified_identifier, true);
         $run_manager = new pts_test_run_manager(false, 2);
         $run_manager->standard_run($qualified_identifier);
         if ($apitrace) {
             putenv('LD_PRELOAD=');
         }
         if ($reference_ss_file) {
             $reference_ss = pts_image::image_file_to_gd($reference_ss_file);
             unlink($reference_ss_file);
             $screenshots_gd = array();
             $screenshots = pts_module_manager::module_call('timed_screenshot', 'get_screenshots');
             var_dump($screenshots);
             foreach ($screenshots as $ss_file) {
                 $screenshots_gd[$ss_file] = pts_image::image_file_to_gd($ss_file);
                 if ($screenshots_gd[$ss_file] == false) {
                     continue;
                 }
                 $ss_delta = pts_image::gd_image_delta_composite($reference_ss, $screenshots_gd[$ss_file], true);
                 if (count($ss_delta) < floor(imagesx($reference_ss) * 0.5600000000000001) || filesize($ss_file) > 2097152) {
                     // If less than 56% of the pixels are changing on X, then likely not much to show off... (CLI only likely)
                     // Or if filesize of image is beyond 2MB
                     //echo 'dropping' . $ss_file . PHP_EOL;
                     unset($screenshots_gd[$ss_file]);
                     pts_file_io::unlink($ss_file);
                 }
             }
             $ss_files = array_keys($screenshots_gd);
             shuffle($ss_files);
             // Don't upload more than 4MB worth of screenshots
             while (pts_file_io::array_filesize($ss_files) > 1048576 * 2) {
                 $f = array_pop($ss_files);
                 unlink($f);
             }
             if (count($ss_files) > 0) {
                 $c = 1;
                 foreach ($ss_files as $i => $file) {
                     $new_file = dirname($file) . '/screenshot-' . $c . '.png';
                     rename($file, $new_file);
                     $ss_files[$i] = $new_file;
                     $c++;
                 }
                 $ss_zip_file = PTS_OPENBENCHMARKING_SCRATCH_PATH . 'screenshots-' . $test_profile->get_identifier_base_name() . '-' . $test_profile->get_test_profile_version() . '.zip';
                 $zip_created = pts_compression::zip_archive_create($ss_zip_file, $ss_files);
                 if ($zip_created) {
                     echo count($ss_files) . ' screenshots captured for use.';
                     //'tp_sha1' => sha1_file($zip_file),
                     //'tp_zip' => base64_encode(file_get_contents($zip_file)),
                 }
                 foreach ($ss_files as $file) {
                     //	pts_file_io::unlink($file);
                 }
             }
         }
         $test_binary = self::locate_test_profile_lead_binary($test_profile);
         $shared_library_dependencies = array();
         $instruction_usage = array();
         $gl_calls = null;
         if (is_executable($test_binary)) {
             if ($apitrace) {
                 // Find the trace...
                 $test_binary_dir = dirname($test_binary);
                 $trace_file = glob($test_binary_dir . '/*.trace');
                 if ($trace_file) {
                     echo 'Analyzing GL traces';
                     $trace_file = array_shift($trace_file);
                     $gl_usage = self::analyze_apitrace_trace_glpop($trace_file);
                     if (!empty($gl_usage)) {
                         $gl_calls = implode(',', $gl_usage);
                     }
                 }
             }
             $ldd = trim(shell_exec('ldd ' . $test_binary));
             foreach (explode(PHP_EOL, $ldd) as $line) {
                 $line = explode(' => ', $line);
                 if (count($line) == 2) {
                     $shared_library_dependencies[] = trim(basename($line[0]));
                 }
             }
             echo PHP_EOL . 'SHARED LIBRARY DEPENDENCIES: ' . PHP_EOL;
             print_r($shared_library_dependencies);
             foreach (array('core-avx-i', 'bdver2') as $march) {
                 // So for any compiling tasks they will try to use the most aggressive instructions possible
                 putenv('CFLAGS=-march=' . $march . ' -O3');
                 putenv('CXXFLAGS=-march=' . $march . ' -O3');
                 pts_test_installer::standard_install($qualified_identifier, true);
                 $instruction_usage[$march] = self::analyze_binary_instruction_usage($test_binary);
                 if ($instruction_usage[$march] == null) {
                     unset($instruction_usage[$march]);
                 }
             }
             if (!empty($instruction_usage) && count(array_unique($instruction_usage)) == 1) {
                 $generic = array_pop($instruction_usage);
                 $instruction_usage = array('generic' => $generic);
             }
             var_dump($instruction_usage);
         } else {
             echo PHP_EOL . $test_binary;
             echo PHP_EOL . 'Test binary could not be found.' . PHP_EOL;
             //		return false;
         }
     }
     sleep(10);
     var_dump($shared_library_dependencies);
     var_dump($instruction_usage);
     var_dump($gl_calls);
     $server_response = pts_openbenchmarking::make_openbenchmarking_request('upload_test_meta', array('i' => $test_profile->get_identifier(), 'screenshots_zip' => $ss_zip_conts = base64_encode(file_get_contents($ss_zip_file)), 'screenshots_zip_sha1' => sha1($ss_zip_conts), 'ldd_libraries' => implode(',', $shared_library_dependencies), 'opengl_calls' => $gl_calls, 'instruction_set_usage' => base64_encode(json_encode($instruction_usage))));
     var_dump($server_response);
     $json = json_decode($server_response, true);
     pts_file_io::unlink($ss_zip_file);
 }
 public static function run($r)
 {
     pts_client::$display->generic_heading('Random Test Execution');
     $allow_new_tests_to_be_installed = pts_user_io::prompt_bool_input('Allow new tests to be installed', true);
     $allow_new_dependencies_to_be_installed = $allow_new_tests_to_be_installed ? pts_user_io::prompt_bool_input('Allow new test external dependencies to be installed', false) : false;
     $limit_test_subsystem = pts_user_io::prompt_bool_input('Limit tests to a given subsystem', false);
     $limit_test_subsystem = $limit_test_subsystem ? pts_user_io::prompt_text_menu('Select subsystem(s) to test', pts_types::subsystem_targets(), true) : false;
     $upload_to_openbenchmarking = pts_user_io::prompt_bool_input('Auto-upload test results to OpenBenchmarking.org', true);
     while (1) {
         $to_test = array();
         if ($limit_test_subsystem) {
             foreach (explode(',', $limit_test_subsystem) as $test_type) {
                 $tests = pts_openbenchmarking_client::popular_tests(-1, $test_type);
                 $to_test = array_merge($to_test, $tests);
             }
             if (empty($to_test)) {
                 pts_client::$display->generic_sub_heading('No tests could be found to run.');
                 return false;
             }
             shuffle($to_test);
             $to_test = array_slice($to_test, 0, rand(1, 12));
         } else {
             if (rand(1, 6) == 2) {
                 $ob_ids = pts_openbenchmarking_client::popular_openbenchmarking_results();
                 $ob_type = rand(0, 1) == 1 ? 'recent_popular_results' : 'recent_results';
                 if (isset($ob_ids[$ob_type]) && !empty($ob_ids[$ob_type])) {
                     shuffle($ob_ids[$ob_type]);
                     $to_test = array(array_pop($ob_ids[$ob_type]));
                 }
             }
         }
         if (empty($to_test)) {
             // Randomly pick some installed tests
             $installed_tests = pts_tests::installed_tests();
             if ($installed_tests > 3) {
                 shuffle($installed_tests);
                 $to_test = array_slice($installed_tests, 0, rand(1, 8));
             }
             if (!isset($to_test[2]) && $allow_new_tests_to_be_installed) {
                 $available_tests = pts_openbenchmarking::available_tests();
                 shuffle($available_tests);
                 $to_test = array_merge($to_test, array_slice($available_tests, 0, rand(1, 10)));
             }
         }
         if (empty($to_test)) {
             pts_client::$display->generic_sub_heading('No tests could be found to run.');
             return false;
         }
         echo PHP_EOL;
         pts_client::$display->generic_sub_heading('Tests To Run: ' . implode(', ', $to_test));
         // QUERY FROM OB
         $random_titles = array(phodevi::read_property('cpu', 'model') . ' Benchmarks', phodevi::read_property('system', 'operating-system') . ' Benchmarks', phodevi::read_property('system', 'operating-system') . ' Performance', phodevi::read_property('cpu', 'model') . ' Performance', phodevi::read_property('cpu', 'model') . ' + ' . phodevi::read_property('gpu', 'model') . ' + ' . phodevi::read_property('motherboard', 'identifier'), phodevi::read_property('motherboard', 'identifier') . ' On ' . phodevi::read_property('system', 'operating-system'), phodevi::read_property('cpu', 'model') . ' On ' . phodevi::read_property('system', 'operating-system'), phodevi::read_property('system', 'kernel') . ' + ' . phodevi::read_property('system', 'operating-system') . ' Tests');
         shuffle($random_titles);
         $title = array_pop($random_titles);
         if ($limit_test_subsystem) {
             $subsystems_to_test = explode(',', $limit_test_subsystem);
             $subsystems_to_avoid = array_diff(pts_types::subsystem_targets(), $subsystems_to_test);
             pts_client::pts_set_environment_variable('SKIP_TESTING_SUBSYSTEMS', implode(',', $subsystems_to_avoid));
         }
         if ($allow_new_tests_to_be_installed) {
             pts_test_installer::standard_install($to_test, false, true, $allow_new_dependencies_to_be_installed);
         }
         $batch_mode_settings = array('UploadResults' => false, 'SaveResults' => true, 'PromptForTestDescription' => false, 'RunAllTestCombinations' => false, 'PromptSaveName' => false, 'PromptForTestIdentifier' => false, 'OpenBrowser' => false);
         if ($upload_to_openbenchmarking) {
             $batch_mode_settings['UploadResults'] = true;
             pts_openbenchmarking_client::override_client_setting('UploadSystemLogsByDefault', true);
         }
         pts_test_run_manager::set_batch_mode($batch_mode_settings);
         $test_run_manager = new pts_test_run_manager($batch_mode_settings, 2);
         if ($test_run_manager->initial_checks($to_test) != false) {
             if ($test_run_manager->load_tests_to_run($to_test)) {
                 // SETUP
                 $test_run_manager->auto_save_results($title, null, 'Various open-source benchmarks by the ' . pts_core::program_title(true) . '.', true);
                 $test_run_manager->auto_generate_results_identifier();
                 echo PHP_EOL;
                 pts_client::$display->generic_sub_heading('Result File: ' . $test_run_manager->get_file_name());
                 pts_client::$display->generic_sub_heading('Result Identifier: ' . $test_run_manager->get_results_identifier());
                 // BENCHMARK
                 $test_run_manager->pre_execution_process();
                 $test_run_manager->call_test_runs();
                 $test_run_manager->post_execution_process();
                 pts_client::remove_saved_result_file($test_run_manager->get_file_name());
             }
         }
         echo PHP_EOL;
         sleep(30);
     }
 }
Esempio n. 28
0
 public static function run($r)
 {
     pts_openbenchmarking::refresh_repository_lists();
     pts_client::$display->generic_heading('Interactive Benchmarking');
     echo 'System Hardware:' . PHP_EOL . phodevi::system_hardware(true) . (phodevi::read_property('motherboard', 'serial-number') != null ? PHP_EOL . 'System Serial Number: ' . phodevi::read_property('motherboard', 'serial-number') : null) . PHP_EOL . PHP_EOL . PHP_EOL;
     $reboot_on_exit = false;
     do {
         $options = array('RUN_TEST' => 'Run A Test', 'RUN_SUITE' => 'Run A Suite [A Collection Of Tests]', 'RUN_SYSTEM_TEST' => 'Run Complex System Test', 'SHOW_INFO' => 'Show System Hardware / Software Information', 'SHOW_SENSORS' => 'Show Auto-Detected System Sensors', 'SET_RUN_COUNT' => 'Set Test Run Repetition');
         if (count(pts_client::saved_test_results()) > 0) {
             $options['BACKUP_RESULTS_TO_USB'] = 'Backup Results To Media Storage';
         }
         $options['EXIT'] = $reboot_on_exit ? 'Exit & Reboot' : 'Exit';
         $response = pts_user_io::prompt_text_menu('Select Task', $options, false, true);
         switch ($response) {
             case 'RUN_TEST':
                 $supported_tests = pts_openbenchmarking::available_tests();
                 $supported_tests = pts_types::identifiers_to_test_profile_objects($supported_tests, false, true);
                 $longest_title_length = 0;
                 foreach ($supported_tests as $i => &$test_profile) {
                     if ($test_profile->get_title() == null) {
                         unset($supported_tests[$i]);
                         continue;
                     }
                     $longest_title_length = max($longest_title_length, strlen($test_profile->get_title()));
                 }
                 $t = array();
                 foreach ($supported_tests as $i => &$test_profile) {
                     if ($test_profile instanceof pts_test_profile) {
                         $t[$test_profile->get_identifier()] = sprintf('%-' . ($longest_title_length + 1) . 'ls - %-10ls', $test_profile->get_title(), $test_profile->get_test_hardware_type());
                     }
                 }
                 $supported_tests = $t;
                 asort($supported_tests);
                 $tests_to_run = pts_user_io::prompt_text_menu('Select Test', $supported_tests, true, true);
                 $tests_to_run = explode(',', $tests_to_run);
                 pts_test_installer::standard_install($tests_to_run);
                 $run_manager = new pts_test_run_manager(false, 2);
                 $run_manager->standard_run($tests_to_run);
                 if ($run_manager != false) {
                     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
                 }
                 break;
             case 'RUN_SUITE':
                 $possible_suites = pts_openbenchmarking::available_suites();
                 foreach (array_map('strtolower', pts_types::subsystem_targets()) as $subsystem) {
                     array_push($possible_suites, 'pts/' . $subsystem);
                 }
                 $suites_to_run = pts_user_io::prompt_text_menu('Select Suite', $possible_suites, true);
                 foreach (explode(',', $suites_to_run) as $suite_to_run) {
                     pts_test_installer::standard_install($suite_to_run);
                     $run_manager = new pts_test_run_manager(false, 2);
                     $run_manager->standard_run($suite_to_run);
                 }
                 break;
             case 'SELECT_DRIVE_MOUNT':
                 self::select_drive_mount();
                 break;
             case 'RUN_SYSTEM_TEST':
                 pts_client::$display->generic_heading('System Test');
                 $system_tests = array('apache', 'c-ray', 'ramspeed', 'postmark');
                 pts_test_installer::standard_install($system_tests);
                 $run_manager = new pts_test_run_manager(false, 2);
                 $run_manager->standard_run($system_tests);
                 if ($run_manager != false) {
                     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $run_manager->get_file_name() . '/index.html', null, true, true);
                 }
                 break;
             case 'SHOW_INFO':
                 pts_client::$display->generic_heading('System Software / Hardware Information');
                 echo 'Hardware:' . PHP_EOL . phodevi::system_hardware(true) . PHP_EOL . PHP_EOL;
                 echo 'Software:' . PHP_EOL . phodevi::system_software(true) . PHP_EOL . PHP_EOL;
                 break;
             case 'SHOW_SENSORS':
                 pts_client::$display->generic_heading('Detected System Sensors');
                 foreach (phodevi::supported_sensors() as $sensor) {
                     echo phodevi::sensor_name($sensor) . ': ' . phodevi::read_sensor($sensor) . ' ' . phodevi::read_sensor_unit($sensor) . PHP_EOL;
                 }
                 break;
             case 'SET_RUN_COUNT':
                 $run_count = pts_user_io::prompt_user_input('Set the minimum number of times each test should repeat', false);
                 putenv('FORCE_TIMES_TO_RUN=' . trim($run_count));
                 break;
             case 'BACKUP_RESULTS_TO_USB':
                 pts_client::$display->generic_heading('Backing Up Test Results');
                 foreach (pts_file_io::glob('/media/*') as $media_dir) {
                     if (!is_writable($media_dir)) {
                         echo PHP_EOL . $media_dir . ' is not writable.' . PHP_EOL;
                         continue;
                     }
                     echo PHP_EOL . 'Writing Test Results To: ' . $media_dir . PHP_EOL;
                     pts_file_io::copy(PTS_SAVE_RESULTS_PATH, $media_dir . '/');
                     break;
                 }
                 break;
         }
         echo PHP_EOL . PHP_EOL;
     } while ($response != 'EXIT');
     if ($reboot_on_exit) {
         if (is_dir('/media/pts-auto-mount')) {
             pts_file_io::delete('/media/pts-auto-mount/pts', null, true);
             exec('umount /media/pts-auto-mount 2>&1');
         }
         exec('reboot');
     }
 }
Esempio n. 29
0
 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)
 {
     $test_profiles = pts_types::identifiers_to_test_profile_objects($r, true, true);
     pts_external_dependencies::install_dependencies($test_profiles);
 }