io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH liburing 1/1] tests: migrate rw tests to t_create_ring()
@ 2021-08-22 12:07 Pavel Begunkov
  2021-08-22 13:36 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Begunkov @ 2021-08-22 12:07 UTC (permalink / raw)
  To: Jens Axboe, io-uring

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@gmail.com>
---
 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH liburing 1/1] tests: migrate rw tests to t_create_ring()
  2021-08-22 12:07 [PATCH liburing 1/1] tests: migrate rw tests to t_create_ring() Pavel Begunkov
@ 2021-08-22 13:36 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2021-08-22 13:36 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On 8/22/21 6:07 AM, Pavel Begunkov wrote:
> Use t_create_ring() in read-write.c and iopoll.c, the function will do
> all the privilege checks.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-22 13:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-22 12:07 [PATCH liburing 1/1] tests: migrate rw tests to t_create_ring() Pavel Begunkov
2021-08-22 13:36 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).