selftests/bpf: prog_tests entry point for migrated test_verifier tests
prog_tests/verifier.c would be used as a host for verifier/*.c tests migrated to use inline assembly and run from test_progs. The run_test_aux() function mimics the test_verifier behavior dropping CAP_SYS_ADMIN upon entry. Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/r/20230325025524.144043-6-eddyz87@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
19a8e06f5f
commit
55108621a3
29
tools/testing/selftests/bpf/prog_tests/verifier.c
Normal file
29
tools/testing/selftests/bpf/prog_tests/verifier.c
Normal file
@ -0,0 +1,29 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
#include <test_progs.h>
|
||||
|
||||
#include "cap_helpers.h"
|
||||
|
||||
__maybe_unused
|
||||
static void run_tests_aux(const char *skel_name, skel_elf_bytes_fn elf_bytes_factory)
|
||||
{
|
||||
struct test_loader tester = {};
|
||||
__u64 old_caps;
|
||||
int err;
|
||||
|
||||
/* test_verifier tests are executed w/o CAP_SYS_ADMIN, do the same here */
|
||||
err = cap_disable_effective(1ULL << CAP_SYS_ADMIN, &old_caps);
|
||||
if (err) {
|
||||
PRINT_FAIL("failed to drop CAP_SYS_ADMIN: %i, %s\n", err, strerror(err));
|
||||
return;
|
||||
}
|
||||
|
||||
test_loader__run_subtests(&tester, skel_name, elf_bytes_factory);
|
||||
test_loader_fini(&tester);
|
||||
|
||||
err = cap_enable_effective(old_caps, NULL);
|
||||
if (err)
|
||||
PRINT_FAIL("failed to restore CAP_SYS_ADMIN: %i, %s\n", err, strerror(err));
|
||||
}
|
||||
|
||||
#define RUN(skel) run_tests_aux(#skel, skel##__elf_bytes)
|
Loading…
x
Reference in New Issue
Block a user