diff options
author | Andrii Nakryiko | 2021-11-10 21:17:58 -0800 |
---|---|---|
committer | Alexei Starovoitov | 2021-11-11 16:44:26 -0800 |
commit | 50dee7078b66d881c62f6177844d625f7ead6003 (patch) | |
tree | a68832f2e9ee4a4c890764fc9d4bb87b11b9b31a /tools/testing/selftests | |
parent | a6ca71583137300f207343d5d950cb1c365ab911 (diff) |
selftests/bpf: Fix bpf_prog_test_load() logic to pass extra log level
After recent refactoring bpf_prog_test_load(), used across multiple
selftests, lost ability to specify extra log_level 1 or 2 (for -vv and
-vvv, respectively). Fix that problem by using bpf_object__load_xattr()
API that supports extra log_level flags. Also restore
BPF_F_TEST_RND_HI32 prog_flags by utilizing new bpf_program__set_extra_flags()
API.
Fixes: f87c1930ac29 ("selftests/bpf: Merge test_stub.c into testing_helpers.c")
Reported-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20211111051758.92283-3-andrii@kernel.org
Diffstat (limited to 'tools/testing/selftests')
-rw-r--r-- | tools/testing/selftests/bpf/testing_helpers.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/testing_helpers.c b/tools/testing/selftests/bpf/testing_helpers.c index ef61d43adfe4..52c2f24e0898 100644 --- a/tools/testing/selftests/bpf/testing_helpers.c +++ b/tools/testing/selftests/bpf/testing_helpers.c @@ -88,6 +88,7 @@ int extra_prog_load_log_flags = 0; int bpf_prog_test_load(const char *file, enum bpf_prog_type type, struct bpf_object **pobj, int *prog_fd) { + struct bpf_object_load_attr attr = {}; struct bpf_object *obj; struct bpf_program *prog; int err; @@ -105,7 +106,11 @@ int bpf_prog_test_load(const char *file, enum bpf_prog_type type, if (type != BPF_PROG_TYPE_UNSPEC) bpf_program__set_type(prog, type); - err = bpf_object__load(obj); + bpf_program__set_extra_flags(prog, BPF_F_TEST_RND_HI32); + + attr.obj = obj; + attr.log_level = extra_prog_load_log_flags; + err = bpf_object__load_xattr(&attr); if (err) goto err_out; |