diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-10 23:03:45 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-10 23:03:45 -0500 |
commit | c32809521de5b31699a33379183848b0c7628f28 (patch) | |
tree | 6879856f5a75059dfcb843a3449d1847be006ec2 /tools | |
parent | 1dd7dcb6eaa677b034e7ef63df8320277507ae70 (diff) | |
parent | 57cee23650d768130ff2d80aa4cd0b053feabf97 (diff) |
Merge tag 'ftracetest-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull ftrace self-test updates from Steven Rostedt:
"Updates for the ftrace self tests:
- Added kprobes on ftrace testcase
- Sort test cases
- Add file to hold helper functions
- Use logfile name supported by busybox's mktemp
- Clear trace buffer after running kprobe test
- Fix show descriptions when run on dash shell
- Add --verbose option for showing echo output"
* tag 'ftracetest-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
ftracetest: Add --verbose option for showing echo output
ftracetest: Fix to show descriptions on dash
ftracetest: Add basic event tracing test cases
ftracetest: Clear trace buffer after running kprobe testcases
ftracetest: Use logfile name supported by busybox's mktemp
ftracetest: Add a couple of ftrace test cases
ftracetest: Add functions file that holds helper functions
ftracetest: Sort testcases
ftracetest: Add kprobes on ftrace testcase
Diffstat (limited to 'tools')
14 files changed, 484 insertions, 13 deletions
diff --git a/tools/testing/selftests/ftrace/ftracetest b/tools/testing/selftests/ftrace/ftracetest index 515247601df4..da48812ab95e 100755 --- a/tools/testing/selftests/ftrace/ftracetest +++ b/tools/testing/selftests/ftrace/ftracetest | |||
@@ -13,6 +13,7 @@ echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]" | |||
13 | echo " Options:" | 13 | echo " Options:" |
14 | echo " -h|--help Show help message" | 14 | echo " -h|--help Show help message" |
15 | echo " -k|--keep Keep passed test logs" | 15 | echo " -k|--keep Keep passed test logs" |
16 | echo " -v|--verbose Show all stdout messages in testcases" | ||
16 | echo " -d|--debug Debug mode (trace all shell commands)" | 17 | echo " -d|--debug Debug mode (trace all shell commands)" |
17 | exit $1 | 18 | exit $1 |
18 | } | 19 | } |
@@ -37,7 +38,7 @@ abspath() { | |||
37 | } | 38 | } |
38 | 39 | ||
39 | find_testcases() { #directory | 40 | find_testcases() { #directory |
40 | echo `find $1 -name \*.tc` | 41 | echo `find $1 -name \*.tc | sort` |
41 | } | 42 | } |
42 | 43 | ||
43 | parse_opts() { # opts | 44 | parse_opts() { # opts |
@@ -53,6 +54,10 @@ parse_opts() { # opts | |||
53 | KEEP_LOG=1 | 54 | KEEP_LOG=1 |
54 | shift 1 | 55 | shift 1 |
55 | ;; | 56 | ;; |
57 | --verbose|-v) | ||
58 | VERBOSE=1 | ||
59 | shift 1 | ||
60 | ;; | ||
56 | --debug|-d) | 61 | --debug|-d) |
57 | DEBUG=1 | 62 | DEBUG=1 |
58 | shift 1 | 63 | shift 1 |
@@ -90,6 +95,7 @@ TEST_CASES=`find_testcases $TEST_DIR` | |||
90 | LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/ | 95 | LOG_DIR=$TOP_DIR/logs/`date +%Y%m%d-%H%M%S`/ |
91 | KEEP_LOG=0 | 96 | KEEP_LOG=0 |
92 | DEBUG=0 | 97 | DEBUG=0 |
98 | VERBOSE=0 | ||
93 | # Parse command-line options | 99 | # Parse command-line options |
94 | parse_opts $* | 100 | parse_opts $* |
95 | 101 | ||
@@ -135,15 +141,12 @@ TOTAL_RESULT=0 | |||
135 | CASENO=0 | 141 | CASENO=0 |
136 | testcase() { # testfile | 142 | testcase() { # testfile |
137 | CASENO=$((CASENO+1)) | 143 | CASENO=$((CASENO+1)) |
138 | prlog -n "[$CASENO]"`grep "^#[ \t]*description:" $1 | cut -f2 -d:` | 144 | desc=`grep "^#[ \t]*description:" $1 | cut -f2 -d:` |
145 | prlog -n "[$CASENO]$desc" | ||
139 | } | 146 | } |
140 | 147 | ||
141 | eval_result() { # retval sigval | 148 | eval_result() { # sigval |
142 | local retval=$2 | 149 | case $1 in |
143 | if [ $2 -eq 0 ]; then | ||
144 | test $1 -ne 0 && retval=$FAIL | ||
145 | fi | ||
146 | case $retval in | ||
147 | $PASS) | 150 | $PASS) |
148 | prlog " [PASS]" | 151 | prlog " [PASS]" |
149 | PASSED_CASES="$PASSED_CASES $CASENO" | 152 | PASSED_CASES="$PASSED_CASES $CASENO" |
@@ -187,6 +190,9 @@ SIG_RESULT= | |||
187 | SIG_BASE=36 # Use realtime signals | 190 | SIG_BASE=36 # Use realtime signals |
188 | SIG_PID=$$ | 191 | SIG_PID=$$ |
189 | 192 | ||
193 | SIG_FAIL=$((SIG_BASE + FAIL)) | ||
194 | trap 'SIG_RESULT=$FAIL' $SIG_FAIL | ||
195 | |||
190 | SIG_UNRESOLVED=$((SIG_BASE + UNRESOLVED)) | 196 | SIG_UNRESOLVED=$((SIG_BASE + UNRESOLVED)) |
191 | exit_unresolved () { | 197 | exit_unresolved () { |
192 | kill -s $SIG_UNRESOLVED $SIG_PID | 198 | kill -s $SIG_UNRESOLVED $SIG_PID |
@@ -215,17 +221,25 @@ exit_xfail () { | |||
215 | } | 221 | } |
216 | trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL | 222 | trap 'SIG_RESULT=$XFAIL' $SIG_XFAIL |
217 | 223 | ||
224 | __run_test() { # testfile | ||
225 | # setup PID and PPID, $$ is not updated. | ||
226 | (cd $TRACING_DIR; read PID _ < /proc/self/stat ; set -e; set -x; . $1) | ||
227 | [ $? -ne 0 ] && kill -s $SIG_FAIL $SIG_PID | ||
228 | } | ||
229 | |||
218 | # Run one test case | 230 | # Run one test case |
219 | run_test() { # testfile | 231 | run_test() { # testfile |
220 | local testname=`basename $1` | 232 | local testname=`basename $1` |
221 | local testlog=`mktemp --tmpdir=$LOG_DIR ${testname}-XXXXXX.log` | 233 | local testlog=`mktemp $LOG_DIR/${testname}-log.XXXXXX` |
222 | testcase $1 | 234 | testcase $1 |
223 | echo "execute: "$1 > $testlog | 235 | echo "execute: "$1 > $testlog |
224 | SIG_RESULT=0 | 236 | SIG_RESULT=0 |
225 | # setup PID and PPID, $$ is not updated. | 237 | if [ $VERBOSE -ne 0 ]; then |
226 | (cd $TRACING_DIR; read PID _ < /proc/self/stat ; | 238 | __run_test $1 2>> $testlog | tee -a $testlog |
227 | set -e; set -x; . $1) >> $testlog 2>&1 | 239 | else |
228 | eval_result $? $SIG_RESULT | 240 | __run_test $1 >> $testlog 2>&1 |
241 | fi | ||
242 | eval_result $SIG_RESULT | ||
229 | if [ $? -eq 0 ]; then | 243 | if [ $? -eq 0 ]; then |
230 | # Remove test log if the test was done as it was expected. | 244 | # Remove test log if the test was done as it was expected. |
231 | [ $KEEP_LOG -eq 0 ] && rm $testlog | 245 | [ $KEEP_LOG -eq 0 ] && rm $testlog |
@@ -235,6 +249,9 @@ run_test() { # testfile | |||
235 | fi | 249 | fi |
236 | } | 250 | } |
237 | 251 | ||
252 | # load in the helper functions | ||
253 | . $TEST_DIR/functions | ||
254 | |||
238 | # Main loop | 255 | # Main loop |
239 | for t in $TEST_CASES; do | 256 | for t in $TEST_CASES; do |
240 | run_test $t | 257 | run_test $t |
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 @@ | |||
1 | #!/bin/sh | ||
2 | # description: Basic event tracing check | ||
3 | test -f available_events -a -f set_event -a -d events | ||
4 | # check scheduler events are available | ||
5 | 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 @@ | |||
1 | #!/bin/sh | ||
2 | # description: event tracing - enable/disable with event level files | ||
3 | |||
4 | do_reset() { | ||
5 | echo > set_event | ||
6 | clear_trace | ||
7 | } | ||
8 | |||
9 | fail() { #msg | ||
10 | do_reset | ||
11 | echo $1 | ||
12 | exit -1 | ||
13 | } | ||
14 | |||
15 | if [ ! -f set_event -o ! -d events/sched ]; then | ||
16 | echo "event tracing is not supported" | ||
17 | exit_unsupported | ||
18 | fi | ||
19 | |||
20 | reset_tracer | ||
21 | do_reset | ||
22 | |||
23 | echo 'sched:sched_switch' > set_event | ||
24 | usleep 1 | ||
25 | |||
26 | count=`cat trace | grep sched_switch | wc -l` | ||
27 | if [ $count -eq 0 ]; then | ||
28 | fail "sched_switch events are not recorded" | ||
29 | fi | ||
30 | |||
31 | do_reset | ||
32 | |||
33 | echo 1 > events/sched/sched_switch/enable | ||
34 | usleep 1 | ||
35 | |||
36 | count=`cat trace | grep sched_switch | wc -l` | ||
37 | if [ $count -eq 0 ]; then | ||
38 | fail "sched_switch events are not recorded" | ||
39 | fi | ||
40 | |||
41 | do_reset | ||
42 | |||
43 | echo 0 > events/sched/sched_switch/enable | ||
44 | usleep 1 | ||
45 | |||
46 | count=`cat trace | grep sched_switch | wc -l` | ||
47 | if [ $count -ne 0 ]; then | ||
48 | fail "sched_switch events should not be recorded" | ||
49 | fi | ||
50 | |||
51 | do_reset | ||
52 | |||
53 | 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 @@ | |||
1 | #!/bin/sh | ||
2 | # description: event tracing - enable/disable with subsystem level files | ||
3 | |||
4 | do_reset() { | ||
5 | echo > set_event | ||
6 | clear_trace | ||
7 | } | ||
8 | |||
9 | fail() { #msg | ||
10 | do_reset | ||
11 | echo $1 | ||
12 | exit -1 | ||
13 | } | ||
14 | |||
15 | if [ ! -f set_event -o ! -d events/sched ]; then | ||
16 | echo "event tracing is not supported" | ||
17 | exit_unsupported | ||
18 | fi | ||
19 | |||
20 | reset_tracer | ||
21 | do_reset | ||
22 | |||
23 | echo 'sched:*' > set_event | ||
24 | usleep 1 | ||
25 | |||
26 | count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` | ||
27 | if [ $count -lt 3 ]; then | ||
28 | fail "at least fork, exec and exit events should be recorded" | ||
29 | fi | ||
30 | |||
31 | do_reset | ||
32 | |||
33 | echo 1 > events/sched/enable | ||
34 | usleep 1 | ||
35 | |||
36 | count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` | ||
37 | if [ $count -lt 3 ]; then | ||
38 | fail "at least fork, exec and exit events should be recorded" | ||
39 | fi | ||
40 | |||
41 | do_reset | ||
42 | |||
43 | echo 0 > events/sched/enable | ||
44 | usleep 1 | ||
45 | |||
46 | count=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` | ||
47 | if [ $count -ne 0 ]; then | ||
48 | fail "any of scheduler events should not be recorded" | ||
49 | fi | ||
50 | |||
51 | do_reset | ||
52 | |||
53 | 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 @@ | |||
1 | #!/bin/sh | ||
2 | # description: event tracing - enable/disable with top level files | ||
3 | |||
4 | do_reset() { | ||
5 | echo > set_event | ||
6 | clear_trace | ||
7 | } | ||
8 | |||
9 | fail() { #msg | ||
10 | do_reset | ||
11 | echo $1 | ||
12 | exit -1 | ||
13 | } | ||
14 | |||
15 | if [ ! -f available_events -o ! -f set_event -o ! -d events ]; then | ||
16 | echo "event tracing is not supported" | ||
17 | exit_unsupported | ||
18 | fi | ||
19 | |||
20 | reset_tracer | ||
21 | do_reset | ||
22 | |||
23 | echo '*:*' > set_event | ||
24 | count=`cat trace | grep -v ^# | wc -l` | ||
25 | if [ $count -eq 0 ]; then | ||
26 | fail "none of events are recorded" | ||
27 | fi | ||
28 | |||
29 | do_reset | ||
30 | |||
31 | echo 1 > events/enable | ||
32 | count=`cat trace | grep -v ^# | wc -l` | ||
33 | if [ $count -eq 0 ]; then | ||
34 | fail "none of events are recorded" | ||
35 | fi | ||
36 | |||
37 | do_reset | ||
38 | |||
39 | echo 0 > events/enable | ||
40 | count=`cat trace | grep -v ^# | wc -l` | ||
41 | if [ $count -ne 0 ]; then | ||
42 | fail "any of events should not be recorded" | ||
43 | fi | ||
44 | |||
45 | do_reset | ||
46 | |||
47 | exit 0 | ||
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 | |||
7 | if ! grep -q function_graph available_tracers; then | ||
8 | echo "no function graph tracer configured" | ||
9 | exit_unsupported | ||
10 | fi | ||
11 | |||
12 | if [ ! -f set_ftrace_filter ]; then | ||
13 | echo "set_ftrace_filter not found? Is dynamic ftrace not set?" | ||
14 | exit_unsupported | ||
15 | fi | ||
16 | |||
17 | do_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 | |||
25 | fail() { # msg | ||
26 | do_reset | ||
27 | echo $1 | ||
28 | exit -1 | ||
29 | } | ||
30 | |||
31 | disable_tracing | ||
32 | clear_trace; | ||
33 | |||
34 | # filter something, schedule is always good | ||
35 | if ! 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 | ||
40 | fi | ||
41 | |||
42 | echo function_graph > current_tracer | ||
43 | |||
44 | if [ ! -f stack_trace ]; then | ||
45 | echo "Stack tracer not configured" | ||
46 | do_reset | ||
47 | exit_unsupported; | ||
48 | fi | ||
49 | |||
50 | echo "Now testing with stack tracer" | ||
51 | |||
52 | echo 1 > /proc/sys/kernel/stack_tracer_enabled | ||
53 | |||
54 | disable_tracing | ||
55 | clear_trace | ||
56 | enable_tracing | ||
57 | sleep 1 | ||
58 | |||
59 | count=`cat trace | grep '()' | grep -v schedule | wc -l` | ||
60 | |||
61 | if [ $count -ne 0 ]; then | ||
62 | fail "Graph filtering not working with stack tracer?" | ||
63 | fi | ||
64 | |||
65 | # Make sure we did find something | ||
66 | count=`cat trace | grep 'schedule()' | wc -l` | ||
67 | if [ $count -eq 0 ]; then | ||
68 | fail "No schedule traces found?" | ||
69 | fi | ||
70 | |||
71 | echo 0 > /proc/sys/kernel/stack_tracer_enabled | ||
72 | clear_trace | ||
73 | sleep 1 | ||
74 | |||
75 | |||
76 | count=`cat trace | grep '()' | grep -v schedule | wc -l` | ||
77 | |||
78 | if [ $count -ne 0 ]; then | ||
79 | fail "Graph filtering not working after stack tracer disabled?" | ||
80 | fi | ||
81 | |||
82 | count=`cat trace | grep 'schedule()' | wc -l` | ||
83 | if [ $count -eq 0 ]; then | ||
84 | fail "No schedule traces found?" | ||
85 | fi | ||
86 | |||
87 | do_reset | ||
88 | |||
89 | 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 @@ | |||
1 | #!/bin/sh | ||
2 | # description: ftrace - function graph filters | ||
3 | |||
4 | # Make sure that function graph filtering works | ||
5 | |||
6 | if ! grep -q function_graph available_tracers; then | ||
7 | echo "no function graph tracer configured" | ||
8 | exit_unsupported | ||
9 | fi | ||
10 | |||
11 | do_reset() { | ||
12 | reset_tracer | ||
13 | enable_tracing | ||
14 | clear_trace | ||
15 | } | ||
16 | |||
17 | fail() { # msg | ||
18 | do_reset | ||
19 | echo $1 | ||
20 | exit -1 | ||
21 | } | ||
22 | |||
23 | disable_tracing | ||
24 | clear_trace | ||
25 | |||
26 | # filter something, schedule is always good | ||
27 | if ! 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 | ||
32 | fi | ||
33 | |||
34 | echo function_graph > current_tracer | ||
35 | enable_tracing | ||
36 | sleep 1 | ||
37 | # search for functions (has "()" on the line), and make sure | ||
38 | # that only the schedule function was found | ||
39 | count=`cat trace | grep '()' | grep -v schedule | wc -l` | ||
40 | if [ $count -ne 0 ]; then | ||
41 | fail "Graph filtering not working by itself?" | ||
42 | fi | ||
43 | |||
44 | # Make sure we did find something | ||
45 | count=`cat trace | grep 'schedule()' | wc -l` | ||
46 | if [ $count -eq 0 ]; then | ||
47 | fail "No schedule traces found?" | ||
48 | fi | ||
49 | |||
50 | do_reset | ||
51 | |||
52 | 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 @@ | |||
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 | ||
15 | if ! grep -q function_graph available_tracers; then | ||
16 | echo "no function graph tracer configured" | ||
17 | exit_unsupported; | ||
18 | fi | ||
19 | |||
20 | if [ ! -f set_ftrace_filter ]; then | ||
21 | echo "set_ftrace_filter not found? Is dynamic ftrace not set?" | ||
22 | exit_unsupported | ||
23 | fi | ||
24 | |||
25 | if [ ! -f function_profile_enabled ]; then | ||
26 | echo "function_profile_enabled not found, function profiling enabled?" | ||
27 | exit_unsupported | ||
28 | fi | ||
29 | |||
30 | fail() { # mesg | ||
31 | reset_tracer | ||
32 | echo > set_ftrace_filter | ||
33 | echo $1 | ||
34 | exit -1 | ||
35 | } | ||
36 | |||
37 | echo "Testing function tracer with profiler:" | ||
38 | echo "enable function tracer" | ||
39 | echo function > current_tracer | ||
40 | echo "enable profiler" | ||
41 | echo 1 > function_profile_enabled | ||
42 | |||
43 | sleep 1 | ||
44 | |||
45 | echo "Now filter on just schedule" | ||
46 | echo '*schedule' > set_ftrace_filter | ||
47 | clear_trace | ||
48 | |||
49 | echo "Now disable function profiler" | ||
50 | echo 0 > function_profile_enabled | ||
51 | |||
52 | sleep 1 | ||
53 | |||
54 | # make sure only schedule functions exist | ||
55 | |||
56 | echo "testing if only schedule is being traced" | ||
57 | if grep -v -e '^#' -e 'schedule' trace; then | ||
58 | fail "more than schedule was found" | ||
59 | fi | ||
60 | |||
61 | echo "Make sure schedule was traced" | ||
62 | if ! grep -e 'schedule' trace > /dev/null; then | ||
63 | cat trace | ||
64 | fail "can not find schedule in trace" | ||
65 | fi | ||
66 | |||
67 | echo > set_ftrace_filter | ||
68 | clear_trace | ||
69 | |||
70 | sleep 1 | ||
71 | |||
72 | echo "make sure something other than scheduler is being traced" | ||
73 | if ! grep -v -e '^#' -e 'schedule' trace > /dev/null; then | ||
74 | cat trace | ||
75 | fail "no other functions besides schedule was found" | ||
76 | fi | ||
77 | |||
78 | reset_tracer | ||
79 | |||
80 | exit 0 | ||
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 @@ | |||
1 | |||
2 | clear_trace() { # reset trace output | ||
3 | echo > trace | ||
4 | } | ||
5 | |||
6 | disable_tracing() { # stop trace recording | ||
7 | echo 0 > tracing_on | ||
8 | } | ||
9 | |||
10 | enable_tracing() { # start trace recording | ||
11 | echo 1 > tracing_on | ||
12 | } | ||
13 | |||
14 | reset_tracer() { # reset the current tracer | ||
15 | echo nop > current_tracer | ||
16 | } | ||
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 | |||
9 | grep myevent kprobe_events | 9 | grep myevent kprobe_events |
10 | test -d events/kprobes/myevent | 10 | test -d events/kprobes/myevent |
11 | echo > kprobe_events | 11 | echo > kprobe_events |
12 | 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 | |||
11 | echo > kprobe_events && exit 1 # this must fail | 11 | echo > kprobe_events && exit 1 # this must fail |
12 | echo 0 > events/kprobes/myevent/enable | 12 | echo 0 > events/kprobes/myevent/enable |
13 | echo > kprobe_events # this must succeed | 13 | echo > kprobe_events # this must succeed |
14 | 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 | |||
12 | ( echo "forked") | 12 | ( echo "forked") |
13 | echo 0 > events/kprobes/testprobe/enable | 13 | echo 0 > events/kprobes/testprobe/enable |
14 | echo "-:testprobe" >> kprobe_events | 14 | echo "-:testprobe" >> kprobe_events |
15 | clear_trace | ||
15 | test -d events/kprobes/testprobe && exit 1 || exit 0 | 16 | test -d events/kprobes/testprobe && exit 1 || exit 0 |
16 | 17 | ||
diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc new file mode 100644 index 000000000000..ab41d2b29841 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc | |||
@@ -0,0 +1,55 @@ | |||
1 | #!/bin/sh | ||
2 | # description: Kprobe dynamic event with function tracer | ||
3 | |||
4 | [ -f kprobe_events ] || exit_unsupported # this is configurable | ||
5 | grep function available_tracers || exit_unsupported # this is configurable | ||
6 | |||
7 | # prepare | ||
8 | echo nop > current_tracer | ||
9 | echo do_fork > set_ftrace_filter | ||
10 | echo 0 > events/enable | ||
11 | echo > kprobe_events | ||
12 | echo 'p:testprobe do_fork' > kprobe_events | ||
13 | |||
14 | # kprobe on / ftrace off | ||
15 | echo 1 > events/kprobes/testprobe/enable | ||
16 | echo > trace | ||
17 | ( echo "forked") | ||
18 | grep testprobe trace | ||
19 | ! grep 'do_fork <-' trace | ||
20 | |||
21 | # kprobe on / ftrace on | ||
22 | echo function > current_tracer | ||
23 | echo > trace | ||
24 | ( echo "forked") | ||
25 | grep testprobe trace | ||
26 | grep 'do_fork <-' trace | ||
27 | |||
28 | # kprobe off / ftrace on | ||
29 | echo 0 > events/kprobes/testprobe/enable | ||
30 | echo > trace | ||
31 | ( echo "forked") | ||
32 | ! grep testprobe trace | ||
33 | grep 'do_fork <-' trace | ||
34 | |||
35 | # kprobe on / ftrace on | ||
36 | echo 1 > events/kprobes/testprobe/enable | ||
37 | echo function > current_tracer | ||
38 | echo > trace | ||
39 | ( echo "forked") | ||
40 | grep testprobe trace | ||
41 | grep 'do_fork <-' trace | ||
42 | |||
43 | # kprobe on / ftrace off | ||
44 | echo nop > current_tracer | ||
45 | echo > trace | ||
46 | ( echo "forked") | ||
47 | grep testprobe trace | ||
48 | ! grep 'do_fork <-' trace | ||
49 | |||
50 | # cleanup | ||
51 | echo nop > current_tracer | ||
52 | echo > set_ftrace_filter | ||
53 | echo 0 > events/kprobes/testprobe/enable | ||
54 | echo > kprobe_events | ||
55 | echo > trace | ||
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 | |||
12 | ( echo "forked") | 12 | ( echo "forked") |
13 | echo 0 > events/kprobes/testprobe2/enable | 13 | echo 0 > events/kprobes/testprobe2/enable |
14 | echo '-:testprobe2' >> kprobe_events | 14 | echo '-:testprobe2' >> kprobe_events |
15 | clear_trace | ||
15 | test -d events/kprobes/testprobe2 && exit 1 || exit 0 | 16 | test -d events/kprobes/testprobe2 && exit 1 || exit 0 |