diff options
| author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2013-01-31 10:12:20 -0500 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2013-01-31 10:24:53 -0500 |
| commit | 04262be3db53d2b77ec09fa3e4d18313b6b9dcf9 (patch) | |
| tree | 641aaad32d3961a8d2f381afb7f6ad41704f4713 /tools/testing/ktest | |
| parent | 35275685bf6123529e67c1dc91b8c05e479124e8 (diff) | |
ktest: Allow a test option to use its default option
Options are allowed to use other options, for example:
LOG_FILE = ${OUTPUT_DIR}/${MACHINE}.log
where the option LOG_FILE used the options OUTPUT_DIR and MACHINE.
But if a test option were to use a default option, it will not get
substituted:
OUTPUT_DIR = ${THIS_DIR}/${MACHINE}
TEST_START
OUTPUT_DIR = ${OUTPUT_DIR}/t1
For the above test, OUTPUT_DIR will stay literally "${OUTPUT_DIR}/t1"
and not be converted to "${THIS_DIR}/${MACHINE}/t1". When the test runs,
it will pass the ${OUTPUT_DIR} to the shell, which would probaly
interpret it as "", and the output directory will end up as "/t1".
Change the code where if a test option has its own option name in
its defined field, and a default option exists, then substitute the
default option in its place.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing/ktest')
| -rwxr-xr-x | tools/testing/ktest/ktest.pl | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index cc9925a68f2a..3d19ee445249 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl | |||
| @@ -1074,7 +1074,7 @@ sub read_config { | |||
| 1074 | } | 1074 | } |
| 1075 | 1075 | ||
| 1076 | sub __eval_option { | 1076 | sub __eval_option { |
| 1077 | my ($option, $i) = @_; | 1077 | my ($name, $option, $i) = @_; |
| 1078 | 1078 | ||
| 1079 | # Add space to evaluate the character before $ | 1079 | # Add space to evaluate the character before $ |
| 1080 | $option = " $option"; | 1080 | $option = " $option"; |
| @@ -1106,7 +1106,11 @@ sub __eval_option { | |||
| 1106 | my $o = "$var\[$i\]"; | 1106 | my $o = "$var\[$i\]"; |
| 1107 | my $parento = "$var\[$parent\]"; | 1107 | my $parento = "$var\[$parent\]"; |
| 1108 | 1108 | ||
| 1109 | if (defined($opt{$o})) { | 1109 | # If a variable contains itself, use the default var |
| 1110 | if (($var eq $name) && defined($opt{$var})) { | ||
| 1111 | $o = $opt{$var}; | ||
| 1112 | $retval = "$retval$o"; | ||
| 1113 | } elsif (defined($opt{$o})) { | ||
| 1110 | $o = $opt{$o}; | 1114 | $o = $opt{$o}; |
| 1111 | $retval = "$retval$o"; | 1115 | $retval = "$retval$o"; |
| 1112 | } elsif ($repeated && defined($opt{$parento})) { | 1116 | } elsif ($repeated && defined($opt{$parento})) { |
| @@ -1130,7 +1134,7 @@ sub __eval_option { | |||
| 1130 | } | 1134 | } |
| 1131 | 1135 | ||
| 1132 | sub eval_option { | 1136 | sub eval_option { |
| 1133 | my ($option, $i) = @_; | 1137 | my ($name, $option, $i) = @_; |
| 1134 | 1138 | ||
| 1135 | my $prev = ""; | 1139 | my $prev = ""; |
| 1136 | 1140 | ||
| @@ -1146,7 +1150,7 @@ sub eval_option { | |||
| 1146 | "Check for recursive variables\n"; | 1150 | "Check for recursive variables\n"; |
| 1147 | } | 1151 | } |
| 1148 | $prev = $option; | 1152 | $prev = $option; |
| 1149 | $option = __eval_option($option, $i); | 1153 | $option = __eval_option($name, $option, $i); |
| 1150 | } | 1154 | } |
| 1151 | 1155 | ||
| 1152 | return $option; | 1156 | return $option; |
| @@ -3683,7 +3687,7 @@ EOF | |||
| 3683 | read_config $ktest_config; | 3687 | read_config $ktest_config; |
| 3684 | 3688 | ||
| 3685 | if (defined($opt{"LOG_FILE"})) { | 3689 | if (defined($opt{"LOG_FILE"})) { |
| 3686 | $opt{"LOG_FILE"} = eval_option($opt{"LOG_FILE"}, -1); | 3690 | $opt{"LOG_FILE"} = eval_option("LOG_FILE", $opt{"LOG_FILE"}, -1); |
| 3687 | } | 3691 | } |
| 3688 | 3692 | ||
| 3689 | # Append any configs entered in manually to the config file. | 3693 | # Append any configs entered in manually to the config file. |
| @@ -3760,7 +3764,7 @@ sub set_test_option { | |||
| 3760 | my $option = __set_test_option($name, $i); | 3764 | my $option = __set_test_option($name, $i); |
| 3761 | return $option if (!defined($option)); | 3765 | return $option if (!defined($option)); |
| 3762 | 3766 | ||
| 3763 | return eval_option($option, $i); | 3767 | return eval_option($name, $option, $i); |
| 3764 | } | 3768 | } |
| 3765 | 3769 | ||
| 3766 | # First we need to do is the builds | 3770 | # First we need to do is the builds |
