From: Steven Rostedt <rostedt@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: "John Warthog9 Hawley" <warthog9@kernel.org>,
"Ricardo B. Marlière" <rbm@suse.com>,
"John Hawley" <warthog9@eaglescrag.net>,
"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>
Subject: [for-next][PATCH 9/9] ktest: Add a --dry-run mode
Date: Mon, 16 Mar 2026 14:40:42 -0400 [thread overview]
Message-ID: <20260316184116.993622559@kernel.org> (raw)
In-Reply-To: 20260316184033.927944169@kernel.org
From: =?UTF-8?q?Ricardo=20B=2E=20Marli=C3=A8re?= <rbm@suse.com>
When working on a ktest configuration, it is often useful to inspect the
final option values after includes, defaults, per-test overrides, and
variable expansion have been applied, without actually starting a test run.
Add a --dry-run option that reads the configuration, prints the test
preamble using resolved option values, and exits before opening LOG_FILE or
executing any test logic.
This is useful for debugging ktest configurations and for scripts that need
to validate the final resolved settings without triggering side effects.
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-9-565d412f4925@suse.com
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/testing/ktest/ktest.pl | 89 +++++++++++++++++++++++++-----------
1 file changed, 63 insertions(+), 26 deletions(-)
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 8962857ce4a6..de99b82d16ad 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -85,6 +85,7 @@ my %default = (
);
my $test_log_start = 0;
+my $dry_run = 0;
my $ktest_config = "ktest.conf";
my $version;
@@ -587,7 +588,7 @@ sub end_monitor;
sub wait_for_monitor;
sub _logit {
- if (defined($opt{"LOG_FILE"})) {
+ if (defined($opt{"LOG_FILE"}) && defined(fileno(LOG))) {
print LOG @_;
}
}
@@ -1365,6 +1366,9 @@ sub read_config {
print "$option\n";
}
print "Set IGNORE_UNUSED = 1 to have ktest ignore unused variables\n";
+ if ($dry_run) {
+ return;
+ }
if (!read_yn "Do you want to continue?") {
exit -1;
}
@@ -4249,6 +4253,53 @@ sub set_test_option {
return eval_option($name, $option, $i);
}
+sub print_test_preamble {
+ my ($resolved) = @_;
+
+ doprint "\n\nSTARTING AUTOMATED TESTS\n\n";
+
+ for (my $i = 0, my $repeat = 1; $i <= $opt{"NUM_TESTS"}; $i += $repeat) {
+
+ if (!$i) {
+ doprint "DEFAULT OPTIONS:\n";
+ } else {
+ doprint "\nTEST $i OPTIONS";
+ if (defined($repeat_tests{$i})) {
+ $repeat = $repeat_tests{$i};
+ doprint " ITERATE $repeat";
+ }
+ doprint "\n";
+ }
+
+ foreach my $option (sort keys %opt) {
+ my $value;
+
+ if ($option =~ /\[(\d+)\]$/) {
+ next if ($i != $1);
+
+ if ($resolved) {
+ my $name = $option;
+ $name =~ s/\[\d+\]$//;
+ $value = set_test_option($name, $i);
+ } else {
+ $value = $opt{$option};
+ }
+ } else {
+ next if ($i);
+
+ if ($resolved) {
+ $value = set_test_option($option, 0);
+ } else {
+ $value = $opt{$option};
+ }
+ }
+
+ $value = "" if (!defined($value));
+ doprint "$option = $value\n";
+ }
+ }
+}
+
sub find_mailer {
my ($mailer) = @_;
@@ -4348,6 +4399,8 @@ ktest.pl version: $VERSION
Sets global BUILD_NOCLEAN to 1
-D TEST_TYPE[2]=build
Sets TEST_TYPE of test 2 to "build"
+ --dry-run
+ Print resolved test options and exit without running tests.
It can also override all temp variables.
-D USE_TEMP_DIR:=1
@@ -4379,6 +4432,9 @@ while ( $#ARGV >= 0 ) {
} else {
$command_vars[$#command_vars + 1] = $val;
}
+ } elsif ( $ARGV[0] eq "--dry-run" ) {
+ $dry_run = 1;
+ shift;
} elsif ( $ARGV[0] eq "-h" ) {
die_usage;
} else {
@@ -4427,6 +4483,11 @@ EOF
}
read_config $ktest_config;
+if ($dry_run) {
+ print_test_preamble 1;
+ exit 0;
+}
+
if (defined($opt{"LOG_FILE"})) {
$opt{"LOG_FILE"} = set_test_option("LOG_FILE", 1);
}
@@ -4458,31 +4519,7 @@ if (defined($opt{"LOG_FILE"})) {
LOG->autoflush(1);
}
-doprint "\n\nSTARTING AUTOMATED TESTS\n\n";
-
-for (my $i = 0, my $repeat = 1; $i <= $opt{"NUM_TESTS"}; $i += $repeat) {
-
- if (!$i) {
- doprint "DEFAULT OPTIONS:\n";
- } else {
- doprint "\nTEST $i OPTIONS";
- if (defined($repeat_tests{$i})) {
- $repeat = $repeat_tests{$i};
- doprint " ITERATE $repeat";
- }
- doprint "\n";
- }
-
- foreach my $option (sort keys %opt) {
- if ($option =~ /\[(\d+)\]$/) {
- next if ($i != $1);
- } else {
- next if ($i);
- }
-
- doprint "$option = $opt{$option}\n";
- }
-}
+print_test_preamble 0;
$SIG{INT} = qw(cancel_test);
--
2.51.0
prev parent reply other threads:[~2026-03-16 18:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 18:40 [for-next][PATCH 0/9] ktest: Updates to ktest for 7.1 Steven Rostedt
2026-03-16 18:40 ` [for-next][PATCH 1/9] ktest: Avoid undef warning when WARNINGS_FILE is unset Steven Rostedt
2026-03-16 18:40 ` [for-next][PATCH 2/9] ktest: Resolve LOG_FILE in test option context Steven Rostedt
2026-03-16 18:40 ` [for-next][PATCH 3/9] ktest: Treat undefined self-reference as empty Steven Rostedt
2026-03-16 18:40 ` [for-next][PATCH 4/9] ktest: Honor empty per-test option overrides Steven Rostedt
2026-03-16 18:40 ` [for-next][PATCH 5/9] ktest: Run commands through list-form shell open Steven Rostedt
2026-03-16 18:40 ` [for-next][PATCH 6/9] ktest: Stop dropping console output during power-cycle reboot Steven Rostedt
2026-03-16 18:40 ` [for-next][PATCH 7/9] ktest: Add PRE_KTEST_DIE for PRE_KTEST failures Steven Rostedt
2026-03-16 18:40 ` [for-next][PATCH 8/9] ktest: Run POST_KTEST hooks on failure and cancellation Steven Rostedt
2026-03-16 18:40 ` Steven Rostedt [this message]
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=20260316184116.993622559@kernel.org \
--to=rostedt@kernel.org \
--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=rbm@suse.com \
--cc=warthog9@eaglescrag.net \
--cc=warthog9@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.