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) { 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($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 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); }
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 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; } } } } } } }