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($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) { $missing_titles = pts_external_dependencies::missing_dependency_titles(); pts_client::$display->generic_heading(count($missing_titles) . ' of ' . count(pts_external_dependencies::all_dependency_names()) . ' External Dependencies Missing'); echo pts_user_io::display_text_list($missing_titles); echo PHP_EOL; }
public static function run($r) { $result_file = false; if (count($r) != 0) { $result_file = $r[0]; } $suite_name = pts_user_io::prompt_user_input('Enter name of suite'); $suite_test_type = pts_user_io::prompt_text_menu('Select test type', pts_types::subsystem_targets()); $suite_maintainer = pts_user_io::prompt_user_input('Enter suite maintainer name'); $suite_description = pts_user_io::prompt_user_input('Enter suite description'); $suite_writer = new pts_test_suite_writer(); $suite_writer->add_suite_information($suite_name, '1.0.0', $suite_maintainer, $suite_test_type, $suite_description); // Read results file $result_file = new pts_result_file($result_file); foreach ($result_file->get_result_objects() as $result_object) { $suite_writer->add_to_suite_from_result_object($result_object); } // Finish it off $suite_identifier = pts_test_run_manager::clean_save_name($suite_name); mkdir(PTS_TEST_SUITE_PATH . 'local/' . $suite_identifier); $save_to = PTS_TEST_SUITE_PATH . 'local/' . $suite_identifier . '/suite-definition.xml'; if ($suite_writer->save_xml($save_to) != false) { echo PHP_EOL . PHP_EOL . 'Saved To: ' . $save_to . PHP_EOL . 'To run this suite, type: phoronix-test-suite benchmark ' . $suite_identifier . PHP_EOL . PHP_EOL; } }
public static function run($r) { $all_dependencies = pts_external_dependencies::all_dependency_titles(); pts_client::$display->generic_heading(count($all_dependencies) . ' External Dependencies Available'); echo pts_user_io::display_text_list($all_dependencies); echo PHP_EOL; }
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($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]; if (is_dir(PTS_SAVE_RESULTS_PATH . $result)) { do { $new_result_name = pts_user_io::prompt_user_input('Enter a new result file name for ' . $result); $clean_result_name = pts_test_run_manager::clean_save_name($new_result_name, true); } while ($clean_result_name == null || is_dir(PTS_SAVE_RESULTS_PATH . $clean_result_name)); } if (rename(PTS_SAVE_RESULTS_PATH . $result, PTS_SAVE_RESULTS_PATH . $clean_result_name)) { echo PHP_EOL . 'Renamed ' . $result . ' to ' . $clean_result_name . '.' . PHP_EOL . PHP_EOL; } pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $clean_result_name . '/index.html'); }
public static function run($r) { $test_profile = new pts_test_profile($r[0]); if ($test_profile->is_test_installed() == false) { echo PHP_EOL . 'This test is not installed.' . PHP_EOL; return false; } if (pts_user_io::prompt_bool_input('Are you sure you wish to remove the test ' . $test_profile, false)) { pts_client::remove_installed_test($test_profile); echo PHP_EOL . $test_profile . ' has been removed.' . PHP_EOL; } else { echo PHP_EOL; } }
public static function set_root_admin_password() { phoromatic_server::prepare_database(); $root_admin_pw = phoromatic_server::read_setting('root_admin_pw'); if ($root_admin_pw != null) { do { $check_root_pw = pts_user_io::prompt_user_input('Please enter the existing root-admin password'); } while (hash('sha256', 'PTS' . $check_root_pw) != $root_admin_pw); } echo PHP_EOL . 'The new root-admin password must be at least six characters long.' . PHP_EOL; do { $new_root_pw = pts_user_io::prompt_user_input('Please enter the new root-admin password'); } while (strlen($new_root_pw) < 6); $new_root_pw = hash('sha256', 'PTS' . $new_root_pw); $root_admin_pw = phoromatic_server::save_setting('root_admin_pw', $new_root_pw); }
public static function run($r) { pts_client::$display->generic_heading('Network Setup'); if (!pts_user_io::prompt_bool_input('Configure the Phoronix Test Suite to use a HTTP proxy', false)) { return false; } $proxy_address = pts_user_io::prompt_user_input('Enter IP address / server name of proxy'); $proxy_port = pts_user_io::prompt_user_input('Enter TCP port for proxy server'); echo PHP_EOL . 'Testing Proxy Server (' . $proxy_address . ':' . $proxy_port . ')' . PHP_EOL; if (pts_network::http_get_contents('http://www.phoronix-test-suite.com/PTS', $proxy_address, $proxy_port) == 'PTS') { echo PHP_EOL . 'Proxy Setup Completed; Storing Network Settings.' . PHP_EOL; pts_config::user_config_generate(array('PhoronixTestSuite/Options/Networking/ProxyAddress' => $proxy_address, 'PhoronixTestSuite/Options/Networking/ProxyPort' => $proxy_port)); } else { echo PHP_EOL . 'Proxy Setup Failed.' . 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($r) { $module = strtolower($r[0]); $pre_message = null; if (!class_exists($module)) { pts_module_manager::load_module($module); } $module_name = pts_module_manager::module_call($module, 'module_name'); $module_description = pts_module_manager::module_call($module, 'module_description'); $module_setup = pts_module_manager::module_call($module, 'module_setup'); pts_client::$display->generic_heading($module_name . ' Module Configuration'); echo $module_description . PHP_EOL; if (count($module_setup) == 0) { echo PHP_EOL . 'There are no options available for configuring with the ' . $module . ' module.' . PHP_EOL; } else { if (($module_presets = pts_client::read_env('PTS_MODULE_SETUP')) != false) { $module_presets = pts_client::parse_value_string_double_identifier($module_presets); } $set_options = array(); foreach ($module_setup as $module_option) { if ($module_option instanceof pts_module_option) { $option_identifier = $module_option->get_identifier(); if (isset($module_presets[$module][$option_identifier]) && $module_option->is_supported_value($module_presets[$module][$option_identifier])) { echo PHP_EOL . $module_option->get_formatted_question(); echo $module_presets[$module][$option_identifier] . PHP_EOL; $input = $module_presets[$module][$option_identifier]; } else { do { echo PHP_EOL . $module_option->get_formatted_question(); $input = pts_user_io::read_user_input(); } while (!$module_option->is_supported_value($input)); } if (empty($input)) { $input = $module_option->get_default_value(); } $set_options[$option_identifier] = $input; } } $set_options = pts_module_manager::module_call($module, 'module_setup_validate', $set_options); if (!empty($set_options)) { pts_module::module_config_save($module, $set_options); } } echo PHP_EOL; }
public static function run($r) { $result_file = new pts_result_file($r[0]); $result_title = $result_file->get_title(); echo PHP_EOL . 'Current Result Title: ' . $result_title . PHP_EOL; $new_title = pts_user_io::prompt_user_input('Enter New Title'); if (!empty($new_title)) { $result_file->set_title($new_title); } $result_description = $result_file->get_description(); echo PHP_EOL . 'Current Result Description: ' . $result_description . PHP_EOL; $new_description = pts_user_io::prompt_user_input('Enter New Description'); if (!empty($new_description)) { $result_file->set_description($new_description); } 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($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) { 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($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) { if (pts_openbenchmarking_client::user_name() == false) { echo PHP_EOL . 'You must first be logged into an OpenBenchmarking.org account.' . PHP_EOL; echo PHP_EOL . 'Create An Account: http://openbenchmarking.org/'; echo PHP_EOL . 'Log-In Command: phoronix-test-suite openbenchmarking-setup' . PHP_EOL . PHP_EOL; return false; } if (($test_suite = pts_types::identifier_to_object($r[0])) != false) { pts_client::$display->generic_heading($r[0]); if (pts_validation::validate_test_suite($test_suite)) { $zip_file = PTS_OPENBENCHMARKING_SCRATCH_PATH . $test_suite->get_identifier(false) . '-' . $test_suite->get_version() . '.zip'; $zip_created = pts_compression::zip_archive_create($zip_file, $test_suite->xml_parser->getFileLocation()); if ($zip_created == false) { echo PHP_EOL . 'Failed to create zip file.' . PHP_EOL; return false; } $zip = new ZipArchive(); $zip->open($zip_file); $zip->renameName(basename($test_suite->xml_parser->getFileLocation()), 'suite-definition.xml'); $zip->close(); $commit_description = pts_user_io::prompt_user_input('Enter a test commit description', false); echo PHP_EOL; $server_response = pts_openbenchmarking::make_openbenchmarking_request('upload_test_suite', array('ts_identifier' => $test_suite->get_identifier_base_name(), 'ts_sha1' => sha1_file($zip_file), 'ts_zip' => base64_encode(file_get_contents($zip_file)), 'ts_zip_name' => basename($zip_file), 'commit_description' => $commit_description)); echo PHP_EOL; $json = json_decode($server_response, true); if (isset($json['openbenchmarking']['upload']['error']) && !empty($json['openbenchmarking']['upload']['error'])) { echo 'ERROR: ' . $json['openbenchmarking']['upload']['error'] . PHP_EOL; } if (isset($json['openbenchmarking']['upload']['id']) && !empty($json['openbenchmarking']['upload']['id'])) { echo 'Command: phoronix-test-suite benchmark ' . $json['openbenchmarking']['upload']['id'] . PHP_EOL; } if (isset($json['openbenchmarking']['upload']['url']) && !empty($json['openbenchmarking']['upload']['url'])) { pts_openbenchmarking::refresh_repository_lists(null, true); echo 'URL: ' . $json['openbenchmarking']['upload']['url'] . PHP_EOL; } echo PHP_EOL; unlink($zip_file); } } }
public static function run($r) { $result_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($r) { $result_file = new pts_result_file($r[0]); $result_title = $result_file->get_title(); echo PHP_EOL . 'Current Result Title: ' . $result_title . PHP_EOL; $new_title = pts_user_io::prompt_user_input('Enter New Title'); if (!empty($new_title)) { $result_title = $new_title; } $result_description = $result_file->get_description(); echo PHP_EOL . 'Current Result Description: ' . $result_description . PHP_EOL; $new_description = pts_user_io::prompt_user_input('Enter New Description'); if (!empty($new_description)) { $result_description = $new_description; } $result_file_writer = new pts_result_file_writer(); $result_file_writer->add_result_file_meta_data($result_file, null, $new_title, $new_description); $result_file_writer->add_system_information_from_result_file($result_file); $result_file_writer->add_results_from_result_file($result_file); pts_client::save_test_result($r[0] . '/composite.xml', $result_file_writer->get_xml()); pts_client::display_web_page(PTS_SAVE_RESULTS_PATH . $r[0] . '/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($r) { echo PHP_EOL . 'These are the default configuration options for when running the Phoronix Test Suite in a batch mode (i.e. running phoronix-test-suite batch-benchmark universe). Running in a batch mode is designed to be as autonomous as possible, except for where you\'d like any end-user interaction.' . PHP_EOL . PHP_EOL; $batch_options = array(); $batch_options['PhoronixTestSuite/Options/BatchMode/SaveResults'] = pts_config::bool_to_string(pts_user_io::prompt_bool_input('Save test results when in batch mode', true)); if ($batch_options['PhoronixTestSuite/Options/BatchMode/SaveResults'] == 'TRUE') { $batch_options['PhoronixTestSuite/Options/BatchMode/OpenBrowser'] = pts_config::bool_to_string(pts_user_io::prompt_bool_input('Open the web browser automatically when in batch mode', false)); $batch_options['PhoronixTestSuite/Options/BatchMode/UploadResults'] = pts_config::bool_to_string(pts_user_io::prompt_bool_input('Auto upload the results to OpenBenchmarking.org', true)); $batch_options['PhoronixTestSuite/Options/BatchMode/PromptForTestIdentifier'] = pts_config::bool_to_string(pts_user_io::prompt_bool_input('Prompt for test identifier', true)); $batch_options['PhoronixTestSuite/Options/BatchMode/PromptForTestDescription'] = pts_config::bool_to_string(pts_user_io::prompt_bool_input('Prompt for test description', true)); $batch_options['PhoronixTestSuite/Options/BatchMode/PromptSaveName'] = pts_config::bool_to_string(pts_user_io::prompt_bool_input('Prompt for saved results file-name', true)); } else { $batch_options['PhoronixTestSuite/Options/BatchMode/OpenBrowser'] = 'FALSE'; $batch_options['PhoronixTestSuite/Options/BatchMode/UploadResults'] = 'FALSE'; $batch_options['PhoronixTestSuite/Options/BatchMode/PromptForTestIdentifier'] = 'FALSE'; $batch_options['PhoronixTestSuite/Options/BatchMode/PromptForTestDescription'] = 'FALSE'; $batch_options['PhoronixTestSuite/Options/BatchMode/PromptSaveName'] = 'FALSE'; } $batch_options['PhoronixTestSuite/Options/BatchMode/RunAllTestCombinations'] = pts_config::bool_to_string(pts_user_io::prompt_bool_input('Run all test options', true)); $batch_options['PhoronixTestSuite/Options/BatchMode/Configured'] = 'TRUE'; pts_config::user_config_generate($batch_options); echo PHP_EOL . 'Batch settings saved.' . PHP_EOL . PHP_EOL; }
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'); }
public static function prompt_text_menu($user_string, $options_r, $allow_multi_select = false, $return_index = false, $line_prefix = null) { $option_count = count($options_r); if ($option_count == 1) { return $return_index ? pts_arrays::last_element(array_keys($options_r)) : array_pop($options_r); } $select = array(); do { echo PHP_EOL; $key_index = array(); foreach (array_keys($options_r) as $i => $key) { $key_index[$i + 1] = $key; echo $line_prefix . ($i + 1) . ': ' . str_repeat(' ', strlen($option_count) - strlen($i + 1)) . $options_r[$key] . PHP_EOL; } echo $line_prefix . $user_string . ': '; $select_choice = pts_user_io::read_user_input(); foreach ($allow_multi_select ? pts_strings::comma_explode($select_choice) : array($select_choice) as $choice) { if (in_array($choice, $options_r)) { $select[] = array_search($choice, $options_r); } else { if (isset($key_index[$choice])) { $select[] = $key_index[$choice]; } else { if ($allow_multi_select && strpos($choice, '-') !== false) { $choice_range = pts_strings::trim_explode('-', $choice); if (count($choice_range) == 2 && is_numeric($choice_range[0]) && is_numeric($choice_range[1]) && isset($key_index[$choice_range[0]]) && isset($key_index[$choice_range[1]])) { for ($i = min($choice_range); $i <= max($choice_range); $i++) { $select[] = $key_index[$i]; } } } } } } } while (!isset($select[0])); if ($return_index == false) { foreach ($select as &$index) { $index = $options_r[$index]; } } return implode(',', $select); }
protected static function install_test_process(&$test_install_request, $no_prompts) { // Install a test $identifier = $test_install_request->test_profile->get_identifier(); $test_install_directory = $test_install_request->test_profile->get_install_dir(); pts_file_io::mkdir(dirname($test_install_directory)); pts_file_io::mkdir($test_install_directory); $installed = false; if (ceil(disk_free_space($test_install_directory) / 1048576) < $test_install_request->test_profile->get_download_size() + 128) { self::test_install_error(null, $test_install_request, 'There is not enough space at ' . $test_install_directory . ' for the test files.'); } else { if (ceil(disk_free_space($test_install_directory) / 1048576) < $test_install_request->test_profile->get_environment_size(false) + 128) { self::test_install_error(null, $test_install_request, 'There is not enough space at ' . $test_install_directory . ' for this test.'); } else { pts_test_installer::setup_test_install_directory($test_install_request, true); // Download test files $download_test_files = pts_test_installer::download_test_files($test_install_request, false, $no_prompts); if ($download_test_files == false) { self::test_install_error(null, $test_install_request, 'Downloading of needed test files failed.'); return false; } if ($test_install_request->test_profile->get_file_installer() != false) { self::create_compiler_mask($test_install_request); pts_module_manager::module_process('__pre_test_install', $identifier); pts_client::$display->test_install_begin($test_install_request); $pre_install_message = $test_install_request->test_profile->get_pre_install_message(); $post_install_message = $test_install_request->test_profile->get_post_install_message(); $install_agreement = $test_install_request->test_profile->get_installation_agreement_message(); if (!empty($install_agreement)) { if (pts_strings::is_url($install_agreement)) { $install_agreement = pts_network::http_get_contents($install_agreement); if (empty($install_agreement)) { self::test_install_error(null, $test_install_request, 'The user agreement could not be found. Test installation aborted.'); return false; } } echo $install_agreement . PHP_EOL; if (!$no_prompts) { $user_agrees = pts_user_io::prompt_bool_input('Do you agree to these terms', false, 'INSTALL_AGREEMENT'); if (!$user_agrees) { self::test_install_error(null, $test_install_request, 'User agreement failed; this test will not be installed.'); return false; } } } pts_client::$display->display_interrupt_message($pre_install_message); $install_time_length_start = microtime(true); $install_log = pts_tests::call_test_script($test_install_request->test_profile, 'install', null, $test_install_directory, $test_install_request->special_environment_vars, false); $test_install_request->install_time_duration = ceil(microtime(true) - $install_time_length_start); pts_client::$display->display_interrupt_message($post_install_message); if (!empty($install_log)) { file_put_contents($test_install_directory . 'install.log', $install_log); pts_file_io::unlink($test_install_directory . 'install-failed.log'); pts_client::$display->test_install_output($install_log); } if (is_file($test_install_directory . 'install-exit-status')) { // If the installer writes its exit status to ~/install-exit-status, if it's non-zero the install failed $install_exit_status = pts_file_io::file_get_contents($test_install_directory . 'install-exit-status'); unlink($test_install_directory . 'install-exit-status'); if ($install_exit_status != 0 && phodevi::is_windows() == false) { $install_error = null; // TODO: perhaps better way to handle this than to remove pts-install.xml pts_file_io::unlink($test_install_directory . 'pts-install.xml'); if (is_file($test_install_directory . 'install.log')) { $install_log = pts_file_io::file_get_contents($test_install_directory . 'install.log'); $install_error = pts_tests::scan_for_error($install_log, $test_install_directory); copy($test_install_directory . 'install.log', $test_install_directory . 'install-failed.log'); } //pts_test_installer::setup_test_install_directory($test_install_request, true); // Remove installed files from the bunked installation self::test_install_error(null, $test_install_request, 'The installer exited with a non-zero exit status.'); if ($install_error != null) { $test_install_request->install_error = pts_tests::pretty_error_string($install_error); if ($test_install_request->install_error != null) { self::test_install_error(null, $test_install_request, 'ERROR: ' . $test_install_request->install_error); } } pts_client::$display->test_install_error('LOG: ' . str_replace(pts_core::user_home_directory(), '~/', $test_install_directory) . 'install-failed.log' . PHP_EOL); if (pts_client::do_anonymous_usage_reporting()) { // If anonymous usage reporting enabled, report test install failure to OpenBenchmarking.org pts_openbenchmarking_client::upload_usage_data('test_install_failure', array($test_install_request, $install_error)); } return false; } } pts_module_manager::module_process('__post_test_install', $identifier); $installed = true; if (pts_config::read_bool_config('PhoronixTestSuite/Options/Installation/RemoveDownloadFiles', 'FALSE')) { // Remove original downloaded files foreach ($test_install_request->get_download_objects() as $download_object) { pts_file_io::unlink($test_install_directory . $download_object->get_filename()); } } } else { pts_client::$display->test_install_error('No installation script found.'); $installed = true; } // Additional validation checks? $custom_validated_output = pts_tests::call_test_script($test_install_request->test_profile, 'validate-install', PHP_EOL . 'Validating Installation...' . PHP_EOL, $test_install_directory, null, false); if (!empty($custom_validated_output) && !pts_strings::string_bool($custom_validated_output)) { $installed = false; } } } echo PHP_EOL; return $installed; }
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 display_web_page($URL, $alt_text = null, $default_open = true, $auto_open = false) { if (pts_client::read_env('DISPLAY') == false && pts_client::read_env('WAYLAND_DISPLAY') == false && phodevi::is_windows() == false && phodevi::is_macosx() == false || defined('PHOROMATIC_PROCESS')) { return; } if ($auto_open == false) { $view_results = pts_user_io::prompt_bool_input($alt_text == null ? 'Do you want to view the results in your web browser' : $alt_text, $default_open); } else { $view_results = true; } if ($view_results) { static $browser = null; if ($browser == null) { $config_browser = pts_config::read_user_config('PhoronixTestSuite/Options/General/DefaultBrowser', null); if ($config_browser != null && (is_executable($config_browser) || ($config_browser = pts_client::executable_in_path($config_browser)))) { $browser = $config_browser; } else { if (phodevi::is_windows()) { $windows_browsers = array('C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe', 'C:\\Program Files\\Internet Explorer\\iexplore.exe'); foreach ($windows_browsers as $browser_test) { if (is_executable($browser_test)) { $browser = $browser_test; break; } } if (substr($URL, 0, 1) == '\\') { $URL = 'file:///C:' . str_replace('/', '\\', $URL); } } else { $possible_browsers = array('firefox', 'mozilla', 'x-www-browser', 'open', 'xdg-open', 'iceweasel', 'konqueror', 'epiphany', 'google-chrome'); foreach ($possible_browsers as &$b) { if ($b = pts_client::executable_in_path($b)) { $browser = $b; break; } } } } } if ($browser != null) { shell_exec($browser . ' "' . $URL . '" 2> /dev/null &'); } else { echo PHP_EOL . 'No Web Browser Found.' . PHP_EOL; } } }
private static function install_packages_on_system($os_packages_to_install) { // Do the actual installing process of packages using the distribution's package management system $vendor_install_file = PTS_EXDEP_PATH . 'scripts/install-' . self::vendor_identifier('installer') . '-packages.sh'; // Rebuild the array index since some OS package XML tags provide multiple package names in a single string $os_packages_to_install = explode(' ', implode(' ', $os_packages_to_install)); if (is_file($vendor_install_file)) { // hook into pts_client::$display here if it's desired echo PHP_EOL . 'The following dependencies are needed and will be installed: ' . PHP_EOL . PHP_EOL; echo pts_user_io::display_text_list($os_packages_to_install); echo PHP_EOL . 'This process may take several minutes.' . PHP_EOL; echo shell_exec('sh ' . $vendor_install_file . ' ' . implode(' ', $os_packages_to_install)); } else { if (phodevi::is_macosx() == false) { echo 'Distribution install script not found!'; } } }
public static function upload_test_result(&$object, $return_json_data = false) { if ($object instanceof pts_test_run_manager) { $result_file = new pts_result_file($object->get_file_name()); $local_file_name = $object->get_file_name(); $results_identifier = $object->get_results_identifier(); } else { if ($object instanceof pts_result_file) { $result_file =& $object; $local_file_name = $result_file->get_identifier(); $results_identifier = null; } } // Ensure the results can be shared if (self::result_upload_supported($result_file) == false) { return false; } if (pts_network::internet_support_available() == false) { echo PHP_EOL . 'No network support available.' . PHP_EOL; return false; } $composite_xml = $result_file->getRawXml(); $system_log_dir = PTS_SAVE_RESULTS_PATH . $result_file->get_identifier() . '/system-logs/'; $upload_system_logs = false; if (is_dir($system_log_dir)) { if (pts_config::read_bool_config('PhoronixTestSuite/Options/OpenBenchmarking/AlwaysUploadSystemLogs', 'FALSE')) { $upload_system_logs = true; } else { if (isset(self::$client_settings['UploadSystemLogsByDefault'])) { $upload_system_logs = self::$client_settings['UploadSystemLogsByDefault']; } else { if (is_dir($system_log_dir)) { $upload_system_logs = pts_user_io::prompt_bool_input('Would you like to attach the system logs (lspci, dmesg, lsusb, etc) to the test result', true, 'UPLOAD_SYSTEM_LOGS'); } } } } $system_logs = null; $system_logs_hash = null; if ($upload_system_logs) { $is_valid_log = true; $finfo = function_exists('finfo_open') ? finfo_open(FILEINFO_MIME_TYPE) : false; foreach (pts_file_io::glob($system_log_dir . '*') as $log_dir) { if ($is_valid_log == false || !is_dir($log_dir)) { $is_valid_log = false; break; } foreach (pts_file_io::glob($log_dir . '/*') as $log_file) { if (!is_file($log_file)) { $is_valid_log = false; break; } if ($finfo && substr(finfo_file($finfo, $log_file), 0, 5) != 'text/') { $is_valid_log = false; break; } } } if ($is_valid_log) { $system_logs_zip = pts_client::create_temporary_file('.zip'); pts_compression::zip_archive_create($system_logs_zip, $system_log_dir); if (filesize($system_logs_zip) < 2097152) { // If it's over 2MB, probably too big $system_logs = base64_encode(file_get_contents($system_logs_zip)); $system_logs_hash = sha1($system_logs); } else { trigger_error('The systems log attachment is too large to upload to OpenBenchmarking.org.', E_USER_WARNING); } unlink($system_logs_zip); } } $composite_xml_hash = sha1($composite_xml); $composite_xml_type = 'composite_xml'; // Compress the result file XML if it's big if (isset($composite_xml[50000]) && function_exists('gzdeflate')) { $composite_xml_gz = gzdeflate($composite_xml); if ($composite_xml_gz != false) { $composite_xml = $composite_xml_gz; $composite_xml_type = 'composite_xml_gz'; } } $to_post = array($composite_xml_type => base64_encode($composite_xml), 'composite_xml_hash' => $composite_xml_hash, 'local_file_name' => $local_file_name, 'this_results_identifier' => $results_identifier, 'system_logs_zip' => $system_logs, 'system_logs_hash' => $system_logs_hash); if (isset(self::$client_settings['ResultUploadsDefaultDisplayStatus']) && is_numeric(self::$client_settings['ResultUploadsDefaultDisplayStatus'])) { $to_post['display_status'] = self::$client_settings['ResultUploadsDefaultDisplayStatus']; } $json_response = pts_openbenchmarking::make_openbenchmarking_request('upload_test_result', $to_post); $json_response = json_decode($json_response, true); if (!is_array($json_response)) { trigger_error('Unhandled Exception', E_USER_ERROR); return false; } if (isset($json_response['openbenchmarking']['upload']['error'])) { trigger_error($json_response['openbenchmarking']['upload']['error'], E_USER_ERROR); } if (isset($json_response['openbenchmarking']['upload']['url'])) { echo PHP_EOL . 'Results Uploaded To: ' . $json_response['openbenchmarking']['upload']['url'] . PHP_EOL; pts_module_manager::module_process('__event_openbenchmarking_upload', $json_response); } //$json['openbenchmarking']['upload']['id'] if (isset(self::$client_settings['RemoveLocalResultsOnUpload']) && self::$client_settings['RemoveLocalResultsOnUpload'] && $local_file_name != null) { pts_client::remove_saved_result_file($local_file_name); } if ($return_json_data) { return isset($json_response['openbenchmarking']['upload']) ? $json_response['openbenchmarking']['upload'] : false; } return isset($json_response['openbenchmarking']['upload']['url']) ? $json_response['openbenchmarking']['upload']['url'] : false; }