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.
#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;
}
