]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ktest: Run commands through list-form shell open
authorRicardo B. Marlière <rbm@suse.com>
Sat, 7 Mar 2026 22:08:00 +0000 (19:08 -0300)
committerSteven Rostedt <rostedt@goodmis.org>
Mon, 9 Mar 2026 14:32:07 +0000 (10:32 -0400)
run_command() currently uses string-form open():

  open(CMD, "$command 2>&1 |")

That delegates parsing to the shell but also mixes the stderr redirection
into the command string. Switch to list-form open() with an explicit sh -c
wrapper so shell syntax errors are captured in the same output stream as
command output. Otherwise, important errors can not be retrieved from the
ktest LOG_FILE.

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-5-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

index 42bc505e14cb9927ce11941ba8199239cf07546f..9d6f50045dbd2c54ac788607c71c09bb43b872e1 100755 (executable)
@@ -1921,7 +1921,10 @@ sub run_command {
     doprint("$command ... ");
     $start_time = time;
 
-    $pid = open(CMD, "$command 2>&1 |") or
+    $pid = open(CMD, "-|",
+               "sh", "-c",
+               'command=$1; shift; exec 2>&1; eval "$command"',
+               "sh", $command) or
        (fail "unable to exec $command" and return 0);
 
     if (defined($opt{"LOG_FILE"})) {