summaryrefslogtreecommitdiffstats
path: root/tools/testing/ktest
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2014-11-21 16:21:25 -0500
committerSteven Rostedt <rostedt@goodmis.org>2014-11-21 19:38:57 -0500
commit22c37a9ac49d0bf3ec384cdbc60a5600d48e298e (patch)
tree7bb7cc996241a58b0a3c5e62fcb47c1a791467f7 /tools/testing/ktest
parent9972fc0b859e7aaeb6d2d33bdb591959d9a436c0 (diff)
downloadlinux-22c37a9ac49d0bf3ec384cdbc60a5600d48e298e.tar.bz2
ktest: Allow tests to undefine default options
Tests can set options that override the default ones. But if a test tries to undefine a default option, it is simply ignored and the default option stays as is. For example, if you want to have a test that defines no MIN_CONFIG then the test should be able to do that with: TEST_START MIN_CONFIG = Which should make MIN_CONFIG not defined for that test. But the way the code currently works, undefined options in tests are dropped. This is because the NULL options are evaluated during the reading of the config file and since one can disable default options in the default section with this method, it is evaluated there (the option turns to a undef). But undef options in the test section mean to use the default option. To fix this, keep the empty string in the option during the reading of the config file, and then evaluate it when running the test. This will allow tests to null out default options. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing/ktest')
-rwxr-xr-xtools/testing/ktest/ktest.pl23
1 files changed, 15 insertions, 8 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 89c2257bed98..ea43dd2f2fd5 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -684,11 +684,8 @@ sub set_value {
}
${$overrides}{$lvalue} = $prvalue;
}
- if ($rvalue =~ /^\s*$/) {
- delete $opt{$lvalue};
- } else {
- $opt{$lvalue} = $prvalue;
- }
+
+ $opt{$lvalue} = $prvalue;
}
sub set_eval {
@@ -3947,12 +3944,22 @@ for (my $i = 0, my $repeat = 1; $i <= $opt{"NUM_TESTS"}; $i += $repeat) {
}
}
+sub option_defined {
+ my ($option) = @_;
+
+ if (defined($opt{$option}) && $opt{$option} !~ /^\s*$/) {
+ return 1;
+ }
+
+ return 0;
+}
+
sub __set_test_option {
my ($name, $i) = @_;
my $option = "$name\[$i\]";
- if (defined($opt{$option})) {
+ if (option_defined($option)) {
return $opt{$option};
}
@@ -3960,13 +3967,13 @@ sub __set_test_option {
if ($i >= $test &&
$i < $test + $repeat_tests{$test}) {
$option = "$name\[$test\]";
- if (defined($opt{$option})) {
+ if (option_defined($option)) {
return $opt{$option};
}
}
}
- if (defined($opt{$name})) {
+ if (option_defined($name)) {
return $opt{$name};
}