diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2023-03-01 11:13:42 -0800 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2023-03-01 11:13:43 -0800 |
commit | d69b5a90e17dca24aad3311c6a020cc692d8711c (patch) | |
tree | f5c108a99370d8163a38b36802eb2aed6b7f92e3 /tools/testing/selftests/bpf/progs/bpf_misc.h | |
parent | 07e2193f106d61332e549b4e31d95da38261e718 (diff) | |
parent | 35cbf7f9156893f55b885f6fc678b2ab8b0d8918 (diff) |
Merge branch 'selftests/bpf: support custom per-test flags and multiple expected messages'
Eduard Zingerman says:
====================
This patch allows to specify program flags and multiple verifier log
messages for the test_loader kind of tests. For example:
tools/testing/selftets/bpf/progs/foobar.c:
SEC("tc")
__success __log_level(7)
__msg("first message")
__msg("next message")
__flag(BPF_F_ANY_ALIGNMENT)
int buz(struct __sk_buff *skb)
{ ... }
It was developed by Andrii Nakryiko ([1]), I reused it in a
"test_verifier tests migration to inline assembly" patch series ([2]),
but the series is currently stuck on my side.
Andrii asked to spin this particular patch separately ([3]).
[1] https://lore.kernel.org/bpf/CAEf4BzZH0ZxorCi7nPDbRqSK9f+410RooNwNJGwfw8=0a5i1nw@mail.gmail.com/
[2] https://lore.kernel.org/bpf/20230123145148.2791939-1-eddyz87@gmail.com/
[3] https://lore.kernel.org/bpf/20230123145148.2791939-1-eddyz87@gmail.com/T/#m52e806c5a679a2aa8f484d011be7ec105939127a
====================
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/progs/bpf_misc.h')
-rw-r--r-- | tools/testing/selftests/bpf/progs/bpf_misc.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/bpf_misc.h b/tools/testing/selftests/bpf/progs/bpf_misc.h index 14e28f991451..f704885aa534 100644 --- a/tools/testing/selftests/bpf/progs/bpf_misc.h +++ b/tools/testing/selftests/bpf/progs/bpf_misc.h @@ -2,10 +2,33 @@ #ifndef __BPF_MISC_H__ #define __BPF_MISC_H__ +/* This set of attributes controls behavior of the + * test_loader.c:test_loader__run_subtests(). + * + * __msg Message expected to be found in the verifier log. + * Multiple __msg attributes could be specified. + * + * __success Expect program load success in privileged mode. + * + * __failure Expect program load failure in privileged mode. + * + * __log_level Log level to use for the program, numeric value expected. + * + * __flag Adds one flag use for the program, the following values are valid: + * - BPF_F_STRICT_ALIGNMENT; + * - BPF_F_TEST_RND_HI32; + * - BPF_F_TEST_STATE_FREQ; + * - BPF_F_SLEEPABLE; + * - BPF_F_XDP_HAS_FRAGS; + * - A numeric value. + * Multiple __flag attributes could be specified, the final flags + * value is derived by applying binary "or" to all specified values. + */ #define __msg(msg) __attribute__((btf_decl_tag("comment:test_expect_msg=" msg))) #define __failure __attribute__((btf_decl_tag("comment:test_expect_failure"))) #define __success __attribute__((btf_decl_tag("comment:test_expect_success"))) #define __log_level(lvl) __attribute__((btf_decl_tag("comment:test_log_level="#lvl))) +#define __flag(flag) __attribute__((btf_decl_tag("comment:test_prog_flags="#flag))) /* Convenience macro for use with 'asm volatile' blocks */ #define __naked __attribute__((naked)) |