summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2019-10-04 13:29:57 -0600
committerJens Axboe <axboe@kernel.dk>2019-10-04 13:29:57 -0600
commit990f34d048a5b7a7bf0be0f77873740da64c2914 (patch)
tree641791206b36025604f0a1c2aac122e87a5c7f8a
parent096f4d0422329aec948f845bd327e26cfb9ddce0 (diff)
downloadliburing-990f34d048a5b7a7bf0be0f77873740da64c2914.tar.gz
liburing-990f34d048a5b7a7bf0be0f77873740da64c2914.tar.bz2
Add test case for application specified cq ring size
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/Makefile5
-rw-r--r--test/cq-size.c54
2 files changed, 57 insertions, 2 deletions
diff --git a/test/Makefile b/test/Makefile
index 3987f89..5ab9143 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -6,7 +6,8 @@ all_targets += poll poll-cancel ring-leak fsync io_uring_setup io_uring_register
io_uring_enter nop sq-full cq-full 35fa71a030ca-test \
917257daa0fe-test b19062a56726-test eeed8b54e0df-test link \
send_recvmsg a4c0b3decb33-test 500f9fbadef8-test timeout \
- sq-space_left stdout cq-ready cq-peek-batch file-register
+ sq-space_left stdout cq-ready cq-peek-batch file-register \
+ cq-size
include ../Makefile.quiet
@@ -20,7 +21,7 @@ test_srcs := poll.c poll-cancel.c ring-leak.c fsync.c io_uring_setup.c \
35fa71a030ca-test.c 917257daa0fe-test.c b19062a56726-test.c \
eeed8b54e0df-test.c link.c send_recvmsg.c a4c0b3decb33-test.c \
500f9fbadef8-test.c timeout.c sq-space_left.c stdout.c cq-ready.c\
- cq-peek-batch.c file-register.c
+ cq-peek-batch.c file-register.c cq-size.c
test_objs := $(patsubst %.c,%.ol,$(test_srcs))
diff --git a/test/cq-size.c b/test/cq-size.c
new file mode 100644
index 0000000..6e4fa9c
--- /dev/null
+++ b/test/cq-size.c
@@ -0,0 +1,54 @@
+/*
+ * Description: test CQ ring sizing
+ */
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "liburing.h"
+
+int main(int argc, char *argv[])
+{
+ struct io_uring_params p;
+ struct io_uring ring;
+ int ret;
+
+ memset(&p, 0, sizeof(p));
+ p.flags = IORING_SETUP_CQSIZE;
+ p.cq_entries = 64;
+
+ ret = io_uring_queue_init_params(4, &ring, &p);
+ if (ret) {
+ if (errno == EINVAL) {
+ printf("Skipped, not supported on this kernel\n");
+ goto done;
+ }
+ printf("ring setup failed\n");
+ return 1;
+ }
+
+ if (p.cq_entries < 64) {
+ printf("cq entries invalid (%d)\n", p.cq_entries);
+ goto err;
+ }
+ io_uring_queue_exit(&ring);
+
+ memset(&p, 0, sizeof(p));
+ p.flags = IORING_SETUP_CQSIZE;
+ p.cq_entries = 0;
+
+ ret = io_uring_queue_init_params(4, &ring, &p);
+ if (ret >= 0 || errno != EINVAL) {
+ printf("zero sized cq ring succeeded\n");
+ goto err;
+ }
+
+done:
+ return 0;
+err:
+ io_uring_queue_exit(&ring);
+ return 1;
+}