Skip to content

Commit 436669a

Browse files
olsajiriKernel Patches Daemon
authored and
Kernel Patches Daemon
committed
selftests/bpf: Add serial_test_kprobe_multi_bench_attach_kernel/module tests
Add bench test for module portion of the symbols as well. # ./test_progs -v -t kprobe_multi_bench_attach_module bpf_testmod.ko is already unloaded. Loading bpf_testmod.ko... Successfully loaded bpf_testmod.ko. test_kprobe_multi_bench_attach:PASS:get_syms 0 nsec test_kprobe_multi_bench_attach:PASS:kprobe_multi_empty__open_and_load 0 nsec test_kprobe_multi_bench_attach:PASS:bpf_program__attach_kprobe_multi_opts 0 nsec test_kprobe_multi_bench_attach: found 26620 functions test_kprobe_multi_bench_attach: attached in 0.182s test_kprobe_multi_bench_attach: detached in 0.082s #96 kprobe_multi_bench_attach_module:OK Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED Successfully unloaded bpf_testmod.ko. It's useful for testing kprobe multi link modules resolving. Acked-by: Song Liu <song@kernel.org> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
1 parent 78eeea8 commit 436669a

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c

+14-5
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ static bool symbol_equal(long key1, long key2, void *ctx __maybe_unused)
322322
return strcmp((const char *) key1, (const char *) key2) == 0;
323323
}
324324

325-
static int get_syms(char ***symsp, size_t *cntp)
325+
static int get_syms(char ***symsp, size_t *cntp, bool kernel)
326326
{
327327
size_t cap = 0, cnt = 0, i;
328328
char *name = NULL, **syms = NULL;
@@ -349,8 +349,9 @@ static int get_syms(char ***symsp, size_t *cntp)
349349
}
350350

351351
while (fgets(buf, sizeof(buf), f)) {
352-
/* skip modules */
353-
if (strchr(buf, '['))
352+
if (kernel && strchr(buf, '['))
353+
continue;
354+
if (!kernel && !strchr(buf, '['))
354355
continue;
355356

356357
free(name);
@@ -404,7 +405,7 @@ static int get_syms(char ***symsp, size_t *cntp)
404405
return err;
405406
}
406407

407-
void serial_test_kprobe_multi_bench_attach(void)
408+
static void test_kprobe_multi_bench_attach(bool kernel)
408409
{
409410
LIBBPF_OPTS(bpf_kprobe_multi_opts, opts);
410411
struct kprobe_multi_empty *skel = NULL;
@@ -415,7 +416,7 @@ void serial_test_kprobe_multi_bench_attach(void)
415416
char **syms = NULL;
416417
size_t cnt = 0, i;
417418

418-
if (!ASSERT_OK(get_syms(&syms, &cnt), "get_syms"))
419+
if (!ASSERT_OK(get_syms(&syms, &cnt, kernel), "get_syms"))
419420
return;
420421

421422
skel = kprobe_multi_empty__open_and_load();
@@ -453,6 +454,14 @@ void serial_test_kprobe_multi_bench_attach(void)
453454
}
454455
}
455456

457+
void serial_test_kprobe_multi_bench_attach(void)
458+
{
459+
if (test__start_subtest("kernel"))
460+
test_kprobe_multi_bench_attach(true);
461+
if (test__start_subtest("modules"))
462+
test_kprobe_multi_bench_attach(false);
463+
}
464+
456465
void test_kprobe_multi_test(void)
457466
{
458467
if (!ASSERT_OK(load_kallsyms(), "load_kallsyms"))

0 commit comments

Comments
 (0)