Skip to content

Commit 3bcdb6e

Browse files
committed
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" <[email protected]> Cc: Dhaval Giani <[email protected]> Cc: Greg KH <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Steven Rostedt <[email protected]>
1 parent 23b772c commit 3bcdb6e

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

tools/testing/ktest/ktest.pl

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
my %repeats;
2323
my %evals;
2424
my @command_vars;
25+
my %command_tmp_vars;
2526

2627
#default opts
2728
my %default = (
@@ -901,14 +902,22 @@ sub set_eval {
901902
}
902903

903904
sub set_variable {
904-
my ($lvalue, $rvalue) = @_;
905+
my ($lvalue, $rvalue, $command) = @_;
905906

907+
# Command line variables override all others
908+
if (defined($command_tmp_vars{$lvalue})) {
909+
return;
910+
}
906911
if ($rvalue =~ /^\s*$/) {
907912
delete $variable{$lvalue};
908913
} else {
909914
$rvalue = process_variables($rvalue);
910915
$variable{$lvalue} = $rvalue;
911916
}
917+
918+
if (defined($command)) {
919+
$command_tmp_vars{$lvalue} = 1;
920+
}
912921
}
913922

914923
sub process_compare {
@@ -4267,6 +4276,11 @@ sub die_usage {
42674276
-D TEST_TYPE[2]=build
42684277
Sets TEST_TYPE of test 2 to "build"
42694278
4279+
It can also override all temp variables.
4280+
-D USE_TEMP_DIR:=1
4281+
Will override all variables that use
4282+
"USE_TEMP_DIR="
4283+
42704284
EOF
42714285
;
42724286
}
@@ -4277,7 +4291,11 @@ sub die_usage {
42774291
die_usage if ($#ARGV < 1);
42784292
my $val = shift;
42794293

4280-
$command_vars[$#command_vars + 1] = $val;
4294+
if ($val =~ m/(.*?):=(.*)$/) {
4295+
set_variable($1, $2, 1);
4296+
} else {
4297+
$command_vars[$#command_vars + 1] = $val;
4298+
}
42814299

42824300
} elsif ( $ARGV[0] eq "-h" ) {
42834301
die_usage;

0 commit comments

Comments
 (0)