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 render_page_process($PATH) { if (isset($_POST['suite_title'])) { // echo '<pre>'; // var_dump($_POST); // echo '</pre>'; if (strlen($_POST['suite_title']) < 3) { echo '<h2>Suite title must be at least three characters.</h2>'; } //echo 'TEST SUITE: ' . $_POST['suite_title'] . '<br />'; //echo 'TEST SUITE: ' . $_POST['suite_description'] . '<br />'; $tests = array(); foreach ($_POST['test_add'] as $i => $test_identifier) { $test_prefix = $_POST['test_prefix'][$i]; $args = array(); $args_name = array(); foreach ($_POST as $i => $v) { if (strpos($i, $test_prefix) !== false && substr($i, -9) != '_selected') { if (strpos($v, '||') !== false) { $opts = explode('||', $v); $a = array(); $d = array(); foreach ($opts as $opt) { $t = explode('::', $opt); array_push($a, $t[1]); array_push($d, $t[0]); } array_push($args, $a); array_push($args_name, $d); } else { array_push($args, array($v)); array_push($args_name, array($_POST[$i . '_selected'])); } } } $test_args = array(); $test_args_description = array(); pts_test_run_options::compute_all_combinations($test_args, null, $args, 0); pts_test_run_options::compute_all_combinations($test_args_description, null, $args_name, 0, ' - '); foreach (array_keys($test_args) as $i) { array_push($tests, array('test' => $test_identifier, 'description' => $test_args_description[$i], 'args' => $test_args[$i])); } } if (count($tests) < 1) { echo '<h2>You must add at least one test to the suite.</h2>'; } $suite_writer = new pts_test_suite_writer(); $version_bump = 0; do { $suite_version = '1.' . $version_bump . '.0'; $suite_id = $suite_writer->clean_save_name_string($_POST['suite_title']) . '-' . $suite_version; $suite_dir = phoromatic_server::phoromatic_account_suite_path($_SESSION['AccountID'], $suite_id); $version_bump++; } while (is_dir($suite_dir)); pts_file_io::mkdir($suite_dir); $save_to = $suite_dir . '/suite-definition.xml'; $suite_writer->add_suite_information($_POST['suite_title'], $suite_version, $_SESSION['UserName'], 'System', $_POST['suite_description']); foreach ($tests as $m) { $suite_writer->add_to_suite($m['test'], $m['args'], $m['description']); } $suite_writer->save_xml($save_to); echo '<h2>Saved As ' . $suite_id . '</h2>'; } echo phoromatic_webui_header_logged_in(); $main = '<h1>Local Suites</h1><p>Find already created local test suites by your account/group via the <a href="/?local_suites">local suites</a> page.</p>'; if (!PHOROMATIC_USER_IS_VIEWER) { $main .= '<h1>Build Suite</h1><p>A test suite in the realm of the Phoronix Test Suite, OpenBenchmarking.org, and Phoromatic is <strong>a collection of test profiles with predefined settings</strong>. Establishing a test suite makes it easy to run repetitive testing on the same set of test profiles by simply referencing the test suite name.</p>'; $main .= '<form action="' . $_SERVER['REQUEST_URI'] . '" name="build_suite" id="build_suite" method="post" onsubmit="return validate_suite();"> <h3>Title:</h3> <p><input type="text" name="suite_title" /></p> <h3>Description:</h3> <p><textarea name="suite_description" id="suite_description" cols="60" rows="2"></textarea></p> <h3>Tests In Schedule:</h3> <p><div id="test_details"></div></p> <h3>Add Another Test</h3>'; $main .= '<select name="add_to_suite_select_test" id="add_to_suite_select_test" onchange="phoromatic_build_suite_test_details();">'; $dc = pts_strings::add_trailing_slash(pts_client::parse_home_directory(pts_config::read_user_config('PhoronixTestSuite/Options/Installation/CacheDirectory', PTS_DOWNLOAD_CACHE_PATH))); $dc_exists = is_file($dc . 'pts-download-cache.json'); foreach (pts_openbenchmarking::available_tests(false, true) as $test) { $cache_checked = false; if ($dc_exists) { $cache_json = file_get_contents($dc . 'pts-download-cache.json'); $cache_json = json_decode($cache_json, true); if ($cache_json && isset($cache_json['phoronix-test-suite']['cached-tests'])) { $cache_checked = true; if (!in_array($test, $cache_json['phoronix-test-suite']['cached-tests'])) { continue; } } } if (!$cache_checked && phoromatic_server::read_setting('show_local_tests_only') && pts_test_install_request::test_files_in_cache($test, true, true) == false) { continue; } $main .= '<option value="' . $test . '">' . $test . '</option>'; } $main .= '</select>'; $main .= '<p align="right"><input name="submit" value="Create Suite" type="submit" onclick="return pts_rmm_validate_suite();" /></p>'; } echo '<div id="pts_phoromatic_main_area">' . $main . '</div>'; echo phoromatic_webui_footer(); }
public function get_test_option_objects($auto_process = true) { $test_options = array(); if ($this->xml->TestSettings && $this->xml->TestSettings->Option) { foreach ($this->xml->TestSettings->Option as $option) { $names = array(); $messages = array(); $values = array(); if (isset($option->Menu->Entry)) { foreach ($option->Menu->Entry as $entry) { array_push($names, $entry->Name->__toString()); array_push($messages, $entry->Message->__toString()); array_push($values, $entry->Value->__toString()); } } if ($auto_process) { pts_test_run_options::auto_process_test_option($this->identifier, $option->Identifier, $names, $values, $messages); } $user_option = new pts_test_option($option->Identifier->__toString(), $option->DisplayName->__toString()); $user_option->set_option_prefix($option->ArgumentPrefix->__toString()); $user_option->set_option_postfix($option->ArgumentPostfix->__toString()); for ($i = 0; $i < count($names); $i++) { $user_option->add_option($names[$i], isset($values[$i]) ? $values[$i] : null, isset($messages[$i]) ? $messages[$i] : null); } $user_option->set_option_default($option->DefaultEntry->__toString()); array_push($test_options, $user_option); } } return $test_options; }
protected function test_prompts_to_result_objects(&$test_profile) { $result_objects = array(); if ($this->batch_mode && $this->batch_mode['RunAllTestCombinations']) { list($test_arguments, $test_arguments_description) = pts_test_run_options::batch_user_options($test_profile); } else { if ($this->auto_mode == 2) { list($test_arguments, $test_arguments_description) = pts_test_run_options::default_user_options($test_profile); } else { list($test_arguments, $test_arguments_description) = pts_test_run_options::prompt_user_options($test_profile); } } foreach (array_keys($test_arguments) as $i) { $test_result = new pts_test_result($test_profile); $test_result->set_used_arguments($test_arguments[$i]); $test_result->set_used_arguments_description($test_arguments_description[$i]); array_push($result_objects, $test_result); } return $result_objects; }
public function get_contained_test_result_objects() { $test_result_objects = array(); $test_names = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/Test'); $sub_modes = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/Mode'); $sub_arguments = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/Arguments'); $sub_arguments_description = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/Description'); $override_test_options = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/Execute/OverrideTestOptions'); for ($i = 0; $i < count($test_names); $i++) { $obj = pts_types::identifier_to_object($test_names[$i]); if ($obj instanceof pts_test_profile) { // Check for test profile values to override $override_options = array(); if (!empty($override_test_options[$i])) { foreach (explode(';', $override_test_options[$i]) as $override_string) { $override_segments = pts_strings::trim_explode('=', $override_string); if (count($override_segments) == 2 && !empty($override_segments[0]) && !empty($override_segments[1])) { $override_options[$override_segments[0]] = $override_segments[1]; } } } switch ($sub_modes[$i]) { case 'BATCH': $option_output = pts_test_run_options::batch_user_options($obj); break; case 'DEFAULTS': $option_output = pts_test_run_options::default_user_options($obj); break; default: $option_output = array(array($sub_arguments[$i]), array($sub_arguments_description[$i])); break; } foreach (array_keys($option_output[0]) as $x) { if ($override_options != null) { $test_profile->set_override_values($override_options); } $test_result = new pts_test_result($obj); $test_result->set_used_arguments($option_output[0][$x]); $test_result->set_used_arguments_description($option_output[1][$x]); array_push($test_result_objects, $test_result); } } else { if ($obj instanceof pts_test_suite) { foreach ($obj->get_contained_test_result_objects() as $test_result) { array_push($test_result_objects, $test_result); } } } } return $test_result_objects; }
public function get_test_option_objects($auto_process = true) { $settings_name = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/TestSettings/Option/DisplayName'); $settings_argument_prefix = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/TestSettings/Option/ArgumentPrefix'); $settings_argument_postfix = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/TestSettings/Option/ArgumentPostfix'); $settings_identifier = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/TestSettings/Option/Identifier'); $settings_default = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/TestSettings/Option/DefaultEntry'); $option_names = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/TestSettings/Option/Menu/Entry/Name', 1); $option_messages = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/TestSettings/Option/Menu/Entry/Message', 1); $option_values = $this->xml_parser->getXMLArrayValues('PhoronixTestSuite/TestSettings/Option/Menu/Entry/Value', 1); $test_options = array(); foreach (array_keys($settings_name) as $option_count) { $names = $option_names[$option_count]; $messages = $option_messages[$option_count]; $values = $option_values[$option_count]; if ($auto_process) { pts_test_run_options::auto_process_test_option($this->identifier, $settings_identifier[$option_count], $names, $values, $messages); } $user_option = new pts_test_option($settings_identifier[$option_count], $settings_name[$option_count]); $user_option->set_option_prefix($settings_argument_prefix[$option_count]); $user_option->set_option_postfix($settings_argument_postfix[$option_count]); for ($i = 0; $i < count($names); $i++) { $user_option->add_option($names[$i], isset($values[$i]) ? $values[$i] : null, isset($messages[$i]) ? $messages[$i] : null); } $user_option->set_option_default($settings_default[$option_count]); array_push($test_options, $user_option); } return $test_options; }