OSDN Git Service

selftests/bpf: Guess function end for test_get_branch_snapshot
authorSong Liu <songliubraving@fb.com>
Fri, 22 Oct 2021 23:48:14 +0000 (16:48 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 26 Oct 2021 04:43:05 +0000 (21:43 -0700)
commit20d1b54a52bd9a1d5d23a45dab75993ce2f1d617
treec9e04e910758f076c94c445121a09df0da51c3cb
parentb4e87072762d063f9c20ba0ab2120e1910fa379f
selftests/bpf: Guess function end for test_get_branch_snapshot

Function in modules could appear in /proc/kallsyms in random order.

ffffffffa02608a0 t bpf_testmod_loop_test
ffffffffa02600c0 t __traceiter_bpf_testmod_test_writable_bare
ffffffffa0263b60 d __tracepoint_bpf_testmod_test_write_bare
ffffffffa02608c0 T bpf_testmod_test_read
ffffffffa0260d08 t __SCT__tp_func_bpf_testmod_test_writable_bare
ffffffffa0263300 d __SCK__tp_func_bpf_testmod_test_read
ffffffffa0260680 T bpf_testmod_test_write
ffffffffa0260860 t bpf_testmod_test_mod_kfunc

Therefore, we cannot reliably use kallsyms_find_next() to find the end of
a function. Replace it with a simple guess (start + 128). This is good
enough for this test.

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211022234814.318457-1-songliubraving@fb.com
tools/testing/selftests/bpf/prog_tests/get_branch_snapshot.c
tools/testing/selftests/bpf/trace_helpers.c
tools/testing/selftests/bpf/trace_helpers.h