public static function run($r)
 {
     $result = $r[0];
     $result_file = new pts_result_file($result);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     $remove_identifiers = explode(',', pts_user_io::prompt_text_menu('Select the test run(s) to remove', $result_file_identifiers, true));
     $keep_identifiers = array();
     foreach ($result_file_identifiers as $identifier) {
         if (!in_array($identifier, $remove_identifiers)) {
             array_push($keep_identifiers, $identifier);
         }
     }
     foreach (array('test-logs', 'system-logs', 'installation-logs') as $dir_name) {
         foreach ($remove_identifiers as $remove_identifier) {
             if (is_dir(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $remove_identifier)) {
                 pts_file_io::delete(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $remove_identifier, null, true);
             }
         }
     }
     $extract_select = new pts_result_merge_select($result, $keep_identifiers);
     $extract_result = pts_merge::merge_test_results($extract_select);
     pts_client::save_test_result($r[0] . '/composite.xml', $extract_result);
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $r[0] . '/index.html');
 }
 public static function run($args)
 {
     $result = $args[0];
     $result_file = new pts_result_file($result);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     $extract_selects = array();
     echo PHP_EOL . 'Enter The New Order To Display The New Results, From Left To Right.' . PHP_EOL;
     do {
         $extract_identifier = pts_user_io::prompt_text_menu('Select the test run to be showed next', $result_file_identifiers);
         array_push($extract_selects, new pts_result_merge_select($result, $extract_identifier));
         $old_identifiers = $result_file_identifiers;
         $result_file_identifiers = array();
         foreach ($old_identifiers as $identifier) {
             if ($identifier != $extract_identifier) {
                 array_push($result_file_identifiers, $identifier);
             }
         }
     } while (count($result_file_identifiers) > 0);
     $ordered_result = pts_merge::merge_test_results_array($extract_selects);
     pts_client::save_test_result($args[0] . '/composite.xml', $ordered_result);
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $args[0] . '/index.html');
 }
 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($args)
 {
     $result_file = new pts_result_file($args[0]);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     echo PHP_EOL . 'Enter The New Order To Display The New Results, From Left To Right.' . PHP_EOL;
     $sorted_identifiers = array();
     do {
         $extract_identifier = pts_user_io::prompt_text_menu('Select the test run to be showed next', $result_file_identifiers);
         $sorted_identifiers[] = $extract_identifier;
         $old_identifiers = $result_file_identifiers;
         $result_file_identifiers = array();
         foreach ($old_identifiers as $identifier) {
             if ($identifier != $extract_identifier) {
                 $result_file_identifiers[] = $identifier;
             }
         }
     } while (count($result_file_identifiers) > 0);
     $result_file->reorder_runs($sorted_identifiers);
     pts_client::save_test_result($result_file->get_file_location(), $result_file->get_xml());
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $args[0] . '/index.html');
 }
 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 static function run($r)
 {
     $result = $r[0];
     $result_file = new pts_result_file($result);
     $result_file_identifiers = $result_file->get_system_identifiers();
     $rename_identifier = pts_user_io::prompt_text_menu('Select the test run to rename', $result_file_identifiers);
     $rename_identifier_new = pts_user_io::prompt_user_input('Enter the new identifier');
     foreach (array('test-logs', 'system-logs', 'installation-logs') as $dir_name) {
         if (is_dir(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier)) {
             rename(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier, PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier_new);
         }
     }
     $result_file->rename_run($rename_identifier, $rename_identifier_new);
     pts_client::save_test_result($result_file->get_file_location(), $result_file->get_xml());
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $r[0] . '/index.html');
 }
 public static function run($args)
 {
     $result_file = new pts_result_file($args[0]);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     $extract_identifiers = pts_strings::comma_explode(pts_user_io::prompt_text_menu('Select the test run(s) to extract', $result_file_identifiers, true));
     $remove_identifiers = array_diff($result_file_identifiers, $extract_identifiers);
     $result_file->remove_run($remove_identifiers);
     do {
         echo PHP_EOL . 'Enter new result file to extract to: ';
         $extract_to = pts_user_io::read_user_input();
         $extract_to = pts_test_run_manager::clean_save_name($extract_to);
     } while (empty($extract_to));
     pts_client::save_test_result($extract_to . '/composite.xml', $result_file->get_xml());
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $extract_to . '/index.html');
 }
 public static function run($r)
 {
     $result_file = new pts_result_file($r[0]);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     $remove_identifiers = explode(',', pts_user_io::prompt_text_menu('Select the test run(s) to remove', $result_file_identifiers, true));
     $result_file->remove_run($remove_identifiers);
     $result_dir = dirname($result_file->get_file_location()) . '/';
     foreach (array('test-logs', 'system-logs', 'installation-logs') as $dir_name) {
         foreach ($remove_identifiers as $remove_identifier) {
             if (is_dir($result_dir . $dir_name . '/' . $remove_identifier)) {
                 pts_file_io::delete($result_dir . $dir_name . '/' . $remove_identifier, null, true);
             }
         }
     }
     pts_client::save_test_result($result_file->get_file_location(), $result_file->get_xml());
     pts_client::display_web_page($result_dir . '/index.html');
 }
 public static function run($args)
 {
     $save_name = $args[0];
     $result_file = new pts_result_file($args[0]);
     $system_identifiers = $result_file->get_system_identifiers();
     $test_positions = array();
     $pos = 0;
     foreach ($result_file->get_result_objects() as $result_object) {
         $this_result_object_identifiers = $result_object->test_result_buffer->get_identifiers();
         foreach ($system_identifiers as $system_identifier) {
             if (!in_array($system_identifier, $this_result_object_identifiers)) {
                 if (!isset($test_positions[$system_identifier])) {
                     $test_positions[$system_identifier] = array();
                 }
                 array_push($test_positions[$system_identifier], $pos);
             }
         }
         $pos++;
     }
     $incomplete_identifiers = array_keys($test_positions);
     if (count($incomplete_identifiers) == 0) {
         echo PHP_EOL . 'It appears that there are no incomplete test results within this saved file.' . PHP_EOL . PHP_EOL;
         return false;
     }
     $selected = pts_user_io::prompt_text_menu('Select which incomplete test run you would like to finish', $incomplete_identifiers);
     // Now run it
     if (pts_test_run_manager::initial_checks($args[0]) == false) {
         return false;
     }
     $test_run_manager = new pts_test_run_manager(pts_c::is_recovering);
     // Load the tests to run
     if ($test_run_manager->load_result_file_to_run($save_name, $selected, $result_file, $test_positions[$selected]) == false) {
         return false;
     }
     // Run the actual tests
     $test_run_manager->pre_execution_process();
     $test_run_manager->call_test_runs();
     $test_run_manager->post_execution_process();
 }
 public static function run($args)
 {
     $result = $args[0];
     $result_file = new pts_result_file($result);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     $extract_identifiers = pts_strings::comma_explode(pts_user_io::prompt_text_menu('Select the test run(s) to extract', $result_file_identifiers, true));
     $extract_selects = array();
     foreach ($extract_identifiers as $extract_identifier) {
         array_push($extract_selects, new pts_result_merge_select($result, $extract_identifier));
     }
     do {
         echo PHP_EOL . 'Enter new result file to extract to: ';
         $extract_to = pts_user_io::read_user_input();
         $extract_to = pts_test_run_manager::clean_save_name($extract_to);
     } while (empty($extract_to) || pts_result_file::is_test_result_file($extract_to));
     $extract_result = call_user_func_array(array('pts_merge', 'merge_test_results'), $extract_selects);
     pts_client::save_test_result($extract_to . '/composite.xml', $extract_result);
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $extract_to . '/index.html');
 }
 public static function run($r)
 {
     $result = $r[0];
     $result_file = new pts_result_file($result);
     $result_file_identifiers = $result_file->get_system_identifiers();
     $rename_identifier = pts_user_io::prompt_text_menu('Select the test run to rename', $result_file_identifiers);
     $rename_identifier_new = pts_user_io::prompt_user_input('Enter the new identifier');
     $merge_selects = array();
     foreach ($result_file_identifiers as $identifier) {
         $this_merge_select = new pts_result_merge_select($result, $identifier);
         if ($identifier == $rename_identifier && $rename_identifier != $rename_identifier_new) {
             $this_merge_select->rename_identifier($rename_identifier_new);
         }
         array_push($merge_selects, $this_merge_select);
     }
     foreach (array('test-logs', 'system-logs', 'installation-logs') as $dir_name) {
         if (is_dir(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier)) {
             rename(PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier, PTS_SAVE_RESULTS_PATH . $r[0] . '/' . $dir_name . '/' . $rename_identifier_new);
         }
     }
     $extract_result = pts_merge::merge_test_results_array($merge_selects);
     pts_client::save_test_result($r[0] . '/composite.xml', $extract_result);
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $r[0] . '/index.html');
 }
 protected static function download_test_files(&$test_install_request, $download_location = false, $no_prompts = false)
 {
     // Download needed files for a test
     if ($test_install_request->get_download_object_count() == 0) {
         return true;
     }
     $identifier = $test_install_request->test_profile->get_identifier();
     pts_client::$display->test_install_downloads($test_install_request);
     if ($download_location == false) {
         $download_location = $test_install_request->test_profile->get_install_dir();
     }
     pts_file_io::mkdir($download_location);
     $module_pass = array($identifier, $test_install_request->get_download_objects());
     pts_module_manager::module_process('__pre_test_download', $module_pass);
     foreach ($test_install_request->get_download_objects() as $download_package) {
         $package_filename = $download_package->get_filename();
         $download_destination = $download_location . $package_filename;
         $download_destination_temp = $download_destination . '.pts';
         if ($download_package->get_download_location_type() == null) {
             // Attempt a possible last-minute look-aside copy cache in case a previous test in the install queue downloaded this file already
             $lookaside_copy = pts_test_install_manager::file_lookaside_test_installations($download_package);
             if ($lookaside_copy) {
                 if ($download_package->get_filesize() == 0) {
                     $download_package->set_filesize(filesize($lookaside_copy));
                 }
                 $download_package->set_download_location('LOOKASIDE_DOWNLOAD_CACHE', array($lookaside_copy));
             }
         }
         switch ($download_package->get_download_location_type()) {
             case 'IN_DESTINATION_DIR':
                 pts_client::$display->test_install_download_file('FILE_FOUND', $download_package);
                 continue;
             case 'REMOTE_DOWNLOAD_CACHE':
                 $download_tries = 0;
                 do {
                     foreach ($download_package->get_download_location_path() as $remote_download_cache_file) {
                         pts_client::$display->test_install_download_file('DOWNLOAD_FROM_CACHE', $download_package);
                         pts_network::download_file($remote_download_cache_file, $download_destination_temp);
                         if (!is_file($download_destination_temp) || filesize($download_destination_temp) == 0) {
                             self::test_install_error(null, $test_install_request, 'The file failed to download from the cache.');
                             pts_file_io::unlink($download_destination_temp);
                             break;
                         } else {
                             if ($download_package->check_file_hash($download_destination_temp)) {
                                 rename($download_destination_temp, $download_destination);
                                 break;
                             } else {
                                 self::test_install_error(null, $test_install_request, 'The check-sum of the downloaded file failed.');
                                 pts_file_io::unlink($download_destination_temp);
                             }
                         }
                     }
                     $download_tries++;
                 } while (!is_file($download_destination) && $download_tries < 2);
                 if (is_file($download_destination)) {
                     continue;
                 }
             case 'MAIN_DOWNLOAD_CACHE':
             case 'LOCAL_DOWNLOAD_CACHE':
             case 'LOOKASIDE_DOWNLOAD_CACHE':
                 $download_cache_file = pts_arrays::last_element($download_package->get_download_location_path());
                 if (is_file($download_cache_file)) {
                     if (pts_config::read_bool_config('PhoronixTestSuite/Options/Installation/SymLinkFilesFromCache', 'FALSE') && $download_package->get_download_location_type() != 'LOOKASIDE_DOWNLOAD_CACHE') {
                         // For look-aside copies never symlink (unless a pre-packaged LiveCD) in case the other test ends up being un-installed
                         // SymLinkFilesFromCache is disabled by default
                         pts_client::$display->test_install_download_file('LINK_FROM_CACHE', $download_package);
                         symlink($download_cache_file, $download_destination);
                     } else {
                         // File is to be copied
                         // Try up to two times to copy a file
                         $attempted_copies = 0;
                         do {
                             pts_client::$display->test_install_download_file('COPY_FROM_CACHE', $download_package);
                             // $context = stream_context_create();
                             // stream_context_set_params($context, array('notification' => array('pts_network', 'stream_status_callback')));
                             // TODO: get the context working correctly for this copy()
                             copy($download_cache_file, $download_destination_temp);
                             pts_client::$display->test_install_progress_completed();
                             // Verify that the file was copied fine
                             if ($download_package->check_file_hash($download_destination_temp)) {
                                 rename($download_destination_temp, $download_destination);
                                 break;
                             } else {
                                 self::test_install_error(null, $test_install_request, 'The check-sum of the copied file failed.');
                                 pts_file_io::unlink($download_destination_temp);
                             }
                             $attempted_copies++;
                         } while ($attempted_copies < 2);
                     }
                     if (is_file($download_destination)) {
                         continue;
                     }
                 }
             default:
                 $package_urls = $download_package->get_download_url_array();
                 // Download the file
                 if (!is_file($download_destination) && count($package_urls) > 0 && $package_urls[0] != null) {
                     $fail_count = 0;
                     do {
                         if (pts_network::internet_support_available()) {
                             if (!$no_prompts && pts_config::read_bool_config('PhoronixTestSuite/Options/Installation/PromptForDownloadMirror', 'FALSE') && count($package_urls) > 1) {
                                 // Prompt user to select mirror
                                 do {
                                     echo PHP_EOL . 'Available Download Mirrors:' . PHP_EOL . PHP_EOL;
                                     $url = pts_user_io::prompt_text_menu('Select Preferred Mirror', $package_urls, false);
                                 } while (pts_strings::is_url($url) == false);
                             } else {
                                 // Auto-select mirror
                                 shuffle($package_urls);
                                 do {
                                     $url = array_pop($package_urls);
                                 } while (pts_strings::is_url($url) == false && !empty($package_urls));
                             }
                             pts_client::$display->test_install_download_file('DOWNLOAD', $download_package);
                             $download_start = time();
                             pts_network::download_file($url, $download_destination_temp);
                             $download_end = time();
                         } else {
                             self::test_install_error(null, $test_install_request, 'Internet support is needed and it\'s disabled or not available.');
                             return false;
                         }
                         if ($download_package->check_file_hash($download_destination_temp)) {
                             // Download worked
                             if (is_file($download_destination_temp)) {
                                 rename($download_destination_temp, $download_destination);
                             }
                             if ($download_package->get_filesize() > 0 && $download_end != $download_start) {
                                 pts_download_speed_manager::update_download_speed_average($download_package->get_filesize(), $download_end - $download_start);
                             }
                         } else {
                             // Download failed
                             if (is_file($download_destination_temp) && filesize($download_destination_temp) < 500 && (stripos(file_get_contents($download_destination_temp), 'not found') !== false || strpos(file_get_contents($download_destination_temp), 404) !== false)) {
                                 self::test_install_error(null, $test_install_request, 'File Not Found: ' . $url);
                                 $md5_failed = false;
                             } else {
                                 if (is_file($download_destination_temp) && filesize($download_destination_temp) > 0) {
                                     self::test_install_error(null, $test_install_request, 'Checksum Failed: ' . $url);
                                     $md5_failed = true;
                                 } else {
                                     self::test_install_error(null, $test_install_request, 'Download Failed: ' . $url);
                                     $md5_failed = false;
                                 }
                             }
                             pts_file_io::unlink($download_destination_temp);
                             $fail_count++;
                             if ($fail_count > 3) {
                                 $try_again = false;
                             } else {
                                 if (count($package_urls) > 0 && $package_urls[0] != null) {
                                     self::test_install_error(null, $test_install_request, 'Attempting to download from alternate mirror.');
                                     $try_again = true;
                                 } else {
                                     if ($no_prompts) {
                                         $try_again = false;
                                     } else {
                                         if ($md5_failed) {
                                             $try_again = pts_user_io::prompt_bool_input('Try downloading the file again', true, 'TRY_DOWNLOAD_AGAIN');
                                         } else {
                                             $try_again = false;
                                         }
                                     }
                                     if ($try_again) {
                                         $package_urls[] = $url;
                                     }
                                 }
                             }
                             if (!$try_again) {
                                 //self::test_install_error(null, $test_install_request, 'Download of Needed Test Dependencies Failed!');
                                 return false;
                             }
                         }
                     } while (!is_file($download_destination));
                 }
                 pts_module_manager::module_process('__interim_test_download', $module_pass);
         }
     }
     pts_module_manager::module_process('__post_test_download', $identifier);
     return true;
 }
 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 static function install_dependencies(&$test_profiles)
 {
     // PTS External Dependencies install on distribution
     if (phodevi::is_windows() || phodevi::is_macosx() || pts_flags::no_external_dependencies()) {
         // Windows doesn't use any external dependencies
         return true;
     }
     // Find all the tests that need to be checked
     $tests_to_check = array();
     foreach ($test_profiles as $test_profile) {
         if (!in_array($test_profile, $tests_to_check) && $test_profile->is_supported()) {
             array_push($tests_to_check, $test_profile);
         }
     }
     // Find all of the POSSIBLE test dependencies
     $required_test_dependencies = array();
     foreach ($tests_to_check as &$test_profile) {
         foreach ($test_profile->get_dependencies() as $test_dependency) {
             if (empty($test_dependency)) {
                 continue;
             }
             if (isset($required_test_dependencies[$test_dependency]) == false) {
                 $required_test_dependencies[$test_dependency] = array();
             }
             array_push($required_test_dependencies[$test_dependency], $test_profile);
         }
     }
     if (pts_c::$test_flags & pts_c::skip_tests_with_missing_dependencies) {
         // Remove tests that have external dependencies that aren't satisfied and then return
         $generic_packages_needed = array();
         $required_test_dependencies_copy = $required_test_dependencies;
         $dependencies_to_install = self::check_dependencies_missing_from_system($required_test_dependencies_copy, $generic_packages_needed);
         self::remove_tests_with_missing_dependencies($test_profiles, $generic_packages_needed, $required_test_dependencies);
         return true;
     }
     if (!empty($required_test_dependencies)) {
         // The 'common-dependencies' package is any general non-explicitly-required but nice-to-have packages like mesa-utils for providing glxinfo about the system
         // So if we're going to be installing external dependencies anyways, might as well try to see the common-dependencies are satisfied
         $required_test_dependencies['common-dependencies'] = array();
     }
     // Does the user wish to skip any particular dependencies?
     if (pts_client::read_env('SKIP_EXTERNAL_DEPENDENCIES')) {
         $dependencies_to_skip = explode(',', pts_client::read_env('SKIP_EXTERNAL_DEPENDENCIES'));
         foreach ($dependencies_to_skip as $dependency_name) {
             if (isset($required_test_dependencies[$dependency_name])) {
                 unset($required_test_dependencies[$dependency_name]);
             }
         }
     }
     // Make a copy for use to check at end of process to see if all dependencies were actually found
     $required_test_dependencies_copy = $required_test_dependencies;
     // Find the dependencies that are actually missing from the system
     $dependencies_to_install = self::check_dependencies_missing_from_system($required_test_dependencies);
     // If it's automated and can't install without root, return true if there are no dependencies to do otherwise false
     if (pts_c::$test_flags & pts_c::auto_mode && phodevi::is_root() == false) {
         return count($dependencies_to_install) == 0;
     }
     // Do the actual dependency install process
     if (count($dependencies_to_install) > 0) {
         self::install_packages_on_system($dependencies_to_install);
     }
     // There were some dependencies not supported on this OS or are missing from the distro's XML file
     if (count($required_test_dependencies) > 0 && count($dependencies_to_install) == 0) {
         $exdep_generic_parser = new pts_exdep_generic_parser();
         $to_report = array();
         foreach (array_keys($required_test_dependencies) as $dependency) {
             $dependency_data = $exdep_generic_parser->get_package_data($dependency);
             if ($dependency_data['possible_packages'] != null) {
                 array_push($to_report, $dependency_data['title'] . PHP_EOL . 'Possible Package Names: ' . $dependency_data['possible_packages']);
             }
         }
         if (count($to_report) > 0) {
             echo PHP_EOL . 'Some additional dependencies are required, but they could not be installed automatically for your operating system.' . PHP_EOL . 'Below are the software packages that must be installed.' . PHP_EOL . PHP_EOL;
             foreach ($to_report as $report) {
                 pts_client::$display->generic_heading($report);
             }
             if (pts_c::$test_flags ^ pts_c::batch_mode && pts_c::$test_flags ^ pts_c::auto_mode) {
                 echo 'The above dependencies should be installed before proceeding. Press any key when you\'re ready to continue.';
                 pts_user_io::read_user_input();
                 echo PHP_EOL;
             }
         }
     }
     // Find the dependencies that are still missing from the system
     if (pts_c::$test_flags ^ pts_c::batch_mode && pts_c::$test_flags ^ pts_c::auto_mode && !defined('PHOROMATIC_PROCESS')) {
         $generic_packages_needed = array();
         $required_test_dependencies = $required_test_dependencies_copy;
         $dependencies_to_install = self::check_dependencies_missing_from_system($required_test_dependencies_copy, $generic_packages_needed);
         if (count($generic_packages_needed) > 0) {
             echo PHP_EOL . 'There are dependencies still missing from the system:' . PHP_EOL;
             echo pts_user_io::display_text_list(self::generic_names_to_titles($generic_packages_needed));
             $actions = array('IGNORE' => 'Ignore missing dependencies and proceed with installation.', 'SKIP_TESTS_WITH_MISSING_DEPS' => 'Skip installing the tests with missing dependencies.', 'REATTEMPT_DEP_INSTALL' => 'Re-attempt to install the missing dependencies.', 'QUIT' => 'Quit the current Phoronix Test Suite process.');
             $selected_action = pts_user_io::prompt_text_menu('Missing dependencies action', $actions, false, true);
             switch ($selected_action) {
                 case 'IGNORE':
                     break;
                 case 'SKIP_TESTS_WITH_MISSING_DEPS':
                     // Unset the tests that have dependencies still missing
                     self::remove_tests_with_missing_dependencies($test_profiles, $generic_packages_needed, $required_test_dependencies);
                     break;
                 case 'REATTEMPT_DEP_INSTALL':
                     self::install_packages_on_system($dependencies_to_install);
                     break;
                 case 'QUIT':
                     exit(0);
             }
         }
     }
     return true;
 }
 public function determine_tests_to_run(&$to_run_objects)
 {
     $unique_test_count = count(array_unique($to_run_objects));
     $run_contains_a_no_result_type = false;
     $request_results_save = false;
     foreach ($to_run_objects as &$run_object) {
         // TODO: determine whether to print the titles of what's being run?
         if ($run_object instanceof pts_test_profile) {
             if ($run_object->get_identifier() == null || $run_object->get_title() == null || $this->validate_test_to_run($run_object) == false) {
                 continue;
             }
             if ($run_contains_a_no_result_type == false && $run_object->get_display_format() == 'NO_RESULT') {
                 $run_contains_a_no_result_type = true;
             }
             if ($request_results_save == false && $run_object->do_auto_save_results()) {
                 $request_results_save = true;
             }
             foreach (self::test_prompts_to_result_objects($run_object) as $result_object) {
                 $this->add_test_result_object($result_object);
             }
         } else {
             if ($run_object instanceof pts_test_suite) {
                 $this->pre_run_message = $run_object->get_pre_run_message();
                 $this->post_run_message = $run_object->get_post_run_message();
                 if ($run_object->get_run_mode() == 'PCQS') {
                     $this->is_pcqs = true;
                 }
                 foreach ($run_object->get_contained_test_result_objects() as $result_object) {
                     $this->add_test_result_object($result_object);
                 }
             } else {
                 if ($run_object instanceof pts_virtual_test_queue) {
                     foreach ($run_object->get_contained_test_result_objects() as $result_object) {
                         $this->add_test_result_object($result_object);
                     }
                 } else {
                     if ($run_object instanceof pts_result_file) {
                         // Print the $to_run ?
                         $this->run_description = $run_object->get_description();
                         $preset_vars = $run_object->get_preset_environment_variables();
                         $result_objects = $run_object->get_result_objects();
                         $this->set_save_name($run_object->get_identifier(), false);
                         $this->file_name_title = $run_object->get_title();
                         pts_module_manager::process_environment_variables_string_to_set($preset_vars);
                         foreach ($result_objects as &$result_object) {
                             if ($result_object->test_profile->get_identifier() == null) {
                                 continue;
                             }
                             $test_result = new pts_test_result($result_object->test_profile);
                             $test_result->set_used_arguments($result_object->get_arguments());
                             $test_result->set_used_arguments_description($result_object->get_arguments_description());
                             $this->add_test_result_object($test_result);
                         }
                     } else {
                         if ($run_object instanceof pts_virtual_test_suite) {
                             $virtual_suite_tests = $run_object->get_contained_test_profiles();
                             foreach (array_keys($virtual_suite_tests) as $i) {
                                 if ($virtual_suite_tests[$i]->is_supported(false) == false || $this->validate_test_to_run($virtual_suite_tests[$i]) == false) {
                                     unset($virtual_suite_tests[$i]);
                                 }
                             }
                             sort($virtual_suite_tests);
                             if (count($virtual_suite_tests) > 1) {
                                 array_push($virtual_suite_tests, 'All Tests In Suite');
                             }
                             if (!$this->auto_mode && !$this->batch_mode) {
                                 $run_index = explode(',', pts_user_io::prompt_text_menu('Select the tests in the virtual suite to run', $virtual_suite_tests, true, true));
                             } else {
                                 $run_index = -1;
                             }
                             if (count($virtual_suite_tests) > 2 && in_array(count($virtual_suite_tests) - 1, $run_index) || $run_index == -1) {
                                 // The appended 'All Tests In Suite' was selected, so run all
                             } else {
                                 foreach (array_keys($virtual_suite_tests) as $i) {
                                     if (!in_array($i, $run_index)) {
                                         unset($virtual_suite_tests[$i]);
                                     }
                                 }
                             }
                             foreach ($virtual_suite_tests as &$test_profile) {
                                 if ($test_profile instanceof pts_test_profile) {
                                     // The user is to configure virtual suites manually
                                     foreach (self::test_prompts_to_result_objects($test_profile) as $result_object) {
                                         $this->add_test_result_object($result_object);
                                     }
                                 }
                             }
                         } else {
                             trigger_error($run_object . ' is not recognized.', E_USER_ERROR);
                             continue;
                         }
                     }
                 }
             }
         }
     }
     // AlwaysUploadResultsToOpenBenchmarking AutoSortRunQueue
     if (pts_config::read_bool_config('PhoronixTestSuite/Options/Testing/AutoSortRunQueue', 'TRUE') && $this->force_save_results == false) {
         // Not that it matters much, but if $this->force_save_results is set that means likely running from a result file...
         // so if running a result file, don't change the ordering of the existing results
         // Sort the run order so that all tests that are similar are grouped together, etc
         usort($this->tests_to_run, array('pts_test_run_manager', 'cmp_result_object_sort'));
     }
     if (pts_client::read_env('RUN_TESTS_IN_RANDOM_ORDER')) {
         shuffle($this->tests_to_run);
     }
     $this->prompt_save_results = $run_contains_a_no_result_type == false || $unique_test_count > 1;
     $this->force_save_results = $this->force_save_results || $request_results_save;
 }
示例#16
0
 private static function select_drive_mount()
 {
     $drives = pts_file_io::glob('/dev/sd*');
     if (count($drives) == 0) {
         echo PHP_EOL . 'No Disk Drives Found' . PHP_EOL . PHP_EOL;
     } else {
         array_push($drives, 'No HDD');
         $to_mount = pts_user_io::prompt_text_menu('Select Drive / Partition To Mount', $drives);
         if ($to_mount != 'No HDD') {
             echo PHP_EOL . 'Attempting to mount: ' . $to_mount . PHP_EOL;
             exec('umount /media/pts-auto-mount 2>&1');
             pts_file_io::delete('/media/pts-auto-mount', null, true);
             pts_file_io::mkdir('/media/pts-auto-mount');
             echo exec('mount ' . $to_mount . ' /media/pts-auto-mount');
             putenv('PTS_TEST_INSTALL_ROOT_PATH=/media/pts-auto-mount/');
         } else {
             if (is_dir('/media/pts-auto-mount')) {
                 exec('umount /media/pts-auto-mount');
                 @rmdir('/media/pts-auto-mount');
             }
             putenv('PTS_TEST_INSTALL_ROOT_PATH=');
         }
     }
 }
 public static function run($args)
 {
     $result = $args[0];
     $result_file = new pts_result_file($result);
     $result_file_identifiers = $result_file->get_system_identifiers();
     if (count($result_file_identifiers) < 2) {
         echo PHP_EOL . 'There are not multiple test runs in this result file.' . PHP_EOL;
         return false;
     }
     $base_identifier = pts_user_io::prompt_text_menu('Select the base test run', $result_file_identifiers);
     $base_select = new pts_result_merge_select($result, $base_identifier);
     $compare_identifier = pts_user_io::prompt_text_menu('Select the test run to compare', $result_file_identifiers);
     $compare_select = new pts_result_merge_select($result, $compare_identifier);
     do {
         $extract_to = 'iqc-analyze-' . rand(100, 999);
     } while (is_dir(PTS_SAVE_RESULTS_PATH . $extract_to));
     $extract_result = pts_merge::merge_test_results($base_select, $compare_select);
     pts_client::save_test_result($extract_to . '/composite.xml', $extract_result);
     $compare_file = new pts_result_file($extract_to);
     $result_file_writer = new pts_result_file_writer('Image Delta');
     foreach ($compare_file->get_result_objects() as $result_object) {
         if ($result_object->test_profile->get_display_format() != 'IMAGE_COMPARISON') {
             continue;
         }
         $base_result = null;
         $compare_result = null;
         foreach ($result_object->test_result_buffer->get_buffer_items() as $buffer_item) {
             if ($buffer_item->get_result_identifier() == $base_identifier && $base_result == null) {
                 $base_result = $buffer_item->get_result_value();
             } else {
                 if ($buffer_item->get_result_identifier() == $compare_identifier && $compare_result == null) {
                     $compare_result = $buffer_item->get_result_value();
                 }
             }
             if ($compare_result != null && $base_result != null) {
                 break;
             }
         }
         if ($compare_result == null || $base_result == null) {
             continue;
         }
         $base_img = imagecreatefromstring(base64_decode($base_result));
         $compare_img = imagecreatefromstring(base64_decode($compare_result));
         $delta_img = imagecreatefromstring(base64_decode($compare_result));
         $img_width = imagesx($base_img);
         $img_height = imagesy($base_img);
         $img_changed = false;
         for ($x = 0; $x < $img_width; $x++) {
             for ($y = 0; $y < $img_height; $y++) {
                 $base_image_color = pts_image::rgb_gd_color_at($base_img, $x, $y);
                 $compare_image_color = pts_image::rgb_gd_color_at($compare_img, $x, $y);
                 if ($base_image_color == $compare_image_color || pts_image::rgb_int_diff($base_image_color, $compare_image_color) < 9) {
                     if ($cords = pts_image::color_pixel_delta($base_img, $compare_img, $x, $y)) {
                         $pixel_rgb = pts_image::rgb_gd_color_at($delta_img, $cords[0], $cords[1]);
                         $color_invert = imagecolorresolve($delta_img, 255 - $pixel_rgb[0], 255 - $pixel_rgb[1], 255 - $pixel_rgb[2]);
                         imagesetpixel($delta_img, $x, $y, $color_invert);
                         $img_changed = true;
                     }
                 }
             }
         }
         if ($img_changed) {
             imagepng($delta_img, PTS_SAVE_RESULTS_PATH . $extract_to . '/scratch.png');
             $result_value = base64_encode(file_get_contents(PTS_SAVE_RESULTS_PATH . $extract_to . '/scratch.png', FILE_BINARY));
             pts_file_io::unlink(PTS_SAVE_RESULTS_PATH . $extract_to . '/scratch.png');
             $result_file_writer->add_result_from_result_object_with_value_string($result_object, $result_value);
         }
     }
     pts_client::save_result_file($result_file_writer, $extract_to);
     pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $extract_to . '/composite.xml');
 }
 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);
     }
 }
 public static function prompt_user_options(&$test_profile, $preset_selections = null)
 {
     $user_args = array();
     $text_args = array();
     if (($cli_presets_env = pts_client::read_env('PRESET_OPTIONS')) != false) {
         // To specify test options externally from an environment variable
         // i.e. PRESET_OPTIONS='stream.run-type=Add' ./phoronix-test-suite benchmark stream
         // The string format is <test-name>.<test-option-name-from-XML-file>=<test-option-value>
         // The test-name can either be the short/base name (e.g. stream) or the full identifier (pts/stream) without version postfix
         // Multiple preset options can be delimited with the PRESET_OPTIONS environment variable via a semicolon ;
         $preset_selections = pts_client::parse_value_string_double_identifier($cli_presets_env);
     }
     $identifier_short = $test_profile->get_identifier_base_name();
     $identifier_full = $test_profile->get_identifier(false);
     if (count($test_profile->get_test_option_objects()) > 0) {
         pts_client::$display->test_run_configure($test_profile);
     }
     foreach ($test_profile->get_test_option_objects() as $i => $o) {
         $option_identifier = $o->get_identifier();
         if ($o->option_count() == 0) {
             // User inputs their option as there is nothing to select
             if (isset($preset_selections[$identifier_short][$option_identifier])) {
                 $value = $preset_selections[$identifier_short][$option_identifier];
                 echo PHP_EOL . '    Using Pre-Set Run Option: ' . $value . PHP_EOL;
             } else {
                 if (isset($preset_selections[$identifier_full][$option_identifier])) {
                     $value = $preset_selections[$identifier_full][$option_identifier];
                     echo PHP_EOL . '    Using Pre-Set Run Option: ' . $value . PHP_EOL;
                 } else {
                     echo PHP_EOL . $o->get_name() . PHP_EOL;
                     $value = pts_user_io::prompt_user_input('Enter Value');
                 }
             }
             array_push($text_args, array($o->format_option_display_from_input($value)));
             array_push($user_args, array($o->format_option_value_from_input($value)));
         } else {
             // Have the user select the desired option
             if (isset($preset_selections[$identifier_short][$option_identifier])) {
                 $bench_choice = $preset_selections[$identifier_short][$option_identifier];
                 echo PHP_EOL . '    Using Pre-Set Run Option: ' . $bench_choice . PHP_EOL;
             } else {
                 if (isset($preset_selections[$identifier_full][$option_identifier])) {
                     $bench_choice = $preset_selections[$identifier_full][$option_identifier];
                     echo PHP_EOL . '    Using Pre-Set Run Option: ' . $bench_choice . PHP_EOL;
                 } else {
                     $option_names = $o->get_all_option_names_with_messages();
                     if (count($option_names) > 1) {
                         //echo PHP_EOL . $o->get_name() . ':' . PHP_EOL;
                         array_push($option_names, 'Test All Options');
                     }
                     $bench_choice = pts_user_io::prompt_text_menu($o->get_name(), $option_names, true, true, pts_client::$display->get_tab() . pts_client::$display->get_tab());
                     echo PHP_EOL;
                 }
             }
             $bench_choice = $o->parse_selection_choice_input($bench_choice);
             // Format the selected option(s)
             $option_args = array();
             $option_args_description = array();
             foreach ($bench_choice as $c) {
                 array_push($option_args, $o->format_option_value_from_select($c));
                 array_push($option_args_description, $o->format_option_display_from_select($c));
             }
             array_push($text_args, $option_args_description);
             array_push($user_args, $option_args);
         }
     }
     $test_args = array();
     $test_args_description = array();
     self::compute_all_combinations($test_args, null, $user_args, 0);
     self::compute_all_combinations($test_args_description, null, $text_args, 0, ' - ');
     return array($test_args, $test_args_description);
 }