mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ricardo B. Marlière" <rbm@suse.com>
To: Steven Rostedt <rostedt@goodmis.org>,
	 John Hawley <warthog9@eaglescrag.net>
Cc: "Andrea Righi" <arighi@nvidia.com>,
	"Marcos Paulo de Souza" <mpdesouza@suse.com>,
	"Matthieu Baerts" <matttbe@kernel.org>,
	"Fernando Fernandez Mancera" <fmancera@suse.de>,
	"Pedro Falcato" <pfalcato@suse.de>,
	linux-kernel@vger.kernel.org,
	"Steven Rostedt" <srostedt@redhat.com>,
	"Ricardo B. Marlière" <rbm@suse.com>
Subject: [PATCH 4/9] ktest: Honor empty per-test option overrides
Date: Sat, 07 Mar 2026 19:07:59 -0300	[thread overview]
Message-ID: <20260307-ktest-fixes-v1-4-565d412f4925@suse.com> (raw)
In-Reply-To: <20260307-ktest-fixes-v1-0-565d412f4925@suse.com>

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.

Fixes: 22c37a9ac49d ("ktest: Allow tests to undefine default options")
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
 tools/testing/ktest/ktest.pl | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index b8fcdabffffe..42bc505e14cb 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -4191,7 +4191,8 @@ sub __set_test_option {
 
     my $option = "$name\[$i\]";
 
-    if (option_defined($option)) {
+    if (exists($opt{$option})) {
+	return undef if (!option_defined($option));
 	return $opt{$option};
     }
 
@@ -4199,7 +4200,8 @@ sub __set_test_option {
 	if ($i >= $test &&
 	    $i < $test + $repeat_tests{$test}) {
 	    $option = "$name\[$test\]";
-	    if (option_defined($option)) {
+	    if (exists($opt{$option})) {
+		return undef if (!option_defined($option));
 		return $opt{$option};
 	    }
 	}

-- 
2.53.0


  parent reply	other threads:[~2026-03-07 22:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-07 22:07 [PATCH 0/9] tools/testing/ktest: Fixes and a new --dry-run Ricardo B. Marlière
2026-03-07 22:07 ` [PATCH 1/9] ktest: Avoid undef warning when WARNINGS_FILE is unset Ricardo B. Marlière
2026-03-07 22:07 ` [PATCH 2/9] ktest: Resolve LOG_FILE in test option context Ricardo B. Marlière
2026-03-07 22:07 ` [PATCH 3/9] ktest: Treat undefined self-reference as empty Ricardo B. Marlière
2026-03-09 14:40   ` Steven Rostedt
2026-03-07 22:07 ` Ricardo B. Marlière [this message]
2026-03-07 22:08 ` [PATCH 5/9] ktest: Run commands through list-form shell open Ricardo B. Marlière
2026-03-07 22:08 ` [PATCH 6/9] ktest: Stop dropping console output during power-cycle reboot Ricardo B. Marlière
2026-03-07 22:08 ` [PATCH 7/9] ktest: Add PRE_KTEST_DIE for PRE_KTEST failures Ricardo B. Marlière
2026-03-09 15:00   ` Steven Rostedt
2026-03-10 10:25     ` Ricardo B. Marlière
2026-03-07 22:08 ` [PATCH 8/9] ktest: Run POST_KTEST hooks on failure and cancellation Ricardo B. Marlière
2026-03-07 22:08 ` [PATCH 9/9] ktest: Add a --dry-run mode Ricardo B. Marlière
2026-03-09 14:21 ` [PATCH 0/9] tools/testing/ktest: Fixes and a new --dry-run Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260307-ktest-fixes-v1-4-565d412f4925@suse.com \
    --to=rbm@suse.com \
    --cc=arighi@nvidia.com \
    --cc=fmancera@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mpdesouza@suse.com \
    --cc=pfalcato@suse.de \
    --cc=rostedt@goodmis.org \
    --cc=srostedt@redhat.com \
    --cc=warthog9@eaglescrag.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®