.. | .. |
---|
1 | | - |
---|
2 | 1 | clear_trace() { # reset trace output |
---|
3 | 2 | echo > trace |
---|
4 | 3 | } |
---|
.. | .. |
---|
46 | 45 | } |
---|
47 | 46 | |
---|
48 | 47 | reset_ftrace_filter() { # reset all triggers in set_ftrace_filter |
---|
| 48 | + if [ ! -f set_ftrace_filter ]; then |
---|
| 49 | + return 0 |
---|
| 50 | + fi |
---|
49 | 51 | echo > set_ftrace_filter |
---|
50 | 52 | grep -v '^#' set_ftrace_filter | while read t; do |
---|
51 | 53 | tr=`echo $t | cut -d: -f2` |
---|
.. | .. |
---|
89 | 91 | reset_tracer |
---|
90 | 92 | reset_trigger |
---|
91 | 93 | reset_events_filter |
---|
| 94 | + reset_ftrace_filter |
---|
92 | 95 | disable_events |
---|
93 | | - echo > set_event_pid # event tracer is always on |
---|
94 | | - [ -f set_ftrace_filter ] && echo | tee set_ftrace_* |
---|
| 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 |
---|
95 | 99 | [ -f set_graph_function ] && echo | tee set_graph_* |
---|
96 | 100 | [ -f stack_trace_filter ] && echo > stack_trace_filter |
---|
97 | 101 | [ -f kprobe_events ] && echo > kprobe_events |
---|
98 | 102 | [ -f uprobe_events ] && echo > uprobe_events |
---|
| 103 | + [ -f synthetic_events ] && echo > synthetic_events |
---|
| 104 | + [ -f snapshot ] && echo 0 > snapshot |
---|
| 105 | + clear_trace |
---|
99 | 106 | enable_tracing |
---|
100 | 107 | } |
---|
| 108 | + |
---|
| 109 | +check_requires() { # Check required files and tracers |
---|
| 110 | + for i in "$@" ; do |
---|
| 111 | + r=${i%:README} |
---|
| 112 | + t=${i%:tracer} |
---|
| 113 | + if [ $t != $i ]; then |
---|
| 114 | + if ! grep -wq $t available_tracers ; then |
---|
| 115 | + echo "Required tracer $t is not configured." |
---|
| 116 | + exit_unsupported |
---|
| 117 | + fi |
---|
| 118 | + elif [ "$r" != "$i" ]; then |
---|
| 119 | + if ! grep -Fq "$r" README ; then |
---|
| 120 | + echo "Required feature pattern \"$r\" is not in README." |
---|
| 121 | + exit_unsupported |
---|
| 122 | + fi |
---|
| 123 | + elif [ ! -e $i ]; then |
---|
| 124 | + echo "Required feature interface $i doesn't exist." |
---|
| 125 | + exit_unsupported |
---|
| 126 | + fi |
---|
| 127 | + done |
---|
| 128 | +} |
---|
| 129 | + |
---|
| 130 | +LOCALHOST=127.0.0.1 |
---|
| 131 | + |
---|
| 132 | +yield() { |
---|
| 133 | + ping $LOCALHOST -c 1 || sleep .001 || usleep 1 || sleep 1 |
---|
| 134 | +} |
---|
| 135 | + |
---|
| 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)` |
---|
| 142 | + |
---|
| 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" |
---|
| 149 | + echo > error_log |
---|
| 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 |
---|
| 155 | +} |
---|