Skip to content

Commit

Permalink
zcrx/test: add RQ entries pow2 test
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
  • Loading branch information
isilence committed Aug 1, 2024
1 parent d8cb537 commit 294ae64
Showing 1 changed file with 29 additions and 30 deletions.
59 changes: 29 additions & 30 deletions test/zcrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static int try_register_ifq(struct io_uring_zcrx_ifq_reg *reg)
return ret;
}

static int test_null_rq_entries_reg_struct(void *area)
static int test_rq_setup(void *area)
{
int ret;
struct io_uring_zcrx_area_reg area_reg = {
Expand All @@ -60,7 +60,33 @@ static int test_null_rq_entries_reg_struct(void *area)
};

ret = try_register_ifq(&reg);
return ret ? T_EXIT_PASS : T_EXIT_FAIL;
if (ret != -EINVAL) {
fprintf(stderr, "registered 0 rq entries\n");
return T_EXIT_FAIL;
}

reg.rq_entries = (__u32)-1;

ret = try_register_ifq(&reg);
if (ret != -EINVAL) {
fprintf(stderr, "registered unlimited nr of rq entries\n");
return T_EXIT_FAIL;
}

reg.rq_entries = 7;
ret = try_register_ifq(&reg);
if (ret != 0) {
fprintf(stderr, "ifq registration failed %i\n", ret);
return T_EXIT_FAIL;
}

if (reg.rq_entries == 7) {
fprintf(stderr, "registered non pow2 refill entries %i\n",
reg.rq_entries);
return T_EXIT_FAIL;
}

return T_EXIT_PASS;
}

static int test_null_area_reg_struct(void)
Expand Down Expand Up @@ -147,27 +173,6 @@ static int test_larger_than_alloc_area(void *area)
return ret ? T_EXIT_PASS : T_EXIT_FAIL;
}

static int test_invalid_rq(void *area)
{
int ret;
struct io_uring_zcrx_area_reg area_reg = {
.addr = (__u64)(unsigned long)area,
.len = AREA_SZ,
.flags = 0,
.area_id = 0,
};

struct io_uring_zcrx_ifq_reg reg = {
.if_idx = ifidx,
.if_rxq = rxq,
.rq_entries = (__u32)-1,
.area_ptr = (__u64)(unsigned long)&area_reg,
};

ret = try_register_ifq(&reg);
return ret ? T_EXIT_PASS : T_EXIT_FAIL;
}

static int probe_ring_support(void)
{
struct io_uring ring;
Expand Down Expand Up @@ -223,7 +228,7 @@ int main(int argc, char *argv[])
return T_EXIT_FAIL;
}

ret = test_null_rq_entries_reg_struct(area);
ret = test_rq_setup(area);
if (ret) {
fprintf(stderr, "test_invalid_reg_struct failed\n");
return ret;
Expand Down Expand Up @@ -253,12 +258,6 @@ int main(int argc, char *argv[])
return ret;
}

ret = test_invalid_rq(area);
if (ret) {
fprintf(stderr, "test_invalid_rq failed\n");
return ret;
}

munmap(area, AREA_SZ);
return 0;
}

0 comments on commit 294ae64

Please sign in to comment.