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 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) { 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; }
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 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; } } }
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; }
public function save_results_prompt() { if (!$this->auto_mode) { pts_client::$display->generic_heading('System Information'); echo 'Hardware:' . PHP_EOL . phodevi::system_hardware(true) . PHP_EOL . PHP_EOL; echo 'Software:' . PHP_EOL . phodevi::system_software(true) . PHP_EOL . PHP_EOL; } if (($this->prompt_save_results || $this->force_save_results) && count($this->tests_to_run) > 0) { if ($this->force_save_results || pts_client::read_env('TEST_RESULTS_NAME')) { $save_results = true; } else { if ($this->batch_mode) { $save_results = $this->batch_mode['SaveResults']; } else { if (pts_client::is_debug_mode()) { $save_results = false; } else { $save_results = pts_user_io::prompt_bool_input('Would you like to save these test results', true); } } } if ($save_results) { // Prompt Save File Name $this->prompt_save_name(); // Prompt Identifier $this->prompt_results_identifier(); if (!isset($this->run_description[16]) || strpos($this->run_description, 'via the Phoronix Test Suite') !== false) { // Write the auto-description if nothing is set or attempt to auto-detect if it was a previous auto-description saved $this->run_description = self::auto_generate_description(); } // Prompt Description if (!$this->batch_mode || $this->batch_mode['PromptForTestDescription']) { if ($this->run_description == null) { $this->run_description = 'N/A'; } if (pts_client::read_env('TEST_RESULTS_DESCRIPTION')) { if (strlen(pts_client::read_env('TEST_RESULTS_DESCRIPTION')) > 1) { $this->run_description = pts_client::read_env('TEST_RESULTS_DESCRIPTION'); echo 'Test Description: ' . $this->run_description . PHP_EOL; } } else { if (!$this->auto_mode) { //echo PHP_EOL . 'Current Title: ' . $this->file_name_title . PHP_EOL; pts_client::$display->generic_heading('If you wish, enter a new description below to better describe this result set / system configuration under test.' . PHP_EOL . 'Press ENTER to proceed without changes.'); echo 'Current Description: ' . $this->run_description . PHP_EOL . PHP_EOL . 'New Description: '; $new_test_description = pts_user_io::read_user_input(); if (!empty($new_test_description)) { $this->run_description = $new_test_description; } } } } } } }
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); } }