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: f87c1930ac ("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
This commit is contained in:
Andrii Nakryiko 2021-11-10 21:17:58 -08:00 коммит произвёл Alexei Starovoitov
Родитель a6ca715831
Коммит 50dee7078b
1 изменённых файлов: 6 добавлений и 1 удалений
tools/testing/selftests/bpf

Просмотреть файл

@ -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;