On Sun, Oct 9, 2022 at 3:01 PM Jiri Olsa <jolsa@xxxxxxxxxx> wrote: > > Adding test that makes sure the kernel module won't be removed > if there's kprobe multi link defined on top of it. > > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> Acked-by: Song Liu <song@xxxxxxxxxx> > --- > tools/testing/selftests/bpf/prog_tests/module_attach.c | 7 +++++++ > tools/testing/selftests/bpf/progs/test_module_attach.c | 6 ++++++ > 2 files changed, 13 insertions(+) > > diff --git a/tools/testing/selftests/bpf/prog_tests/module_attach.c b/tools/testing/selftests/bpf/prog_tests/module_attach.c > index 6d0e50dcf47c..7fc01ff490db 100644 > --- a/tools/testing/selftests/bpf/prog_tests/module_attach.c > +++ b/tools/testing/selftests/bpf/prog_tests/module_attach.c > @@ -103,6 +103,13 @@ void test_module_attach(void) > ASSERT_ERR(delete_module("bpf_testmod", 0), "delete_module"); > bpf_link__destroy(link); > > + link = bpf_program__attach(skel->progs.kprobe_multi); > + if (!ASSERT_OK_PTR(link, "attach_kprobe_multi")) > + goto cleanup; > + > + ASSERT_ERR(delete_module("bpf_testmod", 0), "delete_module"); > + bpf_link__destroy(link); > + > cleanup: > test_module_attach__destroy(skel); > } > diff --git a/tools/testing/selftests/bpf/progs/test_module_attach.c b/tools/testing/selftests/bpf/progs/test_module_attach.c > index 08628afedb77..8a1b50f3a002 100644 > --- a/tools/testing/selftests/bpf/progs/test_module_attach.c > +++ b/tools/testing/selftests/bpf/progs/test_module_attach.c > @@ -110,4 +110,10 @@ int BPF_PROG(handle_fmod_ret, > return 0; /* don't override the exit code */ > } > > +SEC("kprobe.multi/bpf_testmod_test_read") > +int BPF_PROG(kprobe_multi) > +{ > + return 0; > +} > + > char _license[] SEC("license") = "GPL"; > -- > 2.37.3 >