2 # SPDX-License-Identifier: GPL-2.0
3 # description: ftrace - function pid filters
4 # requires: set_ftrace_pid set_ftrace_filter function:tracer
7 # Make sure that function pid matching filter works.
8 # Also test it on an instance directory
12 if [ ! -f options/function-fork ]; then
14 echo "no option for function-fork found. Option will not be tested."
17 read PID _ < /proc/self/stat
19 if [ $do_function_fork -eq 1 ]; then
20 # default value of function-fork option
21 orig_value=`grep function-fork trace_options`
25 if [ $do_function_fork -eq 0 ]; then
29 echo $orig_value > trace_options
41 echo do_execve* > set_ftrace_filter
42 echo *do_fork >> set_ftrace_filter
44 echo $PID > set_ftrace_pid
45 echo function > current_tracer
47 if [ $do_function_fork -eq 1 ]; then
48 # don't allow children to be traced
49 echo nofunction-fork > trace_options
55 count_pid=`cat trace | grep -v ^# | grep $PID | wc -l`
56 count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l`
58 # count_other should be 0
59 if [ $count_pid -eq 0 -o $count_other -ne 0 ]; then
60 fail "PID filtering not working?"
66 if [ $do_function_fork -eq 0 ]; then
70 # allow children to be traced
71 echo function-fork > trace_options
76 count_pid=`cat trace | grep -v ^# | grep $PID | wc -l`
77 count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l`
79 # count_other should NOT be 0
80 if [ $count_pid -eq 0 -o $count_other -eq 0 ]; then
81 fail "PID filtering not following fork?"