Use t_create_ring() in read-write.c and iopoll.c, the function will do all the privilege checks. Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> --- test/iopoll.c | 23 ++++++----------------- test/read-write.c | 21 +++++++-------------- 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/test/iopoll.c b/test/iopoll.c index b450618..5273279 100644 --- a/test/iopoll.c +++ b/test/iopoll.c @@ -271,31 +271,20 @@ static int test_io(const char *file, int write, int sqthread, int fixed, int buf_select) { struct io_uring ring; - int ret, ring_flags; + int ret, ring_flags = IORING_SETUP_IOPOLL; if (no_iopoll) return 0; - ring_flags = IORING_SETUP_IOPOLL; - if (sqthread) { - static int warned; - - if (geteuid()) { - if (!warned) - fprintf(stdout, "SQPOLL requires root, skipping\n"); - warned = 1; - return 0; - } - } - - ret = io_uring_queue_init(64, &ring, ring_flags); - if (ret) { + ret = t_create_ring(64, &ring, ring_flags); + if (ret == T_SETUP_SKIP) + goto done; + if (ret != T_SETUP_OK) { fprintf(stderr, "ring create failed: %d\n", ret); return 1; } - ret = __test_io(file, &ring, write, sqthread, fixed, buf_select); - +done: io_uring_queue_exit(&ring); return ret; } diff --git a/test/read-write.c b/test/read-write.c index b0a2bde..93f6803 100644 --- a/test/read-write.c +++ b/test/read-write.c @@ -235,23 +235,15 @@ static int test_io(const char *file, int write, int buffered, int sqthread, int fixed, int nonvec, int exp_len) { struct io_uring ring; - int ret, ring_flags; + int ret, ring_flags = 0; - if (sqthread) { - if (geteuid()) { - if (!warned) { - fprintf(stderr, "SQPOLL requires root, skipping\n"); - warned = 1; - } - return 0; - } + if (sqthread) ring_flags = IORING_SETUP_SQPOLL; - } else { - ring_flags = 0; - } - ret = io_uring_queue_init(64, &ring, ring_flags); - if (ret) { + ret = t_create_ring(64, &ring, ring_flags); + if (ret == T_SETUP_SKIP) + goto done; + if (ret != T_SETUP_OK) { fprintf(stderr, "ring create failed: %d\n", ret); return 1; } @@ -259,6 +251,7 @@ static int test_io(const char *file, int write, int buffered, int sqthread, ret = __test_io(file, &ring, write, buffered, sqthread, fixed, nonvec, 0, 0, exp_len); +done: io_uring_queue_exit(&ring); return ret; } -- 2.32.0