]>
git.ipfire.org Git - thirdparty/linux.git/blob - tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc
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`
38 if [ $do_function_fork -eq 0 ]; then
42 echo $orig_value > trace_options
54 echo do_execve
* > set_ftrace_filter
55 echo *do_fork
>> set_ftrace_filter
57 echo $PID > set_ftrace_pid
58 echo function > current_tracer
60 if [ $do_function_fork -eq 1 ]; then
61 # don't allow children to be traced
62 echo nofunction-fork
> trace_options
68 count_pid
=`cat trace | grep -v ^# | grep $PID | wc -l`
69 count_other
=`cat trace | grep -v ^# | grep -v $PID | wc -l`
71 # count_other should be 0
72 if [ $count_pid -eq 0 -o $count_other -ne 0 ]; then
73 fail
"PID filtering not working?"
79 if [ $do_function_fork -eq 0 ]; then
83 # allow children to be traced
84 echo function-fork
> trace_options
89 count_pid
=`cat trace | grep -v ^# | grep $PID | wc -l`
90 count_other
=`cat trace | grep -v ^# | grep -v $PID | wc -l`
92 # count_other should NOT be 0
93 if [ $count_pid -eq 0 -o $count_other -eq 0 ]; then
94 fail
"PID filtering not following fork?"