aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2014-09-23 17:33:36 -0400
committerSteven Rostedt <rostedt@goodmis.org>2014-11-06 08:35:52 -0500
commitc6c93242db95371d976cf9b5ff9e614c71f75a70 (patch)
treee0f44cd70676ac8243e1a945016b68bf0195b782
parentee3988c77e37896b0576ba01a793698add13d6f5 (diff)
ftracetest: Add a couple of ftrace test cases
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>
-rw-r--r--tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc89
-rw-r--r--tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc52
-rw-r--r--tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc80
3 files changed, 221 insertions, 0 deletions
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 @@
1#!/bin/sh
2# description: ftrace - function graph filters with stack tracer
3
4# Make sure that function graph filtering works, and is not
5# affected by other tracers enabled (like stack tracer)
6
7if ! grep -q function_graph available_tracers; then
8 echo "no function graph tracer configured"
9 exit_unsupported
10fi
11
12if [ ! -f set_ftrace_filter ]; then
13 echo "set_ftrace_filter not found? Is dynamic ftrace not set?"
14 exit_unsupported
15fi
16
17do_reset() {
18 reset_tracer
19 echo 0 > /proc/sys/kernel/stack_tracer_enabled
20 enable_tracing
21 clear_trace
22 echo > set_ftrace_filter
23}
24
25fail() { # msg
26 do_reset
27 echo $1
28 exit -1
29}
30
31disable_tracing
32clear_trace;
33
34# filter something, schedule is always good
35if ! echo "schedule" > set_ftrace_filter; then
36 # test for powerpc 64
37 if ! echo ".schedule" > set_ftrace_filter; then
38 fail "can not enable schedule filter"
39 fi
40fi
41
42echo function_graph > current_tracer
43
44if [ ! -f stack_trace ]; then
45 echo "Stack tracer not configured"
46 do_reset
47 exit_unsupported;
48fi
49
50echo "Now testing with stack tracer"
51
52echo 1 > /proc/sys/kernel/stack_tracer_enabled
53
54disable_tracing
55clear_trace
56enable_tracing
57sleep 1
58
59count=`cat trace | grep '()' | grep -v schedule | wc -l`
60
61if [ $count -ne 0 ]; then
62 fail "Graph filtering not working with stack tracer?"
63fi
64
65# Make sure we did find something
66count=`cat trace | grep 'schedule()' | wc -l`
67if [ $count -eq 0 ]; then
68 fail "No schedule traces found?"
69fi
70
71echo 0 > /proc/sys/kernel/stack_tracer_enabled
72clear_trace
73sleep 1
74
75
76count=`cat trace | grep '()' | grep -v schedule | wc -l`
77
78if [ $count -ne 0 ]; then
79 fail "Graph filtering not working after stack tracer disabled?"
80fi
81
82count=`cat trace | grep 'schedule()' | wc -l`
83if [ $count -eq 0 ]; then
84 fail "No schedule traces found?"
85fi
86
87do_reset
88
89exit 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 @@
1#!/bin/sh
2# description: ftrace - function graph filters
3
4# Make sure that function graph filtering works
5
6if ! grep -q function_graph available_tracers; then
7 echo "no function graph tracer configured"
8 exit_unsupported
9fi
10
11do_reset() {
12 reset_tracer
13 enable_tracing
14 clear_trace
15}
16
17fail() { # msg
18 do_reset
19 echo $1
20 exit -1
21}
22
23disable_tracing
24clear_trace
25
26# filter something, schedule is always good
27if ! echo "schedule" > set_ftrace_filter; then
28 # test for powerpc 64
29 if ! echo ".schedule" > set_ftrace_filter; then
30 fail "can not enable schedule filter"
31 fi
32fi
33
34echo function_graph > current_tracer
35enable_tracing
36sleep 1
37# search for functions (has "()" on the line), and make sure
38# that only the schedule function was found
39count=`cat trace | grep '()' | grep -v schedule | wc -l`
40if [ $count -ne 0 ]; then
41 fail "Graph filtering not working by itself?"
42fi
43
44# Make sure we did find something
45count=`cat trace | grep 'schedule()' | wc -l`
46if [ $count -eq 0 ]; then
47 fail "No schedule traces found?"
48fi
49
50do_reset
51
52exit 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 @@
1#!/bin/sh
2# description: ftrace - function profiler with function tracing
3
4# There was a bug after a rewrite of the ftrace infrastructure that
5# caused the function_profiler not to be able to run with the function
6# tracer, because the function_profiler used the function_graph tracer
7# and it was assumed the two could not run simultaneously.
8#
9# There was another related bug where the solution to the first bug
10# broke the way filtering of the function tracer worked.
11#
12# This test triggers those bugs on those kernels.
13#
14# We need function_graph and profiling to to run this test
15if ! grep -q function_graph available_tracers; then
16 echo "no function graph tracer configured"
17 exit_unsupported;
18fi
19
20if [ ! -f set_ftrace_filter ]; then
21 echo "set_ftrace_filter not found? Is dynamic ftrace not set?"
22 exit_unsupported
23fi
24
25if [ ! -f function_profile_enabled ]; then
26 echo "function_profile_enabled not found, function profiling enabled?"
27 exit_unsupported
28fi
29
30fail() { # mesg
31 reset_tracer
32 echo > set_ftrace_filter
33 echo $1
34 exit -1
35}
36
37echo "Testing function tracer with profiler:"
38echo "enable function tracer"
39echo function > current_tracer
40echo "enable profiler"
41echo 1 > function_profile_enabled
42
43sleep 1
44
45echo "Now filter on just schedule"
46echo '*schedule' > set_ftrace_filter
47clear_trace
48
49echo "Now disable function profiler"
50echo 0 > function_profile_enabled
51
52sleep 1
53
54# make sure only schedule functions exist
55
56echo "testing if only schedule is being traced"
57if grep -v -e '^#' -e 'schedule' trace; then
58 fail "more than schedule was found"
59fi
60
61echo "Make sure schedule was traced"
62if ! grep -e 'schedule' trace > /dev/null; then
63 cat trace
64 fail "can not find schedule in trace"
65fi
66
67echo > set_ftrace_filter
68clear_trace
69
70sleep 1
71
72echo "make sure something other than scheduler is being traced"
73if ! grep -v -e '^#' -e 'schedule' trace > /dev/null; then
74 cat trace
75 fail "no other functions besides schedule was found"
76fi
77
78reset_tracer
79
80exit 0