summaryrefslogtreecommitdiffstats
path: root/tools/testing/ktest/ktest.pl
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-09-30 22:14:21 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-10-17 11:54:11 -0400
commit3d1cc41432b0491a39a3185b52bfa1d0411bba10 (patch)
treee623dd001b290681f4f8cc653ae5183ff6140209 /tools/testing/ktest/ktest.pl
parent0050b6bbef01d871a34a77685047190aa428b210 (diff)
ktest: Add OVERRIDE keyword to DEFAULTS section
The OVERRIDE keyword will allow options defined in the given DEFAULTS section to override options defined in previous DEFAULT sections. Normally, options will error if they were previous defined. The OVERRIDE keyword allows options that have been previously defined to be changed in the given section. Note, the same option can not be defined in the same DEFAULT section even if that section is marked as OVERRIDE. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing/ktest/ktest.pl')
-rwxr-xr-xtools/testing/ktest/ktest.pl37
1 files changed, 29 insertions, 8 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index b4f32e73474..7bce412bbdc 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -337,10 +337,17 @@ sub process_variables {
}
sub set_value {
- my ($lvalue, $rvalue) = @_;
+ my ($lvalue, $rvalue, $override, $overrides, $name) = @_;
if (defined($opt{$lvalue})) {
- die "Error: Option $lvalue defined more than once!\n";
+ if (!$override || defined(${$overrides}{$lvalue})) {
+ my $extra = "";
+ if ($override) {
+ $extra = "In the same override section!\n";
+ }
+ die "$name: $.: Option $lvalue defined more than once!\n$extra";
+ }
+ ${$overrides}{$lvalue} = $rvalue;
}
if ($rvalue =~ /^\s*$/) {
delete $opt{$lvalue};
@@ -430,6 +437,9 @@ sub __read_config {
my $test_case = 0;
my $if = 0;
my $if_set = 0;
+ my $override = 0;
+
+ my %overrides;
while (<$in>) {
@@ -443,6 +453,7 @@ sub __read_config {
my $old_test_num;
my $old_repeat;
+ $override = 0;
if ($type eq "TEST_START") {
@@ -468,10 +479,20 @@ sub __read_config {
$skip = 0;
}
- if ($rest =~ /\s+ITERATE\s+(\d+)(.*)$/) {
- $repeat = $1;
- $rest = $2;
- $repeat_tests{"$test_num"} = $repeat;
+ if (!$skip) {
+ if ($type eq "TEST_START") {
+ if ($rest =~ /\s+ITERATE\s+(\d+)(.*)$/) {
+ $repeat = $1;
+ $rest = $2;
+ $repeat_tests{"$test_num"} = $repeat;
+ }
+ } elsif ($rest =~ /\sOVERRIDE\b(.*)/) {
+ # DEFAULT only
+ $rest = $1;
+ $override = 1;
+ # Clear previous overrides
+ %overrides = ();
+ }
}
if ($rest =~ /\sIF\s+(.*)/) {
@@ -573,10 +594,10 @@ sub __read_config {
}
if ($default || $lvalue =~ /\[\d+\]$/) {
- set_value($lvalue, $rvalue);
+ set_value($lvalue, $rvalue, $override, \%overrides, $name);
} else {
my $val = "$lvalue\[$test_num\]";
- set_value($val, $rvalue);
+ set_value($val, $rvalue, $override, \%overrides, $name);
if ($repeat > 1) {
$repeats{$val} = $repeat;