[PATCH v2 3/4] io_uring03: Update to use new io_uring_common.h helpers

Sebastian Chlad <[email protected]>
Newsgroups gmane.linux.ltp
Message-ID <[email protected]>
Signed-off-by: Sebastian Chlad <sebastian.chlad-IBi9RG/[email protected]>
---
 .../kernel/syscalls/io_uring/io_uring03.c     | 77 +++++++++++++++----
 1 file changed, 60 insertions(+), 17 deletions(-)

diff --git a/testcases/kernel/syscalls/io_uring/io_uring03.c b/testcases/kernel/syscalls/io_uring/io_uring03.c
index d3b9cff82..521ec0942 100644
--- a/testcases/kernel/syscalls/io_uring/io_uring03.c
+++ b/testcases/kernel/syscalls/io_uring/io_uring03.c
@@ -2,6 +2,9 @@
 /*
  * Copyright (C) 2026 IBM
  * Author: Sachin Sant <[email protected]>
+ *
+ * Copyright (C) 2026 Sebastian Chlad <sebastian.chlad-IBi9RG/[email protected]>
+ *
  */
 /*
  * Test IORING_OP_READ and IORING_OP_WRITE operations.
@@ -53,53 +56,93 @@ static void verify_data_integrity(const char *test_name)
 
 static void test_write_read(void)
 {
+	struct io_uring_sqe *sqe;
+	struct io_uring_cqe *cqe;
 	int fd;
 
 	init_buffer('A');
-
 	fd = SAFE_OPEN(TEST_FILE, O_RDWR | O_CREAT | O_TRUNC, 0644);
 
 	tst_res(TINFO, "Testing IORING_OP_WRITE");
-	io_uring_do_io_op(&s, fd, IORING_OP_WRITE, write_buf, BLOCK_SZ, 0,
-			  &sig);
+	sqe = io_uring_get_sqe(&s);
+	io_uring_prep_write(sqe, fd, write_buf, BLOCK_SZ, 0);
+	io_uring_sqe_set_data64(sqe, 1);
+	io_uring_submit(&s);
+
+	cqe = io_uring_cqe_wait(&s, &sig);
+	if (cqe->res != BLOCK_SZ)
+		tst_brk(TBROK, "IORING_OP_WRITE failed: res=%d", cqe->res);
+	tst_res(TPASS, "IORING_OP_WRITE: %d bytes written", cqe->res);
+	io_uring_cqe_seen(&s);
 
 	SAFE_FSYNC(fd);
 
 	tst_res(TINFO, "Testing IORING_OP_READ");
 	memset(read_buf, 0, BLOCK_SZ);
-	io_uring_do_io_op(&s, fd, IORING_OP_READ, read_buf, BLOCK_SZ, 0,
-			  &sig);
+	sqe = io_uring_get_sqe(&s);
+	io_uring_prep_read(sqe, fd, read_buf, BLOCK_SZ, 0);
+	io_uring_sqe_set_data64(sqe, 2);
+	io_uring_submit(&s);
 
-	verify_data_integrity("Basic I/O");
+	cqe = io_uring_cqe_wait(&s, &sig);
+	if (cqe->res != BLOCK_SZ)
+		tst_brk(TBROK, "IORING_OP_READ failed: res=%d", cqe->res);
+	tst_res(TPASS, "IORING_OP_READ: %d bytes read", cqe->res);
+	io_uring_cqe_seen(&s);
 
+	verify_data_integrity("Basic I/O");
 	SAFE_CLOSE(fd);
 }
 
 static void test_partial_io(void)
 {
-	int fd;
+	struct io_uring_sqe *sqe;
+	struct io_uring_cqe *cqe;
 	size_t half = BLOCK_SZ / 2;
+	int fd;
 
 	tst_res(TINFO, "Testing partial I/O operations");
-
 	init_buffer('a');
-
 	fd = SAFE_OPEN(TEST_FILE, O_RDWR | O_CREAT | O_TRUNC, 0644);
 
-	io_uring_do_io_op(&s, fd, IORING_OP_WRITE, write_buf, half, 0,
-			  &sig);
-
-	io_uring_do_io_op(&s, fd, IORING_OP_WRITE, write_buf + half, half,
-			  half, &sig);
+	sqe = io_uring_get_sqe(&s);
+	io_uring_prep_write(sqe, fd, write_buf, half, 0);
+	io_uring_sqe_set_data64(sqe, 1);
+	io_uring_submit(&s);
+
+	cqe = io_uring_cqe_wait(&s, &sig);
+	if (cqe->res != (int)half)
+		tst_brk(TBROK, "IORING_OP_WRITE failed: res=%d", cqe->res);
+	tst_res(TPASS, "IORING_OP_WRITE: %d bytes written at offset 0", cqe->res);
+	io_uring_cqe_seen(&s);
+
+	sqe = io_uring_get_sqe(&s);
+	io_uring_prep_write(sqe, fd, write_buf + half, half, half);
+	io_uring_sqe_set_data64(sqe, 2);
+	io_uring_submit(&s);
+
+	cqe = io_uring_cqe_wait(&s, &sig);
+	if (cqe->res != (int)half)
+		tst_brk(TBROK, "IORING_OP_WRITE failed: res=%d", cqe->res);
+	tst_res(TPASS, "IORING_OP_WRITE: %d bytes written at offset %zu",
+		cqe->res, half);
+	io_uring_cqe_seen(&s);
 
 	SAFE_FSYNC(fd);
 
 	memset(read_buf, 0, BLOCK_SZ);
-	io_uring_do_io_op(&s, fd, IORING_OP_READ, read_buf, BLOCK_SZ, 0,
-			  &sig);
+	sqe = io_uring_get_sqe(&s);
+	io_uring_prep_read(sqe, fd, read_buf, BLOCK_SZ, 0);
+	io_uring_sqe_set_data64(sqe, 3);
+	io_uring_submit(&s);
 
-	verify_data_integrity("Partial I/O");
+	cqe = io_uring_cqe_wait(&s, &sig);
+	if (cqe->res != BLOCK_SZ)
+		tst_brk(TBROK, "IORING_OP_READ failed: res=%d", cqe->res);
+	tst_res(TPASS, "IORING_OP_READ: %d bytes read", cqe->res);
+	io_uring_cqe_seen(&s);
 
+	verify_data_integrity("Partial I/O");
 	SAFE_CLOSE(fd);
 }
 
-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.