tests: fail early invalid linked setups
We're going to fail links with invalid timeout combinations early. E.g.
op1 -> link timeout -> link timeout
Update tests to handle it.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/d2576c13100bacc00467c9ccfaedca1e71117e97.1629020550.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/test/link-timeout.c b/test/link-timeout.c
index 8c3e203..c8c289c 100644
--- a/test/link-timeout.c
+++ b/test/link-timeout.c
@@ -63,7 +63,7 @@
struct __kernel_timespec ts;
struct io_uring_cqe *cqe;
struct io_uring_sqe *sqe;
- int ret, i;
+ int ret, i, nr_wait;
ts.tv_sec = 1;
ts.tv_nsec = 0;
@@ -114,12 +114,13 @@
sqe->user_data = 4;
ret = io_uring_submit(ring);
- if (ret != 4) {
+ if (ret < 3) {
printf("sqe submit failed: %d\n", ret);
goto err;
}
+ nr_wait = ret;
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < nr_wait; i++) {
ret = io_uring_wait_cqe(ring, &cqe);
if (ret < 0) {
printf("wait completion %d\n", ret);
@@ -981,14 +982,16 @@
}
switch (cqe->user_data) {
case 1:
- if (cqe->res) {
- fprintf(stderr, "Timeout got %d, wanted -EINVAL\n",
+ case 2:
+ if (cqe->res && cqe->res != -ECANCELED) {
+ fprintf(stderr, "Request got %d, wanted -EINVAL "
+ "or -ECANCELED\n",
cqe->res);
goto err;
}
break;
- case 2:
- if (cqe->res != -ECANCELED) {
+ case 3:
+ if (cqe->res != -ECANCELED && cqe->res != -EINVAL) {
fprintf(stderr, "Link timeout got %d, wanted -ECANCELED\n", cqe->res);
goto err;
}