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 check_filter_file set_ftrace_filter
23 echo "Testing function probes with enabling disabling tracing:"
26 grep -v '^#' trace | wc -l
29 echo '** DISABLE TRACING'
34 if [ $cnt -ne 0 ]; then
35 fail "Found junk in trace"
39 echo '** ENABLE EVENTS'
41 echo 1 > events/sched/enable
43 echo '** ENABLE TRACING'
47 if [ $cnt -eq 0 ]; then
48 fail "Nothing found in trace"
51 # powerpc uses .schedule
53 available_file=available_filter_functions
54 if [ -d ../../instances -a -f ../../available_filter_functions ]; then
55 available_file=../../available_filter_functions
57 x=`grep '^\.schedule$' available_filter_functions | wc -l`
58 if [ "$x" -eq 1 ]; then
62 echo '** SET TRACEOFF'
64 echo "$func:traceoff" > set_ftrace_filter
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"
75 cnt=`grep schedule set_ftrace_filter | wc -l`
76 if [ $cnt -ne 1 ]; then
77 fail "Did not find traceoff trigger"
84 if [ $cnt -ne $cnt2 ]; then
85 fail "Tracing is not stopped"
89 if [ $on != "0" ]; then
90 fail "Tracing is not off"
97 if [ "$csum1" != "$csum2" ]; then
98 fail "Tracing file is still changing"
104 if [ $cnt -ne 0 ]; then
105 fail "Tracing is still happeing"
108 echo "!$func:traceoff" >> set_ftrace_filter
110 cnt=`grep schedule set_ftrace_filter | wc -l`
111 if [ $cnt -ne 0 ]; then
112 fail "traceoff trigger still exists"
116 if [ $on != "0" ]; then
117 fail "Tracing is started again"
120 echo "$func:traceon" > set_ftrace_filter
122 cnt=`grep schedule set_ftrace_filter | wc -l`
123 if [ $cnt -ne 1 ]; then
124 fail "traceon trigger not found"
128 if [ $cnt -eq 0 ]; then
129 fail "Tracing did not start"
133 if [ $on != "1" ]; then
134 fail "Tracing was not enabled"
138 echo "!$func:traceon" >> set_ftrace_filter
140 cnt=`grep schedule set_ftrace_filter | wc -l`
141 if [ $cnt -ne 0 ]; then
142 fail "traceon trigger still exists"
148 cat set_ftrace_filter
150 if [ $on != "$val" ]; then
151 fail "Expected tracing_on to be $val, but it was $on"
156 echo "$func:traceoff:3" > set_ftrace_filter
164 echo "!$func:traceoff:0" > set_ftrace_filter
166 if grep -e traceon -e traceoff set_ftrace_filter; then
167 fail "Tracing on and off triggers still exist"