2 # SPDX-License-Identifier: GPL-2.0
3 # description: ftrace - test for function event 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 event 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 events:"
39 EVENT="sched:sched_switch"
40 EVENT_ENABLE="events/sched/sched_switch/enable"
43 grep -v '^#' trace | wc -l
46 test_event_enabled() {
48 check_times=10 # wait for 10 * SLEEP_TIME at most
50 while [ $check_times -ne 0 ]; do
52 if [ "$e" = $val ]; then
56 check_times=$((check_times - 1))
59 fail "Expected $val but found $e"
62 run_enable_disable() {
66 check_enable_star=$4 # 1*
67 check_disable_star=$5 # 0*
70 if [ $cnt -ne 0 ]; then
71 fail "Found junk in trace file"
74 echo "$Enable event all the time"
76 echo $check_disable > $EVENT_ENABLE
79 test_event_enabled $check_disable
81 echo "schedule:${enable}_event:$EVENT" > set_ftrace_filter
82 if [ -d ../../instances ]; then # Check instances
83 cur=`cat set_ftrace_filter`
84 top=`cat ../../set_ftrace_filter`
85 if [ "$cur" = "$top" ]; then
86 echo "This kernel is too old to support per instance filter"
92 echo " make sure it works 5 times"
97 test_event_enabled $check_enable_star
99 echo $check_disable > $EVENT_ENABLE
102 echo " make sure it's still works"
103 test_event_enabled $check_enable_star
107 echo " make sure it only works 3 times"
109 echo $check_disable > $EVENT_ENABLE
112 echo "schedule:${enable}_event:$EVENT:3" > set_ftrace_filter
117 test_event_enabled $check_enable_star
119 echo $check_disable > $EVENT_ENABLE
123 echo " make sure it stop working"
124 test_event_enabled $check_disable_star
129 run_enable_disable enable Enable 0 "1*" "0*"
130 run_enable_disable disable Disable 1 "0*" "1*"