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 check_filter_file set_ftrace_filter
23 if [ ! -f options/function-fork ]; then
25 echo "no option for function-fork found. Option will not be tested."
28 read PID _ < /proc/self/stat
30 if [ $do_function_fork -eq 1 ]; then
31 # default value of function-fork option
32 orig_value=`grep function-fork trace_options`
36 if [ $do_function_fork -eq 0 ]; then
40 echo $orig_value > trace_options
52 echo do_execve* > set_ftrace_filter
53 echo *do_fork >> set_ftrace_filter
55 echo $PID > set_ftrace_pid
56 echo function > current_tracer
58 if [ $do_function_fork -eq 1 ]; then
59 # don't allow children to be traced
60 echo nofunction-fork > trace_options
66 count_pid=`cat trace | grep -v ^# | grep $PID | wc -l`
67 count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l`
69 # count_other should be 0
70 if [ $count_pid -eq 0 -o $count_other -ne 0 ]; then
71 fail "PID filtering not working?"
77 if [ $do_function_fork -eq 0 ]; then
81 # allow children to be traced
82 echo function-fork > trace_options
87 count_pid=`cat trace | grep -v ^# | grep $PID | wc -l`
88 count_other=`cat trace | grep -v ^# | grep -v $PID | wc -l`
90 # count_other should NOT be 0
91 if [ $count_pid -eq 0 -o $count_other -eq 0 ]; then
92 fail "PID filtering not following fork?"