summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--EXPERIMENTAL-CHANGE-LOG1
-rw-r--r--pts-core/functions/pts-functions-run.php34
-rw-r--r--pts-core/objects/pts_test_option.php79
-rw-r--r--pts-core/pts-run-test.php146
4 files changed, 181 insertions, 79 deletions
diff --git a/EXPERIMENTAL-CHANGE-LOG b/EXPERIMENTAL-CHANGE-LOG
index 45cfaac..d9d1137 100644
--- a/EXPERIMENTAL-CHANGE-LOG
+++ b/EXPERIMENTAL-CHANGE-LOG
@@ -29,6 +29,7 @@ Phoronix Test Suite
- pts-core: Move test note creation code for saved results into pts_generate_test_notes()
- pts-core: Update upload-results to use new functions
- pts-core: Various minor improvements in pts-run-cmd.php
+- pts-core: Move test option handling to using pts_test_options() and new pts_test_option() objects
- pts: Move pcqs tests out of tree
- update_checker: Move code to check for PTS updates out of pts-core and into its own module
- install-sh: Remove the Phoronix Test Suite shared and documentation files prior to copying over new files, in case some files were changed removed in new release
diff --git a/pts-core/functions/pts-functions-run.php b/pts-core/functions/pts-functions-run.php
index 95c72f3..7043127 100644
--- a/pts-core/functions/pts-functions-run.php
+++ b/pts-core/functions/pts-functions-run.php
@@ -740,4 +740,38 @@ function pts_auto_process_test_option($identifier, &$option_names, &$option_valu
}
}
}
+function pts_test_options($identifier)
+{
+ $xml_parser = new pts_test_tandem_XmlReader(pts_location_test($identifier));
+ $settings_name = $xml_parser->getXMLArrayValues(P_TEST_OPTIONS_DISPLAYNAME);
+ $settings_argument = $xml_parser->getXMLArrayValues(P_TEST_OPTIONS_ARGUMENTNAME);
+ $settings_identifier = $xml_parser->getXMLArrayValues(P_TEST_OPTIONS_IDENTIFIER);
+ $settings_menu = $xml_parser->getXMLArrayValues(P_TEST_OPTIONS_MENU_GROUP);
+
+ $test_options = array();
+
+ for($option_count = 0; $option_count < count($settings_name); $option_count++)
+ {
+ if(!empty($settings_menu[$option_count]))
+ {
+ $xml_parser = new tandem_XmlReader($settings_menu[$option_count]);
+ $option_names = $xml_parser->getXMLArrayValues(S_TEST_OPTIONS_MENU_GROUP_NAME);
+ $option_values = $xml_parser->getXMLArrayValues(S_TEST_OPTIONS_MENU_GROUP_VALUE);
+ pts_auto_process_test_option($settings_identifier[$option_count], $option_names, $option_values);
+
+ $user_option = new pts_test_option($settings_identifier[$option_count], $settings_name[$option_count]);
+ $user_option->set_option_prefix($settings_argument[$option_count]);
+
+ for($i = 0; $i < count($option_names) && $i < count($option_values); $i++)
+ {
+ $user_option->add_option($option_names[$i], $option_values[$i]);
+ }
+
+ array_push($test_options, $user_option);
+ }
+ }
+
+ return $test_options;
+}
+
?>
diff --git a/pts-core/objects/pts_test_option.php b/pts-core/objects/pts_test_option.php
new file mode 100644
index 0000000..12b2a46
--- /dev/null
+++ b/pts-core/objects/pts_test_option.php
@@ -0,0 +1,79 @@
+<?php
+
+/*
+ Phoronix Test Suite
+ URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/
+ Copyright (C) 2008, Phoronix Media
+ Copyright (C) 2008, Michael Larabel
+ pts_test_option: An object used for storing a test option and its possible values
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+class pts_test_option
+{
+ var $identifier = "";
+ var $option_name = "";
+ var $prefix = "";
+ var $options = array();
+
+ public function __construct($identifier, $option)
+ {
+ $this->identifier = $identifier;
+ $this->option_name = $option;
+ }
+ public function set_option_prefix($prefix)
+ {
+ $this->prefix = $prefix;
+ }
+ public function get_identifier()
+ {
+ return $this->identifier;
+ }
+ public function get_name()
+ {
+ return $this->option_name;
+ }
+ public function get_option_prefix()
+ {
+ return $this->prefix;
+ }
+ public function add_option($name, $value)
+ {
+ array_push($this->options, array($name, $value));
+ }
+ public function get_all_option_names()
+ {
+ $names = array();
+
+ for($i = 0; $i < $this->option_count(); $i++)
+ array_push($names, $this->get_option_name($i));
+
+ return $names;
+ }
+ public function get_option_name($index)
+ {
+ return $this->options[$index][0];
+ }
+ public function get_option_value($index)
+ {
+ return $this->options[$index][1];
+ }
+ public function option_count()
+ {
+ return count($this->options);
+ }
+}
+
+?>
diff --git a/pts-core/pts-run-test.php b/pts-core/pts-run-test.php
index c287662..1c94c94 100644
--- a/pts-core/pts-run-test.php
+++ b/pts-core/pts-run-test.php
@@ -179,53 +179,55 @@ if(is_test($TO_RUN))
{
$xml_parser = new pts_test_tandem_XmlReader(pts_location_test($TO_RUN));
$test_title = $xml_parser->getXMLValue(P_TEST_TITLE);
- $settings_name = $xml_parser->getXMLArrayValues(P_TEST_OPTIONS_DISPLAYNAME);
- $settings_argument = $xml_parser->getXMLArrayValues(P_TEST_OPTIONS_ARGUMENTNAME);
- $settings_identifier = $xml_parser->getXMLArrayValues(P_TEST_OPTIONS_IDENTIFIER);
- $settings_menu = $xml_parser->getXMLArrayValues(P_TEST_OPTIONS_MENU_GROUP);
- $test_title_shown = false;
+ $test_options = pts_test_options($TO_RUN);
if(!IS_BATCH_MODE)
{
$USER_ARGS = "";
$TEXT_ARGS = "";
- for($option_count = 0; $option_count < count($settings_name); $option_count++)
+ echo pts_string_header("Test Configuration: " . $test_title);
+
+ for($this_option_pos = 0; $this_option_pos < count($test_options); $this_option_pos++)
{
- $this_identifier = $settings_identifier[$option_count];
+ $o = $test_options[$this_option_pos];
+ $option_count = $o->option_count();
- if(!empty($settings_menu[$option_count]))
+ if($option_count == 0)
{
- $xml_parser = new tandem_XmlReader($settings_menu[$option_count]);
- $option_names = $xml_parser->getXMLArrayValues(S_TEST_OPTIONS_MENU_GROUP_NAME);
- $option_values = $xml_parser->getXMLArrayValues(S_TEST_OPTIONS_MENU_GROUP_VALUE);
- pts_auto_process_test_option($this_identifier, $option_names, $option_values);
+ // User inputs their option
+ do
+ {
+ echo "\n" . $o->get_name() . "\n" . "Enter Value: ";
+ $value = strtolower(trim(fgets(STDIN)));
+ }
+ while(empty($value));
- if(count($option_values) == 1)
+ $USER_ARGS .= $o->get_option_prefix() . $value;
+ }
+ else
+ {
+ if($option_count == 1)
{
+ // Only one option in menu, so auto-select it
$bench_choice = 1;
}
else
{
- if(!$test_title_shown)
- {
- echo pts_string_header("Test Configuration: " . $test_title);
- $test_title_shown = true;
- }
- else
- echo "\n";
-
- echo $settings_name[$option_count] . ":\n";
+ // Have the user select the desired option
+ echo "\n" . $o->get_name() . ":\n";
+ $all_option_names = $o->get_all_option_names();
$first_try = true;
+
do
{
echo "\n";
- for($i = 0; $i < count($option_names); $i++)
+ for($i = 0; $i < $option_count; $i++)
{
- echo ($i + 1) . ": " . $option_names[$i] . "\n";
+ echo ($i + 1) . ": " . $o->get_option_name($i) . "\n";
}
echo "\nPlease Enter Your Choice: ";
- if($first_try && ($auto_opt = getenv(strtoupper($TO_RUN) . "_" . $option_count)) != FALSE)
+ if($first_try && ($auto_opt = getenv(strtoupper($TO_RUN) . "_" . $this_option_pos)) != FALSE)
{
$bench_choice = $auto_opt;
echo $bench_choice . "\n";
@@ -235,46 +237,38 @@ if(is_test($TO_RUN))
$first_try = false;
}
- while(($bench_choice < 1 || $bench_choice > count($option_names)) && !in_array($bench_choice, $option_names));
+ while(($bench_choice < 1 || $bench_choice > $option_count) && !in_array($bench_choice, $all_option_names));
- if(!is_numeric($bench_choice) && in_array($bench_choice, $option_names))
- for($i = 0; $i < count($option_names); $i++)
- if($option_names[$i] == $bench_choice)
+ if(!is_numeric($bench_choice) && in_array($bench_choice, $all_option_names))
+ {
+ $match_made = false;
+
+ for($i = 0; $i < $option_count && !$match_made; $i++)
+ {
+ if($o->get_option_name($i) == $bench_choice)
+ {
$bench_choice = ($i + 1);
+ $match_made = true;
+ }
+ }
+ }
}
- $option_display_name = $option_names[($bench_choice - 1)];
- if(($cut_point = strpos($option_display_name, '(')) > 1 && strpos($option_display_name, ')') > $cut_point)
+ // Format the selected option
+ $option_display_name = $o->get_option_name(($bench_choice - 1));
+
+ if(($cut_point = strpos($option_display_name, "(")) > 1 && strpos($option_display_name, ")") > $cut_point)
$option_display_name = substr($option_display_name, 0, $cut_point);
- if(count($settings_name) > 1)
- $TEXT_ARGS .= $settings_name[$option_count] . ": ";
+ if(count($test_options) > 1)
+ $TEXT_ARGS .= $o->get_name() . ": ";
$TEXT_ARGS .= $option_display_name;
- if($option_count < count($settings_name) - 1)
+ if($this_option_pos < (count($test_options) - 1))
$TEXT_ARGS .= " - ";
- $USER_ARGS .= $settings_argument[$option_count] . $option_values[($bench_choice - 1)] . " ";
- }
- else
- {
- if(!$test_title_shown)
- {
- echo pts_string_header("Test Configuration: " . $test_title);
- $test_title_shown = true;
- }
- else
- echo "\n";
-
- do
- {
- echo $settings_name[$option_count] . "\n" . "Enter Value: ";
- $value = strtolower(trim(fgets(STDIN)));
- }
- while(empty($value));
-
- $USER_ARGS .= $settings_argument[$option_count] . $value;
+ $USER_ARGS .= $o->get_option_prefix() . $o->get_option_value(($bench_choice - 1)) . " ";
}
}
$TEST_RUN = array($TO_RUN);
@@ -288,38 +282,32 @@ if(is_test($TO_RUN))
$batch_all_args_description = array();
$description_separate = " ";
- for($option_count = 0; $option_count < count($settings_name); $option_count++)
+ for($this_option_pos = 0; $this_option_pos < count($test_options); $this_option_pos++)
{
- $this_identifier = $settings_identifier[$option_count];
- if(!empty($settings_menu[$option_count]))
- {
- $xml_parser = new tandem_XmlReader($settings_menu[$option_count]);
- $option_names = $xml_parser->getXMLArrayValues(S_TEST_OPTIONS_MENU_GROUP_NAME);
- $option_values = $xml_parser->getXMLArrayValues(S_TEST_OPTIONS_MENU_GROUP_VALUE);
- pts_auto_process_test_option($this_identifier, $option_names, $option_values);
+ $o = $test_options[$this_option_pos];
+ $option_count = $o->option_count();
- $option_args = array();
- $option_args_description = array();
+ $option_args = array();
+ $option_args_description = array();
- for($i = 0; $i < count($option_names) && $i < count($option_values); $i++)
- {
- // A bit redundant processing, but will ensure against malformed XML problems and extra stuff added
- $this_arg = $settings_argument[$option_count] . $option_values[$i];
- $this_arg_description = $settings_name[$option_count] . ": " . $option_names[$i];
+ for($i = 0; $i < $o->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);
+ $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);
+ 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($option_args, $this_arg);
+ array_push($option_args_description, $this_arg_description);
+ }
- if($i > 1)
- $description_separate = " - ";
+ if($i > 1)
+ $description_separate = " - ";
- array_push($batch_all_args_real, $option_args);
- array_push($batch_all_args_description, $option_args_description);
- }
+ array_push($batch_all_args_real, $option_args);
+ array_push($batch_all_args_description, $option_args_description);
}
$TEST_ARGS = array();