Commit 6e38ba52 authored by Martin Kelly's avatar Martin Kelly Committed by Andrii Nakryiko

selftests/bpf: Add tests for ring__map_fd

Add tests for the new API ring__map_fd.
Signed-off-by: default avatarMartin Kelly <martin.kelly@crowdstrike.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20230925215045.2375758-13-martin.kelly@crowdstrike.com
parent ae769390
...@@ -92,6 +92,7 @@ static void ringbuf_subtest(void) ...@@ -92,6 +92,7 @@ static void ringbuf_subtest(void)
int page_size = getpagesize(); int page_size = getpagesize();
void *mmap_ptr, *tmp_ptr; void *mmap_ptr, *tmp_ptr;
struct ring *ring; struct ring *ring;
int map_fd;
unsigned long avail_data, ring_size, cons_pos, prod_pos; unsigned long avail_data, ring_size, cons_pos, prod_pos;
skel = test_ringbuf_lskel__open(); skel = test_ringbuf_lskel__open();
...@@ -168,6 +169,9 @@ static void ringbuf_subtest(void) ...@@ -168,6 +169,9 @@ static void ringbuf_subtest(void)
if (!ASSERT_OK_PTR(ring, "ring_buffer__ring_idx_0")) if (!ASSERT_OK_PTR(ring, "ring_buffer__ring_idx_0"))
goto cleanup; goto cleanup;
map_fd = ring__map_fd(ring);
ASSERT_EQ(map_fd, skel->maps.ringbuf.map_fd, "ring_map_fd");
/* 2 submitted + 1 discarded records */ /* 2 submitted + 1 discarded records */
CHECK(skel->bss->avail_data != 3 * rec_sz, CHECK(skel->bss->avail_data != 3 * rec_sz,
"err_avail_size", "exp %ld, got %ld\n", "err_avail_size", "exp %ld, got %ld\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment