Commit bb32dd2c authored by Martin Kelly's avatar Martin Kelly Committed by Andrii Nakryiko

selftests/bpf: Add tests for ring__size

Add tests for the new API ring__size.
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-11-martin.kelly@crowdstrike.com
parent e79abf71
...@@ -92,7 +92,7 @@ static void ringbuf_subtest(void) ...@@ -92,7 +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;
unsigned long avail_data, cons_pos, prod_pos; unsigned long avail_data, ring_size, cons_pos, prod_pos;
skel = test_ringbuf_lskel__open(); skel = test_ringbuf_lskel__open();
if (CHECK(!skel, "skel_open", "skeleton open failed\n")) if (CHECK(!skel, "skel_open", "skeleton open failed\n"))
...@@ -187,6 +187,8 @@ static void ringbuf_subtest(void) ...@@ -187,6 +187,8 @@ static void ringbuf_subtest(void)
*/ */
avail_data = ring__avail_data_size(ring); avail_data = ring__avail_data_size(ring);
ASSERT_EQ(avail_data, 3 * rec_sz, "ring_avail_size"); ASSERT_EQ(avail_data, 3 * rec_sz, "ring_avail_size");
ring_size = ring__size(ring);
ASSERT_EQ(ring_size, page_size, "ring_ring_size");
cons_pos = ring__consumer_pos(ring); cons_pos = ring__consumer_pos(ring);
ASSERT_EQ(cons_pos, 0, "ring_cons_pos"); ASSERT_EQ(cons_pos, 0, "ring_cons_pos");
prod_pos = ring__producer_pos(ring); prod_pos = ring__producer_pos(ring);
......
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