All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roesch <shr@fb.com>
To: <io-uring@vger.kernel.org>, <kernel-team@fb.com>
Cc: <viro@zeniv.linux.org.uk>, <shr@fb.com>
Subject: [PATCH v1] liburing: add test for stable statx api
Date: Wed, 9 Feb 2022 11:04:30 -0800	[thread overview]
Message-ID: <20220209190430.2378305-1-shr@fb.com> (raw)

This adds a test for the statx api to verify that io-uring statx api is
stable.

Signed-off-by: Stefan Roesch <shr@fb.com>
---
 test/statx.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

diff --git a/test/statx.c b/test/statx.c
index c0f9e9c..61268d4 100644
--- a/test/statx.c
+++ b/test/statx.c
@@ -77,6 +77,61 @@ err:
 	return -1;
 }
 
+static int test_statx_stable(struct io_uring *ring, const char *path)
+{
+	struct io_uring_cqe *cqe;
+	struct io_uring_sqe *sqe;
+	struct statx x1, x2;
+	char path1[PATH_MAX];
+	char path2[PATH_MAX];
+	int ret = -1;
+
+	strcpy(path2, path);
+	strcpy(path1, path);
+
+	sqe = io_uring_get_sqe(ring);
+	if (!sqe) {
+		fprintf(stderr, "get sqe failed\n");
+		goto err;
+	}
+
+	io_uring_prep_statx(sqe, -1, path1, 0, STATX_ALL, &x1);
+
+	ret = io_uring_submit(ring);
+	if (ret <= 0) {
+		fprintf(stderr, "sqe submit failed: %d\n", ret);
+		goto err;
+	}
+	memset(path1, 0, sizeof(path1));
+
+	ret = io_uring_wait_cqe(ring, &cqe);
+	if (ret < 0) {
+		fprintf(stderr, "wait completion %d\n", ret);
+		goto err;
+	}
+
+	ret = cqe->res;
+	io_uring_cqe_seen(ring, cqe);
+	if (ret) {
+		fprintf(stderr, "statx res = %d\n", ret);
+		goto err;
+	}
+
+	ret = do_statx(-1, path2, 0, STATX_ALL, &x2);
+	if (ret < 0)
+		return statx_syscall_supported();
+
+	if (memcmp(&x1, &x2, sizeof(x1))) {
+		fprintf(stderr, "Miscompare between io_uring and statx\n");
+		goto err;
+	}
+
+	ret = 0;
+
+err:
+	return ret;
+}
+
 static int test_statx_fd(struct io_uring *ring, const char *path)
 {
 	struct io_uring_cqe *cqe;
@@ -156,6 +211,16 @@ int main(int argc, char *argv[])
 		goto err;
 	}
 
+	ret = test_statx_stable(&ring, fname);
+	if (ret) {
+		if (ret == -EINVAL) {
+			fprintf(stdout, "statx not supported, skipping\n");
+			goto done;
+		}
+		fprintf(stderr, "test_statx_loop failed: %d\n", ret);
+		goto err;
+	}
+
 	ret = test_statx_fd(&ring, fname);
 	if (ret) {
 		fprintf(stderr, "test_statx_fd failed: %d\n", ret);

base-commit: d9b0a424471f5c584f1d3f370e1746925733c01a
-- 
2.30.2


             reply	other threads:[~2022-02-09 19:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09 19:04 Stefan Roesch [this message]
2022-02-10  0:43 ` [PATCH v1] liburing: add test for stable statx api Ammar Faizi
2022-02-10  0:53 ` Ammar Faizi
2022-02-10  2:06 ` Ammar Faizi

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=20220209190430.2378305-1-shr@fb.com \
    --to=shr@fb.com \
    --cc=io-uring@vger.kernel.org \
    --cc=kernel-team@fb.com \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.