mirror of
https://github.com/raspberrypi/linux.git
synced 2026-01-03 08:14:12 +00:00
selftests/bpf: Add tests for bpf_dynptr_copy
Add XDP setup type for dynptr tests, enabling testing for non-contiguous buffer. Add 2 tests: - test_dynptr_copy - verify correctness for the fast (contiguous buffer) code path. - test_dynptr_copy_xdp - verifies code paths that handle non-contiguous buffer. Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20250226183201.332713-4-mykyta.yatsenko5@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
committed by
Alexei Starovoitov
parent
daec295a70
commit
064e9aacfd
@@ -10,6 +10,7 @@ enum test_setup_type {
|
||||
SETUP_SYSCALL_SLEEP,
|
||||
SETUP_SKB_PROG,
|
||||
SETUP_SKB_PROG_TP,
|
||||
SETUP_XDP_PROG,
|
||||
};
|
||||
|
||||
static struct {
|
||||
@@ -18,6 +19,8 @@ static struct {
|
||||
} success_tests[] = {
|
||||
{"test_read_write", SETUP_SYSCALL_SLEEP},
|
||||
{"test_dynptr_data", SETUP_SYSCALL_SLEEP},
|
||||
{"test_dynptr_copy", SETUP_SYSCALL_SLEEP},
|
||||
{"test_dynptr_copy_xdp", SETUP_XDP_PROG},
|
||||
{"test_ringbuf", SETUP_SYSCALL_SLEEP},
|
||||
{"test_skb_readonly", SETUP_SKB_PROG},
|
||||
{"test_dynptr_skb_data", SETUP_SKB_PROG},
|
||||
@@ -120,6 +123,24 @@ static void verify_success(const char *prog_name, enum test_setup_type setup_typ
|
||||
|
||||
break;
|
||||
}
|
||||
case SETUP_XDP_PROG:
|
||||
{
|
||||
char data[5000];
|
||||
int err, prog_fd;
|
||||
LIBBPF_OPTS(bpf_test_run_opts, opts,
|
||||
.data_in = &data,
|
||||
.data_size_in = sizeof(data),
|
||||
.repeat = 1,
|
||||
);
|
||||
|
||||
prog_fd = bpf_program__fd(prog);
|
||||
err = bpf_prog_test_run_opts(prog_fd, &opts);
|
||||
|
||||
if (!ASSERT_OK(err, "test_run"))
|
||||
goto cleanup;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_EQ(skel->bss->err, 0, "err");
|
||||
|
||||
Reference in New Issue
Block a user