Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ktest: Treat undefined self-reference as empty

Config variables are expanded when they are assigned. A first-time append
such as:

VAR := ${VAR} foo

leaves the literal ${VAR} in the stored value because VAR has not been
defined yet. Later expansions then carry the self-reference forward instead
of behaving like an empty prefix.

Drop an unescaped self-reference when the variable has no current value,
and trim the outer whitespace left behind. Keep escaped \${VAR} references
unchanged so literal text still works.

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-3-565d412f4925@suse.com
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

authored by

Ricardo B. Marlière and committed by
Steven Rostedt
a2706c6c eb30942e

+8
+8
tools/testing/ktest/ktest.pl
··· 910 910 if (defined($command_tmp_vars{$lvalue})) { 911 911 return; 912 912 } 913 + 914 + # If a variable is undefined, treat an unescaped self-reference as empty. 915 + if (!defined($variable{$lvalue})) { 916 + $rvalue =~ s/(?<!\\)\$\{\Q$lvalue\E\}//g; 917 + $rvalue =~ s/^\s+//; 918 + $rvalue =~ s/\s+$//; 919 + } 920 + 913 921 if ($rvalue =~ /^\s*$/) { 914 922 delete $variable{$lvalue}; 915 923 } else {