mirror of
https://github.com/torvalds/linux.git
synced 2026-06-03 12:03:54 +02:00
selftests/bpf: Add cookies check for raw_tp fill_link_info test
Adding tests for getting cookie with fill_link_info for raw_tp. Signed-off-by: Tao Chen <chen.dylane@linux.dev> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/bpf/20250603154309.3063644-2-chen.dylane@linux.dev
This commit is contained in:
parent
2fe1c59347
commit
25a0d04d38
|
|
@ -635,10 +635,29 @@ static void tp_btf_subtest(struct test_bpf_cookie *skel)
|
|||
bpf_link__destroy(link);
|
||||
}
|
||||
|
||||
static int verify_raw_tp_link_info(int fd, u64 cookie)
|
||||
{
|
||||
struct bpf_link_info info;
|
||||
int err;
|
||||
u32 len = sizeof(info);
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
err = bpf_link_get_info_by_fd(fd, &info, &len);
|
||||
if (!ASSERT_OK(err, "get_link_info"))
|
||||
return -1;
|
||||
|
||||
if (!ASSERT_EQ(info.type, BPF_LINK_TYPE_RAW_TRACEPOINT, "link_type"))
|
||||
return -1;
|
||||
|
||||
ASSERT_EQ(info.raw_tracepoint.cookie, cookie, "raw_tp_cookie");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void raw_tp_subtest(struct test_bpf_cookie *skel)
|
||||
{
|
||||
__u64 cookie;
|
||||
int prog_fd, link_fd = -1;
|
||||
int err, prog_fd, link_fd = -1;
|
||||
struct bpf_link *link = NULL;
|
||||
LIBBPF_OPTS(bpf_raw_tp_opts, raw_tp_opts);
|
||||
LIBBPF_OPTS(bpf_raw_tracepoint_opts, opts);
|
||||
|
|
@ -656,6 +675,11 @@ static void raw_tp_subtest(struct test_bpf_cookie *skel)
|
|||
goto cleanup;
|
||||
|
||||
usleep(1); /* trigger */
|
||||
|
||||
err = verify_raw_tp_link_info(link_fd, cookie);
|
||||
if (!ASSERT_OK(err, "verify_raw_tp_link_info"))
|
||||
goto cleanup;
|
||||
|
||||
close(link_fd); /* detach */
|
||||
link_fd = -1;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user