diff options
author | Steven Rostedt (Google) <rostedt@goodmis.org> | 2022-12-07 21:29:44 -0500 |
---|---|---|
committer | Steven Rostedt (Google) <rostedt@goodmis.org> | 2022-12-08 23:23:05 -0500 |
commit | 88a51b4f2e65ca4378a81ff0925fad076e82e177 (patch) | |
tree | 9ddfade2a4ce5a7ac23b5c09b1e1549e1f834583 /tools/testing/ktest/ktest.pl | |
parent | 26df05a8c1420ad3de314fdd407e7fc2058cc7aa (diff) | |
download | linux-stable-88a51b4f2e65ca4378a81ff0925fad076e82e177.tar.gz linux-stable-88a51b4f2e65ca4378a81ff0925fad076e82e177.tar.bz2 linux-stable-88a51b4f2e65ca4378a81ff0925fad076e82e177.zip |
ktest.pl: Add shell commands to variables
Allow variables to execute shell commands. Note, these are processed when
they are first seen while parsing the config file. This is useful if you
have the same config file used for multiple hosts (as they may be in a git
repository).
HOSTNAME := ${shell hostname}
DEFAULTS IF "${HOSTNAME}" == "frodo"
Link: https://lkml.kernel.org/r/20221207212944.277ee850@gandalf.local.home
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Diffstat (limited to 'tools/testing/ktest/ktest.pl')
-rwxr-xr-x | tools/testing/ktest/ktest.pl | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl index 1737c59e4ff6..ac59999ed3de 100755 --- a/tools/testing/ktest/ktest.pl +++ b/tools/testing/ktest/ktest.pl @@ -802,7 +802,14 @@ sub process_variables { my $end = $3; # append beginning of value to retval $retval = "$retval$begin"; - if (defined($variable{$var})) { + if ($var =~ s/^shell\s+//) { + $retval = `$var`; + if ($?) { + doprint "WARNING: $var returned an error\n"; + } else { + chomp $retval; + } + } elsif (defined($variable{$var})) { $retval = "$retval$variable{$var}"; } elsif (defined($remove_undef) && $remove_undef) { # for if statements, any variable that is not defined, |