Skip to contentSkip to conversation

tracing/selftests: Fix false bashism in kprobe_non_uniq_symbol.tc

PATCH In review Steven Rostedt 3 participants 3 messages Oct 30 – Nov 5

Subsystems (2)
lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

PATCH 1/1 tracing/selftests: Fix false bashism in kprobe_non_uniq_symbol.tc

From: Steven Rostedt <[email protected]>

The checkbashism is giving a false positive to the kprobe test of:

($"foo" should be eval_gettext "foo"):
if [ "$(grep -c -E "[[:alnum:]]+ t ${SYMBOL}$" /proc/kallsyms)" -le '1' ]; then

This is because it sees the $" at the end of the grep as a bash symbol. Instead, escape the '$' with a backslash as it is within quotes and that '$' is for grep to process an end of line character and not a bash variable.

Fixes d22c3e0088e85 ("selftests/ftrace: Fix unique symbol check in kprobe_non_uniq_symbol.tc")
---
 .../selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc +1 -1
index 03eb9e70b438..f8e18ea8c268 100644
@@ -6,7 +6,7 @@
 SYMBOL='init_once'
 
 # We skip this test on kernel where SYMBOL is unique or does not exist.
-if [ "$(grep -c -E "[[:alnum:]]+ t ${SYMBOL}$" /proc/kallsyms)" -le '1' ]; then
+if [ "$(grep -c -E "[[:alnum:]]+ t ${SYMBOL}\$" /proc/kallsyms)" -le '1' ]; then
 	exit_unsupported
 fi
 
Signature · 1 line
2.53.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Steven Rostedt

From: Steven Rostedt <[email protected]>

The checkbashism is giving a false positive to the kprobe test of:

($"foo" should be eval_gettext "foo"):
if [ "$(grep -c -E "[[:alnum:]]+ t ${SYMBOL}$" /proc/kallsyms)" -le '1' ]; then

Quoted 8 lines

This is because it sees the $" at the end of the grep as a bash symbol. Instead, escape the '$' with a backslash as it is within quotes and that '$' is for grep to process an end of line character and not a bash variable.

Fixes d22c3e0088e85 ("selftests/ftrace: Fix unique symbol check in kprobe_non_uniq_symbol.tc")

Oops, good catch!

Looks good to me.

Shuah, can you pick this?

Thanks,

Quoted 18 lines
---
 .../selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_non_uniq_symbol.tc +1 -1
index 03eb9e70b438..f8e18ea8c268 100644
@@ -6,7 +6,7 @@
 SYMBOL='init_once'
 
 # We skip this test on kernel where SYMBOL is unique or does not exist.
-if [ "$(grep -c -E "[[:alnum:]]+ t ${SYMBOL}$" /proc/kallsyms)" -le '1' ]; then
+if [ "$(grep -c -E "[[:alnum:]]+ t ${SYMBOL}\$" /proc/kallsyms)" -le '1' ]; then
 	exit_unsupported
 fi
 
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
maintainer
#2 lore raw
Quoted 17 lines · Masami Hiramatsu (Google)
Quoted 7 lines · Steven Rostedt

From: Steven Rostedt <[email protected]>

The checkbashism is giving a false positive to the kprobe test of:

($"foo" should be eval_gettext "foo"):

   if [ "$(grep -c -E "[[:alnum:]]+ t ${SYMBOL}$" /proc/kallsyms)" -le '1' ]; then
Quoted 8 lines

This is because it sees the $" at the end of the grep as a bash symbol. Instead, escape the '$' with a backslash as it is within quotes and that '$' is for grep to process an end of line character and not a bash variable.

Fixes d22c3e0088e85 ("selftests/ftrace: Fix unique symbol check in kprobe_non_uniq_symbol.tc")
Quoted 8 lines

Oops, good catch!

Looks good to me.

Shuah, can you pick this?

Applied to kselftest fixes branch for next rc

thanks,
-- Shuah