public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] ftracetest: Updates for 3.19
@ 2014-11-11 21:41 Steven Rostedt
  2014-11-11 21:41 ` [PATCH 1/6] ftracetest: Sort testcases Steven Rostedt
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Steven Rostedt @ 2014-11-11 21:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Masami Hiramatsu, Andrew Morton

  git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
for-next

Head SHA1: 815b18ea66d6fb67a3534edf68dfa23bdcec0485


Heiko Carstens (1):
      ftracetest: Sort testcases

Namhyung Kim (3):
      ftracetest: Use logfile name supported by busybox's mktemp
      ftracetest: Clear trace buffer after running kprobe testcases
      ftracetest: Add basic event tracing test cases

Steven Rostedt (Red Hat) (2):
      ftracetest: Add functions file that holds helper functions
      ftracetest: Add a couple of ftrace test cases

----
 tools/testing/selftests/ftrace/ftracetest          |  7 +-
 .../selftests/ftrace/test.d/00basic/basic4.tc      |  5 ++
 .../selftests/ftrace/test.d/event/event-enable.tc  | 53 +++++++++++++
 .../ftrace/test.d/event/subsystem-enable.tc        | 53 +++++++++++++
 .../ftrace/test.d/event/toplevel-enable.tc         | 47 ++++++++++++
 .../ftrace/test.d/ftrace/fgraph-filter-stack.tc    | 89 ++++++++++++++++++++++
 .../ftrace/test.d/ftrace/fgraph-filter.tc          | 52 +++++++++++++
 .../ftrace/test.d/ftrace/func_profiler.tc          | 80 +++++++++++++++++++
 tools/testing/selftests/ftrace/test.d/functions    | 16 ++++
 .../ftrace/test.d/kprobe/add_and_remove.tc         |  1 +
 .../selftests/ftrace/test.d/kprobe/busy_check.tc   |  1 +
 .../selftests/ftrace/test.d/kprobe/kprobe_args.tc  |  1 +
 .../ftrace/test.d/kprobe/kretprobe_args.tc         |  1 +
 13 files changed, 404 insertions(+), 2 deletions(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/6] ftracetest: Sort testcases
  2014-11-11 21:41 [PATCH 0/6] ftracetest: Updates for 3.19 Steven Rostedt
@ 2014-11-11 21:41 ` Steven Rostedt
  2014-11-11 21:41 ` [PATCH 2/6] ftracetest: Add functions file that holds helper functions Steven Rostedt
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2014-11-11 21:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Masami Hiramatsu, Andrew Morton, Heiko Carstens

[-- Attachment #1: 0001-ftracetest-Sort-testcases.patch --]
[-- Type: text/plain, Size: 889 bytes --]

From: Heiko Carstens <heiko.carstens@de.ibm.com>

Make sure the order of the executed testcases is always the same.

Link: http://lkml.kernel.org/p/1413802323-5297-3-git-send-email-heiko.carstens@de.ibm.com

Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 tools/testing/selftests/ftrace/ftracetest | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index 515247601df4..f15c0da07aca 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -37,7 +37,7 @@ abspath() {
 }
 
 find_testcases() { #directory
-  echo `find $1 -name \*.tc`
+  echo `find $1 -name \*.tc | sort`
 }
 
 parse_opts() { # opts
-- 
2.1.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/6] ftracetest: Add functions file that holds helper functions
  2014-11-11 21:41 [PATCH 0/6] ftracetest: Updates for 3.19 Steven Rostedt
  2014-11-11 21:41 ` [PATCH 1/6] ftracetest: Sort testcases Steven Rostedt
@ 2014-11-11 21:41 ` Steven Rostedt
  2014-11-11 21:41 ` [PATCH 3/6] ftracetest: Add a couple of ftrace test cases Steven Rostedt
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2014-11-11 21:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Masami Hiramatsu, Andrew Morton, Namhyung Kim

[-- Attachment #1: 0002-ftracetest-Add-functions-file-that-holds-helper-func.patch --]
[-- Type: text/plain, Size: 2094 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

Created the file tools/testing/ftrace/test.d/functions that will
hold helper functions.

Current helper functions include:

 Add clear_trace() helper to reset the trace file

   Used as a descriptive name to show that "echo > trace" is clearing
   the trace file.

 Add disable/enable_tracing() helper calls

   Add calls that disable and enable tracing respectively by echoing
   0 or 1 into tracing_on.

 Add helper reset_tracer() function

    Add a helper function reset_tracer() that will clear the current_tracer
    (echo nop > current_tracer).

Link: http://lkml.kernel.org/r/20141103212737.696365174@goodmis.org
Link: http://lkml.kernel.org/r/20141104153028.465517119@goodmis.org

Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 tools/testing/selftests/ftrace/ftracetest       |  3 +++
 tools/testing/selftests/ftrace/test.d/functions | 16 ++++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 tools/testing/selftests/ftrace/test.d/functions

diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index f15c0da07aca..c6381a9faf83 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -235,6 +235,9 @@ run_test() { # testfile
   fi
 }
 
+# load in the helper functions
+. $TEST_DIR/functions
+
 # Main loop
 for t in $TEST_CASES; do
   run_test $t
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
new file mode 100644
index 000000000000..5d8cd06d920f
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -0,0 +1,16 @@
+
+clear_trace() { # reset trace output
+    echo > trace
+}
+
+disable_tracing() { # stop trace recording
+    echo 0 > tracing_on
+}
+
+enable_tracing() { # start trace recording
+    echo 1 > tracing_on
+}
+
+reset_tracer() { # reset the current tracer
+    echo nop > current_tracer
+}
-- 
2.1.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/6] ftracetest: Add a couple of ftrace test cases
  2014-11-11 21:41 [PATCH 0/6] ftracetest: Updates for 3.19 Steven Rostedt
  2014-11-11 21:41 ` [PATCH 1/6] ftracetest: Sort testcases Steven Rostedt
  2014-11-11 21:41 ` [PATCH 2/6] ftracetest: Add functions file that holds helper functions Steven Rostedt
@ 2014-11-11 21:41 ` Steven Rostedt
  2014-11-11 21:41 ` [PATCH 4/6] ftracetest: Use logfile name supported by busyboxs mktemp Steven Rostedt
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2014-11-11 21:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Masami Hiramatsu, Andrew Morton, Namhyung Kim

[-- Attachment #1: 0003-ftracetest-Add-a-couple-of-ftrace-test-cases.patch --]
[-- Type: text/plain, Size: 7376 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

Added three test cases to get the feel of adding tests to ftracetest.
The three cases are:

  function profiling test, to make sure function profiling still works
   with function tracing (was a regression)

  function graph filter test to make sure that function graph filtering works.

  function graph filter with stack tracing test to make sure that the function
   graph filter does filter and also continues to filter when another function tracer
   is running (like the stack tracer)

Link: http://lkml.kernel.org/r/20141103212737.696365174@goodmis.org
Link: http://lkml.kernel.org/r/20141104153028.602754370@goodmis.org

Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 .../ftrace/test.d/ftrace/fgraph-filter-stack.tc    | 89 ++++++++++++++++++++++
 .../ftrace/test.d/ftrace/fgraph-filter.tc          | 52 +++++++++++++
 .../ftrace/test.d/ftrace/func_profiler.tc          | 80 +++++++++++++++++++
 3 files changed, 221 insertions(+)
 create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc
 create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc
 create mode 100644 tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc

diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc
new file mode 100644
index 000000000000..c15e018e0220
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc
@@ -0,0 +1,89 @@
+#!/bin/sh
+# description: ftrace - function graph filters with stack tracer
+
+# Make sure that function graph filtering works, and is not
+# affected by other tracers enabled (like stack tracer)
+
+if ! grep -q function_graph available_tracers; then
+    echo "no function graph tracer configured"
+    exit_unsupported
+fi
+
+if [ ! -f set_ftrace_filter ]; then
+    echo "set_ftrace_filter not found? Is dynamic ftrace not set?"
+    exit_unsupported
+fi
+
+do_reset() {
+    reset_tracer
+    echo 0 > /proc/sys/kernel/stack_tracer_enabled
+    enable_tracing
+    clear_trace
+    echo > set_ftrace_filter
+}
+
+fail() { # msg
+    do_reset
+    echo $1
+    exit -1
+}
+
+disable_tracing
+clear_trace;
+
+# filter something, schedule is always good
+if ! echo "schedule" > set_ftrace_filter; then
+    # test for powerpc 64
+    if ! echo ".schedule" > set_ftrace_filter; then
+	fail "can not enable schedule filter"
+    fi
+fi
+
+echo function_graph > current_tracer
+
+if [ ! -f stack_trace ]; then
+    echo "Stack tracer not configured"
+    do_reset
+    exit_unsupported;
+fi
+
+echo "Now testing with stack tracer"
+
+echo 1 > /proc/sys/kernel/stack_tracer_enabled
+
+disable_tracing
+clear_trace
+enable_tracing
+sleep 1
+
+count=`cat trace | grep '()' | grep -v schedule | wc -l`
+
+if [ $count -ne 0 ]; then
+    fail "Graph filtering not working with stack tracer?"
+fi
+
+# Make sure we did find something
+count=`cat trace | grep 'schedule()' | wc -l` 
+if [ $count -eq 0 ]; then
+    fail "No schedule traces found?"
+fi
+
+echo 0 > /proc/sys/kernel/stack_tracer_enabled
+clear_trace
+sleep 1
+
+
+count=`cat trace | grep '()' | grep -v schedule | wc -l`
+
+if [ $count -ne 0 ]; then
+    fail "Graph filtering not working after stack tracer disabled?"
+fi
+
+count=`cat trace | grep 'schedule()' | wc -l` 
+if [ $count -eq 0 ]; then
+    fail "No schedule traces found?"
+fi
+
+do_reset
+
+exit 0
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc
new file mode 100644
index 000000000000..6af5f6360b18
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc
@@ -0,0 +1,52 @@
+#!/bin/sh
+# description: ftrace - function graph filters
+
+# Make sure that function graph filtering works
+
+if ! grep -q function_graph available_tracers; then
+    echo "no function graph tracer configured"
+    exit_unsupported
+fi
+
+do_reset() {
+    reset_tracer
+    enable_tracing
+    clear_trace
+}
+
+fail() { # msg
+    do_reset
+    echo $1
+    exit -1
+}
+
+disable_tracing
+clear_trace
+
+# filter something, schedule is always good
+if ! echo "schedule" > set_ftrace_filter; then
+    # test for powerpc 64
+    if ! echo ".schedule" > set_ftrace_filter; then
+	fail "can not enable schedule filter"
+    fi
+fi
+
+echo function_graph > current_tracer
+enable_tracing
+sleep 1
+# search for functions (has "()" on the line), and make sure
+# that only the schedule function was found
+count=`cat trace | grep '()' | grep -v schedule | wc -l`
+if [ $count -ne 0 ]; then
+    fail "Graph filtering not working by itself?"
+fi
+
+# Make sure we did find something
+count=`cat trace | grep 'schedule()' | wc -l` 
+if [ $count -eq 0 ]; then
+    fail "No schedule traces found?"
+fi
+
+do_reset
+
+exit 0
diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc
new file mode 100644
index 000000000000..2e719cb1fc4d
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc
@@ -0,0 +1,80 @@
+#!/bin/sh
+# description: ftrace - function profiler with function tracing
+
+# There was a bug after a rewrite of the ftrace infrastructure that
+# caused the function_profiler not to be able to run with the function
+# tracer, because the function_profiler used the function_graph tracer
+# and it was assumed the two could not run simultaneously.
+#
+# There was another related bug where the solution to the first bug
+# broke the way filtering of the function tracer worked.
+#
+# This test triggers those bugs on those kernels.
+#
+# We need function_graph and profiling to to run this test
+if ! grep -q function_graph available_tracers; then
+    echo "no function graph tracer configured"
+    exit_unsupported;
+fi
+
+if [ ! -f set_ftrace_filter ]; then
+    echo "set_ftrace_filter not found? Is dynamic ftrace not set?"
+    exit_unsupported
+fi
+
+if [ ! -f function_profile_enabled ]; then
+    echo "function_profile_enabled not found, function profiling enabled?"
+    exit_unsupported
+fi
+
+fail() { # mesg
+    reset_tracer
+    echo > set_ftrace_filter
+    echo $1
+    exit -1
+}
+
+echo "Testing function tracer with profiler:"
+echo "enable function tracer"
+echo function > current_tracer
+echo "enable profiler"
+echo 1 > function_profile_enabled
+
+sleep 1
+
+echo "Now filter on just schedule"
+echo '*schedule' > set_ftrace_filter
+clear_trace
+
+echo "Now disable function profiler"
+echo 0 > function_profile_enabled
+
+sleep 1
+
+# make sure only schedule functions exist
+
+echo "testing if only schedule is being traced"
+if grep -v -e '^#' -e 'schedule' trace; then
+	fail "more than schedule was found"
+fi
+
+echo "Make sure schedule was traced"
+if ! grep -e 'schedule' trace > /dev/null; then
+	cat trace
+	fail "can not find schedule in trace"
+fi
+
+echo > set_ftrace_filter
+clear_trace
+
+sleep 1
+
+echo "make sure something other than scheduler is being traced"
+if ! grep -v -e '^#' -e 'schedule' trace > /dev/null; then
+	cat trace
+	fail "no other functions besides schedule was found"
+fi
+
+reset_tracer
+
+exit 0
-- 
2.1.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/6] ftracetest: Use logfile name supported by busyboxs mktemp
  2014-11-11 21:41 [PATCH 0/6] ftracetest: Updates for 3.19 Steven Rostedt
                   ` (2 preceding siblings ...)
  2014-11-11 21:41 ` [PATCH 3/6] ftracetest: Add a couple of ftrace test cases Steven Rostedt
@ 2014-11-11 21:41 ` Steven Rostedt
  2014-11-11 21:41 ` [PATCH 5/6] ftracetest: Clear trace buffer after running kprobe testcases Steven Rostedt
  2014-11-11 21:41 ` [PATCH 6/6] ftracetest: Add basic event tracing test cases Steven Rostedt
  5 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2014-11-11 21:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Masami Hiramatsu, Andrew Morton, Namhyung Kim

[-- Attachment #1: 0004-ftracetest-Use-logfile-name-supported-by-busybox-s-m.patch --]
[-- Type: text/plain, Size: 2129 bytes --]

From: Namhyung Kim <namhyung@kernel.org>

When I run the ftracetest in a busybox docker container, I saw
following error.  Make the logfile template to comply with busybox's
mktemp.  It also keep the logfiles under the logs directory.

  # /linux/tools/testing/selftests/ftrace/ftracetest
  === Ftrace unit tests ===
  mktemp: unrecognized option `--tmpdir=/linux/tools/testing/selftests/ftrace/logs/20141106-003624/'
  BusyBox v1.22.1 (2014-05-22 23:22:11 UTC) multi-call binary.

  Usage: mktemp [-dt] [-p DIR] [TEMPLATE]

  Create a temporary file with name based on TEMPLATE and print its name.
  TEMPLATE must end with XXXXXX (e.g. [/dir/]nameXXXXXX).
  Without TEMPLATE, -t tmp.XXXXXX is assumed.

  	-d	  Make directory, not file
  	-q	  Fail silently on errors
  	-t	  Prepend base directory name to TEMPLATE
  	-p DIR	  Use DIR as a base directory (implies -t)
  	-u Do not create anything; print a name

  Base directory is: -p DIR, else $TMPDIR, else /tmp

  [1] Basic trace file check/linux/tools/testing/selftests/ftrace/ftracetest: line 244: can't create : nonexistent directory
  /linux/tools/testing/selftests/ftrace/ftracetest: line 244: can't create : nonexistent directory
						  [FAIL]

Link: http://lkml.kernel.org/r/1415239470-28705-1-git-send-email-namhyung@kernel.org

Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 tools/testing/selftests/ftrace/ftracetest | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest
index c6381a9faf83..535b98b79c29 100755
--- a/tools/testing/selftests/ftrace/ftracetest
+++ b/tools/testing/selftests/ftrace/ftracetest
@@ -218,7 +218,7 @@ trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL
 # Run one test case
 run_test() { # testfile
   local testname=`basename $1`
-  local testlog=`mktemp --tmpdir=$LOG_DIR ${testname}-XXXXXX.log`
+  local testlog=`mktemp $LOG_DIR/${testname}-log.XXXXXX`
   testcase $1
   echo "execute: "$1 > $testlog
   SIG_RESULT=0
-- 
2.1.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/6] ftracetest: Clear trace buffer after running kprobe testcases
  2014-11-11 21:41 [PATCH 0/6] ftracetest: Updates for 3.19 Steven Rostedt
                   ` (3 preceding siblings ...)
  2014-11-11 21:41 ` [PATCH 4/6] ftracetest: Use logfile name supported by busyboxs mktemp Steven Rostedt
@ 2014-11-11 21:41 ` Steven Rostedt
  2014-11-11 21:41 ` [PATCH 6/6] ftracetest: Add basic event tracing test cases Steven Rostedt
  5 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2014-11-11 21:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Masami Hiramatsu, Andrew Morton, Namhyung Kim

[-- Attachment #1: 0005-ftracetest-Clear-trace-buffer-after-running-kprobe-t.patch --]
[-- Type: text/plain, Size: 3458 bytes --]

From: Namhyung Kim <namhyung@kernel.org>

The kprobe testcases create, use and delete dynamic events during the
test but didn't clear the trace buffer so it'll leave the result after
it finishes.

  # ./ftracetest
  ...

  # cat trace
  # tracer: nop
  #
  # entries-in-buffer/entries-written: 2/2   #P:12
  #
  #                              _-----=> irqs-off
  #                             / _----=> need-resched
  #                            | / _---=> hardirq/softirq
  #                            || / _--=> preempt-depth
  #                            ||| /     delay
  #           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
  #              | |       |   ||||       |         |
        ftracetest-26474 [009] d..1 79417.143782: Unknown type 1099
        ftracetest-26498 [009] d..1 79417.208034: Unknown type 1101

Link: http://lkml.kernel.org/r/1415239470-28705-2-git-send-email-namhyung@kernel.org

Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc | 1 +
 tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc     | 1 +
 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc    | 1 +
 tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc | 1 +
 4 files changed, 4 insertions(+)

diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc b/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc
index 1b8b665ab2b3..a5a426211129 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/add_and_remove.tc
@@ -9,3 +9,4 @@ echo p:myevent do_fork > kprobe_events
 grep myevent kprobe_events
 test -d events/kprobes/myevent
 echo > kprobe_events
+clear_trace
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc b/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc
index b55c84003587..d8c7bb6581fe 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/busy_check.tc
@@ -11,3 +11,4 @@ echo 1 > events/kprobes/myevent/enable
 echo > kprobe_events && exit 1 # this must fail
 echo 0 > events/kprobes/myevent/enable
 echo > kprobe_events # this must succeed
+clear_trace
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc
index a603d3f8db7b..c45ee2761354 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args.tc
@@ -12,5 +12,6 @@ echo 1 > events/kprobes/testprobe/enable
 ( echo "forked")
 echo 0 > events/kprobes/testprobe/enable
 echo "-:testprobe" >> kprobe_events
+clear_trace
 test -d events/kprobes/testprobe && exit 1 || exit 0
 
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc
index 283c29e7f7c4..31717985acc7 100644
--- a/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc
+++ b/tools/testing/selftests/ftrace/test.d/kprobe/kretprobe_args.tc
@@ -12,4 +12,5 @@ echo 1 > events/kprobes/testprobe2/enable
 ( echo "forked")
 echo 0 > events/kprobes/testprobe2/enable
 echo '-:testprobe2' >> kprobe_events
+clear_trace
 test -d events/kprobes/testprobe2 && exit 1 || exit 0
-- 
2.1.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 6/6] ftracetest: Add basic event tracing test cases
  2014-11-11 21:41 [PATCH 0/6] ftracetest: Updates for 3.19 Steven Rostedt
                   ` (4 preceding siblings ...)
  2014-11-11 21:41 ` [PATCH 5/6] ftracetest: Clear trace buffer after running kprobe testcases Steven Rostedt
@ 2014-11-11 21:41 ` Steven Rostedt
  5 siblings, 0 replies; 7+ messages in thread
From: Steven Rostedt @ 2014-11-11 21:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Masami Hiramatsu, Andrew Morton, Namhyung Kim

[-- Attachment #1: 0006-ftracetest-Add-basic-event-tracing-test-cases.patch --]
[-- Type: text/plain, Size: 6202 bytes --]

From: Namhyung Kim <namhyung@kernel.org>

This patch adds basic event tracing tests like enable/disable with
top-level, subsystem-level and individual event files.

  # ./ftracetest
  === Ftrace unit tests ===
  [1] Basic trace file check	[PASS]
  [2] Basic trace clock test	[PASS]
  [3] Basic event tracing check	[PASS]
  [4] Basic test for tracers	[PASS]
  [5] event tracing - enable/disable with top level files	[PASS]
  [6] event tracing - enable/disable with subsystem level files	[PASS]
  [7] event tracing - enable/disable with event level files	[PASS]
  [8] ftrace - function graph filters	[PASS]
  [9] ftrace - function profiler with function tracing	[PASS]
  [10] ftrace - function graph filters with stack tracer	[PASS]
  [11] Kretprobe dynamic event with arguments	[PASS]
  [12] Kprobe dynamic event - busy event check	[PASS]
  [13] Kprobe dynamic event with arguments	[PASS]
  [14] Kprobe dynamic event - adding and removing	[PASS]

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

Link: http://lkml.kernel.org/r/1415239470-28705-3-git-send-email-namhyung@kernel.org

Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 .../selftests/ftrace/test.d/00basic/basic4.tc      |  5 ++
 .../selftests/ftrace/test.d/event/event-enable.tc  | 53 ++++++++++++++++++++++
 .../ftrace/test.d/event/subsystem-enable.tc        | 53 ++++++++++++++++++++++
 .../ftrace/test.d/event/toplevel-enable.tc         | 47 +++++++++++++++++++
 4 files changed, 158 insertions(+)
 create mode 100644 tools/testing/selftests/ftrace/test.d/00basic/basic4.tc
 create mode 100644 tools/testing/selftests/ftrace/test.d/event/event-enable.tc
 create mode 100644 tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
 create mode 100644 tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc

diff --git a/tools/testing/selftests/ftrace/test.d/00basic/basic4.tc b/tools/testing/selftests/ftrace/test.d/00basic/basic4.tc
new file mode 100644
index 000000000000..fd9c49a13612
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/00basic/basic4.tc
@@ -0,0 +1,5 @@
+#!/bin/sh
+# description: Basic event tracing check
+test -f available_events -a -f set_event -a -d events
+# check scheduler events are available
+grep -q sched available_events && exit 0 || exit -1
\ No newline at end of file
diff --git a/tools/testing/selftests/ftrace/test.d/event/event-enable.tc b/tools/testing/selftests/ftrace/test.d/event/event-enable.tc
new file mode 100644
index 000000000000..668616d9bb03
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/event/event-enable.tc
@@ -0,0 +1,53 @@
+#!/bin/sh
+# description: event tracing - enable/disable with event level files
+
+do_reset() {
+    echo > set_event
+    clear_trace
+}
+
+fail() { #msg
+    do_reset
+    echo $1
+    exit -1
+}
+
+if [ ! -f set_event -o ! -d events/sched ]; then
+    echo "event tracing is not supported"
+    exit_unsupported
+fi
+
+reset_tracer
+do_reset
+
+echo 'sched:sched_switch' > set_event
+usleep 1
+
+count=`cat trace | grep sched_switch | wc -l`
+if [ $count -eq 0 ]; then
+    fail "sched_switch events are not recorded"
+fi
+
+do_reset
+
+echo 1 > events/sched/sched_switch/enable
+usleep 1
+
+count=`cat trace | grep sched_switch | wc -l`
+if [ $count -eq 0 ]; then
+    fail "sched_switch events are not recorded"
+fi
+
+do_reset
+
+echo 0 > events/sched/sched_switch/enable
+usleep 1
+
+count=`cat trace | grep sched_switch | wc -l`
+if [ $count -ne 0 ]; then
+    fail "sched_switch events should not be recorded"
+fi
+
+do_reset
+
+exit 0
diff --git a/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc b/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
new file mode 100644
index 000000000000..655c415b6e7f
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/event/subsystem-enable.tc
@@ -0,0 +1,53 @@
+#!/bin/sh
+# description: event tracing - enable/disable with subsystem level files
+
+do_reset() {
+    echo > set_event
+    clear_trace
+}
+
+fail() { #msg
+    do_reset
+    echo $1
+    exit -1
+}
+
+if [ ! -f set_event -o ! -d events/sched ]; then
+    echo "event tracing is not supported"
+    exit_unsupported
+fi
+
+reset_tracer
+do_reset
+
+echo 'sched:*' > set_event
+usleep 1
+
+count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
+if [ $count -lt 3 ]; then
+    fail "at least fork, exec and exit events should be recorded"
+fi
+
+do_reset
+
+echo 1 > events/sched/enable
+usleep 1
+
+count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
+if [ $count -lt 3 ]; then
+    fail "at least fork, exec and exit events should be recorded"
+fi
+
+do_reset
+
+echo 0 > events/sched/enable
+usleep 1
+
+count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
+if [ $count -ne 0 ]; then
+    fail "any of scheduler events should not be recorded"
+fi
+
+do_reset
+
+exit 0
diff --git a/tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc b/tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc
new file mode 100644
index 000000000000..480845774007
--- /dev/null
+++ b/tools/testing/selftests/ftrace/test.d/event/toplevel-enable.tc
@@ -0,0 +1,47 @@
+#!/bin/sh
+# description: event tracing - enable/disable with top level files
+
+do_reset() {
+    echo > set_event
+    clear_trace
+}
+
+fail() { #msg
+    do_reset
+    echo $1
+    exit -1
+}
+
+if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then
+    echo "event tracing is not supported"
+    exit_unsupported
+fi
+
+reset_tracer
+do_reset
+
+echo '*:*' > set_event
+count=`cat trace | grep -v ^# | wc -l`
+if [ $count -eq 0 ]; then
+    fail "none of events are recorded"
+fi
+
+do_reset
+
+echo 1 > events/enable
+count=`cat trace | grep -v ^# | wc -l`
+if [ $count -eq 0 ]; then
+    fail "none of events are recorded"
+fi
+
+do_reset
+
+echo 0 > events/enable
+count=`cat trace | grep -v ^# | wc -l`
+if [ $count -ne 0 ]; then
+    fail "any of events should not be recorded"
+fi
+
+do_reset
+
+exit 0
-- 
2.1.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-11-11 21:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-11 21:41 [PATCH 0/6] ftracetest: Updates for 3.19 Steven Rostedt
2014-11-11 21:41 ` [PATCH 1/6] ftracetest: Sort testcases Steven Rostedt
2014-11-11 21:41 ` [PATCH 2/6] ftracetest: Add functions file that holds helper functions Steven Rostedt
2014-11-11 21:41 ` [PATCH 3/6] ftracetest: Add a couple of ftrace test cases Steven Rostedt
2014-11-11 21:41 ` [PATCH 4/6] ftracetest: Use logfile name supported by busyboxs mktemp Steven Rostedt
2014-11-11 21:41 ` [PATCH 5/6] ftracetest: Clear trace buffer after running kprobe testcases Steven Rostedt
2014-11-11 21:41 ` [PATCH 6/6] ftracetest: Add basic event tracing test cases Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox