1 clear_trace() { # reset trace output
5 disable_tracing() { # stop trace recording
9 enable_tracing() { # start trace recording
13 reset_tracer() { # reset the current tracer
14 echo nop > current_tracer
17 reset_trigger_file() {
18 # remove action triggers first
19 grep -H ':on[^:]*(' $@ |
21 cmd=`echo $line | cut -f2- -d: | cut -f1 -d"["`
22 file=`echo $line | cut -f1 -d:`
27 cmd=`echo $line | cut -f2- -d: | cut -f1 -d"["`
28 file=`echo $line | cut -f1 -d:`
33 reset_trigger() { # reset all current setting triggers
34 if [ -d events/synthetic ]; then
35 reset_trigger_file events/synthetic/*/trigger
37 reset_trigger_file events/*/*/trigger
40 reset_events_filter() { # reset all current setting filters
41 grep -v ^none events/*/*/filter |
43 echo 0 > `echo $line | cut -f1 -d:`
47 reset_ftrace_filter() { # reset all triggers in set_ftrace_filter
48 if [ ! -f set_ftrace_filter ]; then
51 echo > set_ftrace_filter
52 grep -v '^#' set_ftrace_filter | while read t; do
53 tr=`echo $t | cut -d: -f2`
54 if [ "$tr" = "" ]; then
57 if ! grep -q "$t" set_ftrace_filter; then
60 name=`echo $t | cut -d: -f1 | cut -d' ' -f1`
61 if [ $tr = "enable_event" -o $tr = "disable_event" ]; then
62 tr=`echo $t | cut -d: -f2-4`
63 limit=`echo $t | cut -d: -f5`
65 tr=`echo $t | cut -d: -f2`
66 limit=`echo $t | cut -d: -f3`
68 if [ "$limit" != "unlimited" ]; then
71 echo "!$name:$tr" > set_ftrace_filter
76 echo 0 > events/enable
79 clear_synthetic_events() { # reset all current synthetic events
80 grep -v ^# synthetic_events |
82 echo "!$line" >> synthetic_events
86 initialize_ftrace() { # Reset ftrace to initial-state
87 # As the initial state, ftrace will be set to nop tracer,
88 # no events, no triggers, no filters, no function filters,
89 # no probes, and tracing on.
96 [ -f set_event_pid ] && echo > set_event_pid
97 [ -f set_ftrace_pid ] && echo > set_ftrace_pid
98 [ -f set_ftrace_notrace ] && echo > set_ftrace_notrace
99 [ -f set_graph_function ] && echo | tee set_graph_*
100 [ -f stack_trace_filter ] && echo > stack_trace_filter
101 [ -f kprobe_events ] && echo > kprobe_events
102 [ -f uprobe_events ] && echo > uprobe_events
103 [ -f synthetic_events ] && echo > synthetic_events
104 [ -f snapshot ] && echo 0 > snapshot
109 check_requires() { # Check required files and tracers
113 if [ $t != $i ]; then
114 if ! grep -wq $t available_tracers ; then
115 echo "Required tracer $t is not configured."
118 elif [ $r != $i ]; then
119 if ! grep -Fq "$r" README ; then
120 echo "Required feature pattern \"$r\" is not in README."
123 elif [ ! -e $i ]; then
124 echo "Required feature interface $i doesn't exist."
133 ping $LOCALHOST -c 1 || sleep .001 || usleep 1 || sleep 1
136 # The fork function in the kernel was renamed from "_do_fork" to
137 # "kernel_fork". As older tests should still work with older kernels
138 # as well as newer kernels, check which version of fork is used on this
139 # kernel so that the tests can use the fork function for the running kernel.
140 FUNCTION_FORK=`(if grep '\bkernel_clone\b' /proc/kallsyms > /dev/null; then
141 echo kernel_clone; else echo '_do_fork'; fi)`
143 # Since probe event command may include backslash, explicitly use printf "%s"
144 # to NOT interpret it.
145 ftrace_errlog_check() { # err-prefix command-with-error-pos-by-^ command-file
146 pos=$(printf "%s" "${2%^*}" | wc -c) # error position
147 command=$(printf "%s" "$2" | tr -d ^)
148 echo "Test command: $command"
150 (! printf "%s" "$command" >> "$3" ) 2> /dev/null
151 grep "$1: error:" -A 3 error_log
152 N=$(tail -n 1 error_log | wc -c)
153 # " Command: " and "^\n" => 13
154 test $(expr 13 + $pos) -eq $N