]> git.ipfire.org Git - thirdparty/linux.git/blame - tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc
Merge tag 'drm/tegra/for-5.7-fixes' of git://anongit.freedesktop.org/tegra/linux...
[thirdparty/linux.git] / tools / testing / selftests / ftrace / test.d / ftrace / func_traceonoff_triggers.tc
CommitLineData
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 14check_filter_file set_ftrace_filter
d8b39e1d 15
d8b39e1d 16fail() { # mesg
d8b39e1d 17 echo $1
42534b1f 18 exit_fail
d8b39e1d
SRV
19}
20
21SLEEP_TIME=".1"
22
d8b39e1d
SRV
23echo "Testing function probes with enabling disabling tracing:"
24
25cnt_trace() {
26 grep -v '^#' trace | wc -l
27}
28
29echo '** DISABLE TRACING'
30disable_tracing
31clear_trace
32
33cnt=`cnt_trace`
34if [ $cnt -ne 0 ]; then
35 fail "Found junk in trace"
36fi
37
38
39echo '** ENABLE EVENTS'
40
8c77f0ba 41echo 1 > events/sched/enable
d8b39e1d
SRV
42
43echo '** ENABLE TRACING'
44enable_tracing
45
46cnt=`cnt_trace`
47if [ $cnt -eq 0 ]; then
48 fail "Nothing found in trace"
49fi
50
51# powerpc uses .schedule
52func="schedule"
565d5576
MH
53available_file=available_filter_functions
54if [ -d ../../instances -a -f ../../available_filter_functions ]; then
55 available_file=../../available_filter_functions
56fi
d8b39e1d
SRV
57x=`grep '^\.schedule$' available_filter_functions | wc -l`
58if [ "$x" -eq 1 ]; then
59 func=".schedule"
60fi
61
62echo '** SET TRACEOFF'
63
64echo "$func:traceoff" > set_ftrace_filter
bc5f1598
MH
65if [ -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
73fi
d8b39e1d
SRV
74
75cnt=`grep schedule set_ftrace_filter | wc -l`
76if [ $cnt -ne 1 ]; then
77 fail "Did not find traceoff trigger"
78fi
79
80cnt=`cnt_trace`
81sleep $SLEEP_TIME
82cnt2=`cnt_trace`
83
84if [ $cnt -ne $cnt2 ]; then
85 fail "Tracing is not stopped"
86fi
87
88on=`cat tracing_on`
89if [ $on != "0" ]; then
90 fail "Tracing is not off"
91fi
92
d87b2917 93csum1=`md5sum trace`
d8b39e1d 94sleep $SLEEP_TIME
d87b2917 95csum2=`md5sum trace`
d8b39e1d 96
d87b2917 97if [ "$csum1" != "$csum2" ]; then
d8b39e1d
SRV
98 fail "Tracing file is still changing"
99fi
100
101clear_trace
102
103cnt=`cnt_trace`
104if [ $cnt -ne 0 ]; then
105 fail "Tracing is still happeing"
106fi
107
108echo "!$func:traceoff" >> set_ftrace_filter
109
110cnt=`grep schedule set_ftrace_filter | wc -l`
111if [ $cnt -ne 0 ]; then
112 fail "traceoff trigger still exists"
113fi
114
115on=`cat tracing_on`
116if [ $on != "0" ]; then
117 fail "Tracing is started again"
118fi
119
120echo "$func:traceon" > set_ftrace_filter
121
122cnt=`grep schedule set_ftrace_filter | wc -l`
123if [ $cnt -ne 1 ]; then
124 fail "traceon trigger not found"
125fi
126
127cnt=`cnt_trace`
128if [ $cnt -eq 0 ]; then
129 fail "Tracing did not start"
130fi
131
132on=`cat tracing_on`
133if [ $on != "1" ]; then
134 fail "Tracing was not enabled"
135fi
136
137
138echo "!$func:traceon" >> set_ftrace_filter
139
140cnt=`grep schedule set_ftrace_filter | wc -l`
141if [ $cnt -ne 0 ]; then
142 fail "traceon trigger still exists"
143fi
144
145check_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
156echo "$func:traceoff:3" > set_ftrace_filter
157check_sleep "0"
158echo 1 > tracing_on
159check_sleep "0"
160echo 1 > tracing_on
161check_sleep "0"
162echo 1 > tracing_on
163check_sleep "1"
164echo "!$func:traceoff:0" > set_ftrace_filter
165
166if grep -e traceon -e traceoff set_ftrace_filter; then
167 fail "Tracing on and off triggers still exist"
168fi
169
170disable_events
171
172exit 0