Skip to content

Commit f8e0a5a

Browse files
RichardCaoshuahkh
authored andcommitted
selftests/ftrace: Quote check_requires comparisons
check_requires() compares requirement strings that can contain shell pattern characters such as '[' and ']'. Under /bin/sh, the unquoted test expressions can emit 'unexpected operator' warnings while parsing README-backed requirements. Quote the relevant comparisons and path checks so the helper handles those patterns without spurious shell warnings. Validated by rerunning fprobe_syntax_errors.tc and confirming the previous '/bin/sh: unexpected operator' lines disappear from the detailed ftracetest log. Signed-off-by: Cao Ruichuang <[email protected]> Reviewed-by: Steven Rostedt (Google) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Shuah Khan <[email protected]>
1 parent 7e47389 commit f8e0a5a

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

  • tools/testing/selftests/ftrace/test.d

tools/testing/selftests/ftrace/test.d/functions

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ check_requires() { # Check required files and tracers
145145
p=${i%:program}
146146
r=${i%:README}
147147
t=${i%:tracer}
148-
if [ $p != $i ]; then
149-
if ! which $p ; then
148+
if [ "$p" != "$i" ]; then
149+
if ! which "$p" ; then
150150
echo "Required program $p is not found."
151151
exit_unresolved
152152
fi
153-
elif [ $t != $i ]; then
154-
if ! grep -wq $t available_tracers ; then
153+
elif [ "$t" != "$i" ]; then
154+
if ! grep -wq "$t" available_tracers ; then
155155
echo "Required tracer $t is not configured."
156156
exit_unsupported
157157
fi
@@ -162,11 +162,11 @@ check_requires() { # Check required files and tracers
162162
else
163163
test=$TRACING_DIR
164164
fi
165-
if ! grep -Fq "$r" $test/README ; then
165+
if ! grep -Fq "$r" "$test"/README ; then
166166
echo "Required feature pattern \"$r\" is not in README."
167167
exit_unsupported
168168
fi
169-
elif [ ! -e $i ]; then
169+
elif [ ! -e "$i" ]; then
170170
echo "Required feature interface $i doesn't exist."
171171
exit_unsupported
172172
fi
@@ -227,4 +227,4 @@ get_mnt_options() {
227227
local opts=$(mount | grep -m1 "$mnt_point" | sed -e 's/.*(\(.*\)).*/\1/')
228228

229229
echo "$opts"
230-
}
230+
}

0 commit comments

Comments
 (0)