diff mbox series

[liburing,2/4] test/reg-wait: basic test + probing of kernel regions

Message ID 8a525a846002b2a899addbae52f922d9034b4257.1731987026.git.asml.silence@gmail.com (mailing list archive)
State New
Headers show
Series test kernel allocated regions | expand

Commit Message

Pavel Begunkov Nov. 20, 2024, 11:39 p.m. UTC
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 test/reg-wait.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/test/reg-wait.c b/test/reg-wait.c
index 544cd48..9b18ab1 100644
--- a/test/reg-wait.c
+++ b/test/reg-wait.c
@@ -23,6 +23,8 @@  static const struct io_uring_reg_wait brief_wait = {
 	.ts.tv_nsec = 1000,
 };
 
+static bool has_kernel_regions;
+
 static int test_wait_reg_offset(struct io_uring *ring,
 				 unsigned wait_nr, unsigned long offset)
 {
@@ -380,6 +382,27 @@  static int test_regions(void)
 		return T_EXIT_FAIL;
 	}
 
+	rd.flags = 0;
+	rd.user_addr = 0;
+	ret = test_try_register_region(&mr, true);
+	if (ret == -EINVAL) {
+		has_kernel_regions = false;
+		goto out;
+	}
+	if (ret) {
+		fprintf(stderr, "test_try_register_region() failed kernel alloc %i\n", ret);
+		return T_EXIT_FAIL;
+	}
+
+	has_kernel_regions = true;
+	rd.flags = 0;
+	rd.user_addr = (__u64)(unsigned long)buffer;
+	ret = test_try_register_region(&mr, true);
+	if (!ret) {
+		fprintf(stderr, "test_try_register_region() failed uptr w kernel alloc %i\n", ret);
+		return T_EXIT_FAIL;
+	}
+out:
 	munmap(buffer, page_size);
 	return 0;
 }