diff options
author | Namhyung Kim <namhyung@kernel.org> | 2016-05-10 10:53:06 -0400 |
---|---|---|
committer | Shuah Khan <shuahkh@osg.samsung.com> | 2016-05-16 11:02:03 -0400 |
commit | 2c6c3946c3955f96ae0d48fdac940903918207d8 (patch) | |
tree | f3f1752d48642a41db3cf35db766ae8a96209df2 /tools | |
parent | 5a614ec8a7cfe9098475fa1221b409fb7eec6054 (diff) |
kselftests/ftrace: Add a test case for event pid filtering
Check event is filtered by set_event_pid and options/event-fork.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/ftrace/test.d/event/event-pid.tc | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tools/testing/selftests/ftrace/test.d/event/event-pid.tc b/tools/testing/selftests/ftrace/test.d/event/event-pid.tc new file mode 100644 index 000000000000..d4ab27b522f8 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/event/event-pid.tc | |||
@@ -0,0 +1,72 @@ | |||
1 | #!/bin/sh | ||
2 | # description: event tracing - restricts events based on pid | ||
3 | |||
4 | do_reset() { | ||
5 | echo > set_event | ||
6 | echo > set_event_pid | ||
7 | echo 0 > options/event-fork | ||
8 | clear_trace | ||
9 | } | ||
10 | |||
11 | fail() { #msg | ||
12 | do_reset | ||
13 | echo $1 | ||
14 | exit $FAIL | ||
15 | } | ||
16 | |||
17 | yield() { | ||
18 | ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1 | ||
19 | } | ||
20 | |||
21 | if [ ! -f set_event -o ! -d events/sched ]; then | ||
22 | echo "event tracing is not supported" | ||
23 | exit_unsupported | ||
24 | fi | ||
25 | |||
26 | if [ ! -f set_event_pid ]; then | ||
27 | echo "event pid filtering is not supported" | ||
28 | exit_unsupported | ||
29 | fi | ||
30 | |||
31 | reset_tracer | ||
32 | do_reset | ||
33 | |||
34 | echo 1 > events/sched/sched_switch/enable | ||
35 | |||
36 | yield | ||
37 | |||
38 | count=`cat trace | grep sched_switch | wc -l` | ||
39 | if [ $count -eq 0 ]; then | ||
40 | fail "sched_switch events are not recorded" | ||
41 | fi | ||
42 | |||
43 | do_reset | ||
44 | |||
45 | read mypid rest < /proc/self/stat | ||
46 | |||
47 | echo $mypid > set_event_pid | ||
48 | echo 'sched:sched_switch' > set_event | ||
49 | |||
50 | yield | ||
51 | |||
52 | count=`cat trace | grep sched_switch | grep -v "pid=$mypid" | wc -l` | ||
53 | if [ $count -ne 0 ]; then | ||
54 | fail "sched_switch events from other task are recorded" | ||
55 | fi | ||
56 | |||
57 | do_reset | ||
58 | |||
59 | echo $mypid > set_event_pid | ||
60 | echo 1 > options/event-fork | ||
61 | echo 1 > events/sched/sched_switch/enable | ||
62 | |||
63 | yield | ||
64 | |||
65 | count=`cat trace | grep sched_switch | grep -v "pid=$mypid" | wc -l` | ||
66 | if [ $count -eq 0 ]; then | ||
67 | fail "sched_switch events from other task are not recorded" | ||
68 | fi | ||
69 | |||
70 | do_reset | ||
71 | |||
72 | exit 0 | ||