tests: improve multicqe_drain
Small improvements for multicqe_drain test.
close pipes
use a helper for multishot poll
don't touch cqe after io_uring_cqe_seen()
Link:
@@ -288,9 +288,9 @@ static int test_simple_drain(struct io_uring *ring)
}
}
- io_uring_prep_poll_add(sqe[0], pipe1[0], POLLIN);
- sqe[0]->len |= IORING_POLL_ADD_MULTI;
+ io_uring_prep_poll_multishot(sqe[0], pipe1[0], POLLIN);
sqe[0]->user_data = 0;
+
io_uring_prep_poll_add(sqe[1], pipe2[0], POLLIN);
sqe[1]->user_data = 1;
@@ -320,6 +320,7 @@ static int test_simple_drain(struct io_uring *ring)
io_uring_prep_poll_remove(sqe[0], 0);
sqe[0]->user_data = 2;
+
io_uring_prep_nop(sqe[1]);
sqe[1]->flags |= IOSQE_IO_DRAIN;
sqe[1]->user_data = 3;
@@ -333,18 +334,21 @@ static int test_simple_drain(struct io_uring *ring)
goto err;
}
-
for (i = 0; i < 6; i++) {
ret = io_uring_wait_cqe(ring, &cqe);
if (ret < 0) {
printf("wait completion %d\n", ret);
goto err;
}
- io_uring_cqe_seen(ring, cqe);
if ((i == 5) && (cqe->user_data != 3))
goto err;
+ io_uring_cqe_seen(ring, cqe);
}
+ close(pipe1[0]);
+ close(pipe1[1]);
+ close(pipe2[0]);
+ close(pipe2[1]);
return 0;
err:
return 1;
