Skip to content

Commit 3908b6b

Browse files
hcahcarostedt
authored andcommitted
selftests/ftrace: Let fprobe test consider already enabled functions
The fprobe test fails on Fedora 41 since the fprobe test assumption that the number of enabled_functions is zero before the test starts is not necessarily true. Some user space tools, like systemd, add BPF programs that attach to functions. Those will show up in the enabled_functions table and must be taken into account by the fprobe test. Therefore count the number of lines of enabled_functions before tests start, and use that as base when comparing expected results. 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/20250226142703.910860-1-hca@linux.ibm.com Fixes: e85c5e9 ("selftests/ftrace: Update fprobe test to check enabled_functions file") Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 6f86bde commit 3908b6b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,24 @@ PLACE=$FUNCTION_FORK
1010
PLACE2="kmem_cache_free"
1111
PLACE3="schedule_timeout"
1212

13+
# Some functions may have BPF programs attached, therefore
14+
# count already enabled_functions before tests start
15+
ocnt=`cat enabled_functions | wc -l`
16+
1317
echo "f:myevent1 $PLACE" >> dynamic_events
1418

1519
# Make sure the event is attached and is the only one
1620
grep -q $PLACE enabled_functions
1721
cnt=`cat enabled_functions | wc -l`
18-
if [ $cnt -ne 1 ]; then
22+
if [ $cnt -ne $((ocnt + 1)) ]; then
1923
exit_fail
2024
fi
2125

2226
echo "f:myevent2 $PLACE%return" >> dynamic_events
2327

2428
# It should till be the only attached function
2529
cnt=`cat enabled_functions | wc -l`
26-
if [ $cnt -ne 1 ]; then
30+
if [ $cnt -ne $((ocnt + 1)) ]; then
2731
exit_fail
2832
fi
2933

@@ -32,7 +36,7 @@ echo "f:myevent3 $PLACE2" >> dynamic_events
3236

3337
grep -q $PLACE2 enabled_functions
3438
cnt=`cat enabled_functions | wc -l`
35-
if [ $cnt -ne 2 ]; then
39+
if [ $cnt -ne $((ocnt + 2)) ]; then
3640
exit_fail
3741
fi
3842

@@ -49,31 +53,31 @@ grep -q myevent1 dynamic_events
4953

5054
# should still have 2 left
5155
cnt=`cat enabled_functions | wc -l`
52-
if [ $cnt -ne 2 ]; then
56+
if [ $cnt -ne $((ocnt + 2)) ]; then
5357
exit_fail
5458
fi
5559

5660
echo > dynamic_events
5761

5862
# Should have none left
5963
cnt=`cat enabled_functions | wc -l`
60-
if [ $cnt -ne 0 ]; then
64+
if [ $cnt -ne $ocnt ]; then
6165
exit_fail
6266
fi
6367

6468
echo "f:myevent4 $PLACE" >> dynamic_events
6569

6670
# Should only have one enabled
6771
cnt=`cat enabled_functions | wc -l`
68-
if [ $cnt -ne 1 ]; then
72+
if [ $cnt -ne $((ocnt + 1)) ]; then
6973
exit_fail
7074
fi
7175

7276
echo > dynamic_events
7377

7478
# Should have none left
7579
cnt=`cat enabled_functions | wc -l`
76-
if [ $cnt -ne 0 ]; then
80+
if [ $cnt -ne $ocnt ]; then
7781
exit_fail
7882
fi
7983

0 commit comments

Comments
 (0)