public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>,
	[email protected], [email protected]
Subject: [PATCH liburing 4/4] splice/tee/tests: test len=0 splice/tee
Date: Sun, 17 May 2020 14:23:47 +0300	[thread overview]
Message-ID: <1c3b277135e8f98dacc2a6ce582a48ae4d64780f.1589714504.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

Check zero-length splice() and tee().

Signed-off-by: Pavel Begunkov <[email protected]>
---
 test/splice.c | 38 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/test/splice.c b/test/splice.c
index 119c493..b81aa4b 100644
--- a/test/splice.c
+++ b/test/splice.c
@@ -144,7 +144,7 @@ static int do_splice_op(struct io_uring *ring,
 	struct io_uring_sqe *sqe;
 	int ret = -1;
 
-	while (len) {
+	do {
 		sqe = io_uring_get_sqe(ring);
 		if (!sqe) {
 			fprintf(stderr, "get sqe failed\n");
@@ -179,7 +179,7 @@ static int do_splice_op(struct io_uring *ring,
 		if (off_out != -1)
 			off_out += cqe->res;
 		io_uring_cqe_seen(ring, cqe);
-	}
+	} while (len);
 
 	return 0;
 }
@@ -215,6 +215,21 @@ static void check_tee_support(struct io_uring *ring, struct test_ctx *ctx)
 	has_tee = (ret == -EBADF);
 }
 
+static int check_zero_splice(struct io_uring *ring, struct test_ctx *ctx)
+{
+	int ret;
+
+	ret = do_splice(ring, ctx->fd_in, -1, ctx->pipe1[1], -1, 0);
+	if (ret)
+		return ret;
+
+	ret = do_splice(ring, ctx->pipe2[0], -1, ctx->pipe1[1], -1, 0);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
 static int splice_to_pipe(struct io_uring *ring, struct test_ctx *ctx)
 {
 	int ret;
@@ -349,11 +364,23 @@ static int check_tee(struct io_uring *ring, struct test_ctx *ctx)
 	return 0;
 }
 
+static int check_zero_tee(struct io_uring *ring, struct test_ctx *ctx)
+{
+	return do_tee(ring, ctx->pipe2[0], ctx->pipe1[1], 0);
+}
+
 static int test_splice(struct io_uring *ring, struct test_ctx *ctx)
 {
 	int ret;
 
 	if (has_splice) {
+		ret = check_zero_splice(ring, ctx);
+		if (ret) {
+			fprintf(stderr, "check_zero_splice failed %i %i\n",
+				ret, errno);
+			return ret;
+		}
+
 		ret = splice_to_pipe(ring, ctx);
 		if (ret) {
 			fprintf(stderr, "splice_to_pipe failed %i %i\n",
@@ -384,6 +411,13 @@ static int test_splice(struct io_uring *ring, struct test_ctx *ctx)
 	}
 
 	if (has_tee) {
+		ret = check_zero_tee(ring, ctx);
+		if (ret) {
+			fprintf(stderr, "check_zero_tee() failed %i %i\n",
+				ret, errno);
+			return ret;
+		}
+
 		ret = fail_tee_nonpipe(ring, ctx);
 		if (ret) {
 			fprintf(stderr, "fail_tee_nonpipe() failed %i %i\n",
-- 
2.24.0


  parent reply	other threads:[~2020-05-17 11:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-17 11:23 [PATCH liburing 0/4] splice/tee testing Pavel Begunkov
2020-05-17 11:23 ` [PATCH liburing 1/4] splice/test: improve splice tests Pavel Begunkov
2020-05-17 11:23 ` [PATCH liburing 2/4] update io_uring.h with tee() Pavel Begunkov
2020-05-17 11:23 ` [PATCH liburing 3/4] tee/test: add test for tee(2) Pavel Begunkov
2020-05-17 11:23 ` Pavel Begunkov [this message]
2020-05-17 20:24 ` [PATCH liburing 0/4] splice/tee testing 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=1c3b277135e8f98dacc2a6ce582a48ae4d64780f.1589714504.git.asml.silence@gmail.com \
    [email protected] \
    [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