public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing 1/1] tests: migrate rw tests to t_create_ring()
Date: Sun, 22 Aug 2021 13:07:58 +0100	[thread overview]
Message-ID: <ecb8603a6ffc2e296cf9ed7e6c0f5913c60e6032.1629633967.git.asml.silence@gmail.com> (raw)

Use t_create_ring() in read-write.c and iopoll.c, the function will do
all the privilege checks.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 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


             reply	other threads:[~2021-08-22 12:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-22 12:07 Pavel Begunkov [this message]
2021-08-22 13:36 ` [PATCH liburing 1/1] tests: migrate rw tests to t_create_ring() Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ecb8603a6ffc2e296cf9ed7e6c0f5913c60e6032.1629633967.git.asml.silence@gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox