diff options
author | Yafang Shao <laoar.shao@gmail.com> | 2025-03-18 14:44:47 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2025-03-19 05:07:18 +0300 |
commit | be16ddeaae960f8d03472e8b62aae50fc469f1c9 (patch) | |
tree | f99c75ef5e0aa594a31a2d5376db8512df9620aa | |
parent | cfe816d469dce9c0864062cf65dd7b3c42adc6f8 (diff) | |
download | linux-be16ddeaae960f8d03472e8b62aae50fc469f1c9.tar.xz |
selftests/bpf: Add selftest for attaching fexit to __noreturn functions
The reuslt:
$ tools/testing/selftests/bpf/test_progs --name=fexit_noreturns
#99/1 fexit_noreturns/noreturns:OK
#99 fexit_noreturns:OK
Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Link: https://lore.kernel.org/r/20250318114447.75484-3-laoar.shao@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
-rw-r--r-- | tools/testing/selftests/bpf/prog_tests/fexit_noreturns.c | 9 | ||||
-rw-r--r-- | tools/testing/selftests/bpf/progs/fexit_noreturns.c | 15 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/fexit_noreturns.c b/tools/testing/selftests/bpf/prog_tests/fexit_noreturns.c new file mode 100644 index 000000000000..568d3aa48a78 --- /dev/null +++ b/tools/testing/selftests/bpf/prog_tests/fexit_noreturns.c @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <test_progs.h> +#include "fexit_noreturns.skel.h" + +void test_fexit_noreturns(void) +{ + RUN_TESTS(fexit_noreturns); +} diff --git a/tools/testing/selftests/bpf/progs/fexit_noreturns.c b/tools/testing/selftests/bpf/progs/fexit_noreturns.c new file mode 100644 index 000000000000..54654539f550 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/fexit_noreturns.c @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/bpf.h> +#include <bpf/bpf_helpers.h> +#include <bpf/bpf_tracing.h> +#include "bpf_misc.h" + +char _license[] SEC("license") = "GPL"; + +SEC("fexit/do_exit") +__failure __msg("Attaching fexit/fmod_ret to __noreturn functions is rejected.") +int BPF_PROG(noreturns) +{ + return 0; +} |