2 # SPDX-License-Identifier: GPL-2.0
3 # description: ftrace - function pid filters
5 # Make sure that function pid matching filter works.
6 # Also test it on an instance directory
8 if ! grep -q function available_tracers; then
9 echo "no function tracer configured"
13 if [ ! -f set_ftrace_pid ]; then
14 echo "set_ftrace_pid not found? Is function tracer not set?"
18 if [ ! -f set_ftrace_filter ]; then
19 echo "set_ftrace_filter not found? Is function tracer not set?"
25 if [ ! -f options/function-fork ]; then
27 echo "no option for function-fork found. Option will not be tested."
30 read PID _ < /proc/self/stat
32 if [ $do_function_fork -eq 1 ]; then
33 # default value of function-fork option
34 orig_value=`grep function-fork trace_options`
41 echo > set_ftrace_filter
44 if [ $do_function_fork -eq 0 ]; then
48 echo $orig_value > trace_options
58 ping localhost -c 1 || sleep .001 || usleep 1 || sleep 1
64 echo do_execve* > set_ftrace_filter
65 echo *do_fork >> set_ftrace_filter
67 echo $PID > set_ftrace_pid
68 echo function > current_tracer
70 if [ $do_function_fork -eq 1 ]; then
71 # don't allow children to be traced
72 echo nofunction-fork > trace_options
78 count_pid=`cat trace | grep -v ^# | grep $PID | wc -l`
79 count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l`
81 # count_other should be 0
82 if [ $count_pid -eq 0 -o $count_other -ne 0 ]; then
83 fail "PID filtering not working?"
89 if [ $do_function_fork -eq 0 ]; then
93 # allow children to be traced
94 echo function-fork > trace_options
99 count_pid=`cat trace | grep -v ^# | grep $PID | wc -l`
100 count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l`
102 # count_other should NOT be 0
103 if [ $count_pid -eq 0 -o $count_other -eq 0 ]; then
104 fail "PID filtering not following fork?"