]>
Commit | Line | Data |
---|---|---|
43bb45da SRV |
1 | #!/bin/sh |
2 | # description: ftrace - test for function event triggers | |
6df0fee3 | 3 | # flags: instance |
43bb45da SRV |
4 | # |
5 | # Ftrace allows to add triggers to functions, such as enabling or disabling | |
6 | # tracing, enabling or disabling trace events, or recording a stack trace | |
7 | # within the ring buffer. | |
8 | # | |
9 | # This test is designed to test event triggers | |
10 | # | |
11 | ||
12 | # The triggers are set within the set_ftrace_filter file | |
13 | if [ ! -f set_ftrace_filter ]; then | |
14 | echo "set_ftrace_filter not found? Is dynamic ftrace not set?" | |
15 | exit_unsupported | |
16 | fi | |
17 | ||
18 | do_reset() { | |
19 | reset_ftrace_filter | |
20 | reset_tracer | |
21 | disable_events | |
22 | clear_trace | |
23 | enable_tracing | |
24 | } | |
25 | ||
26 | fail() { # mesg | |
27 | do_reset | |
28 | echo $1 | |
29 | exit $FAIL | |
30 | } | |
31 | ||
32 | SLEEP_TIME=".1" | |
33 | ||
34 | do_reset | |
35 | ||
36 | echo "Testing function probes with events:" | |
37 | ||
38 | EVENT="sched:sched_switch" | |
39 | EVENT_ENABLE="events/sched/sched_switch/enable" | |
40 | ||
41 | cnt_trace() { | |
42 | grep -v '^#' trace | wc -l | |
43 | } | |
44 | ||
45 | test_event_enabled() { | |
46 | val=$1 | |
47 | ||
48 | e=`cat $EVENT_ENABLE` | |
49 | if [ "$e" != $val ]; then | |
50 | echo "Expected $val but found $e" | |
d2ffb8d3 | 51 | exit 1 |
43bb45da SRV |
52 | fi |
53 | } | |
54 | ||
55 | run_enable_disable() { | |
56 | enable=$1 # enable | |
57 | Enable=$2 # Enable | |
58 | check_disable=$3 # 0 | |
59 | check_enable_star=$4 # 1* | |
60 | check_disable_star=$5 # 0* | |
61 | ||
62 | cnt=`cnt_trace` | |
63 | if [ $cnt -ne 0 ]; then | |
64 | fail "Found junk in trace file" | |
65 | fi | |
66 | ||
67 | echo "$Enable event all the time" | |
68 | ||
69 | echo $check_disable > $EVENT_ENABLE | |
70 | sleep $SLEEP_TIME | |
71 | ||
72 | test_event_enabled $check_disable | |
73 | ||
74 | echo "schedule:${enable}_event:$EVENT" > set_ftrace_filter | |
75 | ||
76 | echo " make sure it works 5 times" | |
77 | ||
78 | for i in `seq 5`; do | |
79 | sleep $SLEEP_TIME | |
80 | echo " test $i" | |
81 | test_event_enabled $check_enable_star | |
82 | ||
83 | echo $check_disable > $EVENT_ENABLE | |
84 | done | |
85 | sleep $SLEEP_TIME | |
86 | echo " make sure it's still works" | |
87 | test_event_enabled $check_enable_star | |
88 | ||
89 | reset_ftrace_filter | |
90 | ||
91 | echo " make sure it only works 3 times" | |
92 | ||
93 | echo $check_disable > $EVENT_ENABLE | |
94 | sleep $SLEEP_TIME | |
95 | ||
96 | echo "schedule:${enable}_event:$EVENT:3" > set_ftrace_filter | |
97 | ||
98 | for i in `seq 3`; do | |
99 | sleep $SLEEP_TIME | |
100 | echo " test $i" | |
101 | test_event_enabled $check_enable_star | |
102 | ||
103 | echo $check_disable > $EVENT_ENABLE | |
104 | done | |
105 | ||
106 | sleep $SLEEP_TIME | |
107 | echo " make sure it stop working" | |
108 | test_event_enabled $check_disable_star | |
109 | ||
110 | do_reset | |
111 | } | |
112 | ||
113 | run_enable_disable enable Enable 0 "1*" "0*" | |
114 | run_enable_disable disable Disable 1 "0*" "1*" |