summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2021-01-23 17:03:07 -0700
committerJens Axboe <axboe@kernel.dk>2021-01-24 10:08:49 -0700
commit6598701385988eaec80189ef71d8f25f1899d482 (patch)
treeb3693af03549f555427b9f5d985821ed29275f08
parentfe0dfad9e3b0cf2d941e090aaf661398e5f30406 (diff)
downloadliburing-6598701385988eaec80189ef71d8f25f1899d482.tar.gz
liburing-6598701385988eaec80189ef71d8f25f1899d482.tar.bz2
Add circular poll ring test case
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/Makefile3
-rw-r--r--test/poll-ring.c48
2 files changed, 50 insertions, 1 deletions
diff --git a/test/Makefile b/test/Makefile
index ce5d9e3..481f4d4 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -78,6 +78,7 @@ test_targets += \
poll-cancel-ton \
poll-link \
poll-many \
+ poll-ring \
poll-v-poll \
probe \
read-write \
@@ -199,7 +200,7 @@ test_srcs := \
poll-cancel-ton.c \
poll-cancel.c \
poll-link.c \
- poll-many.c \
+ poll-ring.c \
poll-v-poll.c \
poll.c \
probe.c \
diff --git a/test/poll-ring.c b/test/poll-ring.c
new file mode 100644
index 0000000..1f69e20
--- /dev/null
+++ b/test/poll-ring.c
@@ -0,0 +1,48 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Description: Test poll against ring itself. A buggy kernel will end up
+ * having io_wq_* workers pending, as the circular reference
+ * will prevent full exit.
+ *
+ */
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/poll.h>
+
+#include "liburing.h"
+
+int main(int argc, char *argv[])
+{
+ struct io_uring_sqe *sqe;
+ struct io_uring ring;
+ int ret;
+
+ if (argc > 1)
+ return 0;
+
+ ret = io_uring_queue_init(1, &ring, 0);
+ if (ret) {
+ fprintf(stderr, "child: ring setup failed: %d\n", ret);
+ return 1;
+ }
+
+ sqe = io_uring_get_sqe(&ring);
+ if (!sqe) {
+ fprintf(stderr, "get sqe failed\n");
+ return 1;
+ }
+
+ io_uring_prep_poll_add(sqe, ring.ring_fd, POLLIN);
+ io_uring_sqe_set_data(sqe, sqe);
+
+ ret = io_uring_submit(&ring);
+ if (ret <= 0) {
+ fprintf(stderr, "child: sqe submit failed: %d\n", ret);
+ return 1;
+ }
+
+ return 0;
+}