2 # SPDX-License-Identifier: GPL-2.0
3 # description: ftrace - test for function traceon/off triggers
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.
10 # This test is designed to test enabling and disabling tracing triggers
13 # The triggers are set within the set_ftrace_filter file
14 if [ ! -f set_ftrace_filter
]; then
15 echo "set_ftrace_filter not found? Is dynamic ftrace not set?"
26 echo "Testing function probes with enabling disabling tracing:"
29 grep -v '^#' trace |
wc -l
32 echo '** DISABLE TRACING'
37 if [ $cnt -ne 0 ]; then
38 fail
"Found junk in trace"
42 echo '** ENABLE EVENTS'
44 echo 1 > events
/sched
/enable
46 echo '** ENABLE TRACING'
50 if [ $cnt -eq 0 ]; then
51 fail
"Nothing found in trace"
54 # powerpc uses .schedule
56 available_file
=available_filter_functions
57 if [ -d ..
/..
/instances
-a -f ..
/..
/available_filter_functions
]; then
58 available_file
=..
/..
/available_filter_functions
60 x
=`grep '^\.schedule$' available_filter_functions | wc -l`
61 if [ "$x" -eq 1 ]; then
65 echo '** SET TRACEOFF'
67 echo "$func:traceoff" > set_ftrace_filter
68 if [ -d ..
/..
/instances
]; then # Check instances
69 cur
=`cat set_ftrace_filter`
70 top
=`cat ../../set_ftrace_filter`
71 if [ "$cur" = "$top" ]; then
72 echo "This kernel is too old to support per instance filter"
78 cnt
=`grep schedule set_ftrace_filter | wc -l`
79 if [ $cnt -ne 1 ]; then
80 fail
"Did not find traceoff trigger"
87 if [ $cnt -ne $cnt2 ]; then
88 fail
"Tracing is not stopped"
92 if [ $on != "0" ]; then
93 fail
"Tracing is not off"
100 if [ "$csum1" != "$csum2" ]; then
101 fail
"Tracing file is still changing"
107 if [ $cnt -ne 0 ]; then
108 fail
"Tracing is still happeing"
111 echo "!$func:traceoff" >> set_ftrace_filter
113 cnt
=`grep schedule set_ftrace_filter | wc -l`
114 if [ $cnt -ne 0 ]; then
115 fail
"traceoff trigger still exists"
119 if [ $on != "0" ]; then
120 fail
"Tracing is started again"
123 echo "$func:traceon" > set_ftrace_filter
125 cnt
=`grep schedule set_ftrace_filter | wc -l`
126 if [ $cnt -ne 1 ]; then
127 fail
"traceon trigger not found"
131 if [ $cnt -eq 0 ]; then
132 fail
"Tracing did not start"
136 if [ $on != "1" ]; then
137 fail
"Tracing was not enabled"
141 echo "!$func:traceon" >> set_ftrace_filter
143 cnt
=`grep schedule set_ftrace_filter | wc -l`
144 if [ $cnt -ne 0 ]; then
145 fail
"traceon trigger still exists"
151 cat set_ftrace_filter
153 if [ $on != "$val" ]; then
154 fail
"Expected tracing_on to be $val, but it was $on"
159 echo "$func:traceoff:3" > set_ftrace_filter
167 echo "!$func:traceoff:0" > set_ftrace_filter
169 if grep -e traceon
-e traceoff set_ftrace_filter
; then
170 fail
"Tracing on and off triggers still exist"