summaryrefslogtreecommitdiff
path: root/test/nop.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2022-02-20 12:08:42 -0700
committerJens Axboe <axboe@kernel.dk>2022-05-16 09:30:46 -0600
commite6f6a2d0e4ff10cadd13d115c48b36df11b846b4 (patch)
tree5d2857aae12fa8fc9b33843e371486eb4254c042 /test/nop.c
parent1efee07cc554c0d59ffbc323b577e28bc96fac24 (diff)
downloadliburing-e6f6a2d0e4ff10cadd13d115c48b36df11b846b4.tar.gz
liburing-e6f6a2d0e4ff10cadd13d115c48b36df11b846b4.tar.bz2
test/nop: add basic IORING_SETUP_SQE128 tests
Just repeats the original test cases, but using a big ring. Assign and check for user_data never being NULL, which would be a common issue with mistakes between big and normal SQEs. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'test/nop.c')
-rw-r--r--test/nop.c64
1 files changed, 57 insertions, 7 deletions
diff --git a/test/nop.c b/test/nop.c
index 82201bd..d477a1b 100644
--- a/test/nop.c
+++ b/test/nop.c
@@ -12,6 +12,8 @@
#include "liburing.h"
+static int seq;
+
static int test_single_nop(struct io_uring *ring)
{
struct io_uring_cqe *cqe;
@@ -25,6 +27,7 @@ static int test_single_nop(struct io_uring *ring)
}
io_uring_prep_nop(sqe);
+ sqe->user_data = ++seq;
ret = io_uring_submit(ring);
if (ret <= 0) {
@@ -37,7 +40,10 @@ static int test_single_nop(struct io_uring *ring)
fprintf(stderr, "wait completion %d\n", ret);
goto err;
}
-
+ if (!cqe->user_data) {
+ fprintf(stderr, "Unexpected 0 user_data\n");
+ goto err;
+ }
io_uring_cqe_seen(ring, cqe);
return 0;
err:
@@ -60,6 +66,7 @@ static int test_barrier_nop(struct io_uring *ring)
io_uring_prep_nop(sqe);
if (i == 4)
sqe->flags = IOSQE_IO_DRAIN;
+ sqe->user_data = ++seq;
}
ret = io_uring_submit(ring);
@@ -77,6 +84,10 @@ static int test_barrier_nop(struct io_uring *ring)
fprintf(stderr, "wait completion %d\n", ret);
goto err;
}
+ if (!cqe->user_data) {
+ fprintf(stderr, "Unexpected 0 user_data\n");
+ goto err;
+ }
io_uring_cqe_seen(ring, cqe);
}
@@ -85,15 +96,12 @@ err:
return 1;
}
-int main(int argc, char *argv[])
+static int test_p(struct io_uring_params *p)
{
struct io_uring ring;
int ret;
- if (argc > 1)
- return 0;
-
- ret = io_uring_queue_init(8, &ring, 0);
+ ret = io_uring_queue_init_params(8, &ring, p);
if (ret) {
fprintf(stderr, "ring setup failed: %d\n", ret);
return 1;
@@ -102,12 +110,54 @@ int main(int argc, char *argv[])
ret = test_single_nop(&ring);
if (ret) {
fprintf(stderr, "test_single_nop failed\n");
- return ret;
+ goto err;
}
ret = test_barrier_nop(&ring);
if (ret) {
fprintf(stderr, "test_barrier_nop failed\n");
+ goto err;
+ }
+
+ io_uring_queue_exit(&ring);
+ return 0;
+err:
+ io_uring_queue_exit(&ring);
+ return ret;
+}
+
+static int test_normal_ring(void)
+{
+ struct io_uring_params p = { };
+
+ return test_p(&p);
+}
+
+static int test_big_ring(void)
+{
+ struct io_uring_params p = { };
+
+ p.flags = IORING_SETUP_SQE128;
+ return test_p(&p);
+}
+
+
+int main(int argc, char *argv[])
+{
+ int ret;
+
+ if (argc > 1)
+ return 0;
+
+ ret = test_normal_ring();
+ if (ret) {
+ fprintf(stderr, "Normal ring test failed\n");
+ return ret;
+ }
+
+ ret = test_big_ring();
+ if (ret) {
+ fprintf(stderr, "Big ring test failed\n");
return ret;
}