Skip to contentSkip to conversation

Add checkbashisms meta-testcase

PATCH In review Masami Hiramatsu 3 participants 6 messages Feb 22, 2019 – May 24, 2019

Subsystems (2)
lore
Share & tools
lore

Masami Hiramatsu

author maintainer
#0 lore raw

cover Add checkbashisms meta-testcase

Hi,

Here are patches for making sure the ftracetest testcases are checkbashisms clean.

This actually needs a patch from Juerg, "selftests/ftrace:
Make the coloring POSIX compliant" to complete the work.

http://lkml.kernel.org/r/20190220161333.28109-1-juergh at canonical.com (Note that this is still under development)

So as Juerg pointed, recently ftracetest becomes not POSIX compliant, and such kind of issues happened repeatedly. To avoid those anymore, I decided to introduce a testcase which runs checkbasisms on ftracetest and its testcases. I think this can help us to find out whether it was written in a way out of POSIX.

Thank you,

---

Masami Hiramatsu (2):
selftests/ftrace: Make a script checkbashisms clean selftests/ftrace: Add checkbashisms meta-testcase

 tools/testing/selftests/ftrace/ftracetest          |    1 +
 .../ftrace/test.d/kprobe/kprobe_ftrace.tc          |    2 +-
 .../selftests/ftrace/test.d/selftest/bashisms.tc   |   21 ++++++++++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/ftrace/test.d/selftest/bashisms.tc

--
Masami Hiramatsu (Linaro) <mhiramat at kernel.org>

author maintainer
#1 lore raw

PATCH 1/2 selftests/ftrace: Make a script checkbashisms clean

Make kprobe_ftrace.tc checkbashisms clean. Since
"grep function available_tracers" causes an error
on checkbashisms, fix it by explicitly escaping
with double-quotations.

Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>
---
 .../ftrace/test.d/kprobe/kprobe_ftrace.tc          |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc +1 -1
index 492426e95e09..7650a82db3f5 100644
@@ -3,7 +3,7 @@
 # description: Kprobe dynamic event with function tracer
 
 [ -f kprobe_events ] || exit_unsupported # this is configurable
-grep function available_tracers || exit_unsupported # this is configurable
+grep "function" available_tracers || exit_unsupported # this is configurable
 
 # prepare
 echo nop > current_tracer
author maintainer
#2 lore raw

PATCH 2/2 selftests/ftrace: Add checkbashisms meta-testcase

In reply to Masami Hiramatsu

Add a meta-testcase which tests ftracetest itself with checkbasisms. This helps us to keep our test script bashisms clean.

Signed-off-by Masami Hiramatsu <mhiramat at kernel.org>
---
 tools/testing/selftests/ftrace/ftracetest          |    1 +
 .../selftests/ftrace/test.d/selftest/bashisms.tc   |   21 ++++++++++++++++++++
 2 files changed, 22 insertions(+)
 create mode 100644 tools/testing/selftests/ftrace/test.d/selftest/bashisms.tc
tools/testing/selftests/ftrace/ftracetest +1 -0
index 75244db70331..72b6df37cdb9 100755
@@ -313,6 +313,7 @@ run_test() { # testfile
     local testlog=/proc/self/fd/1
   fi
   export TMPDIR=`mktemp -d /tmp/ftracetest-dir.XXXXXX`
+  export FTRACETEST_ROOT=$TOP_DIR
   echo "execute$INSTANCE: "$1 > $testlog
   SIG_RESULT=0
   if [ $VERBOSE -eq -1 ]; then
tools/testing/selftests/ftrace/test.d/selftest/bashisms.tc new file +21 -0
new file mode 100644
index 000000000000..1b081e910e14
@@ -0,0 +1,21 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# description: Meta-selftest: Checkbashisms
+
+if [ ! -f $FTRACETEST_ROOT/ftracetest ]; then
+  echo "Hmm, we can not find ftracetest"
+  exit_unresolved
+fi
+
+if ! which checkbashisms > /dev/null 2>&1 ; then
+  echo "No checkbashisms found. skipped."
+  exit_unresolved
+fi
+
+checkbashisms $FTRACETEST_ROOT/ftracetest
+checkbashisms $FTRACETEST_ROOT/test.d/functions
+for t in $(find $FTRACETEST_ROOT/test.d -name \*.tc); do
+  checkbashisms $t
+done
+
+exit 0
author maintainer
#3 lore raw
In reply to Masami Hiramatsu

Hi Shuah,

Could you pick this to your tree? I think this can prevent further simillar errors before release...

Thank you,

Quoted 35 lines · On Fri, 22 Feb 2019 10:26:27 +0900 Masami Hiramatsu <[email protected]> wrote:

Hi,

Here are patches for making sure the ftracetest testcases are checkbashisms clean.

This actually needs a patch from Juerg, "selftests/ftrace:
Make the coloring POSIX compliant" to complete the work.

http://lkml.kernel.org/r/20190220161333.28109-1-juergh at canonical.com (Note that this is still under development)

So as Juerg pointed, recently ftracetest becomes not POSIX compliant, and such kind of issues happened repeatedly. To avoid those anymore, I decided to introduce a testcase which runs checkbasisms on ftracetest and its testcases. I think this can help us to find out whether it was written in a way out of POSIX.

Thank you,

---

Masami Hiramatsu (2):
selftests/ftrace: Make a script checkbashisms clean selftests/ftrace: Add checkbashisms meta-testcase

 tools/testing/selftests/ftrace/ftracetest          |    1 +
 .../ftrace/test.d/kprobe/kprobe_ftrace.tc          |    2 +-
 .../selftests/ftrace/test.d/selftest/bashisms.tc   |   21 ++++++++++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/ftrace/test.d/selftest/bashisms.tc

--
Masami Hiramatsu (Linaro) <mhiramat at kernel.org>

Signature · 1 line
Masami Hiramatsu <mhiramat at kernel.org>
maintainer
#4 lore raw

Shuah,

Want to take this or would you want me to?

-- Steve

Quoted 47 lines · On Sat, 23 Mar 2019 19:27:46 +0900 Masami Hiramatsu <mhiramat at kernel.org>…

Hi Shuah,

Could you pick this to your tree? I think this can prevent further simillar errors before release...

Thank you,

Quoted 35 lines · On Fri, 22 Feb 2019 10:26:27 +0900 Masami Hiramatsu <mhiramat at kernel.org>…

Hi,

Here are patches for making sure the ftracetest testcases are checkbashisms clean.

This actually needs a patch from Juerg, "selftests/ftrace:
Make the coloring POSIX compliant" to complete the work.

http://lkml.kernel.org/r/20190220161333.28109-1-juergh at canonical.com (Note that this is still under development)

So as Juerg pointed, recently ftracetest becomes not POSIX compliant, and such kind of issues happened repeatedly. To avoid those anymore, I decided to introduce a testcase which runs checkbasisms on ftracetest and its testcases. I think this can help us to find out whether it was written in a way out of POSIX.

Thank you,

---

Masami Hiramatsu (2):
selftests/ftrace: Make a script checkbashisms clean selftests/ftrace: Add checkbashisms meta-testcase

 tools/testing/selftests/ftrace/ftracetest          |    1 +
 .../ftrace/test.d/kprobe/kprobe_ftrace.tc          |    2 +-
 .../selftests/ftrace/test.d/selftest/bashisms.tc   |   21 ++++++++++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/ftrace/test.d/selftest/bashisms.tc

--
Masami Hiramatsu (Linaro) <mhiramat at kernel.org>

maintainer
#5 lore raw
Quoted 8 lines · Steven Rostedt

Shuah,

Want to take this or would you want me to?

-- Steve

I can take them through my tree.

thanks,
-- Shuah