On Mon, Feb 7, 2022 at 6:21 AM Alan Maguire <alan.maguire@xxxxxxxxxx> wrote: > > On Sat, 5 Feb 2022, Andrii Nakryiko wrote: > > > Add a selftest validating various aspects of libbpf's handling of custom > > SEC() handlers. It also demonstrates how libraries can ensure very early > > callbacks registration and unregistration using > > __attribute__((constructor))/__attribute__((destructor)) functions. > > > > Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > > A few suggestions here for additional tests, but > > Reviewed-by: Alan Maguire <alan.maguire@xxxxxxxxxx> > > Should we override a default attach method to demonstrate that > custom handlers can do that? Or would that break parallel > testing mode? Yep, I should. I was a bit lazy and wanted some feedback before adding more tests. I'll add some kprobe overload to auto-attach to sys_enter or something like that. If I do that during the test (not in constructor/destructor), it won't interfere with parallel tests (they each run in a different process). > > Also might be good to have a test that captured the difference > in auto-attach behaviour between a skeleton attach and an > explicit bpf_prog__attach(); running the bpf_prog__attach on the > SEC("xyz") should result in -EOPNOTSUPP. Sure, can add that as well. > > > > --- > > .../bpf/prog_tests/custom_sec_handlers.c | 136 ++++++++++++++++++ > > .../bpf/progs/test_custom_sec_handlers.c | 51 +++++++ > > 2 files changed, 187 insertions(+) > > create mode 100644 tools/testing/selftests/bpf/prog_tests/custom_sec_handlers.c > > create mode 100644 tools/testing/selftests/bpf/progs/test_custom_sec_handlers.c > > [...]