Add test case for -EAGAIN issue

Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/test/Makefile b/test/Makefile
index d2a3cc4..7866047 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -2,13 +2,14 @@
 
 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
+		917257daa0fe-test b19062a56726-test eeed8b54e0df-test
 
 all: $(all_targets)
 
 test_srcs := poll.c poll-cancel.c ring-leak.c fsync.c io_uring_setup.c \
 	io_uring_register.c io_uring_enter.c nop.c sq-full.c cq-full.c \
-	35fa71a030ca-test.c 917257daa0fe-test.c b19062a56726-test.c
+	35fa71a030ca-test.c 917257daa0fe-test.c b19062a56726-test.c \
+	eeed8b54e0df-test
 
 test_objs := $(patsubst %.c,%.ol,$(test_srcs))
 
@@ -38,6 +39,8 @@
 	$(CC) $(CFLAGS) -o $@ 917257daa0fe-test.c
 b19062a56726-test: b19062a56726-test.c
 	$(CC) $(CFLAGS) -o $@ b19062a56726-test.c
+eeed8b54e0df-test: eeed8b54e0df-test.c
+	$(CC) $(CFLAGS) -o $@ eeed8b54e0df-test.c -luring
 
 clean:
 	rm -f $(all_targets) $(test_objs)
diff --git a/test/eeed8b54e0df-test.c b/test/eeed8b54e0df-test.c
new file mode 100644
index 0000000..428b42b
--- /dev/null
+++ b/test/eeed8b54e0df-test.c
@@ -0,0 +1,87 @@
+/*
+ * Description: -EAGAIN handling
+ *
+ */
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "../src/liburing.h"
+
+static int get_file_fd(void)
+{
+	char *buf;
+	int fd;
+
+	fd = open("testfile", O_RDWR | O_CREAT, 0644);
+	if (fd < 0) {
+		perror("open file");
+		return -1;
+	}
+
+	buf = malloc(4096);
+	write(fd, buf, 4096);
+	fsync(fd);
+
+	if (posix_fadvise(fd, 0, 4096, POSIX_FADV_DONTNEED)) {
+		perror("fadvise");
+		close(fd);
+		free(buf);
+		return -1;
+	}
+
+	free(buf);
+	return fd;
+}
+
+static void put_file_fd(int fd)
+{
+	close(fd);
+	unlink("testfile");
+}
+
+int main(int argc, char *argv[])
+{
+	struct io_uring ring;
+	struct io_uring_sqe *sqe;
+	struct iovec iov;
+	int ret, fd;
+
+	iov.iov_base = malloc(4096);
+	iov.iov_len = 4096;
+
+	ret = io_uring_queue_init(2, &ring, 0);
+	if (ret) {
+		printf("ring setup failed\n");
+		return 1;
+
+	}
+
+	sqe = io_uring_get_sqe(&ring);
+	if (!sqe) {
+		printf("get sqe failed\n");
+		return 1;
+	}
+
+	fd = get_file_fd();
+	if (fd < 0)
+		return 1;
+
+	io_uring_prep_readv(sqe, fd, &iov, 1, 0);
+	sqe->rw_flags = RWF_NOWAIT;
+
+	ret = io_uring_submit(&ring);
+	if (ret != -EAGAIN) {
+		printf("Got submit %d, expected EAGAIN\n", ret);
+		goto err;
+	}
+
+	put_file_fd(fd);
+	return 0;
+err:
+	put_file_fd(fd);
+	return 1;
+}