diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2014-11-21 16:21:25 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2014-11-21 19:38:57 -0500 |
commit | 22c37a9ac49d0bf3ec384cdbc60a5600d48e298e (patch) | |
tree | 7bb7cc996241a58b0a3c5e62fcb47c1a791467f7 /tools/testing/ktest/ktest.pl | |
parent | 9972fc0b859e7aaeb6d2d33bdb591959d9a436c0 (diff) |
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/ktest.pl')
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 23 |
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 { | |||
684 | } | 684 | } |
685 | ${$overrides}{$lvalue} = $prvalue; | 685 | ${$overrides}{$lvalue} = $prvalue; |
686 | } | 686 | } |
687 | if ($rvalue =~ /^\s*$/) { | 687 | |
688 | delete $opt{$lvalue}; | 688 | $opt{$lvalue} = $prvalue; |
689 | } else { | ||
690 | $opt{$lvalue} = $prvalue; | ||
691 | } | ||
692 | } | 689 | } |
693 | 690 | ||
694 | sub set_eval { | 691 | sub set_eval { |
@@ -3947,12 +3944,22 @@ for (my $i = 0, my $repeat = 1; $i <= $opt{"NUM_TESTS"}; $i += $repeat) { | |||
3947 | } | 3944 | } |
3948 | } | 3945 | } |
3949 | 3946 | ||
3947 | sub option_defined { | ||
3948 | my ($option) = @_; | ||
3949 | |||
3950 | if (defined($opt{$option}) && $opt{$option} !~ /^\s*$/) { | ||
3951 | return 1; | ||
3952 | } | ||
3953 | |||
3954 | return 0; | ||
3955 | } | ||
3956 | |||
3950 | sub __set_test_option { | 3957 | sub __set_test_option { |
3951 | my ($name, $i) = @_; | 3958 | my ($name, $i) = @_; |
3952 | 3959 | ||
3953 | my $option = "$name\[$i\]"; | 3960 | my $option = "$name\[$i\]"; |
3954 | 3961 | ||
3955 | if (defined($opt{$option})) { | 3962 | if (option_defined($option)) { |
3956 | return $opt{$option}; | 3963 | return $opt{$option}; |
3957 | } | 3964 | } |
3958 | 3965 | ||
@@ -3960,13 +3967,13 @@ sub __set_test_option { | |||
3960 | if ($i >= $test && | 3967 | if ($i >= $test && |
3961 | $i < $test + $repeat_tests{$test}) { | 3968 | $i < $test + $repeat_tests{$test}) { |
3962 | $option = "$name\[$test\]"; | 3969 | $option = "$name\[$test\]"; |
3963 | if (defined($opt{$option})) { | 3970 | if (option_defined($option)) { |
3964 | return $opt{$option}; | 3971 | return $opt{$option}; |
3965 | } | 3972 | } |
3966 | } | 3973 | } |
3967 | } | 3974 | } |
3968 | 3975 | ||
3969 | if (defined($opt{$name})) { | 3976 | if (option_defined($name)) { |
3970 | return $opt{$name}; | 3977 | return $opt{$name}; |
3971 | } | 3978 | } |
3972 | 3979 | ||