Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1523278 > unrolled thread

[PATCH -tip v3 0/9] ftrace: selftests: Add full glob matching and update ftracetest

Started byMasami Hiramatsu <mhiramat@kernel.org>
First post2016-11-16 09:20 +0100
Last post2016-11-16 09:20 +0100
Articles 7 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH -tip v3 0/9] ftrace: selftests: Add full glob matching and update ftracetest Masami Hiramatsu <mhiramat@kernel.org> - 2016-11-16 09:20 +0100
    [PATCH -tip v3 9/9] selftests: ftrace: Add a testcase for types of kprobe event Masami Hiramatsu <mhiramat@kernel.org> - 2016-11-16 09:20 +0100
    [PATCH -tip v3 4/9] selftests: ftrace: Check whether snapshot trigger is supported correctly Masami Hiramatsu <mhiramat@kernel.org> - 2016-11-16 09:20 +0100
    [PATCH -tip v3 2/9] selftests: ftrace: Initialize ftrace before each test Masami Hiramatsu <mhiramat@kernel.org> - 2016-11-16 09:20 +0100
    [PATCH -tip v3 5/9] selftests: ftrace: Fix trigger-mod to run without syscall trace Masami Hiramatsu <mhiramat@kernel.org> - 2016-11-16 09:20 +0100
    [PATCH -tip v3 8/9] selftests: ftrace: Add a testcase for function filter glob match Masami Hiramatsu <mhiramat@kernel.org> - 2016-11-16 09:20 +0100
    [PATCH -tip v3 7/9] selftests: ftrace: Introduce TMPDIR for temporary files Masami Hiramatsu <mhiramat@kernel.org> - 2016-11-16 09:20 +0100

#1523278 — [PATCH -tip v3 0/9] ftrace: selftests: Add full glob matching and update ftracetest

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-11-16 09:20 +0100
Subject[PATCH -tip v3 0/9] ftrace: selftests: Add full glob matching and update ftracetest
Message-ID<sE3BL-jF-3@gated-at.bofh.it>
Hi,

Here is the 3rd version of the series of patches to
add full glob matching support in ftrace, and update
ftracetest to fix bugs and add test for the glob
matching and hexadecimal types.

Previous version is here:
 https://lkml.org/lkml/2016/10/30/16

I've fix some bugs related to ftrace kconfig
selection on ftracetest, and add --quiet option
in this version.
Here is the short description, 3/9 - 5/9 are
newly added.

[1/9] Add full glob matching support on ftrace's
     function filter and event filter expression.
[2/9] Initialize ftrace before running each testcase.
      (updated in v2 for checking supported features)
[3/9] Add --quiet option to suppress error logs
[4/9] Fix snapshot trigger test to be unsupported
      if the kernel has no snapshot feature.
[5/9] Fix hist trigger-mod test to run correctly
      without syscall trace.
[6/9] Hide logs direcotry from git.
[7/9] Introduce temporary directory for test cases,
     which is used for storing temporary test data.
[8/9] Add a testcase for function-name glob matching
[9/9] Add a testcase for types of event arguments 

Thanks,
---

Masami Hiramatsu (9):
      ftrace: Support full glob matching
      selftests: ftrace: Initialize ftrace before each test
      selftests: ftrace: Add --quiet option not to show error logs on screen
      selftests: ftrace: Check whether snapshot trigger is supported correctly
      selftests: ftrace: Fix trigger-mod to run without syscall trace
      selftests: ftrace: Hide ftracetest logs from git
      selftests: ftrace: Introduce TMPDIR for temporary files
      selftests: ftrace: Add a testcase for function filter glob match
      selftests: ftrace: Add a testcase for types of kprobe event


 Documentation/trace/events.txt                     |    9 +---
 Documentation/trace/ftrace.txt                     |    9 +---
 kernel/trace/Kconfig                               |    2 +
 kernel/trace/ftrace.c                              |    4 ++
 kernel/trace/trace.c                               |    2 -
 kernel/trace/trace.h                               |    2 +
 kernel/trace/trace_events_filter.c                 |   17 +++++++
 tools/testing/selftests/ftrace/.gitignore          |    1 
 tools/testing/selftests/ftrace/ftracetest          |   12 ++++-
 .../ftrace/test.d/ftrace/func-filter-glob.tc       |   49 ++++++++++++++++++++
 tools/testing/selftests/ftrace/test.d/functions    |   28 +++++++++++
 .../ftrace/test.d/kprobe/kprobe_args_type.tc       |   37 +++++++++++++++
 .../ftrace/test.d/trigger/trigger-hist-mod.tc      |    2 -
 .../ftrace/test.d/trigger/trigger-snapshot.tc      |    5 ++
 14 files changed, 162 insertions(+), 17 deletions(-)
 create mode 100644 tools/testing/selftests/ftrace/.gitignore
 create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc
 create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc

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

[toc] | [next] | [standalone]


#1523279 — [PATCH -tip v3 9/9] selftests: ftrace: Add a testcase for types of kprobe event

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-11-16 09:20 +0100
Subject[PATCH -tip v3 9/9] selftests: ftrace: Add a testcase for types of kprobe event
Message-ID<sE3BM-jF-11@gated-at.bofh.it>
In reply to#1523278
Add a testcase for types of kprobe event. This checks
kprobe event can accept and correctly expressed the
arguments typed as s32, u32, x32 and bitfield.

Here is the test result.
  -----
  # ./ftracetest test.d/kprobe/kprobe_args_type.tc
  === Ftrace unit tests ===
  [1] Kprobes event arguments with types	[PASS]

  # of passed:  1
  # of failed:  0
  # of unresolved:  0
  # of untested:  0
  # of unsupported:  0
  # of xfailed:  0
  # of undefined(test bug):  0
  -----

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 .../ftrace/test.d/kprobe/kprobe_args_type.tc       |   37 ++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc

diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
new file mode 100644
index 0000000..0a78705
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
@@ -0,0 +1,37 @@
+#!/bin/sh
+# description: Kprobes event arguments with types
+
+[ -f kprobe_events ] || exit_unsupported # this is configurable
+
+grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue
+
+echo 0 > events/enable
+echo > kprobe_events
+enable_tracing
+
+echo 'p:testprobe _do_fork $stack0:s32 $stack0:u32 $stack0:x32 $stack0:b8@4/32' > kprobe_events
+grep testprobe kprobe_events
+test -d events/kprobes/testprobe
+
+echo 1 > events/kprobes/testprobe/enable
+( echo "forked")
+echo 0 > events/kprobes/testprobe/enable
+ARGS=`tail -n 1 trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'`
+
+check_types() {
+  X1=`printf "%x" $1 | tail -c 8`
+  X2=`printf "%x" $2`
+  X3=`printf "%x" $3`
+  test $X1 = $X2
+  test $X2 = $X3
+  test 0x$X3 = $3
+
+  B4=`printf "%x" $4`
+  B3=`echo -n $X3 | tail -c 3 | head -c 2`
+  test $B3 = $B4
+}
+check_types $ARGS
+
+echo "-:testprobe" >> kprobe_events
+clear_trace
+test -d events/kprobes/testprobe && exit 1 || exit 0

[toc] | [prev] | [next] | [standalone]


#1523282 — [PATCH -tip v3 4/9] selftests: ftrace: Check whether snapshot trigger is supported correctly

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-11-16 09:20 +0100
Subject[PATCH -tip v3 4/9] selftests: ftrace: Check whether snapshot trigger is supported correctly
Message-ID<sE3BM-jF-17@gated-at.bofh.it>
In reply to#1523278
If "snapshot" special file doesn't exist, that kernel does
not support snapshot and snapshot trigger too. In that case
snapshot trigger test results to unsupported instead of fail.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 .../ftrace/test.d/trigger/trigger-snapshot.tc      |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc
index f84b80d..ed94f0c 100644
--- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc
+++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-snapshot.tc
@@ -23,6 +23,11 @@ if [ ! -f events/sched/sched_process_fork/trigger ]; then
     exit_unsupported
 fi
 
+if [ ! -f snapshot ]; then
+    echo "snapshot is not supported"
+    exit_unsupported
+fi
+
 reset_tracer
 do_reset
 

[toc] | [prev] | [next] | [standalone]


#1523284 — [PATCH -tip v3 2/9] selftests: ftrace: Initialize ftrace before each test

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-11-16 09:20 +0100
Subject[PATCH -tip v3 2/9] selftests: ftrace: Initialize ftrace before each test
Message-ID<sE3BM-jF-19@gated-at.bofh.it>
In reply to#1523278
Reset ftrace to initial state before running each test.
This fixes some test cases to enable tracing before starting
trace test. This can avoid false-positive failure when
previous testcase fails while disabling tracing.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Suggested-by: Steven Rostedt <rostedt@goodmis.org>

---
 Changes in v3:
  - Fix to avoid initializing error by checking all optional features
---
 tools/testing/selftests/ftrace/ftracetest       |    2 +-
 tools/testing/selftests/ftrace/test.d/functions |   28 +++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index 4c6a0bf..a03d366 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -228,7 +228,7 @@ trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL
 
 __run_test() { # testfile
   # setup PID and PPID, $$ is not updated.
-  (cd $TRACING_DIR; read PID _ < /proc/self/stat ; set -e; set -x; . $1)
+  (cd $TRACING_DIR; read PID _ < /proc/self/stat; set -e; set -x; initialize_ftrace; . $1)
   [ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID
 }
 
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
index c37262f..91de1a8 100644
--- a/tools/testing/selftests/ftrace/test.d/functions
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -23,3 +23,31 @@ reset_trigger() { # reset all current setting triggers
     done
 }
 
+reset_events_filter() { # reset all current setting filters
+    grep -v ^none events/*/*/filter |
+    while read line; do
+	echo 0 > `echo $line | cut -f1 -d:`
+    done
+}
+
+disable_events() {
+    echo 0 > events/enable
+}
+
+initialize_ftrace() { # Reset ftrace to initial-state
+# As the initial state, ftrace will be set to nop tracer,
+# no events, no triggers, no filters, no function filters,
+# no probes, and tracing on.
+    disable_tracing
+    reset_tracer
+    reset_trigger
+    reset_events_filter
+    disable_events
+    echo > set_event_pid	# event tracer is always on
+    [ -f set_ftrace_filter ] && echo | tee set_ftrace_*
+    [ -f set_graph_function ] && echo | tee set_graph_*
+    [ -f stack_trace_filter ] && echo > stack_trace_filter
+    [ -f kprobe_events ] && echo > kprobe_events
+    [ -f uprobe_events ] && echo > uprobe_events
+    enable_tracing
+}

[toc] | [prev] | [next] | [standalone]


#1523285 — [PATCH -tip v3 5/9] selftests: ftrace: Fix trigger-mod to run without syscall trace

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-11-16 09:20 +0100
Subject[PATCH -tip v3 5/9] selftests: ftrace: Fix trigger-mod to run without syscall trace
Message-ID<sE3BM-jF-25@gated-at.bofh.it>
In reply to#1523278
Since histogram trigger id.syscall depends on CONFIG_FTRACE_SYSCALLS,
a testcase in trigger-modifier test fails if that config is disabled.

Fix this bug by using flexible pattern to check the histogram output.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 .../ftrace/test.d/trigger/trigger-hist-mod.tc      |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc
index 0bf5085..400e98b 100644
--- a/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc
+++ b/tools/testing/selftests/ftrace/test.d/trigger/trigger-hist-mod.tc
@@ -56,7 +56,7 @@ echo "Test histogram with syscall modifier"
 
 echo 'hist:keys=id.syscall' > events/raw_syscalls/sys_exit/trigger
 for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
-grep "id: sys_" events/raw_syscalls/sys_exit/hist > /dev/null || \
+grep "id: \(unknown_\|sys_\)" events/raw_syscalls/sys_exit/hist > /dev/null || \
     fail "syscall modifier on raw_syscalls/sys_exit did not work"
 
 

[toc] | [prev] | [next] | [standalone]


#1523286 — [PATCH -tip v3 8/9] selftests: ftrace: Add a testcase for function filter glob match

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-11-16 09:20 +0100
Subject[PATCH -tip v3 8/9] selftests: ftrace: Add a testcase for function filter glob match
Message-ID<sE3BM-jF-21@gated-at.bofh.it>
In reply to#1523278
Add function filter glob matching test case.
This checks whether the kernel supports glob matching
(front match, end match, middle match, side match,
character class and '?').

Here is the test result.
  -----
  ./ftracetest test.d/ftrace/func-filter-glob.tc
  === Ftrace unit tests ===
  [1] ftrace - function glob filters	[PASS]

  # of passed:  1
  # of failed:  0
  # of unresolved:  0
  # of untested:  0
  # of unsupported:  0
  # of xfailed:  0
  # of undefined(test bug):  0
  -----

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 .../ftrace/test.d/ftrace/func-filter-glob.tc       |   49 ++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc

diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc
new file mode 100644
index 0000000..9dcd0ca
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc
@@ -0,0 +1,49 @@
+#!/bin/sh
+# description: ftrace - function glob filters
+
+# Make sure that function glob matching filter works.
+
+if ! grep -q function available_tracers; then
+    echo "no function tracer configured"
+    exit_unsupported
+fi
+
+disable_tracing
+clear_trace
+
+# filter by ?, schedule is always good
+if ! echo "sch?dule" > set_ftrace_filter; then
+    # test for powerpc 64
+    if ! echo ".sch?dule" > set_ftrace_filter; then
+	fail "can not enable schedule filter"
+    fi
+    cat set_ftrace_filter | grep '^.schedule$'
+else
+    cat set_ftrace_filter | grep '^schedule$'
+fi
+
+ftrace_filter_check() { # glob grep
+  echo "$1" > set_ftrace_filter
+  cut -f1 -d" " set_ftrace_filter > $TMPDIR/actual
+  cut -f1 -d" " available_filter_functions | grep "$2" > $TMPDIR/expected
+  DIFF=`diff $TMPDIR/actual $TMPDIR/expected`
+  test -z "$DIFF"
+}
+
+# filter by *, front match
+ftrace_filter_check '*schedule' '^.*schedule$'
+
+# filter by *, middle match
+ftrace_filter_check '*schedule*' '^.*schedule.*$'
+
+# filter by *, end match
+ftrace_filter_check 'schedule*' '^schedule.*$'
+
+# filter by *, both side match
+ftrace_filter_check 'sch*ule' '^sch.*ule$'
+
+# filter by char class.
+ftrace_filter_check '[Ss]y[Ss]_*' '^[Ss]y[Ss]_.*$'
+
+echo > set_ftrace_filter
+enable_tracing

[toc] | [prev] | [next] | [standalone]


#1523287 — [PATCH -tip v3 7/9] selftests: ftrace: Introduce TMPDIR for temporary files

FromMasami Hiramatsu <mhiramat@kernel.org>
Date2016-11-16 09:20 +0100
Subject[PATCH -tip v3 7/9] selftests: ftrace: Introduce TMPDIR for temporary files
Message-ID<sE3BM-jF-29@gated-at.bofh.it>
In reply to#1523278
Introduce TMPDIR variable which is removed after each test
is done, so that the test script can put their temporary
files in that.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 tools/testing/selftests/ftrace/ftracetest |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index d08235f..685376b4 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -242,6 +242,7 @@ __run_test() { # testfile
 run_test() { # testfile
   local testname=`basename $1`
   local testlog=`mktemp $LOG_DIR/${testname}-log.XXXXXX`
+  export TMPDIR=`mktemp -d /tmp/ftracetest-dir.XXXXXX`
   testcase $1
   echo "execute: "$1 > $testlog
   SIG_RESULT=0
@@ -258,6 +259,7 @@ run_test() { # testfile
     [ $BE_QUIET -eq 0 ] && catlog $testlog
     TOTAL_RESULT=1
   fi
+  rm -rf $TMPDIR
 }
 
 # load in the helper functions

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web