On Sun, Oct 9, 2022 at 3:00 PM Jiri Olsa <jolsa@xxxxxxxxxx> wrote: > > Adding 3 bpf_testmod_fentry_* functions to have a way to test > kprobe multi link on kernel module. They follow bpf_fentry_test* > functions prototypes/code. > > Adding equivalent functions to all bpf_fentry_test* does not > seems necessary at the moment, could be added later. > > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> Acked-by: Song Liu <song@xxxxxxxxxx> > --- > .../selftests/bpf/bpf_testmod/bpf_testmod.c | 24 +++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c > index a6021d6117b5..5085fea3cac5 100644 > --- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c > +++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c > @@ -128,6 +128,23 @@ __weak noinline struct file *bpf_testmod_return_ptr(int arg) > } > } > > +noinline int bpf_testmod_fentry_test1(int a) > +{ > + return a + 1; > +} > + > +noinline int bpf_testmod_fentry_test2(int a, u64 b) > +{ > + return a + b; > +} > + > +noinline int bpf_testmod_fentry_test3(char a, int b, u64 c) > +{ > + return a + b + c; > +} > + > +int bpf_testmod_fentry_ok; > + > noinline ssize_t > bpf_testmod_test_read(struct file *file, struct kobject *kobj, > struct bin_attribute *bin_attr, > @@ -167,6 +184,13 @@ bpf_testmod_test_read(struct file *file, struct kobject *kobj, > return snprintf(buf, len, "%d\n", writable.val); > } > > + if (bpf_testmod_fentry_test1(1) != 2 || > + bpf_testmod_fentry_test2(2, 3) != 5 || > + bpf_testmod_fentry_test3(4, 5, 6) != 15) > + goto out; > + > + bpf_testmod_fentry_ok = 1; > +out: > return -EIO; /* always fail */ > } > EXPORT_SYMBOL(bpf_testmod_test_read); > -- > 2.37.3 >