Linux Test Project
 help / color / mirror / Atom feed
From: Sachin Sant <sachinp@linux.ibm.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 3/4] io_uring: Add io_uring06 test for varying buffer sizes
Date: Thu,  7 May 2026 13:04:16 +0530	[thread overview]
Message-ID: <20260507073417.64123-3-sachinp@linux.ibm.com> (raw)
In-Reply-To: <20260507073417.64123-1-sachinp@linux.ibm.com>

Add io_uring06 test to validate vectored I/O operations (IORING_OP_READV
and IORING_OP_WRITEV) with non-uniform buffer sizes including a
zero-length buffer.

The test verifies:
- Writing data using iovec with varying sizes (512, 0, 1024, 256 bytes)
- Reading data back into buffers of the same varying sizes
- Data integrity verification with zero-length buffer handling
- Proper handling of iovec arrays with mixed buffer sizes

This test ensures the kernel correctly handles zero-length buffers in
vectored I/O operations, which is important for applications that may
dynamically construct iovec arrays.

Signed-off-by: Sachin Sant <sachinp@linux.ibm.com>
---
V2 changes:
- Declare fd as static with file scope.
- Reset fd at the top of run(), and close it in cleanup()
- Remove extra blank line from description
- Link to v1 https://lore.kernel.org/ltp/20260506183750.97191-1-sachinp@linux.ibm.com/T/#t
---
 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/io_uring/.gitignore |   1 +
 .../kernel/syscalls/io_uring/io_uring06.c     | 101 ++++++++++++++++++
 3 files changed, 103 insertions(+)
 create mode 100644 testcases/kernel/syscalls/io_uring/io_uring06.c

diff --git a/runtest/syscalls b/runtest/syscalls
index bab0e8f3b..fc4892221 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -1906,6 +1906,7 @@ io_uring02 io_uring02
 io_uring03 io_uring03
 io_uring04 io_uring04
 io_uring05 io_uring05
+io_uring06 io_uring06
 
 # Tests below may cause kernel memory leak
 perf_event_open03 perf_event_open03
diff --git a/testcases/kernel/syscalls/io_uring/.gitignore b/testcases/kernel/syscalls/io_uring/.gitignore
index bce7048cd..dfe7cca5a 100644
--- a/testcases/kernel/syscalls/io_uring/.gitignore
+++ b/testcases/kernel/syscalls/io_uring/.gitignore
@@ -3,3 +3,4 @@
 /io_uring03
 /io_uring04
 /io_uring05
+/io_uring06
diff --git a/testcases/kernel/syscalls/io_uring/io_uring06.c b/testcases/kernel/syscalls/io_uring/io_uring06.c
new file mode 100644
index 000000000..dc3a1ae08
--- /dev/null
+++ b/testcases/kernel/syscalls/io_uring/io_uring06.c
@@ -0,0 +1,101 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) 2026 IBM
+ * Author: Sachin Sant <sachinp@linux.ibm.com>
+ */
+/*\
+ * Test varying buffer sizes including zero-length buffers with
+ * IORING_OP_READV and IORING_OP_WRITEV.
+ *
+ * This test validates vectored I/O operations with non-uniform buffer
+ * sizes including a zero-length buffer. It tests:
+ * 1. IORING_OP_WRITEV - Writing data using buffers of varying sizes
+ *    (512, 0, 1024, 256 bytes)
+ * 2. IORING_OP_READV - Reading data into buffers of varying sizes
+ * 3. Data integrity verification with zero-length buffer handling
+ * 4. Proper handling of iovec arrays with mixed buffer sizes
+ */
+
+#include "io_uring_common.h"
+
+#define TEST_FILE "io_uring_test_file"
+#define QUEUE_DEPTH 2
+#define NUM_VECS 4
+#define VAR_BUF1_SIZE 512
+#define VAR_BUF2_SIZE 1024
+#define VAR_BUF3_SIZE 256
+
+static struct iovec *write_iovs, *read_iovs;
+static struct io_uring_submit s;
+static sigset_t sig;
+static int fd = -1;
+
+static void run(void)
+{
+	int expected_size = VAR_BUF1_SIZE + VAR_BUF2_SIZE + VAR_BUF3_SIZE;
+
+	fd = -1;
+
+	tst_res(TINFO,
+		"Testing vectors with varying sizes including zero-length buffer");
+
+	io_uring_init_iovec_pattern(write_iovs, NUM_VECS, 'X', 0);
+	io_uring_clear_iovec(read_iovs, NUM_VECS);
+
+	fd = SAFE_OPEN(TEST_FILE, O_RDWR | O_CREAT | O_TRUNC, 0644);
+
+	tst_res(TINFO,
+		"Writing %d bytes using buffers of sizes: 512, 0, 1024, 256",
+		expected_size);
+	io_uring_do_vec_io_op(&s, fd, IORING_OP_WRITEV, write_iovs, NUM_VECS,
+			      0, expected_size, &sig);
+
+	SAFE_FSYNC(fd);
+
+	tst_res(TINFO,
+		"Reading %d bytes using buffers of sizes: 512, 0, 1024, 256",
+		expected_size);
+	io_uring_do_vec_io_op(&s, fd, IORING_OP_READV, read_iovs, NUM_VECS, 0,
+			      expected_size, &sig);
+
+	io_uring_verify_iovec(write_iovs, read_iovs, NUM_VECS);
+
+	SAFE_CLOSE(fd);
+}
+
+static void setup(void)
+{
+	io_uring_setup_supported_by_kernel();
+	sigemptyset(&sig);
+	memset(&s, 0, sizeof(s));
+	io_uring_setup_queue(&s, QUEUE_DEPTH, 0);
+}
+
+static void cleanup(void)
+{
+	if (fd >= 0)
+		SAFE_CLOSE(fd);
+
+	io_uring_cleanup_queue(&s, QUEUE_DEPTH);
+}
+
+static struct tst_test test = {
+	.test_all = run,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_tmpdir = 1,
+	.bufs = (struct tst_buffers []) {
+		{&write_iovs, .iov_sizes = (int[]){VAR_BUF1_SIZE, 0,
+						   VAR_BUF2_SIZE,
+						   VAR_BUF3_SIZE, -1}},
+		{&read_iovs, .iov_sizes = (int[]){VAR_BUF1_SIZE, 0,
+						  VAR_BUF2_SIZE,
+						  VAR_BUF3_SIZE, -1}},
+		{}
+	},
+	.save_restore = (const struct tst_path_val[]) {
+		{"/proc/sys/kernel/io_uring_disabled", "0",
+			TST_SR_SKIP_MISSING | TST_SR_TCONF_RO},
+		{}
+	}
+};
-- 
2.39.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2026-05-07  7:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07  7:34 [LTP] [PATCH v7 1/4] io_uring: Add io_uring04 test for vectored I/O operations Sachin Sant
2026-05-07  7:34 ` [LTP] [PATCH v2 2/4] io_uring: Add io_uring05 test for partial vector operations Sachin Sant
2026-05-07  7:34 ` Sachin Sant [this message]
2026-05-07  7:34 ` [LTP] [PATCH v2 4/4] io_uring: remove unused io_uring_init_buffer_pattern() Sachin Sant
2026-05-07  9:39 ` [LTP] io_uring: Add io_uring04 test for vectored I/O operations linuxtestproject.agent

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=20260507073417.64123-3-sachinp@linux.ibm.com \
    --to=sachinp@linux.ibm.com \
    --cc=ltp@lists.linux.it \
    /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