diff options
author | Michael Larabel <michael@phx-laptop.(none)> | 2008-12-07 22:37:27 -0500 |
---|---|---|
committer | Michael Larabel <michael@phx-laptop.(none)> | 2008-12-07 22:37:27 -0500 |
commit | ce2ac86de2b21184af90be394a262a18f6efc52b (patch) | |
tree | 081fb720b6aecee2c0aba6c966a05eb1ec806e13 /pts-core | |
parent | 561c8423f860da1b7f082bc1cbf800fab1289383 (diff) | |
download | phoronix-test-suite-upstream-ce2ac86de2b21184af90be394a262a18f6efc52b.tar.gz phoronix-test-suite-upstream-ce2ac86de2b21184af90be394a262a18f6efc52b.tar.xz phoronix-test-suite-upstream-ce2ac86de2b21184af90be394a262a18f6efc52b.zip |
pts-core: Add DefaultEntry tag to XML test specification for specifying
defaults mode
Diffstat (limited to 'pts-core')
-rw-r--r-- | pts-core/functions/pts-functions-run.php | 64 | ||||
-rw-r--r-- | pts-core/functions/pts-interfaces.php | 1 | ||||
-rw-r--r-- | pts-core/objects/pts_test_option.php | 20 | ||||
-rw-r--r-- | pts-core/options/run_test.php | 33 |
4 files changed, 108 insertions, 10 deletions
diff --git a/pts-core/functions/pts-functions-run.php b/pts-core/functions/pts-functions-run.php index 685cafa..bce9ef2 100644 --- a/pts-core/functions/pts-functions-run.php +++ b/pts-core/functions/pts-functions-run.php @@ -247,6 +247,65 @@ function pts_prompt_test_options($identifier) return array($USER_ARGS, $TEXT_ARGS); } +function pts_defaults_test_options($identifier) +{ + // Defaults mode for single test + $all_args_real = array(); + $all_args_description = array(); + $description_separate = " - "; + $test_options = pts_test_options($identifier); + + for($this_option_pos = 0; $this_option_pos < count($test_options); $this_option_pos++) + { + $o = $test_options[$this_option_pos]; + $option_count = $o->option_count(); + + $option_args = array(); + $option_args_description = array(); + + $default_entry = $o->get_option_default(); + + if($option_count == 2) + { + for($i = 0; $i < $option_count; $i++) + { + $this_arg = $o->get_option_prefix() . $o->get_option_value($i) . $o->get_option_postfix(); + $this_arg_description = $o->get_name() . ": " . $o->get_option_name($i); + + if(($cut_point = strpos($this_arg_description, "(")) > 1 && strpos($this_arg_description, ")") > $cut_point) + { + $this_arg_description = substr($this_arg_description, 0, $cut_point); + } + + array_push($option_args, $this_arg); + array_push($option_args_description, $this_arg_description); + } + } + else + { + $this_arg = $o->get_option_prefix() . $o->get_option_value($default_entry) . $o->get_option_postfix(); + $this_arg_description = $o->get_name() . ": " . $o->get_option_name($default_entry); + + if(($cut_point = strpos($this_arg_description, "(")) > 1 && strpos($this_arg_description, ")") > $cut_point) + { + $this_arg_description = substr($this_arg_description, 0, $cut_point); + } + array_push($option_args, $this_arg); + array_push($option_args_description, $this_arg_description); + } + + array_push($all_args_real, $option_args); + array_push($all_args_description, $option_args_description); + } + + $TEST_ARGS = array(); + pts_all_combos($TEST_ARGS, "", $all_args_real, 0); + + $TEST_ARGS_DESCRIPTION = array(); + pts_all_combos($TEST_ARGS_DESCRIPTION, "", $all_args_description, 0, $description_separate); + + return array($TEST_ARGS, $TEST_ARGS_DESCRIPTION); +} function pts_generate_batch_run_options($identifier) { // Batch mode for single test @@ -263,7 +322,7 @@ function pts_generate_batch_run_options($identifier) $option_args = array(); $option_args_description = array(); - for($i = 0; $i < $o->option_count(); $i++) + for($i = 0; $i < $option_count; $i++) { // A bit redundant processing, but will ensure against malformed XML problems and extra stuff added $this_arg = $o->get_option_prefix() . $o->get_option_value($i) . $o->get_option_postfix(); @@ -1096,6 +1155,7 @@ function pts_test_options($identifier) $settings_argument_prefix = $xml_parser->getXMLArrayValues(P_TEST_OPTIONS_ARGPREFIX); $settings_argument_postfix = $xml_parser->getXMLArrayValues(P_TEST_OPTIONS_ARGPOSTFIX); $settings_identifier = $xml_parser->getXMLArrayValues(P_TEST_OPTIONS_IDENTIFIER); + $settings_default = $xml_parser->getXMLArrayValues(P_TEST_OPTIONS_DEFAULTENTRY); $settings_menu = $xml_parser->getXMLArrayValues(P_TEST_OPTIONS_MENU_GROUP); $test_options = array(); @@ -1118,6 +1178,8 @@ function pts_test_options($identifier) $user_option->add_option($option_names[$i], $option_values[$i]); } + $user_option->set_option_default($settings_default[$option_count]); + array_push($test_options, $user_option); } diff --git a/pts-core/functions/pts-interfaces.php b/pts-core/functions/pts-interfaces.php index c08639c..4141a1d 100644 --- a/pts-core/functions/pts-interfaces.php +++ b/pts-core/functions/pts-interfaces.php @@ -64,6 +64,7 @@ define("P_TEST_OPTIONS_DISPLAYNAME", "PhoronixTestSuite/TestSettings/Option/Disp define("P_TEST_OPTIONS_ARGPREFIX", "PhoronixTestSuite/TestSettings/Option/ArgumentPrefix"); // The option argument prefix define("P_TEST_OPTIONS_ARGPOSTFIX", "PhoronixTestSuite/TestSettings/Option/ArgumentPostfix"); // The option argument postfix define("P_TEST_OPTIONS_IDENTIFIER", "PhoronixTestSuite/TestSettings/Option/Identifier"); // Identifiers for each option +define("P_TEST_OPTIONS_DEFAULTENTRY", "PhoronixTestSuite/TestSettings/Option/DefaultEntry"); // The menu entry number to use when running in the defaults mode define("P_TEST_OPTIONS_MENU_GROUP", "PhoronixTestSuite/TestSettings/Option/Menu"); // XML group containing the menu options for the test define("S_TEST_OPTIONS_MENU_GROUP_NAME", "Entry/Name"); // From inside the XML options menu group, the option name define("S_TEST_OPTIONS_MENU_GROUP_VALUE", "Entry/Value"); // From inside the XML options menu group, the option value diff --git a/pts-core/objects/pts_test_option.php b/pts-core/objects/pts_test_option.php index 72600e3..659c11f 100644 --- a/pts-core/objects/pts_test_option.php +++ b/pts-core/objects/pts_test_option.php @@ -27,6 +27,7 @@ class pts_test_option var $option_name = ""; var $prefix = ""; var $postfix = ""; + var $default_entry = -1; var $options = array(); public function __construct($identifier, $option) @@ -42,6 +43,14 @@ class pts_test_option { $this->postfix = $postfix; } + public function set_option_default($default_node) + { + $default_node--; + if(isset($this->options[$default_node])) + { + $this->default_entry = $default_node; + } + } public function get_identifier() { return $this->identifier; @@ -58,6 +67,17 @@ class pts_test_option { return $this->postfix; } + public function get_option_default() + { + $default = $this->default_entry; + + if($default == -1) + { + $default = $this->option_count() - 1; + } + + return $default; + } public function add_option($name, $value) { array_push($this->options, array($name, $value)); diff --git a/pts-core/options/run_test.php b/pts-core/options/run_test.php index 5fb8c37..4501c77 100644 --- a/pts-core/options/run_test.php +++ b/pts-core/options/run_test.php @@ -145,15 +145,7 @@ class run_test implements pts_option_interface if(pts_is_test($to_run)) { - if(!IS_BATCH_MODE) - { - $option_output = pts_prompt_test_options($to_run); - - $TEST_RUN = array($to_run); - $TEST_ARGS = array($option_output[0]); - $TEST_ARGS_DESCRIPTION = array($option_output[1]); - } - else + if(IS_BATCH_MODE) { $option_output = pts_generate_batch_run_options($to_run); @@ -166,6 +158,29 @@ class run_test implements pts_option_interface array_push($TEST_RUN, $to_run); } } + else if(pts_read_assignment("DEFAULTS_MODE") == true) + { + $option_output = pts_defaults_test_options($to_run); + + $TEST_RUN = array($to_run); + $TEST_ARGS = array($option_output[0]); + $TEST_ARGS_DESCRIPTION = array($option_output[1]); + + for($i = 0; $i < count($TEST_ARGS); $i++) + { + array_push($TEST_RUN, $to_run); + } + + print_r($option_output); exit; + } + else + { + $option_output = pts_prompt_test_options($to_run); + + $TEST_RUN = array($to_run); + $TEST_ARGS = array($option_output[0]); + $TEST_ARGS_DESCRIPTION = array($option_output[1]); + } if($unique_test_names == 1) { |