Skip to content

Commit a43796b

Browse files
Yonghong Songanakryiko
authored andcommitted
selftests/bpf: Add a test for kprobe multi with unique_match
Add a kprobe multi subtest to test kprobe multi unique_match option. Signed-off-by: Yonghong Song <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent e2b0bda commit a43796b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,31 @@ static void test_session_cookie_skel_api(void)
397397
kprobe_multi_session_cookie__destroy(skel);
398398
}
399399

400+
static void test_unique_match(void)
401+
{
402+
LIBBPF_OPTS(bpf_kprobe_multi_opts, opts);
403+
struct kprobe_multi *skel = NULL;
404+
struct bpf_link *link = NULL;
405+
406+
skel = kprobe_multi__open_and_load();
407+
if (!ASSERT_OK_PTR(skel, "kprobe_multi__open_and_load"))
408+
return;
409+
410+
opts.unique_match = true;
411+
skel->bss->pid = getpid();
412+
link = bpf_program__attach_kprobe_multi_opts(skel->progs.test_kprobe_manual,
413+
"bpf_fentry_test*", &opts);
414+
if (!ASSERT_ERR_PTR(link, "bpf_program__attach_kprobe_multi_opts"))
415+
bpf_link__destroy(link);
416+
417+
link = bpf_program__attach_kprobe_multi_opts(skel->progs.test_kprobe_manual,
418+
"bpf_fentry_test8*", &opts);
419+
if (ASSERT_OK_PTR(link, "bpf_program__attach_kprobe_multi_opts"))
420+
bpf_link__destroy(link);
421+
422+
kprobe_multi__destroy(skel);
423+
}
424+
400425
static size_t symbol_hash(long key, void *ctx __maybe_unused)
401426
{
402427
return str_hash((const char *) key);
@@ -765,5 +790,7 @@ void test_kprobe_multi_test(void)
765790
test_session_skel_api();
766791
if (test__start_subtest("session_cookie"))
767792
test_session_cookie_skel_api();
793+
if (test__start_subtest("unique_match"))
794+
test_unique_match();
768795
RUN_TESTS(kprobe_multi_verifier);
769796
}

0 commit comments

Comments
 (0)