예제 #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)
 {
     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)
 {
     $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 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 available_virtual_suites()
 {
     $virtual_suites = array();
     $possible_identifiers = array_merge(array('all', 'installed'), array_map('strtolower', self::available_operating_systems()), array_map('strtolower', pts_types::subsystem_targets()), array_map('strtolower', pts_types::test_profile_software_types()));
     foreach (pts_openbenchmarking::linked_repositories() as $repo) {
         $repo_identifiers = array_merge($possible_identifiers, self::tags_in_repo($repo));
         foreach ($repo_identifiers as $id) {
             $virt_suite = $repo . '/' . $id;
             if (self::is_virtual_suite($virt_suite)) {
                 $virtual_suite = pts_types::identifier_to_object($virt_suite);
                 if ($virtual_suite instanceof pts_virtual_test_suite) {
                     array_push($virtual_suites, $virtual_suite);
                 }
             }
         }
     }
     return $virtual_suites;
 }
 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);
         }
     }
 }
예제 #9
0
 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'));
 }
 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;
 }
예제 #11
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;
                     }
                 }
             }
         }
     }
 }
예제 #12
0
 public static function is_result_file($identifier)
 {
     return pts_types::identifier_to_object($identifier) instanceof pts_result_file ? true : false;
 }
 public function is_supported_value($input)
 {
     $supported = false;
     if (is_array($this->option_supported_values)) {
         if (in_array($input, $this->option_supported_values)) {
             $supported = true;
         }
     } else {
         if (empty($input) && $this->option_default_value != null) {
             $supported = true;
         } else {
             switch ($this->option_supported_values) {
                 case 'NUMERIC':
                     if (is_numeric($input)) {
                         $supported = true;
                     }
                     break;
                 case 'NUMERIC_DASH':
                     if (!empty($input) && pts_strings::string_only_contains($input, pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DASH)) {
                         $supported = true;
                     }
                     break;
                 case 'ALPHA_NUMERIC':
                     if (!empty($input) && pts_strings::string_only_contains($input, pts_strings::CHAR_NUMERIC | pts_strings::CHAR_LETTER)) {
                         $supported = true;
                     }
                     break;
                 case 'HTTP_URL':
                     if (substr($input, 0, 7) == 'http://') {
                         $supported = true;
                     }
                     break;
                 case 'LOCAL_DIRECTORY':
                     if (is_dir($input)) {
                         $supported = true;
                     }
                     break;
                 case 'LOCAL_FILE':
                     if (is_file($input)) {
                         $supported = true;
                     }
                     break;
                 case 'LOCAL_EXECUTABLE':
                     if (is_executable($input)) {
                         $supported = true;
                     }
                     break;
                 case 'PTS_TEST_RESULT':
                     if (pts_result_file::is_test_result_file($input)) {
                         $supported = true;
                     }
                 case 'INSTALLED_TEST':
                     if (in_array($input, pts_tests::installed_tests())) {
                         $supported = true;
                     }
                 case 'VALID_SAVE_NAME':
                     if (!empty($input) && pts_types::identifier_to_object($input) == false) {
                         $supported = true;
                     }
                 case 'NOT_EMPTY':
                     if (!empty($input)) {
                         $supported = true;
                     }
                 case '':
                     $supported = true;
                     break;
             }
         }
     }
     if ($supported && !empty($this->option_function_check)) {
         $supported = call_user_func($this->option_function_check, $input) == true;
     }
     return $supported;
 }