summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2020-01-15 10:05:49 -0700
committerJens Axboe <axboe@kernel.dk>2020-01-15 10:05:49 -0700
commit7d14c3c0cc6a84080ace4c18ffc97e93e6ff9283 (patch)
tree403f517b6251fb475ba4fd2088baa168f1a31e6f
parent4697a07253e115f8bf916bb254dec567d530ebdb (diff)
downloadliburing-7d14c3c0cc6a84080ace4c18ffc97e93e6ff9283.tar.gz
liburing-7d14c3c0cc6a84080ace4c18ffc97e93e6ff9283.tar.bz2
test/file-register: add intensive update/remove test case
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/file-register.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/file-register.c b/test/file-register.c
index e4f77de..2e7053f 100644
--- a/test/file-register.c
+++ b/test/file-register.c
@@ -527,6 +527,60 @@ err:
return 1;
}
+static int test_sparse_updates(void)
+{
+ struct io_uring ring;
+ int ret, i, *fds, newfd;
+
+ ret = io_uring_queue_init(8, &ring, 0);
+ if (ret) {
+ fprintf(stderr, "queue_init: %d\n", ret);
+ return ret;
+ }
+
+ fds = malloc(256 * sizeof(int));
+ for (i = 0; i < 256; i++)
+ fds[i] = -1;
+
+ ret = io_uring_register_files(&ring, fds, 256);
+ if (ret) {
+ fprintf(stderr, "file_register: %d\n", ret);
+ return ret;
+ }
+
+ newfd = 1;
+ for (i = 0; i < 256; i++) {
+ ret = io_uring_register_files_update(&ring, i, &newfd, 1);
+ if (ret != 1) {
+ fprintf(stderr, "file_update: %d\n", ret);
+ return ret;
+ }
+ }
+ io_uring_unregister_files(&ring);
+
+ for (i = 0; i < 256; i++)
+ fds[i] = 1;
+
+ ret = io_uring_register_files(&ring, fds, 256);
+ if (ret) {
+ fprintf(stderr, "file_register: %d\n", ret);
+ return ret;
+ }
+
+ newfd = -1;
+ for (i = 0; i < 256; i++) {
+ ret = io_uring_register_files_update(&ring, i, &newfd, 1);
+ if (ret != 1) {
+ fprintf(stderr, "file_update: %d\n", ret);
+ return ret;
+ }
+ }
+ io_uring_unregister_files(&ring);
+
+ io_uring_queue_exit(&ring);
+ return 0;
+}
+
int main(int argc, char *argv[])
{
struct io_uring ring;
@@ -607,5 +661,11 @@ int main(int argc, char *argv[])
return ret;
}
+ ret = test_sparse_updates();
+ if (ret) {
+ printf("test_sparse_updates failed\n");
+ return ret;
+ }
+
return 0;
}