aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/liburing/test/no-mmap-inval.c
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.com>2024-06-09 11:55:21 +0300
committerthegeorg <thegeorg@yandex-team.com>2024-06-09 12:07:55 +0300
commitafd4899380eea1c70e2a68714b5da1c9919ccdbd (patch)
treecd5120708784139bc6a0f8881da1ed8389a065b3 /contrib/libs/liburing/test/no-mmap-inval.c
parenta83bd2dd3c21e38c6c0807ec5e679497ab567f24 (diff)
downloadydb-afd4899380eea1c70e2a68714b5da1c9919ccdbd.tar.gz
Update contrib/libs/liburing to 2.6
3b51a9fb14de805208d11f1c077c78bb5d487e0f
Diffstat (limited to 'contrib/libs/liburing/test/no-mmap-inval.c')
-rw-r--r--contrib/libs/liburing/test/no-mmap-inval.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/contrib/libs/liburing/test/no-mmap-inval.c b/contrib/libs/liburing/test/no-mmap-inval.c
new file mode 100644
index 0000000000..e340311ac3
--- /dev/null
+++ b/contrib/libs/liburing/test/no-mmap-inval.c
@@ -0,0 +1,43 @@
+#include "../config-host.h"
+/* SPDX-License-Identifier: MIT */
+/*
+ * Description: test that using SETUP_NO_MMAP with an invalid SQ ring
+ * address fails.
+ *
+ */
+#include <stdlib.h>
+#include <sys/types.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "liburing.h"
+#include "helpers.h"
+
+int main(int argc, char *argv[])
+{
+ struct io_uring_params p = {
+ .sq_entries = 2,
+ .cq_entries = 4,
+ .flags = IORING_SETUP_NO_MMAP,
+ };
+ struct io_uring ring;
+ void *addr;
+ int ret;
+
+ if (argc > 1)
+ return T_EXIT_SKIP;
+
+ t_posix_memalign(&addr, sysconf(_SC_PAGESIZE), 8192);
+ p.cq_off.user_addr = (unsigned long long) (uintptr_t) addr;
+
+ ret = io_uring_queue_init_params(2, &ring, &p);
+ if (ret == -EINVAL) {
+ /* kernel doesn't support SETUP_NO_MMAP */
+ return T_EXIT_SKIP;
+ } else if (ret && ret != -EFAULT) {
+ fprintf(stderr, "Got %d, wanted -EFAULT\n", ret);
+ return T_EXIT_FAIL;
+ }
+
+ return T_EXIT_PASS;
+}