public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] test/statx: verify against statx(2) on all archs
@ 2020-07-09 21:34 Tobias Klauser
  2020-07-10 13:55 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Tobias Klauser @ 2020-07-09 21:34 UTC (permalink / raw)
  To: io-uring

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 <[email protected]>
---
 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


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

end of thread, other threads:[~2020-07-10 14:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-09 21:34 [PATCH] test/statx: verify against statx(2) on all archs Tobias Klauser
2020-07-10 13:55 ` Jens Axboe
2020-07-10 14:25   ` Tobias Klauser
2020-07-10 14:27     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox