Skip to content

Commit

Permalink
test/resize-rings: test IOSQE_ASYNC as well
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Oct 22, 2024
1 parent 07de936 commit 86d805b
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions test/resize-rings.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#define min(a, b) ((a) < (b) ? (a) : (b))

static int test_busy(struct io_uring *ring, int fd)
static int test_busy(struct io_uring *ring, int fd, int async)
{
struct io_uring_params p = { };
struct io_uring_sqe *sqe;
Expand Down Expand Up @@ -66,6 +66,8 @@ static int test_busy(struct io_uring *ring, int fd)
break;
io_uring_prep_read(sqe, fd, vecs[i].iov_base,
vecs[i].iov_len, offset);
if (async)
sqe->flags |= IOSQE_ASYNC;
offset += 8192;
if (start_ud == -1UL)
start_ud = ud;
Expand Down Expand Up @@ -132,7 +134,7 @@ static int test_busy(struct io_uring *ring, int fd)
return 0;
}

static int test_basic(struct io_uring *ring)
static int test_basic(struct io_uring *ring, int async)
{
struct io_uring_params p = { };
struct io_uring_sqe *sqe;
Expand All @@ -141,6 +143,8 @@ static int test_basic(struct io_uring *ring)

sqe = io_uring_get_sqe(ring);
io_uring_prep_nop(sqe);
if (async)
sqe->flags |= IOSQE_ASYNC;
sqe->user_data = 1;
io_uring_submit(ring);

Expand All @@ -152,6 +156,8 @@ static int test_basic(struct io_uring *ring)

sqe = io_uring_get_sqe(ring);
io_uring_prep_nop(sqe);
if (async)
sqe->flags |= IOSQE_ASYNC;
sqe->user_data = 2;
io_uring_submit(ring);

Expand All @@ -171,7 +177,7 @@ static int test_basic(struct io_uring *ring)
return T_EXIT_PASS;
}

static int test(int flags, int fd)
static int test(int flags, int fd, int async)
{
struct io_uring_params p = {
.flags = flags,
Expand All @@ -185,15 +191,15 @@ static int test(int flags, int fd)
return T_EXIT_FAIL;
}

ret = test_basic(&ring);
ret = test_basic(&ring, async);
if (ret == T_EXIT_SKIP) {
return T_EXIT_SKIP;
} else if (ret == T_EXIT_FAIL) {
fprintf(stderr, "test_basic %x failed\n", flags);
return T_EXIT_FAIL;
}

ret = test_busy(&ring, fd);
ret = test_busy(&ring, fd, async);
if (ret == T_EXIT_FAIL) {
fprintf(stderr, "test_busy %x failed\n", flags);
return T_EXIT_FAIL;
Expand All @@ -210,19 +216,32 @@ int main(int argc, char *argv[])
if (argc > 1)
fd = open("/dev/nvme0n1", O_RDONLY | O_DIRECT);

ret = test(0, fd);
ret = test(0, fd, 0);
if (ret == T_EXIT_SKIP)
return T_EXIT_SKIP;
else if (ret == T_EXIT_FAIL)
return T_EXIT_FAIL;

ret = test(IORING_SETUP_SQPOLL, fd);
ret = test(0, fd, 1);
if (ret == T_EXIT_FAIL)
return T_EXIT_FAIL;

ret = test(IORING_SETUP_SINGLE_ISSUER | IORING_SETUP_DEFER_TASKRUN, fd);
ret = test(IORING_SETUP_SQPOLL, fd, 0);
if (ret == T_EXIT_FAIL)
return T_EXIT_FAIL;

ret = test(IORING_SETUP_SQPOLL, fd, 1);
if (ret == T_EXIT_FAIL)
return T_EXIT_FAIL;

ret = test(IORING_SETUP_SINGLE_ISSUER | IORING_SETUP_DEFER_TASKRUN, fd, 0);
if (ret == T_EXIT_FAIL)
return T_EXIT_FAIL;

ret = test(IORING_SETUP_SINGLE_ISSUER | IORING_SETUP_DEFER_TASKRUN, fd, 1);
if (ret == T_EXIT_FAIL)
return T_EXIT_FAIL;


return T_EXIT_PASS;
}

0 comments on commit 86d805b

Please sign in to comment.