io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tobias Klauser <tklauser@distanz.ch>
To: io-uring@vger.kernel.org
Subject: [PATCH] test/statx: verify against statx(2) on all archs
Date: Thu,  9 Jul 2020 23:34:52 +0200	[thread overview]
Message-ID: <20200709213452.21290-1-tklauser@distanz.ch> (raw)

Use __NR_statx in do_statx and unconditionally use it to check the
result on all architectures, not just x86_64. This relies on the
fact that __NR_statx should be defined if struct statx and STATX_ALL are
available as well.

Don't fail the test if the statx syscall returns EOPNOTSUPP though.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
---
 test/statx.c | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/test/statx.c b/test/statx.c
index a397593f7c11..d354d19fb095 100644
--- a/test/statx.c
+++ b/test/statx.c
@@ -15,13 +15,11 @@
 
 #include "liburing.h"
 
-#if defined(__x86_64)
 static int do_statx(int dfd, const char *path, int flags, unsigned mask,
 		    struct statx *statxbuf)
 {
-	return syscall(332, dfd, path, flags, mask, statxbuf);
+	return syscall(__NR_statx, dfd, path, flags, mask, statxbuf);
 }
-#endif
 
 static int create_file(const char *file, size_t size)
 {
@@ -42,14 +40,16 @@ static int create_file(const char *file, size_t size)
 	return ret != size;
 }
 
+static int statx_syscall_supported(void)
+{
+	return errno == EOPNOTSUPP ? 0 : -1;
+}
+
 static int test_statx(struct io_uring *ring, const char *path)
 {
 	struct io_uring_cqe *cqe;
 	struct io_uring_sqe *sqe;
-	struct statx x1;
-#if defined(__x86_64)
-	struct statx x2;
-#endif
+	struct statx x1, x2;
 	int ret;
 
 	sqe = io_uring_get_sqe(ring);
@@ -74,15 +74,13 @@ static int test_statx(struct io_uring *ring, const char *path)
 	io_uring_cqe_seen(ring, cqe);
 	if (ret)
 		return ret;
-#if defined(__x86_64)
 	ret = do_statx(-1, path, 0, STATX_ALL, &x2);
 	if (ret < 0)
-		return -1;
+		return statx_syscall_supported();
 	if (memcmp(&x1, &x2, sizeof(x1))) {
 		fprintf(stderr, "Miscompare between io_uring and statx\n");
 		goto err;
 	}
-#endif
 	return 0;
 err:
 	return -1;
@@ -92,10 +90,7 @@ static int test_statx_fd(struct io_uring *ring, const char *path)
 {
 	struct io_uring_cqe *cqe;
 	struct io_uring_sqe *sqe;
-	struct statx x1;
-#if defined(__x86_64)
-	struct statx x2;
-#endif
+	struct statx x1, x2;
 	int ret, fd;
 
 	fd = open(path, O_RDONLY);
@@ -128,16 +123,14 @@ static int test_statx_fd(struct io_uring *ring, const char *path)
 	io_uring_cqe_seen(ring, cqe);
 	if (ret)
 		return ret;
-#if defined(__x86_64)
 	memset(&x2, 0, sizeof(x2));
 	ret = do_statx(fd, "", AT_EMPTY_PATH, STATX_ALL, &x2);
 	if (ret < 0)
-		return -1;
+		return statx_syscall_supported();
 	if (memcmp(&x1, &x2, sizeof(x1))) {
 		fprintf(stderr, "Miscompare between io_uring and statx\n");
 		goto err;
 	}
-#endif
 	return 0;
 err:
 	return -1;
-- 
2.27.0


             reply	other threads:[~2020-07-09 21:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-09 21:34 Tobias Klauser [this message]
2020-07-10 13:55 ` [PATCH] test/statx: verify against statx(2) on all archs Jens Axboe
2020-07-10 14:25   ` Tobias Klauser
2020-07-10 14:27     ` 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=20200709213452.21290-1-tklauser@distanz.ch \
    --to=tklauser@distanz.ch \
    --cc=io-uring@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).