public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com
Subject: [PATCH liburing 3/6] tests: introduce t_iovec_data_length helper
Date: Thu, 11 Sep 2025 12:26:28 +0100	[thread overview]
Message-ID: <197a9ef7cdee6cd1704f75b9d80b788751db78c6.1757589613.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1757589613.git.asml.silence@gmail.com>

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 test/helpers.c    | 10 ++++++++++
 test/helpers.h    |  2 ++
 test/vec-regbuf.c |  6 ++----
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/test/helpers.c b/test/helpers.c
index 18af2be8..15ceb17a 100644
--- a/test/helpers.c
+++ b/test/helpers.c
@@ -526,3 +526,13 @@ int t_submit_and_wait_single(struct io_uring *ring, struct io_uring_cqe **cqe)
 	}
 	return 0;
 }
+
+size_t t_iovec_data_length(struct iovec *iov, unsigned iov_len)
+{
+	size_t sz = 0;
+	int i;
+
+	for (i = 0; i < iov_len; i++)
+		sz += iov[i].iov_len;
+	return sz;
+}
diff --git a/test/helpers.h b/test/helpers.h
index b7465890..a45b8683 100644
--- a/test/helpers.h
+++ b/test/helpers.h
@@ -124,6 +124,8 @@ unsigned long long utime_since_now(struct timeval *tv);
 
 int t_submit_and_wait_single(struct io_uring *ring, struct io_uring_cqe **cqe);
 
+size_t t_iovec_data_length(struct iovec *iov, unsigned iov_len);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/test/vec-regbuf.c b/test/vec-regbuf.c
index 286b78c6..0cbe2c74 100644
--- a/test/vec-regbuf.c
+++ b/test/vec-regbuf.c
@@ -269,7 +269,7 @@ static int test_vec(struct buf_desc *bd, struct iovec *vecs, int nr_vec,
 	struct sockaddr_storage addr;
 	int sock_server, sock_client;
 	struct verify_data vd;
-	size_t total_len = 0;
+	size_t total_len;
 	int i, ret;
 	void *verify_res;
 	pthread_t th;
@@ -284,9 +284,7 @@ static int test_vec(struct buf_desc *bd, struct iovec *vecs, int nr_vec,
 	for (i = 0; i < bd->size; i++)
 		bd->buf_wr[i] = i;
 	memset(bd->buf_rd, 0, bd->size);
-
-	for (i = 0; i < nr_vec; i++)
-		total_len += vecs[i].iov_len;
+	total_len = t_iovec_data_length(vecs, nr_vec);
 
 	vd.bd = bd;
 	vd.vecs = vecs;
-- 
2.49.0


  parent reply	other threads:[~2025-09-11 11:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-11 11:26 [PATCH liburing 0/6] Add query and mock tests Pavel Begunkov
2025-09-11 11:26 ` [PATCH liburing 1/6] tests: test the query interface Pavel Begunkov
2025-09-19 14:11   ` Pavel Begunkov
2025-09-11 11:26 ` [PATCH liburing 2/6] tests: add t_submit_and_wait_single helper Pavel Begunkov
2025-09-11 11:26 ` Pavel Begunkov [this message]
2025-09-11 11:26 ` [PATCH liburing 4/6] tests: add t_sqe_prep_cmd helper Pavel Begunkov
2025-09-11 11:26 ` [PATCH liburing 5/6] tests: add helper for iov data verification Pavel Begunkov
2025-09-11 11:26 ` [PATCH liburing 6/6] tests: add mock file based tests Pavel Begunkov
2025-09-19 13:15 ` [PATCH liburing 0/6] Add query and mock tests Jens Axboe
2025-09-19 16:56   ` Jens Axboe
2025-09-22  7:55     ` Pavel Begunkov
2025-09-22 12:00       ` 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=197a9ef7cdee6cd1704f75b9d80b788751db78c6.1757589613.git.asml.silence@gmail.com \
    --to=asml.silence@gmail.com \
    --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