mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-28 21:46:02 -04:00
selftests/bpf: Add unit tests for bpf_arena_alloc/free_pages
Add unit tests for bpf_arena_alloc/free_pages() functionality and bpf_arena_common.h with a set of common helpers and macros that is used in this test and the following patches. Also modify test_loader that didn't support running bpf_prog_type_syscall programs. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20240308010812.89848-13-alexei.starovoitov@gmail.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
204c628730
commit
80a4129fcf
@@ -501,7 +501,7 @@ static bool is_unpriv_capable_map(struct bpf_map *map)
|
||||
}
|
||||
}
|
||||
|
||||
static int do_prog_test_run(int fd_prog, int *retval)
|
||||
static int do_prog_test_run(int fd_prog, int *retval, bool empty_opts)
|
||||
{
|
||||
__u8 tmp_out[TEST_DATA_LEN << 2] = {};
|
||||
__u8 tmp_in[TEST_DATA_LEN] = {};
|
||||
@@ -514,6 +514,10 @@ static int do_prog_test_run(int fd_prog, int *retval)
|
||||
.repeat = 1,
|
||||
);
|
||||
|
||||
if (empty_opts) {
|
||||
memset(&topts, 0, sizeof(struct bpf_test_run_opts));
|
||||
topts.sz = sizeof(struct bpf_test_run_opts);
|
||||
}
|
||||
err = bpf_prog_test_run_opts(fd_prog, &topts);
|
||||
saved_errno = errno;
|
||||
|
||||
@@ -649,7 +653,8 @@ void run_subtest(struct test_loader *tester,
|
||||
}
|
||||
}
|
||||
|
||||
do_prog_test_run(bpf_program__fd(tprog), &retval);
|
||||
do_prog_test_run(bpf_program__fd(tprog), &retval,
|
||||
bpf_program__type(tprog) == BPF_PROG_TYPE_SYSCALL ? true : false);
|
||||
if (retval != subspec->retval && subspec->retval != POINTER_VALUE) {
|
||||
PRINT_FAIL("Unexpected retval: %d != %d\n", retval, subspec->retval);
|
||||
goto tobj_cleanup;
|
||||
|
||||
Reference in New Issue
Block a user