From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: "John Warthog9 Hawley" <warthog9@kernel.org>, dhaval@gianis.ca
Subject: [PATCH 2/4] ktest.pl: Allow command option -D to override temp variables
Date: Tue, 17 Jun 2025 11:43:05 -0400 [thread overview]
Message-ID: <20250617154351.696892698@goodmis.org> (raw)
In-Reply-To: <20250617154303.952651744@goodmis.org>
From: Steven Rostedt <rostedt@goodmis.org>
Currently -D only updates the persistent variables that are defined with
"=". Allow it to also override all temp variables that are defined with
":=".
ktest.pl -D 'USE_TEMP_DIR:=1' -D 'TEST_TYPE[2]=build' config
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
tools/testing/ktest/ktest.pl | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 8fcc09893986..c441934f1def 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -22,6 +22,7 @@ my %repeat_tests;
my %repeats;
my %evals;
my @command_vars;
+my %command_tmp_vars;
#default opts
my %default = (
@@ -901,14 +902,22 @@ sub set_eval {
}
sub set_variable {
- my ($lvalue, $rvalue) = @_;
+ my ($lvalue, $rvalue, $command) = @_;
+ # Command line variables override all others
+ if (defined($command_tmp_vars{$lvalue})) {
+ return;
+ }
if ($rvalue =~ /^\s*$/) {
delete $variable{$lvalue};
} else {
$rvalue = process_variables($rvalue);
$variable{$lvalue} = $rvalue;
}
+
+ if (defined($command)) {
+ $command_tmp_vars{$lvalue} = 1;
+ }
}
sub process_compare {
@@ -4267,6 +4276,11 @@ ktest.pl version: $VERSION
-D TEST_TYPE[2]=build
Sets TEST_TYPE of test 2 to "build"
+ It can also override all temp variables.
+ -D USE_TEMP_DIR:=1
+ Will override all variables that use
+ "USE_TEMP_DIR="
+
EOF
;
}
@@ -4277,7 +4291,11 @@ while ( $#ARGV >= 0 ) {
die_usage if ($#ARGV < 1);
my $val = shift;
- $command_vars[$#command_vars + 1] = $val;
+ if ($val =~ m/(.*?):=(.*)$/) {
+ set_variable($1, $2, 1);
+ } else {
+ $command_vars[$#command_vars + 1] = $val;
+ }
} elsif ( $ARGV[0] eq "-h" ) {
die_usage;
--
2.47.2
next prev parent reply other threads:[~2025-06-17 15:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 15:43 [PATCH 0/4] ktest.pl: Updates for 6.17 Steven Rostedt
2025-06-17 15:43 ` [PATCH 1/4] ktest.pl: Add -D option to override variables Steven Rostedt
2025-06-17 15:43 ` Steven Rostedt [this message]
2025-06-17 15:43 ` [PATCH 3/4] ktest.pl: Have -D option work without a space Steven Rostedt
2025-06-17 15:43 ` [PATCH 4/4] ktest.pl: Prevent recursion of default variable options 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=20250617154351.696892698@goodmis.org \
--to=rostedt@goodmis.org \
--cc=dhaval@gianis.ca \
--cc=linux-kernel@vger.kernel.org \
--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 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®