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?"
34 echo "Testing function probes with events:"
36 EVENT="sched:sched_switch"
37 EVENT_ENABLE="events/sched/sched_switch/enable"
40 grep -v '^#' trace | wc -l
43 test_event_enabled() {
47 if [ "$e" != $val ]; then
48 fail "Expected $val but found $e"
52 run_enable_disable() {
56 check_enable_star=$4 # 1*
57 check_disable_star=$5 # 0*
60 if [ $cnt -ne 0 ]; then
61 fail "Found junk in trace file"
64 echo "$Enable event all the time"
66 echo $check_disable > $EVENT_ENABLE
69 test_event_enabled $check_disable
71 echo "schedule:${enable}_event:$EVENT" > set_ftrace_filter
72 if [ -d ../../instances ]; then # Check instances
73 cur=`cat set_ftrace_filter`
74 top=`cat ../../set_ftrace_filter`
75 if [ "$cur" = "$top" ]; then
76 echo "This kernel is too old to support per instance filter"
82 echo " make sure it works 5 times"
87 test_event_enabled $check_enable_star
89 echo $check_disable > $EVENT_ENABLE
92 echo " make sure it's still works"
93 test_event_enabled $check_enable_star
97 echo " make sure it only works 3 times"
99 echo $check_disable > $EVENT_ENABLE
102 echo "schedule:${enable}_event:$EVENT:3" > set_ftrace_filter
107 test_event_enabled $check_enable_star
109 echo $check_disable > $EVENT_ENABLE
113 echo " make sure it stop working"
114 test_event_enabled $check_disable_star
119 run_enable_disable enable Enable 0 "1*" "0*"
120 run_enable_disable disable Disable 1 "0*" "1*"