summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2025-07-18 16:18:42 -0400
committerSteven Rostedt <rostedt@goodmis.org>2025-07-21 16:31:04 -0400
commit3bcdb6e90c9f5403e764dc9cdbe7907026de59a0 (patch)
treed770dca41f34e12f6d71536864c677042bb80cfb
parent23b772c15f5b39fb2c27b386946232769e4dcc32 (diff)
ktest.pl: Allow command option -D to override temp variables
Currently -D only updates the persistent options 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 Cc: "John Warthog9 Hawley" <warthog9@kernel.org> Cc: Dhaval Giani <dhaval.giani@gmail.com> Cc: Greg KH <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/20250718202053.399653933@kernel.org Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rwxr-xr-xtools/testing/ktest/ktest.pl22
1 files changed, 20 insertions, 2 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 16e20d4137b3..7b94b9b83ee7 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;