2 # SPDX-License-Identifier: GPL-2.0
3 # description: ftrace - function pid filters
6 # Make sure that function pid matching filter works.
7 # Also test it on an instance directory
9 if ! grep -q function available_tracers; then
10 echo "no function tracer configured"
14 if [ ! -f set_ftrace_pid ]; then
15 echo "set_ftrace_pid not found? Is function tracer not set?"
19 if [ ! -f set_ftrace_filter ]; then
20 echo "set_ftrace_filter not found? Is function tracer not set?"
26 if [ ! -f options/function-fork ]; then
28 echo "no option for function-fork found. Option will not be tested."
31 read PID _ < /proc/self/stat
33 if [ $do_function_fork -eq 1 ]; then
34 # default value of function-fork option
35 orig_value=`grep function-fork trace_options`
39 if [ $do_function_fork -eq 0 ]; then
43 echo $orig_value > trace_options
55 echo do_execve* > set_ftrace_filter
56 echo *do_fork >> set_ftrace_filter
58 echo $PID > set_ftrace_pid
59 echo function > current_tracer
61 if [ $do_function_fork -eq 1 ]; then
62 # don't allow children to be traced
63 echo nofunction-fork > trace_options
69 count_pid=`cat trace | grep -v ^# | grep $PID | wc -l`
70 count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l`
72 # count_other should be 0
73 if [ $count_pid -eq 0 -o $count_other -ne 0 ]; then
74 fail "PID filtering not working?"
80 if [ $do_function_fork -eq 0 ]; then
84 # allow children to be traced
85 echo function-fork > trace_options
90 count_pid=`cat trace | grep -v ^# | grep $PID | wc -l`
91 count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l`
93 # count_other should NOT be 0
94 if [ $count_pid -eq 0 -o $count_other -eq 0 ]; then
95 fail "PID filtering not following fork?"