public inbox for linux-kselftest@vger.kernel.org
 help / color / mirror / Atom feed
From: Cao Ruichuang <create0818@163.com>
To: rostedt@goodmis.org, mhiramat@kernel.org
Cc: mathieu.desnoyers@efficios.com, shuah@kernel.org,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org
Subject: [PATCH] selftests/ftrace: Quote check_requires comparisons
Date: Wed,  8 Apr 2026 12:32:12 +0800	[thread overview]
Message-ID: <20260408043212.8063-1-create0818@163.com> (raw)

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 <create0818@163.com>
---
 tools/testing/selftests/ftrace/test.d/functions | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
index e8e718139..442aa28ff 100644
--- a/tools/testing/selftests/ftrace/test.d/functions
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -145,13 +145,13 @@ check_requires() { # Check required files and tracers
 	p=${i%:program}
         r=${i%:README}
         t=${i%:tracer}
-	if [ $p != $i ]; then
-	    if ! which $p ; then
+	if [ "$p" != "$i" ]; then
+	    if ! which "$p" ; then
                 echo "Required program $p is not found."
                 exit_unresolved
 	    fi
-        elif [ $t != $i ]; then
-            if ! grep -wq $t available_tracers ; then
+        elif [ "$t" != "$i" ]; then
+            if ! grep -wq "$t" available_tracers ; then
                 echo "Required tracer $t is not configured."
                 exit_unsupported
             fi
@@ -162,11 +162,11 @@ check_requires() { # Check required files and tracers
 	    else
 		test=$TRACING_DIR
 	    fi
-            if ! grep -Fq "$r" $test/README ; then
+            if ! grep -Fq "$r" "$test"/README ; then
                 echo "Required feature pattern \"$r\" is not in README."
                 exit_unsupported
             fi
-        elif [ ! -e $i ]; then
+        elif [ ! -e "$i" ]; then
             echo "Required feature interface $i doesn't exist."
             exit_unsupported
         fi
@@ -223,4 +223,4 @@ get_mnt_options() {
 	local opts=$(mount | grep -m1 "$mnt_point" | sed -e 's/.*(\(.*\)).*/\1/')
 
 	echo "$opts"
-}
\ No newline at end of file
+}
-- 
2.39.5 (Apple Git-154)


             reply	other threads:[~2026-04-08  4:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-08  4:32 Cao Ruichuang [this message]
2026-04-08 21:18 ` [PATCH] selftests/ftrace: Quote check_requires comparisons Steven Rostedt
2026-04-08 21:22   ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260408043212.8063-1-create0818@163.com \
    --to=create0818@163.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox