A light skeleton loads a program by a path of its own: its loader program builds the attr and resolves kfunc names when it runs. Build progs/exceptions_cleanup.c as a light skeleton too, and run the case in which every pad runs: a table that lost records or came out at the wrong offsets would fail to load, or run the wrong pads. Signed-off-by: Yonghong Song --- tools/testing/selftests/bpf/Makefile.skel | 2 +- .../bpf/prog_tests/exceptions_cleanup.c | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/Makefile.skel b/tools/testing/selftests/bpf/Makefile.skel index 06e297a17156..d9cbe8ac85b7 100644 --- a/tools/testing/selftests/bpf/Makefile.skel +++ b/tools/testing/selftests/bpf/Makefile.skel @@ -40,7 +40,7 @@ LSKELS_SIGNED := fentry_test.c fexit_test.c atomics.c # Generate both light skeleton and libbpf skeleton for these LSKELS_EXTRA := test_ksyms_module.c test_ksyms_weak.c kfunc_call_test.c \ - kfunc_call_test_subprog.c test_global_percpu_data.c + kfunc_call_test_subprog.c test_global_percpu_data.c exceptions_cleanup.c SKEL_BLACKLIST += $(LSKELS) $(LSKELS_SIGNED) test_static_linked.skel.h-deps := test_static_linked1.bpf.o test_static_linked2.bpf.o diff --git a/tools/testing/selftests/bpf/prog_tests/exceptions_cleanup.c b/tools/testing/selftests/bpf/prog_tests/exceptions_cleanup.c index 76fdb3355420..b8581716bbd4 100644 --- a/tools/testing/selftests/bpf/prog_tests/exceptions_cleanup.c +++ b/tools/testing/selftests/bpf/prog_tests/exceptions_cleanup.c @@ -6,6 +6,7 @@ #include "exceptions_cleanup_fail.skel.h" #include "exceptions_cleanup_shapes.skel.h" #include "exceptions_cleanup_tracing.skel.h" +#include "exceptions_cleanup.lskel.h" /* foo3 unwound: every frame that has a pad ran it. */ #define PADS_FOO3_UNWOUND \ @@ -89,6 +90,33 @@ static void test_tracing(struct exceptions_cleanup *tgt) exceptions_cleanup_tracing__destroy(skel); } +static void test_light_skeleton(void) +{ + struct exceptions_cleanup_lskel *skel; + __u64 ctx = 0; + int err; + + LIBBPF_OPTS(bpf_test_run_opts, topts, + .ctx_in = &ctx, + .ctx_size_in = sizeof(ctx), + ); + + skel = exceptions_cleanup_lskel__open_and_load(); + if (!ASSERT_OK_PTR(skel, "light open_and_load")) + return; + + /* foo3 unwinds, so every pad runs: the whole table has to arrive. */ + skel->bss->input = 101; + err = bpf_prog_test_run_opts(skel->progs.entry.prog_fd, &topts); + if (!ASSERT_OK(err, "run")) + goto out; + ASSERT_EQ(topts.retval, 0, "retval"); + ASSERT_EQ(skel->bss->pads_ran, PADS_FOO3_UNWOUND | RAN_BUMP, + "pads_ran"); +out: + exceptions_cleanup_lskel__destroy(skel); +} + void test_exceptions_cleanup(void) { char log[8192] = {}; @@ -137,6 +165,9 @@ void test_exceptions_cleanup(void) exceptions_cleanup__destroy(skel); + if (test__start_subtest("light_skeleton")) + test_light_skeleton(); + RUN_TESTS(exceptions_cleanup_fail); RUN_TESTS(exceptions_cleanup_shapes); } -- 2.53.0-Meta