]>
Commit | Line | Data |
---|---|---|
d8b39e1d | 1 | #!/bin/sh |
b2441318 | 2 | # SPDX-License-Identifier: GPL-2.0 |
d8b39e1d | 3 | # description: ftrace - test for function traceon/off triggers |
6df0fee3 | 4 | # flags: instance |
d8b39e1d SRV |
5 | # |
6 | # Ftrace allows to add triggers to functions, such as enabling or disabling | |
7 | # tracing, enabling or disabling trace events, or recording a stack trace | |
8 | # within the ring buffer. | |
9 | # | |
10 | # This test is designed to test enabling and disabling tracing triggers | |
11 | # | |
12 | ||
13 | # The triggers are set within the set_ftrace_filter file | |
16bcd0f5 | 14 | check_filter_file set_ftrace_filter |
d8b39e1d | 15 | |
d8b39e1d | 16 | fail() { # mesg |
d8b39e1d | 17 | echo $1 |
42534b1f | 18 | exit_fail |
d8b39e1d SRV |
19 | } |
20 | ||
21 | SLEEP_TIME=".1" | |
22 | ||
d8b39e1d SRV |
23 | echo "Testing function probes with enabling disabling tracing:" |
24 | ||
25 | cnt_trace() { | |
26 | grep -v '^#' trace | wc -l | |
27 | } | |
28 | ||
29 | echo '** DISABLE TRACING' | |
30 | disable_tracing | |
31 | clear_trace | |
32 | ||
33 | cnt=`cnt_trace` | |
34 | if [ $cnt -ne 0 ]; then | |
35 | fail "Found junk in trace" | |
36 | fi | |
37 | ||
38 | ||
39 | echo '** ENABLE EVENTS' | |
40 | ||
8c77f0ba | 41 | echo 1 > events/sched/enable |
d8b39e1d SRV |
42 | |
43 | echo '** ENABLE TRACING' | |
44 | enable_tracing | |
45 | ||
46 | cnt=`cnt_trace` | |
47 | if [ $cnt -eq 0 ]; then | |
48 | fail "Nothing found in trace" | |
49 | fi | |
50 | ||
51 | # powerpc uses .schedule | |
52 | func="schedule" | |
565d5576 MH |
53 | available_file=available_filter_functions |
54 | if [ -d ../../instances -a -f ../../available_filter_functions ]; then | |
55 | available_file=../../available_filter_functions | |
56 | fi | |
d8b39e1d SRV |
57 | x=`grep '^\.schedule$' available_filter_functions | wc -l` |
58 | if [ "$x" -eq 1 ]; then | |
59 | func=".schedule" | |
60 | fi | |
61 | ||
62 | echo '** SET TRACEOFF' | |
63 | ||
64 | echo "$func:traceoff" > set_ftrace_filter | |
bc5f1598 MH |
65 | if [ -d ../../instances ]; then # Check instances |
66 | cur=`cat set_ftrace_filter` | |
67 | top=`cat ../../set_ftrace_filter` | |
68 | if [ "$cur" = "$top" ]; then | |
69 | echo "This kernel is too old to support per instance filter" | |
70 | reset_ftrace_filter | |
71 | exit_unsupported | |
72 | fi | |
73 | fi | |
d8b39e1d SRV |
74 | |
75 | cnt=`grep schedule set_ftrace_filter | wc -l` | |
76 | if [ $cnt -ne 1 ]; then | |
77 | fail "Did not find traceoff trigger" | |
78 | fi | |
79 | ||
80 | cnt=`cnt_trace` | |
81 | sleep $SLEEP_TIME | |
82 | cnt2=`cnt_trace` | |
83 | ||
84 | if [ $cnt -ne $cnt2 ]; then | |
85 | fail "Tracing is not stopped" | |
86 | fi | |
87 | ||
88 | on=`cat tracing_on` | |
89 | if [ $on != "0" ]; then | |
90 | fail "Tracing is not off" | |
91 | fi | |
92 | ||
d87b2917 | 93 | csum1=`md5sum trace` |
d8b39e1d | 94 | sleep $SLEEP_TIME |
d87b2917 | 95 | csum2=`md5sum trace` |
d8b39e1d | 96 | |
d87b2917 | 97 | if [ "$csum1" != "$csum2" ]; then |
d8b39e1d SRV |
98 | fail "Tracing file is still changing" |
99 | fi | |
100 | ||
101 | clear_trace | |
102 | ||
103 | cnt=`cnt_trace` | |
104 | if [ $cnt -ne 0 ]; then | |
105 | fail "Tracing is still happeing" | |
106 | fi | |
107 | ||
108 | echo "!$func:traceoff" >> set_ftrace_filter | |
109 | ||
110 | cnt=`grep schedule set_ftrace_filter | wc -l` | |
111 | if [ $cnt -ne 0 ]; then | |
112 | fail "traceoff trigger still exists" | |
113 | fi | |
114 | ||
115 | on=`cat tracing_on` | |
116 | if [ $on != "0" ]; then | |
117 | fail "Tracing is started again" | |
118 | fi | |
119 | ||
120 | echo "$func:traceon" > set_ftrace_filter | |
121 | ||
122 | cnt=`grep schedule set_ftrace_filter | wc -l` | |
123 | if [ $cnt -ne 1 ]; then | |
124 | fail "traceon trigger not found" | |
125 | fi | |
126 | ||
127 | cnt=`cnt_trace` | |
128 | if [ $cnt -eq 0 ]; then | |
129 | fail "Tracing did not start" | |
130 | fi | |
131 | ||
132 | on=`cat tracing_on` | |
133 | if [ $on != "1" ]; then | |
134 | fail "Tracing was not enabled" | |
135 | fi | |
136 | ||
137 | ||
138 | echo "!$func:traceon" >> set_ftrace_filter | |
139 | ||
140 | cnt=`grep schedule set_ftrace_filter | wc -l` | |
141 | if [ $cnt -ne 0 ]; then | |
142 | fail "traceon trigger still exists" | |
143 | fi | |
144 | ||
145 | check_sleep() { | |
146 | val=$1 | |
147 | sleep $SLEEP_TIME | |
148 | cat set_ftrace_filter | |
149 | on=`cat tracing_on` | |
150 | if [ $on != "$val" ]; then | |
151 | fail "Expected tracing_on to be $val, but it was $on" | |
152 | fi | |
153 | } | |
154 | ||
155 | ||
156 | echo "$func:traceoff:3" > set_ftrace_filter | |
157 | check_sleep "0" | |
158 | echo 1 > tracing_on | |
159 | check_sleep "0" | |
160 | echo 1 > tracing_on | |
161 | check_sleep "0" | |
162 | echo 1 > tracing_on | |
163 | check_sleep "1" | |
164 | echo "!$func:traceoff:0" > set_ftrace_filter | |
165 | ||
166 | if grep -e traceon -e traceoff set_ftrace_filter; then | |
167 | fail "Tracing on and off triggers still exist" | |
168 | fi | |
169 | ||
170 | disable_events | |
171 | ||
172 | exit 0 |