public static function run($r)
 {
     pts_client::$display->generic_heading('Available Tests');
     $test_count = 0;
     foreach (pts_openbenchmarking::available_tests(false) as $identifier) {
         $repo = substr($identifier, 0, strpos($identifier, '/'));
         $id = substr($identifier, strlen($repo) + 1);
         $repo_index = pts_openbenchmarking::read_repository_index($repo);
         if (!in_array(phodevi::operating_system(), $repo_index['tests'][$id]['supported_platforms']) || empty($repo_index['tests'][$id]['title'])) {
             // Don't show unsupported tests
             continue;
         }
         echo sprintf('%-30ls - %-35ls %-9ls', $identifier, $repo_index['tests'][$id]['title'], $repo_index['tests'][$id]['test_type']) . PHP_EOL;
         $test_count++;
     }
     foreach (pts_file_io::glob(PTS_TEST_PROFILE_PATH . 'local/*/test-definition.xml') as $path) {
         $test_profile = new pts_test_profile('local/' . basename(dirname($path)));
         if ($test_profile->get_title() != null && $test_profile->is_supported(false)) {
             echo sprintf('%-30ls - %-35ls %-9ls', $test_profile->get_identifier(), $test_profile->get_title(), $test_profile->get_test_hardware_type()) . PHP_EOL;
             $test_count++;
         }
     }
     if ($test_count == 0) {
         echo PHP_EOL . 'No tests found. Please check that you have Internet connectivity to download test profile data from OpenBenchmarking.org. The Phoronix Test Suite has documentation on configuring the network setup, proxy settings, and PHP network options. Please contact Phoronix Media if you continuing to experience problems.' . PHP_EOL . PHP_EOL;
     }
 }
 public static function run($r)
 {
     $available_suites = pts_openbenchmarking::available_suites(false);
     pts_client::$display->generic_heading('Available Suites');
     if (count($available_suites) > 0) {
         $has_partially_supported_suite = false;
         foreach ($available_suites as $identifier) {
             $suite_info = new pts_test_suite($identifier);
             $partially_supported = $suite_info->is_supported() == 1;
             if (!$has_partially_supported_suite && $partially_supported) {
                 $has_partially_supported_suite = true;
             }
             if ($suite_info->is_supported()) {
                 $identifier_prefix = $partially_supported ? '*' : ' ';
                 if ($suite_info->get_title() != null) {
                     echo sprintf('%-34ls - %-32ls %s' . PHP_EOL, $identifier_prefix . ' ' . $identifier, $suite_info->get_title(), $suite_info->get_suite_type());
                 }
             }
         }
         echo PHP_EOL;
         if ($has_partially_supported_suite) {
             echo '* Indicates a partially supported suite.' . PHP_EOL . PHP_EOL;
         }
     } else {
         echo PHP_EOL . 'No suites found. Please check that you have Internet connectivity to download test suite data from OpenBenchmarking.org. The Phoronix Test Suite has documentation on configuring the network setup, proxy settings, and PHP network options. Please contact Phoronix Media if you continuing to experience problems.' . PHP_EOL . PHP_EOL;
     }
 }
 public static function run($r)
 {
     echo PHP_EOL . 'OpenBenchmarking.org Repositories:' . PHP_EOL . PHP_EOL;
     foreach (pts_openbenchmarking::linked_repositories() as $repo) {
         if ($repo == 'local') {
             // Skip local since it's a fake repository
             continue;
         }
         $repo_index = pts_openbenchmarking::read_repository_index($repo);
         $generated_time = date('F d H:i', $repo_index['main']['generated']);
         $tab = '    ';
         foreach (array('tests', 'suites') as $t) {
             echo PHP_EOL . str_repeat('=', 40) . PHP_EOL . strtoupper($repo . ' ' . $t) . PHP_EOL . 'Generated: ' . $generated_time . PHP_EOL . str_repeat('=', 40) . PHP_EOL . PHP_EOL;
             foreach ($repo_index[$t] as $identifier => $test) {
                 echo 'Identifier: ' . $identifier . PHP_EOL;
                 foreach ($test as $i => $j) {
                     echo sprintf('%-22ls', $i) . ': ';
                     if (is_array($j)) {
                         echo implode(', ', $j);
                     } else {
                         echo $j;
                     }
                     echo PHP_EOL;
                 }
                 echo PHP_EOL;
             }
         }
     }
 }
 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;
     }
 }
 protected static function search_test_profiles($q)
 {
     $ret = null;
     foreach (pts_openbenchmarking::available_tests() as $test) {
         $tp = new pts_test_profile($test);
         if (stripos($test, $q) !== false || stripos($tp->get_title(), $q) === 0) {
             $ret .= '<h3>' . $tp->get_title() . '</h3><p>' . $tp->get_description() . '<br /><a href="http://openbenchmarking.org/test/' . $tp->get_identifier(false) . '">Learn More On OpenBenchmarking.org</a></p>';
         }
     }
     return $ret;
 }
 public function __construct($identifier)
 {
     if (PTS_IS_CLIENT) {
         $ob_identifier = pts_openbenchmarking::evaluate_string_to_qualifier($identifier, true, 'suite');
         if ($ob_identifier != false) {
             $identifier = $ob_identifier;
         }
     }
     $this->identifier = $identifier;
     $this->xml_parser = new pts_suite_nye_XmlReader($identifier);
 }
 public static function run($args)
 {
     $result_files = array();
     foreach ($args as $id) {
         $xml = pts_openbenchmarking::clone_openbenchmarking_result($id, true);
         if ($xml) {
             $result_file = new pts_result_file($xml);
             pts_client::save_test_result($id . '/composite.xml', $result_file->get_xml(), true);
             echo PHP_EOL . 'Result Saved To: ' . PTS_SAVE_RESULTS_PATH . $id . '/composite.xml' . PHP_EOL;
         }
     }
 }
 public static function run($args)
 {
     $result_files = array();
     foreach ($args as $id) {
         $xml = pts_openbenchmarking::clone_openbenchmarking_result($id, true);
         array_push($result_files, new pts_result_file($xml));
     }
     $writer = new pts_result_file_writer(null);
     pts_merge::merge_test_results_process($writer, $result_files);
     pts_client::save_test_result($args[0] . '/composite.xml', $writer->get_xml(), true);
     echo PHP_EOL . 'Result Saved To: ' . PTS_SAVE_RESULTS_PATH . $args[0] . '/composite.xml' . PHP_EOL;
 }
 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 __construct($read = null, $normal_init = true)
 {
     $this->overrides = array();
     $this->tp_extends = null;
     if ($normal_init == false) {
         $this->identifier = $read;
         return;
     }
     if (!isset($read[200]) && strpos($read, '<?xml version="1.0"?>') === false) {
         if (PTS_IS_CLIENT && (!defined('PTS_TEST_PROFILE_PATH') || !is_file(PTS_TEST_PROFILE_PATH . $read . '/test-definition.xml'))) {
             $read = pts_openbenchmarking::evaluate_string_to_qualifier($read, true, 'test');
             if ($read == false && pts_openbenchmarking::openbenchmarking_has_refreshed() == false) {
                 // Test profile might be brand new, so refresh repository and then check
                 // pts_openbenchmarking::refresh_repository_lists(null, true);
                 $read = pts_openbenchmarking::evaluate_string_to_qualifier($read, true, 'test');
             }
         }
     }
     if (!isset($read[64])) {
         // Passed is not an identifier since it's too long
         $this->identifier = $read;
     }
     if (!isset($read[512]) && !is_file($read)) {
         if (defined('PTS_TEST_PROFILE_PATH') && is_file(PTS_TEST_PROFILE_PATH . $read . '/test-definition.xml')) {
             $read = PTS_TEST_PROFILE_PATH . $read . '/test-definition.xml';
         } else {
             if (substr($read, -4) == '.zip' && is_file($read)) {
                 $zip = new ZipArchive();
                 if ($zip->open($read) === true) {
                     $read = $zip->getFromName('test-definition.xml');
                     $zip->close();
                 }
             }
         }
     }
     //$xml_options = 0;
     //if(defined('LIBXML_COMPACT'))
     //{
     $xml_options = LIBXML_COMPACT | LIBXML_PARSEHUGE;
     //}
     if (is_file($read)) {
         $this->file_location = $read;
         $this->xml = simplexml_load_file($read, 'SimpleXMLElement', $xml_options);
     } else {
         $this->raw_xml = $read;
         if (strpos($read, '<') !== false) {
             $this->xml = simplexml_load_string($read, 'SimpleXMLElement', $xml_options);
         }
     }
 }
 public static function run($r)
 {
     pts_client::$display->generic_heading('Recommended OpenBenchmarking.org Test Profiles');
     $test_count = 0;
     $recommendation_index = pts_openbenchmarking::make_openbenchmarking_request('recommended_tests_index');
     $recommendation_index = json_decode($recommendation_index, true);
     foreach ($recommendation_index['recommended_tests'] as $subsystem => $tests) {
         pts_client::$display->generic_heading($subsystem . ' Tests');
         foreach ($tests as $test) {
             echo sprintf('%-32ls - %-35ls', $test['test_profile'], $test['title']) . PHP_EOL;
         }
         $test_count++;
     }
     if ($test_count == 0) {
         echo PHP_EOL . 'No tests found. Please check that you have Internet connectivity to download test profile data from OpenBenchmarking.org. The Phoronix Test Suite has documentation on configuring the network setup, proxy settings, and PHP network options. Please contact Phoronix Media if you continuing to experience problems.' . PHP_EOL . PHP_EOL;
     }
 }
 public static function run($r)
 {
     $installed_suites = array();
     foreach (pts_openbenchmarking::available_suites() as $suite) {
         $suite = new pts_test_suite($suite);
         if ($suite->needs_updated_install() == false) {
             $installed_suites[] = $suite;
         }
     }
     pts_client::$display->generic_heading(count($installed_suites) . ' Suites Installed');
     if (count($installed_suites) > 0) {
         foreach ($installed_suites as $identifier) {
             $test_suite = new pts_test_suite($identifier);
             echo '- ' . $test_suite->get_title() . PHP_EOL;
         }
         echo PHP_EOL;
     }
 }
 public function __construct($identifier = null)
 {
     if (strpos($identifier, '<?xml version="1.0"?>') === false) {
         if (PTS_IS_CLIENT && (!defined('PTS_TEST_PROFILE_PATH') || !is_file(PTS_TEST_PROFILE_PATH . $identifier . '/test-definition.xml'))) {
             $identifier = pts_openbenchmarking::evaluate_string_to_qualifier($identifier, true, 'test');
             if ($identifier == false && pts_openbenchmarking::openbenchmarking_has_refreshed() == false) {
                 // Test profile might be brand new, so refresh repository and then check
                 // pts_openbenchmarking::refresh_repository_lists(null, true);
                 $identifier = pts_openbenchmarking::evaluate_string_to_qualifier($identifier, true, 'test');
             }
         }
     }
     $this->xml_parser = new pts_test_nye_XmlReader($identifier);
     if (!isset($identifier[64])) {
         // Passed is not an identifier since it's too long
         $this->identifier = $identifier;
     }
 }
 public function add_to_suite_from_reader(&$xml_reader)
 {
     $test_names = $xml_reader->getXMLArrayValues('PhoronixTestSuite/Execute/Test');
     $sub_arguments = $xml_reader->getXMLArrayValues('PhoronixTestSuite/Execute/Arguments');
     $sub_arguments_description = $xml_reader->getXMLArrayValues('PhoronixTestSuite/Execute/Description');
     $sub_modes = $xml_reader->getXMLArrayValues('PhoronixTestSuite/Execute/Mode');
     $override_test_options = $xml_reader->getXMLArrayValues('PhoronixTestSuite/Execute/OverrideTestOptions');
     for ($i = 0; $i < count($test_names); $i++) {
         $identifier = pts_openbenchmarking::evaluate_string_to_qualifier($test_names[$i]);
         if (empty($identifier)) {
             echo PHP_EOL . $test_names[$i] . ' fails.' . PHP_EOL;
             exit;
         }
         $identifier = substr($identifier, 0, strrpos($identifier, '-'));
         // strip the version for now
         $this->add_to_suite($identifier, $sub_arguments[$i], $sub_arguments_description[$i], $sub_modes[$i], $override_test_options[$i]);
     }
 }
 public static function run($r)
 {
     pts_client::$display->generic_heading('Unsupported Tests');
     foreach (pts_openbenchmarking::available_tests() as $identifier) {
         $unsupported = false;
         $test_profile = new pts_test_profile($identifier);
         if ($test_profile->is_test_architecture_supported() == false) {
             $unsupported = 'UNSUPPORTED ARCHITECTURE';
         } else {
             if ($test_profile->is_test_platform_supported() == false) {
                 $unsupported = 'UNSUPPORTED PLATFORM';
             }
         }
         if ($unsupported) {
             echo sprintf('%-28ls - %-30ls %-9ls', $identifier, $unsupported, $repo_index['tests'][$id]['test_type']) . PHP_EOL;
         }
     }
 }
 public static function run($r)
 {
     echo PHP_EOL . 'Linked OpenBenchmarking.org Repositories:' . PHP_EOL . PHP_EOL;
     foreach (pts_openbenchmarking::linked_repositories() as $repo) {
         if ($repo == 'local') {
             // Skip local since it's a fake repository
             continue;
         }
         $repo_index = pts_openbenchmarking::read_repository_index($repo);
         $test_count = count($repo_index['tests']);
         $suite_count = count($repo_index['suites']);
         $generated_time = date('F d H:i', $repo_index['main']['generated']);
         echo sprintf('    REPO: %-20ls WEB: %-35ls' . PHP_EOL, $repo, 'http://openbenchmarking.org/user/' . $repo);
         echo sprintf('        LAST GENERATED:  %-3ls' . PHP_EOL, $generated_time);
         echo sprintf('        TEST COUNT:      %-3ls    SUITE COUNT: %-3ls' . PHP_EOL, $test_count, $suite_count);
         echo PHP_EOL;
     }
 }
 public static function run($r)
 {
     pts_client::$display->generic_heading('Recently Updated OpenBenchmarking.org Tests');
     $recently_updated = array();
     foreach (pts_openbenchmarking::linked_repositories() as $repo) {
         if ($repo == 'local') {
             // Skip local since it's a fake repository
             continue;
         }
         $repo_index = pts_openbenchmarking::read_repository_index($repo);
         $changes[$repo] = pts_openbenchmarking_client::fetch_repository_changelog($repo);
         if (isset($repo_index['tests']) && is_array($repo_index['tests'])) {
             foreach (array_keys($repo_index['tests']) as $identifier) {
                 if ($repo_index['tests'][$identifier]['last_updated'] > time() - 90 * 86400) {
                     $recently_updated[$repo . '/' . $identifier] = $repo_index['tests'][$identifier];
                 }
             }
         }
     }
     if (count($recently_updated) > 0) {
         // sort by date
         uasort($recently_updated, array('openbenchmarking_changes', 'compare_time_stamps'));
         // so that tests are shown from newest to oldest
         $recently_updated = array_reverse($recently_updated);
         $longest_identifier_length = array_keys($recently_updated);
         $longest_identifier_length = strlen(pts_strings::find_longest_string($longest_identifier_length)) + 1;
         foreach ($recently_updated as $test_profile => $repo_data) {
             echo sprintf('%-' . $longest_identifier_length . 'ls - %-35ls', $test_profile, $repo_data['title']) . PHP_EOL;
             $br = explode('/', $test_profile);
             if (isset($changes[$br[0]]['tests'][$br[1]]['changes'])) {
                 foreach ($changes[$br[0]]['tests'][$br[1]]['changes'] as $test_profile_version => $data) {
                     echo 'v' . $test_profile_version . ' [' . date('d M Y', $data['last_updated']) . ']' . PHP_EOL;
                     echo '  - ' . $data['commit_description'] . PHP_EOL;
                 }
             } else {
                 echo 'Last Updated: ' . date('d F Y', $repo_data['last_updated']) . PHP_EOL;
             }
             echo PHP_EOL;
             // $repo_data['test_type']
         }
     } else {
         echo PHP_EOL . 'No updated tests were found.' . PHP_EOL;
     }
 }
 public static function run($r)
 {
     echo PHP_EOL . 'If you have not already registered for your free OpenBenchmarking.org account, you can do so at http://openbenchmarking.org/' . PHP_EOL . PHP_EOL . 'Once you have registered your account and clicked the link within the verification email, enter your log-in information below.' . PHP_EOL . PHP_EOL;
     echo 'User-Name: ';
     $username = pts_user_io::read_user_input();
     echo 'Password: '******'s_u' => $username, 's_p' => sha1($password), 's_s' => base64_encode(phodevi::system_software(true)), 's_h' => base64_encode(phodevi::system_hardware(true)));
     $login_state = pts_openbenchmarking::make_openbenchmarking_request('account_login', $login_payload);
     $json = json_decode($login_state, true);
     if (isset($json['openbenchmarking']['response']['error'])) {
         trigger_error($json['openbenchmarking']['response']['error'], E_USER_ERROR);
         pts_storage_object::remove_in_file(PTS_CORE_STORAGE, 'openbenchmarking');
     } else {
         $openbenchmarking_payload = array('user_name' => $json['openbenchmarking']['account']['user_name'], 'communication_id' => $json['openbenchmarking']['account']['communication_id'], 'sav' => $json['openbenchmarking']['account']['sav']);
         pts_storage_object::set_in_file(PTS_CORE_STORAGE, 'openbenchmarking', $openbenchmarking_payload);
         echo PHP_EOL . PHP_EOL . 'The Account Has Been Setup.' . PHP_EOL . PHP_EOL;
     }
 }
 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);
         }
     }
 }
 protected function process_hand_shake($user, $buffer)
 {
     $buffer_wrote = parent::process_hand_shake($user, $buffer);
     return $buffer_wrote;
     // TODO potentially don't need below code for this back-end XXX
     if ($buffer_wrote > 0) {
         $resource = substr($user->res, strrpos($user->res, '/') + 1);
         switch (strstr($resource . ' ', ' ', true)) {
             case 'start-user-session':
                 $json = array();
                 $json['pts']['msg']['name'] = 'user_session_start';
                 $this->add_to_status('Starting Session', $json);
                 $this->send_json_data($user->socket, $json);
                 // Phodevi
                 $this->add_to_status('Generating Phodevi Cache + VFS', $json);
                 $this->send_json_data($user->socket, $json);
                 phodevi::system_software(true);
                 phodevi::system_hardware(true);
                 $this->phodevi_vfs = new phodevi_vfs();
                 $this->phodevi_vfs->list_cache_nodes();
                 // Sensors
                 $this->add_to_status('Starting Phodevi Sensor Handler', $json);
                 $this->send_json_data($user->socket, $json);
                 $this->sensor_logging = new phodevi_sensor_monitor(array('all'));
                 $this->sensor_logging->sensor_logging_start();
                 // Test Information
                 $this->add_to_status('Downloading Test Information', $json);
                 $this->send_json_data($user->socket, $json);
                 pts_openbenchmarking::available_tests(true);
                 // Complete
                 $this->add_to_status('Session Startup Complete', $json);
                 $this->send_json_data($user->socket, $json);
                 //$this->disconnect($user->socket);
                 break;
         }
         return true;
     }
 }
 public static function render_page_process($PATH)
 {
     $main = null;
     $identifier_item = isset($PATH[1]) ? $PATH[0] . '/' . $PATH[1] : false;
     if ($identifier_item && pts_test_profile::is_test_profile($identifier_item)) {
         $tp = new pts_test_profile($identifier_item);
         $tp_identifier = $tp->get_identifier(false);
         $main .= '<h1>' . $tp->get_title() . '</h1><p>' . $tp->get_description() . '</p>';
         $main .= '<p><strong>' . $tp->get_test_hardware_type() . ' - ' . phoromatic_server::test_result_count_for_test_profile($_SESSION['AccountID'], $tp_identifier) . ' Results On This Account - ' . $tp->get_test_software_type() . ' - Maintained By: ' . $tp->get_maintainer() . ' - Supported Platforms: ' . implode(', ', $tp->get_supported_platforms()) . '</strong></p>';
         $main .= '<p><a href="http://openbenchmarking.org/test/' . $tp_identifier . '">Find out more about this test profile on OpenBenchmarking.org</a>.</p>';
         $main .= '<h2>Recent Results With This Test</h2>';
         $stmt = phoromatic_server::$db->prepare('SELECT Title, PPRID FROM phoromatic_results WHERE AccountID = :account_id AND UploadID IN (SELECT DISTINCT UploadID FROM phoromatic_results_results WHERE AccountID = :account_id AND TestProfile LIKE :tp) ORDER BY UploadTime DESC LIMIT 30');
         $stmt->bindValue(':account_id', $_SESSION['AccountID']);
         $stmt->bindValue(':tp', $tp_identifier . '%');
         $result = $stmt->execute();
         $recent_result_count = 0;
         while ($result && ($row = $result->fetchArray())) {
             $recent_result_count++;
             $main .= '<h2><a href="/?result/' . $row['PPRID'] . '">' . $row['Title'] . '</a></h2>';
         }
         if ($recent_result_count == 0) {
             $main .= '<p>No results found on this Phoromatic Server for the ' . $tp->get_title() . ' test profile.</p>';
         } else {
             if ($recent_result_count > 5) {
                 $stmt = phoromatic_server::$db->prepare('SELECT UploadID, SystemID, UploadTime FROM phoromatic_results WHERE AccountID = :account_id AND UploadID IN (SELECT DISTINCT UploadID FROM phoromatic_results_results WHERE AccountID = :account_id AND TestProfile LIKE :tp) ORDER BY UploadTime DESC LIMIT 1000');
                 $stmt->bindValue(':account_id', $_SESSION['AccountID']);
                 $stmt->bindValue(':tp', $tp_identifier . '%');
                 $result = $stmt->execute();
                 $recent_result_count = 0;
                 $result_file = new pts_result_file(null, true);
                 while ($result && ($row = $result->fetchArray())) {
                     $composite_xml = phoromatic_server::phoromatic_account_result_path($_SESSION['AccountID'], $row['UploadID']) . 'composite.xml';
                     if (!is_file($composite_xml)) {
                         continue;
                     }
                     // Add to result file
                     $system_name = strtotime($row['UploadTime']) . ': ' . phoromatic_server::system_id_to_name($row['SystemID']);
                     $sub_result_file = new pts_result_file($composite_xml, true);
                     foreach ($sub_result_file->get_result_objects() as $obj) {
                         if ($obj->test_profile->get_identifier(false) == $tp_identifier) {
                             $obj->test_result_buffer->rename(null, $system_name);
                             $result_file->add_result($obj);
                         }
                     }
                 }
                 $table = null;
                 $extra_attributes = array('multi_way_comparison_invert_default' => false);
                 $f = false;
                 foreach ($result_file->get_result_objects() as $obj) {
                     $obj->test_profile->set_display_format('SCATTER_PLOT');
                     foreach ($obj->test_result_buffer->buffer_items as $i => &$item) {
                         if (!is_numeric(substr($item->get_result_identifier(), 0, strpos($item->get_result_identifier(), ':')))) {
                             unset($obj->test_result_buffer->buffer_items[$i]);
                         }
                     }
                     $result_file = null;
                     $main .= '<p align="center">' . pts_render::render_graph_inline_embed($obj, $result_file, $extra_attributes) . '</p>';
                 }
             }
         }
     } else {
         $dc = pts_strings::add_trailing_slash(pts_strings::parse_for_home_directory(pts_config::read_user_config('PhoronixTestSuite/Options/Installation/CacheDirectory', PTS_DOWNLOAD_CACHE_PATH)));
         $dc_exists = is_file($dc . 'pts-download-cache.json');
         if ($dc_exists) {
             $cache_json = file_get_contents($dc . 'pts-download-cache.json');
             $cache_json = json_decode($cache_json, true);
         }
         $test_counts_for_account = phoromatic_server::test_result_count_for_test_profiles($_SESSION['AccountID']);
         foreach (pts_openbenchmarking::available_tests() as $test) {
             $cache_checked = false;
             if ($dc_exists) {
                 if ($cache_json && isset($cache_json['phoronix-test-suite']['cached-tests'])) {
                     $cache_checked = true;
                     if (!in_array($test, $cache_json['phoronix-test-suite']['cached-tests'])) {
                         //continue;
                     }
                 }
             }
             if (!$cache_checked && phoromatic_server::read_setting('show_local_tests_only') && pts_test_install_request::test_files_in_cache($test, true, true) == false) {
                 continue;
             }
             $tp = new pts_test_profile($test);
             if ($tp->get_title() == null) {
                 continue;
             }
             $test_count = 0;
             $tpid = $tp->get_identifier(false);
             foreach ($test_counts_for_account as $test => $count) {
                 if (strpos($test, $tpid) !== false) {
                     $test_count += $count;
                     unset($test_counts_for_account[$test]);
                 }
             }
             $main .= '<h1 style="margin-bottom: 0;"><a href="/?tests/' . $tp->get_identifier(false) . '">' . $tp->get_title() . '</a></h1>';
             $main .= '<p style="font-size: 90%;"><strong>' . $tp->get_test_hardware_type() . '</strong> <em>-</em> ' . $test_count . ' Results On This Account' . ' </p>';
         }
     }
     echo phoromatic_webui_header_logged_in();
     echo '<div id="pts_phoromatic_main_area">' . $main . '</div>';
     echo phoromatic_webui_footer();
 }
        foreach ($index_files as $index_file) {
            $index_data = json_decode(file_get_contents($index_file), true);
            $json_repos['repos'][basename($index_file, '.index')] = array('title' => basename($index_file, '.index'), 'generated' => $index_data['main']['generated']);
        }
        echo json_encode($json_repos);
    } else {
        if (isset($_GET['test'])) {
            $repo = str_replace(array('..', '/'), null, $_GET['repo']);
            $test = str_replace(array('..', '/'), null, $_GET['test']);
            if (pts_openbenchmarking::is_repository($repo)) {
                pts_logger::add_to_log($_SERVER['REMOTE_ADDR'] . ' requested a copy of the ' . $repo . '/' . $test . ' test profile');
                $realpath_file = realpath(PTS_OPENBENCHMARKING_SCRATCH_PATH . $repo . '/' . $test . '.zip');
                if (is_file($realpath_file) && strpos($realpath_file, PTS_OPENBENCHMARKING_SCRATCH_PATH) === 0) {
                    echo base64_encode(file_get_contents($realpath_file));
                }
            }
        } else {
            if (isset($_GET['suite'])) {
                $repo = str_replace(array('..', '/'), null, $_GET['repo']);
                $test = str_replace(array('..', '/'), null, $_GET['test']);
                if (pts_openbenchmarking::is_repository($repo)) {
                    pts_logger::add_to_log($_SERVER['REMOTE_ADDR'] . ' requested a copy of the ' . $repo . '/' . $test . ' test suite');
                    $realpath_file = realpath(PTS_OPENBENCHMARKING_SCRATCH_PATH . $repo . '/' . $test . '.zip');
                    if (is_file($realpath_file) && strpos($realpath_file, PTS_OPENBENCHMARKING_SCRATCH_PATH) === 0) {
                        echo base64_encode(file_get_contents($realpath_file));
                    }
                }
            }
        }
    }
}
 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'));
 }
Esempio n. 25
0
 private static function core_storage_init_process()
 {
     $pso = pts_storage_object::recover_from_file(PTS_CORE_STORAGE);
     if ($pso == false) {
         $pso = new pts_storage_object(true, true);
     }
     // OpenBenchmarking.org - GSID
     $global_gsid = $pso->read_object('global_system_id');
     $global_gsid_e = $pso->read_object('global_system_id_e');
     $global_gsid_p = $pso->read_object('global_system_id_p');
     if (empty($global_gsid) || pts_openbenchmarking::is_valid_gsid_format($global_gsid) == false) {
         // Global System ID for anonymous uploads, etc
         $requested_gsid = true;
         $global_gsid = pts_openbenchmarking_client::request_gsid();
         if (is_array($global_gsid)) {
             $pso->add_object('global_system_id', $global_gsid['gsid']);
             // GSID
             $pso->add_object('global_system_id_p', $global_gsid['gsid_p']);
             // GSID_P
             $pso->add_object('global_system_id_e', $global_gsid['gsid_e']);
             // GSID_E
             pts_define('PTS_GSID', $global_gsid['gsid']);
             pts_define('PTS_GSID_E', $global_gsid['gsid_e']);
         }
     } else {
         if (pts_openbenchmarking::is_valid_gsid_e_format($global_gsid_e) == false || pts_openbenchmarking::is_valid_gsid_p_format($global_gsid_p) == false) {
             pts_define('PTS_GSID', $global_gsid);
             $requested_gsid = false;
             $global_gsid = pts_openbenchmarking_client::retrieve_gsid();
             if (is_array($global_gsid)) {
                 $pso->add_object('global_system_id_p', $global_gsid['gsid_p']);
                 // GSID_P
                 $pso->add_object('global_system_id_e', $global_gsid['gsid_e']);
                 // GSID_E
                 pts_define('PTS_GSID_E', $global_gsid['gsid_e']);
             }
         } else {
             pts_define('PTS_GSID', $global_gsid);
             pts_define('PTS_GSID_E', $global_gsid_e);
             $requested_gsid = false;
         }
     }
     $machine_self_id = $pso->read_object('machine_self_id');
     if (empty($machine_self_id)) {
         $ns = md5('phoronix-test-suite');
         $binary_ns = null;
         for ($i = 0; $i < strlen($ns); $i += 2) {
             $binary_ns .= chr(hexdec($ns[$i] . $ns[$i + 1]));
         }
         $msi_hash = sha1($binary_ns . uniqid(PTS_CORE_VERSION, true) . getenv('USERNAME') . getenv('USER') . getenv('HOSTNAME') . pts_network::get_local_ip());
         $machine_self_id = sprintf('%08s-%04s-%04x-%04x-%12s', substr($msi_hash, 0, 8), substr($msi_hash, 8, 4), hexdec(substr($msi_hash, 12, 4)) & 0xfff | 0x5000, hexdec(substr($msi_hash, 16, 4)) & 0x3fff | 0x8000, substr($msi_hash, 20, 12));
         // machine_self_id is self-generated unique name for Phoromatic/OB purposes in UUIDv5 format
         $pso->add_object('machine_self_id', $machine_self_id);
     }
     pts_define('PTS_MACHINE_SELF_ID', $machine_self_id);
     // Last Run Processing
     $last_core_version = $pso->read_object('last_core_version');
     pts_define('FIRST_RUN_ON_PTS_UPGRADE', $last_core_version != PTS_CORE_VERSION);
     if (FIRST_RUN_ON_PTS_UPGRADE || $pso->read_object('last_php_version') != PTS_PHP_VERSION) {
         // Report any missing/recommended extensions
         self::program_requirement_checks();
     }
     if (FIRST_RUN_ON_PTS_UPGRADE) {
         if ($requested_gsid == false) {
             pts_openbenchmarking_client::update_gsid();
         }
         pts_client::build_temp_cache();
     }
     $pso->add_object('last_core_version', PTS_CORE_VERSION);
     // PTS version last run
     $pso->add_object('last_php_version', PTS_PHP_VERSION);
     // PHP version last run
     //$last_pts_version = $pso->read_object('last_pts_version');
     // do something here with $last_pts_version if you want that information
     $pso->add_object('last_pts_version', PTS_VERSION);
     // PTS version last run
     // Last Run Processing
     $last_run = $pso->read_object('last_run_time');
     pts_define('IS_FIRST_RUN_TODAY', substr($last_run, 0, 10) != date('Y-m-d'));
     $pso->add_object('last_run_time', date('Y-m-d H:i:s'));
     // Time PTS was last run
     pts_define('TIME_SINCE_LAST_RUN', ceil((time() - strtotime($last_run)) / 60));
     // TIME_SINCE_LAST_RUN is in minutes
     // User Agreement Checking
     $agreement_cs = $pso->read_object('user_agreement_cs');
     $pso->add_object('user_agreement_cs', $agreement_cs);
     // User agreement check-sum
     // Phodevi Cache Handling
     $phodevi_cache = $pso->read_object('phodevi_smart_cache');
     if ($phodevi_cache instanceof phodevi_cache && pts_client::read_env('NO_PHODEVI_CACHE') == false) {
         $phodevi_cache = $phodevi_cache->restore_cache(PTS_USER_PATH, PTS_CORE_VERSION);
         phodevi::set_device_cache($phodevi_cache);
         if ($external_phodevi_cache = pts_client::read_env('EXTERNAL_PHODEVI_CACHE')) {
             if (is_dir($external_phodevi_cache) && is_file($external_phodevi_cache . '/core.pt2so')) {
                 $external_phodevi_cache .= '/core.pt2so';
             }
             if (is_file($external_phodevi_cache)) {
                 $external_phodevi_cache = pts_storage_object::force_recover_from_file($external_phodevi_cache);
                 if ($external_phodevi_cache != false) {
                     $external_phodevi_cache = $external_phodevi_cache->read_object('phodevi_smart_cache');
                     $external_phodevi_cache = $external_phodevi_cache->restore_cache(null, PTS_CORE_VERSION);
                     if ($external_phodevi_cache != false) {
                         //unset($external_phodevi_cache['system']['operating-system']);
                         //unset($external_phodevi_cache['system']['vendor-identifier']);
                         phodevi::set_device_cache($external_phodevi_cache);
                     }
                 }
             }
         }
     }
     // Archive to disk
     $pso->save_to_file(PTS_CORE_STORAGE);
 }
 public function get_contained_test_profiles()
 {
     $contained = array();
     // read the repo
     $repo_index = pts_openbenchmarking::read_repository_index($this->repo);
     if (isset($repo_index['tests']) && is_array($repo_index['tests'])) {
         foreach ($repo_index['tests'] as $test_identifier => &$test) {
             if (!in_array(phodevi::operating_system(), $test['supported_platforms']) || empty($test['title'])) {
                 // Initial check to not do unsupported tests
                 continue;
             }
             if ($this->is_virtual_os_selector && !in_array($this->virtual, array_map('strtolower', $test['supported_platforms']))) {
                 // Doing a virtual suite of all tests specific to an OS, but this test profile is not supported there
                 continue;
             } else {
                 if ($this->is_virtual_subsystem_selector && $this->virtual != strtolower($test['test_type'])) {
                     // Doing a virtual suite of all tests specific to a test_type, but this test profile is not supported there
                     continue;
                 } else {
                     if ($this->is_virtual_software_type && $this->virtual != strtolower($test['software_type'])) {
                         // Doing a virtual suite of all tests specific to a software_type, but this test profile is not supported there
                         continue;
                     } else {
                         if ($this->is_virtual_internal_tag && !in_array($this->virtual, array_map('strtolower', $test['internal_tags']))) {
                             // Doing a virtual suite of all tests matching an internal tag
                             continue;
                         }
                     }
                 }
             }
             $test_version = array_shift($test['versions']);
             $test_profile = new pts_test_profile($this->repo . '/' . $test_identifier . '-' . $test_version);
             if ($test_profile->get_display_format() != 'BAR_GRAPH' || !in_array($test_profile->get_license(), array('Free', 'Non-Free'))) {
                 // Also ignore these tests
                 continue;
             }
             if ($this->is_virtual_installed && $test_profile->is_test_installed() == false) {
                 // Test is not installed
                 continue;
             }
             if ($test_profile->is_supported(false)) {
                 // All checks passed, add to virtual suite
                 array_push($contained, $test_profile);
                 continue;
             }
         }
     }
     return $contained;
 }
    public static function render_page_process($PATH)
    {
        if (isset($_POST['suite_title'])) {
            //	echo '<pre>';
            //	var_dump($_POST);
            //	echo '</pre>';
            if (strlen($_POST['suite_title']) < 3) {
                echo '<h2>Suite title must be at least three characters.</h2>';
            }
            //echo 'TEST SUITE: ' . $_POST['suite_title'] . '<br />';
            //echo 'TEST SUITE: ' . $_POST['suite_description'] . '<br />';
            $tests = array();
            foreach ($_POST['test_add'] as $i => $test_identifier) {
                $test_prefix = $_POST['test_prefix'][$i];
                $args = array();
                $args_name = array();
                foreach ($_POST as $i => $v) {
                    if (strpos($i, $test_prefix) !== false && substr($i, -9) != '_selected') {
                        if (strpos($v, '||') !== false) {
                            $opts = explode('||', $v);
                            $a = array();
                            $d = array();
                            foreach ($opts as $opt) {
                                $t = explode('::', $opt);
                                array_push($a, $t[1]);
                                array_push($d, $t[0]);
                            }
                            array_push($args, $a);
                            array_push($args_name, $d);
                        } else {
                            array_push($args, array($v));
                            array_push($args_name, array($_POST[$i . '_selected']));
                        }
                    }
                }
                $test_args = array();
                $test_args_description = array();
                pts_test_run_options::compute_all_combinations($test_args, null, $args, 0);
                pts_test_run_options::compute_all_combinations($test_args_description, null, $args_name, 0, ' - ');
                foreach (array_keys($test_args) as $i) {
                    array_push($tests, array('test' => $test_identifier, 'description' => $test_args_description[$i], 'args' => $test_args[$i]));
                }
            }
            if (count($tests) < 1) {
                echo '<h2>You must add at least one test to the suite.</h2>';
            }
            $suite_writer = new pts_test_suite_writer();
            $version_bump = 0;
            do {
                $suite_version = '1.' . $version_bump . '.0';
                $suite_id = $suite_writer->clean_save_name_string($_POST['suite_title']) . '-' . $suite_version;
                $suite_dir = phoromatic_server::phoromatic_account_suite_path($_SESSION['AccountID'], $suite_id);
                $version_bump++;
            } while (is_dir($suite_dir));
            pts_file_io::mkdir($suite_dir);
            $save_to = $suite_dir . '/suite-definition.xml';
            $suite_writer->add_suite_information($_POST['suite_title'], $suite_version, $_SESSION['UserName'], 'System', $_POST['suite_description']);
            foreach ($tests as $m) {
                $suite_writer->add_to_suite($m['test'], $m['args'], $m['description']);
            }
            $suite_writer->save_xml($save_to);
            echo '<h2>Saved As ' . $suite_id . '</h2>';
        }
        echo phoromatic_webui_header_logged_in();
        $main = '<h1>Local Suites</h1><p>Find already created local test suites by your account/group via the <a href="/?local_suites">local suites</a> page.</p>';
        if (!PHOROMATIC_USER_IS_VIEWER) {
            $main .= '<h1>Build Suite</h1><p>A test suite in the realm of the Phoronix Test Suite, OpenBenchmarking.org, and Phoromatic is <strong>a collection of test profiles with predefined settings</strong>. Establishing a test suite makes it easy to run repetitive testing on the same set of test profiles by simply referencing the test suite name.</p>';
            $main .= '<form action="' . $_SERVER['REQUEST_URI'] . '" name="build_suite" id="build_suite" method="post" onsubmit="return validate_suite();">
			<h3>Title:</h3>
			<p><input type="text" name="suite_title" /></p>
			<h3>Description:</h3>
			<p><textarea name="suite_description" id="suite_description" cols="60" rows="2"></textarea></p>
			<h3>Tests In Schedule:</h3>
			<p><div id="test_details"></div></p>
			<h3>Add Another Test</h3>';
            $main .= '<select name="add_to_suite_select_test" id="add_to_suite_select_test" onchange="phoromatic_build_suite_test_details();">';
            $dc = pts_strings::add_trailing_slash(pts_client::parse_home_directory(pts_config::read_user_config('PhoronixTestSuite/Options/Installation/CacheDirectory', PTS_DOWNLOAD_CACHE_PATH)));
            $dc_exists = is_file($dc . 'pts-download-cache.json');
            foreach (pts_openbenchmarking::available_tests(false, true) as $test) {
                $cache_checked = false;
                if ($dc_exists) {
                    $cache_json = file_get_contents($dc . 'pts-download-cache.json');
                    $cache_json = json_decode($cache_json, true);
                    if ($cache_json && isset($cache_json['phoronix-test-suite']['cached-tests'])) {
                        $cache_checked = true;
                        if (!in_array($test, $cache_json['phoronix-test-suite']['cached-tests'])) {
                            continue;
                        }
                    }
                }
                if (!$cache_checked && phoromatic_server::read_setting('show_local_tests_only') && pts_test_install_request::test_files_in_cache($test, true, true) == false) {
                    continue;
                }
                $main .= '<option value="' . $test . '">' . $test . '</option>';
            }
            $main .= '</select>';
            $main .= '<p align="right"><input name="submit" value="Create Suite" type="submit" onclick="return pts_rmm_validate_suite();" /></p>';
        }
        echo '<div id="pts_phoromatic_main_area">' . $main . '</div>';
        echo phoromatic_webui_footer();
    }
 public static function retrieve_gsid()
 {
     if (!pts_network::internet_support_available()) {
         return false;
     }
     // If the GSID_E and GSID_P are not known due to being from an old client
     $json = pts_openbenchmarking::make_openbenchmarking_request('retrieve_gsid', array());
     $json = json_decode($json, true);
     return isset($json['openbenchmarking']['gsid']) ? $json['openbenchmarking']['gsid'] : false;
 }
 public function get_estimated_run_time()
 {
     // get estimated run-time (in seconds)
     if ($this->test_installation != false && is_numeric($this->test_installation->get_average_run_time()) && $this->test_installation->get_average_run_time() > 0) {
         $estimated_run_time = $this->test_installation->get_average_run_time();
     } else {
         $estimated_run_time = parent::get_estimated_run_time();
     }
     if ($estimated_run_time < 2 && PTS_IS_CLIENT) {
         $identifier = explode('/', $this->get_identifier(false));
         $repo_index = pts_openbenchmarking::read_repository_index($identifier[0]);
         $estimated_run_time = isset($identifier[1]) && isset($repo_index['tests'][$identifier[1]]) && isset($repo_index['tests'][$identifier[1]]['average_run_time']) ? $repo_index['tests'][$identifier[1]]['average_run_time'] : 0;
     }
     return $estimated_run_time;
 }
 public function post_execution_process()
 {
     if ($this->do_save_results()) {
         if ($this->result_file->get_test_count() == 0 && $this->is_new_result_file) {
             pts_file_io::delete(PTS_SAVE_RESULTS_PATH . $this->get_file_name());
             return false;
         }
         pts_file_io::delete(PTS_SAVE_RESULTS_PATH . $this->get_file_name() . '/test-logs/active/', null, true);
         if ($this->is_new_result_file || $this->result_already_contains_identifier() == false) {
             // nothing to do here now
         }
         echo PHP_EOL;
         pts_module_manager::module_process('__event_results_process', $this);
         pts_client::save_test_result($this->get_file_name() . '/composite.xml', $this->result_file->get_xml(), true, $this->results_identifier);
         pts_module_manager::module_process('__event_results_saved', $this);
         //echo PHP_EOL . 'Results Saved To: ; . PTS_SAVE_RESULTS_PATH . $this->get_file_name() . ;/composite.xml' . PHP_EOL;
         if (!$this->auto_mode) {
             if ($this->batch_mode) {
                 if ($this->batch_mode['OpenBrowser']) {
                     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $this->get_file_name() . '/index.html', null, true, true);
                 }
             } else {
                 pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $this->get_file_name() . '/index.html', null, true, false);
             }
         }
         if ($this->allow_sharing_of_results && pts_network::internet_support_available()) {
             if ($this->auto_upload_to_openbenchmarking || pts_openbenchmarking_client::auto_upload_results() || pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/AlwaysUploadResultsToOpenBenchmarking', 'FALSE')) {
                 $upload_results = true;
             } else {
                 if ($this->batch_mode) {
                     $upload_results = $this->batch_mode['UploadResults'];
                 } else {
                     if (!$this->auto_mode) {
                         $upload_results = pts_user_io::prompt_bool_input('Would you like to upload the results to OpenBenchmarking.org', true);
                     } else {
                         $upload_results = false;
                     }
                 }
             }
             if ($upload_results) {
                 $this->openbenchmarking_results_data = pts_openbenchmarking::upload_test_result($this, true);
                 if ($this->get_results_url()) {
                     if (!$this->auto_mode && !$this->batch_mode && pts_openbenchmarking_client::auto_upload_results() == false) {
                         pts_client::display_web_page($this->get_results_url(), 'Do you want to launch OpenBenchmarking.org', true);
                     }
                 } else {
                     echo PHP_EOL . 'Results Failed To Upload.' . PHP_EOL;
                 }
             }
         }
     }
 }