Skip to content

Commit e85c5e9

Browse files
committed
selftests/ftrace: Update fprobe test to check enabled_functions file
A few bugs were found in the fprobe accounting logic along with it using the function graph infrastructure. Update the fprobe selftest to catch those bugs in case they or something similar shows up in the future. The test now checks the enabled_functions file which shows all the functions attached to ftrace or fgraph. When enabling a fprobe, make sure that its corresponding function is also added to that file. Also add two more fprobes to enable to make sure that the fprobe logic works properly with multiple probes. Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Link: https://lore.kernel.org/20250220202055.733001756@goodmis.org Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Tested-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent ca26554 commit e85c5e9

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

tools/testing/selftests/ftrace/test.d/dynevent/add_remove_fprobe.tc

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,38 @@ echo 0 > events/enable
77
echo > dynamic_events
88

99
PLACE=$FUNCTION_FORK
10+
PLACE2="kmem_cache_free"
11+
PLACE3="schedule_timeout"
1012

1113
echo "f:myevent1 $PLACE" >> dynamic_events
14+
15+
# Make sure the event is attached and is the only one
16+
grep -q $PLACE enabled_functions
17+
cnt=`cat enabled_functions | wc -l`
18+
if [ $cnt -ne 1 ]; then
19+
exit_fail
20+
fi
21+
1222
echo "f:myevent2 $PLACE%return" >> dynamic_events
1323

24+
# It should till be the only attached function
25+
cnt=`cat enabled_functions | wc -l`
26+
if [ $cnt -ne 1 ]; then
27+
exit_fail
28+
fi
29+
30+
# add another event
31+
echo "f:myevent3 $PLACE2" >> dynamic_events
32+
33+
grep -q $PLACE2 enabled_functions
34+
cnt=`cat enabled_functions | wc -l`
35+
if [ $cnt -ne 2 ]; then
36+
exit_fail
37+
fi
38+
1439
grep -q myevent1 dynamic_events
1540
grep -q myevent2 dynamic_events
41+
grep -q myevent3 dynamic_events
1642
test -d events/fprobes/myevent1
1743
test -d events/fprobes/myevent2
1844

@@ -21,6 +47,34 @@ echo "-:myevent2" >> dynamic_events
2147
grep -q myevent1 dynamic_events
2248
! grep -q myevent2 dynamic_events
2349

50+
# should still have 2 left
51+
cnt=`cat enabled_functions | wc -l`
52+
if [ $cnt -ne 2 ]; then
53+
exit_fail
54+
fi
55+
2456
echo > dynamic_events
2557

58+
# Should have none left
59+
cnt=`cat enabled_functions | wc -l`
60+
if [ $cnt -ne 0 ]; then
61+
exit_fail
62+
fi
63+
64+
echo "f:myevent4 $PLACE" >> dynamic_events
65+
66+
# Should only have one enabled
67+
cnt=`cat enabled_functions | wc -l`
68+
if [ $cnt -ne 1 ]; then
69+
exit_fail
70+
fi
71+
72+
echo > dynamic_events
73+
74+
# Should have none left
75+
cnt=`cat enabled_functions | wc -l`
76+
if [ $cnt -ne 0 ]; then
77+
exit_fail
78+
fi
79+
2680
clear_trace

0 commit comments

Comments
 (0)