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() {
50 if [ "$e" != $val ]; then
51 echo "Expected $val but found $e"
56 run_enable_disable() {
60 check_enable_star=$4 # 1*
61 check_disable_star=$5 # 0*
64 if [ $cnt -ne 0 ]; then
65 fail "Found junk in trace file"
68 echo "$Enable event all the time"
70 echo $check_disable > $EVENT_ENABLE
73 test_event_enabled $check_disable
75 echo "schedule:${enable}_event:$EVENT" > set_ftrace_filter
76 if [ -d ../../instances ]; then # Check instances
77 cur=`cat set_ftrace_filter`
78 top=`cat ../../set_ftrace_filter`
79 if [ "$cur" = "$top" ]; then
80 echo "This kernel is too old to support per instance filter"
86 echo " make sure it works 5 times"
91 test_event_enabled $check_enable_star
93 echo $check_disable > $EVENT_ENABLE
96 echo " make sure it's still works"
97 test_event_enabled $check_enable_star
101 echo " make sure it only works 3 times"
103 echo $check_disable > $EVENT_ENABLE
106 echo "schedule:${enable}_event:$EVENT:3" > set_ftrace_filter
111 test_event_enabled $check_enable_star
113 echo $check_disable > $EVENT_ENABLE
117 echo " make sure it stop working"
118 test_event_enabled $check_disable_star
123 run_enable_disable enable Enable 0 "1*" "0*"
124 run_enable_disable disable Disable 1 "0*" "1*"