aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/ktest
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
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')
-rwxr-xr-xtools/testing/ktest/ktest.pl37
-rw-r--r--tools/testing/ktest/sample.conf15
2 files changed, 44 insertions, 8 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index b4f32e734745..7bce412bbdcc 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -337,10 +337,17 @@ sub process_variables {
337} 337}
338 338
339sub set_value { 339sub set_value {
340 my ($lvalue, $rvalue) = @_; 340 my ($lvalue, $rvalue, $override, $overrides, $name) = @_;
341 341
342 if (defined($opt{$lvalue})) { 342 if (defined($opt{$lvalue})) {
343 die "Error: Option $lvalue defined more than once!\n"; 343 if (!$override || defined(${$overrides}{$lvalue})) {
344 my $extra = "";
345 if ($override) {
346 $extra = "In the same override section!\n";
347 }
348 die "$name: $.: Option $lvalue defined more than once!\n$extra";
349 }
350 ${$overrides}{$lvalue} = $rvalue;
344 } 351 }
345 if ($rvalue =~ /^\s*$/) { 352 if ($rvalue =~ /^\s*$/) {
346 delete $opt{$lvalue}; 353 delete $opt{$lvalue};
@@ -430,6 +437,9 @@ sub __read_config {
430 my $test_case = 0; 437 my $test_case = 0;
431 my $if = 0; 438 my $if = 0;
432 my $if_set = 0; 439 my $if_set = 0;
440 my $override = 0;
441
442 my %overrides;
433 443
434 while (<$in>) { 444 while (<$in>) {
435 445
@@ -443,6 +453,7 @@ sub __read_config {
443 453
444 my $old_test_num; 454 my $old_test_num;
445 my $old_repeat; 455 my $old_repeat;
456 $override = 0;
446 457
447 if ($type eq "TEST_START") { 458 if ($type eq "TEST_START") {
448 459
@@ -468,10 +479,20 @@ sub __read_config {
468 $skip = 0; 479 $skip = 0;
469 } 480 }
470 481
471 if ($rest =~ /\s+ITERATE\s+(\d+)(.*)$/) { 482 if (!$skip) {
472 $repeat = $1; 483 if ($type eq "TEST_START") {
473 $rest = $2; 484 if ($rest =~ /\s+ITERATE\s+(\d+)(.*)$/) {
474 $repeat_tests{"$test_num"} = $repeat; 485 $repeat = $1;
486 $rest = $2;
487 $repeat_tests{"$test_num"} = $repeat;
488 }
489 } elsif ($rest =~ /\sOVERRIDE\b(.*)/) {
490 # DEFAULT only
491 $rest = $1;
492 $override = 1;
493 # Clear previous overrides
494 %overrides = ();
495 }
475 } 496 }
476 497
477 if ($rest =~ /\sIF\s+(.*)/) { 498 if ($rest =~ /\sIF\s+(.*)/) {
@@ -573,10 +594,10 @@ sub __read_config {
573 } 594 }
574 595
575 if ($default || $lvalue =~ /\[\d+\]$/) { 596 if ($default || $lvalue =~ /\[\d+\]$/) {
576 set_value($lvalue, $rvalue); 597 set_value($lvalue, $rvalue, $override, \%overrides, $name);
577 } else { 598 } else {
578 my $val = "$lvalue\[$test_num\]"; 599 my $val = "$lvalue\[$test_num\]";
579 set_value($val, $rvalue); 600 set_value($val, $rvalue, $override, \%overrides, $name);
580 601
581 if ($repeat > 1) { 602 if ($repeat > 1) {
582 $repeats{$val} = $repeat; 603 $repeats{$val} = $repeat;
diff --git a/tools/testing/ktest/sample.conf b/tools/testing/ktest/sample.conf
index ae2a93c732ac..0fd3ca30ad0c 100644
--- a/tools/testing/ktest/sample.conf
+++ b/tools/testing/ktest/sample.conf
@@ -72,6 +72,21 @@
72# the same option name under the same test or as default 72# the same option name under the same test or as default
73# ktest will fail to execute, and no tests will run. 73# ktest will fail to execute, and no tests will run.
74# 74#
75# DEFAULTS OVERRIDE
76#
77# Options defined in the DEFAULTS section can not be duplicated
78# even if they are defined in two different DEFAULT sections.
79# This is done to catch mistakes where an option is added but
80# the previous option was forgotten about and not commented.
81#
82# The OVERRIDE keyword can be added to a section to allow this
83# section to override other DEFAULT sections values that have
84# been defined previously. It will only override options that
85# have been defined before its use. Options defined later
86# in a non override section will still error. The same option
87# can not be defined in the same section even if that section
88# is marked OVERRIDE.
89#
75# 90#
76# 91#
77# Both TEST_START and DEFAULTS sections can also have the IF keyword 92# Both TEST_START and DEFAULTS sections can also have the IF keyword