aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-04-02 09:10:35 -0600
committerJens Axboe <axboe@kernel.dk>2024-04-02 09:10:35 -0600
commitf46b77cc95ec31f20b261522879a0c8a17ee67d1 (patch)
tree4d368a36db10368f54bc16c9230c59cafdbdfe47
parent2381e6f383566194d32fcb120792395fce8d87d6 (diff)
downloadliburing-f46b77cc95ec31f20b261522879a0c8a17ee67d1.tar.gz
test/msg-ring-fd: fix bugs in test case
Add more error checking, and ensure we mark the MSG_RING completion as seen. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/msg-ring-fd.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/test/msg-ring-fd.c b/test/msg-ring-fd.c
index 5f734459..f7ae0aab 100644
--- a/test/msg-ring-fd.c
+++ b/test/msg-ring-fd.c
@@ -58,6 +58,7 @@ static void *thread_fn(void *__data)
}
fd = cqe->res;
+ io_uring_cqe_seen(&ring, cqe);
sqe = io_uring_get_sqe(&ring);
io_uring_prep_read(sqe, fd, d->buf, sizeof(d->buf), 0);
sqe->flags |= IOSQE_FIXED_FILE;
@@ -127,6 +128,14 @@ static int test_remote(struct io_uring *src, int ring_flags)
fprintf(stderr, "wait_cqe: %d\n", ret);
return 1;
}
+ if (cqe->res < 0) {
+ fprintf(stderr, "cqe res %d\n", cqe->res);
+ return 1;
+ }
+ if (cqe->user_data == 1 && cqe->res != sizeof(buf)) {
+ fprintf(stderr, "short write %d\n", cqe->res);
+ return 1;
+ }
io_uring_cqe_seen(src, cqe);
}
@@ -181,17 +190,26 @@ static int test_local(struct io_uring *src, struct io_uring *dst)
sqe->user_data = 1;
sqe = io_uring_get_sqe(src);
- io_uring_prep_msg_ring_fd(sqe, dst->ring_fd, 0, 0, 0, 0);
+ io_uring_prep_msg_ring_fd(sqe, dst->ring_fd, 0, 0, 10, 0);
sqe->user_data = 2;
io_uring_submit(src);
+ fd = -1;
for (i = 0; i < 2; i++) {
ret = io_uring_wait_cqe(src, &cqe);
if (ret) {
fprintf(stderr, "wait_cqe: %d\n", ret);
return 1;
}
+ if (cqe->res < 0) {
+ fprintf(stderr, "cqe res %d\n", cqe->res);
+ return 1;
+ }
+ if (cqe->user_data == 1 && cqe->res != sizeof(buf)) {
+ fprintf(stderr, "short write %d\n", cqe->res);
+ return 1;
+ }
io_uring_cqe_seen(src, cqe);
}
@@ -206,9 +224,11 @@ static int test_local(struct io_uring *src, struct io_uring *dst)
}
fd = cqe->res;
+ io_uring_cqe_seen(dst, cqe);
sqe = io_uring_get_sqe(dst);
io_uring_prep_read(sqe, fd, dst_buf, sizeof(dst_buf), 0);
sqe->flags |= IOSQE_FIXED_FILE;
+ sqe->user_data = 3;
io_uring_submit(dst);
ret = io_uring_wait_cqe(dst, &cqe);
@@ -220,6 +240,10 @@ static int test_local(struct io_uring *src, struct io_uring *dst)
fprintf(stderr, "cqe error dst: %d\n", cqe->res);
return 1;
}
+ if (cqe->res != sizeof(dst_buf)) {
+ fprintf(stderr, "short read %d\n", cqe->res);
+ return 1;
+ }
if (memcmp(buf, dst_buf, sizeof(buf))) {
fprintf(stderr, "buffers differ\n");
return 1;