summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Moyer <jmoyer@redhat.com>2019-10-04 12:52:46 -0600
committerJens Axboe <axboe@kernel.dk>2019-10-04 12:52:46 -0600
commitd21cb864b5ae136c8d3de6fd56897f148d3bdf50 (patch)
tree76343daa95a013e699a40300816e63f10058feaa
parent720449896f0d1d849bc5b3ce8ab816d63cf642af (diff)
downloadliburing-d21cb864b5ae136c8d3de6fd56897f148d3bdf50.tar.gz
liburing-d21cb864b5ae136c8d3de6fd56897f148d3bdf50.tar.bz2
test/file-register: add test case for zero initial fds
Then grow it by one. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/file-register.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/file-register.c b/test/file-register.c
index b25f0f5..322545f 100644
--- a/test/file-register.c
+++ b/test/file-register.c
@@ -358,6 +358,40 @@ err:
return 1;
}
+/*
+ * Register 0 files, but reserve space for 10. Then add one file.
+ */
+static int test_zero(struct io_uring *ring)
+{
+ struct io_uring_files_update up;
+ int *files;
+ int ret;
+
+ files = open_files(0, 10, 0);
+ ret = io_uring_register(ring->ring_fd, IORING_REGISTER_FILES, files, 10);
+ if (ret)
+ goto err;
+
+ up.fds = open_files(1, 0, 1);
+ up.offset = 0;
+ ret = io_uring_register(ring->ring_fd,
+ IORING_REGISTER_FILES_UPDATE, &up, 1);
+ if (ret != 1) {
+ printf("ret=%d, errno=%d\n", ret, errno);
+ goto err;
+ }
+
+ ret = io_uring_register(ring->ring_fd, IORING_UNREGISTER_FILES, NULL, 0);
+ if (ret)
+ goto err;
+
+ close_files(up.fds, 1, 1);
+ return 0;
+err:
+ close_files(up.fds, 1, 1);
+ return 1;
+}
+
int main(int argc, char *argv[])
{
struct io_uring ring;
@@ -426,5 +460,11 @@ int main(int argc, char *argv[])
return ret;
}
+ ret = test_zero(&ring);
+ if (ret) {
+ printf("test_zero failed\n");
+ return ret;
+ }
+
return 0;
}