Skip to content

Commit af6de05

Browse files
rbmarlieregregkh
authored andcommitted
ktest: Honor empty per-test option overrides
[ Upstream commit a2de57a ] A per-test override can clear an inherited default option by assigning an empty value, but __set_test_option() still used option_defined() to decide whether a per-test key existed. That turned an empty per-test assignment back into "fall back to the default", so tests still could not clear inherited settings. For example: DEFAULTS (...) LOG_FILE = /tmp/ktest-empty-override.log CLEAR_LOG = 1 ADD_CONFIG = /tmp/.config TEST_START TEST_TYPE = build BUILD_TYPE = nobuild ADD_CONFIG = This would run the test with ADD_CONFIG[1] = /tmp/.config Fix by checking whether the per-test key exists before falling back. If it does exist but is empty, treat it as unset for that test and stop the fallback chain there. Cc: John Hawley <warthog9@eaglescrag.net> Cc: Andrea Righi <arighi@nvidia.com> Cc: Marcos Paulo de Souza <mpdesouza@suse.com> Cc: Matthieu Baerts <matttbe@kernel.org> Cc: Fernando Fernandez Mancera <fmancera@suse.de> Cc: Pedro Falcato <pfalcato@suse.de> Link: https://patch.msgid.link/20260307-ktest-fixes-v1-4-565d412f4925@suse.com Fixes: 22c37a9 ("ktest: Allow tests to undefine default options") Signed-off-by: Ricardo B. Marlière <rbm@suse.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 1ebf1c6 commit af6de05

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tools/testing/ktest/ktest.pl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4127,15 +4127,17 @@ sub __set_test_option {
41274127

41284128
my $option = "$name\[$i\]";
41294129

4130-
if (option_defined($option)) {
4130+
if (exists($opt{$option})) {
4131+
return undef if (!option_defined($option));
41314132
return $opt{$option};
41324133
}
41334134

41344135
foreach my $test (keys %repeat_tests) {
41354136
if ($i >= $test &&
41364137
$i < $test + $repeat_tests{$test}) {
41374138
$option = "$name\[$test\]";
4138-
if (option_defined($option)) {
4139+
if (exists($opt{$option})) {
4140+
return undef if (!option_defined($option));
41394141
return $opt{$option};
41404142
}
41414143
}

0 commit comments

Comments
 (0)