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?"
37 echo "Testing function probes with enabling disabling tracing:"
40 grep -v '^#' trace |
wc -l
43 echo '** DISABLE TRACING'
48 if [ $cnt -ne 0 ]; then
49 fail
"Found junk in trace"
53 echo '** ENABLE EVENTS'
55 echo 1 > events
/enable
57 echo '** ENABLE TRACING'
61 if [ $cnt -eq 0 ]; then
62 fail
"Nothing found in trace"
65 # powerpc uses .schedule
67 available_file
=available_filter_functions
68 if [ -d ..
/..
/instances
-a -f ..
/..
/available_filter_functions
]; then
69 available_file
=..
/..
/available_filter_functions
71 x
=`grep '^\.schedule$' available_filter_functions | wc -l`
72 if [ "$x" -eq 1 ]; then
76 echo '** SET TRACEOFF'
78 echo "$func:traceoff" > set_ftrace_filter
79 if [ -d ..
/..
/instances
]; then # Check instances
80 cur
=`cat set_ftrace_filter`
81 top
=`cat ../../set_ftrace_filter`
82 if [ "$cur" = "$top" ]; then
83 echo "This kernel is too old to support per instance filter"
89 cnt
=`grep schedule set_ftrace_filter | wc -l`
90 if [ $cnt -ne 1 ]; then
91 fail
"Did not find traceoff trigger"
98 if [ $cnt -ne $cnt2 ]; then
99 fail
"Tracing is not stopped"
103 if [ $on != "0" ]; then
104 fail
"Tracing is not off"
111 if [ "$csum1" != "$csum2" ]; then
112 fail
"Tracing file is still changing"
118 if [ $cnt -ne 0 ]; then
119 fail
"Tracing is still happeing"
122 echo "!$func:traceoff" >> set_ftrace_filter
124 cnt
=`grep schedule set_ftrace_filter | wc -l`
125 if [ $cnt -ne 0 ]; then
126 fail
"traceoff trigger still exists"
130 if [ $on != "0" ]; then
131 fail
"Tracing is started again"
134 echo "$func:traceon" > set_ftrace_filter
136 cnt
=`grep schedule set_ftrace_filter | wc -l`
137 if [ $cnt -ne 1 ]; then
138 fail
"traceon trigger not found"
142 if [ $cnt -eq 0 ]; then
143 fail
"Tracing did not start"
147 if [ $on != "1" ]; then
148 fail
"Tracing was not enabled"
152 echo "!$func:traceon" >> set_ftrace_filter
154 cnt
=`grep schedule set_ftrace_filter | wc -l`
155 if [ $cnt -ne 0 ]; then
156 fail
"traceon trigger still exists"
162 cat set_ftrace_filter
164 if [ $on != "$val" ]; then
165 fail
"Expected tracing_on to be $val, but it was $on"
170 echo "$func:traceoff:3" > set_ftrace_filter
178 echo "!$func:traceoff:0" > set_ftrace_filter
180 if grep -e traceon
-e traceoff set_ftrace_filter
; then
181 fail
"Tracing on and off triggers still exist"