Skip to contentSkip to conversation

update linked timeout tests

PATCH Applied Pavel Begunkov 2 participants 4 messages Aug 15, 2021 io_uring

lore
Share & tools
lore
#0 lore raw

cover update linked timeout tests

The main part is 2/2, which prepares the tests for early fail of invalid linked timeout SQE sequences.

Pavel Begunkov (2):
tests: close pipes in link-timeout
tests: fail early invalid linked setups

 test/link-timeout.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)
Signature · 1 line
2.32.0
#1 lore raw

PATCH 1/2 tests: close pipes in link-timeout

Don't forget to close pipe fds after link-timeout tests

---
 test/link-timeout.c | 8 ++++++++
 1 file changed, 8 insertions(+)
test/link-timeout.c +8 -0
index 5d8417f..8c3e203 100644
@@ -619,6 +619,8 @@ static int test_timeout_link_chain1(struct io_uring *ring)
 		io_uring_cqe_seen(ring, cqe);
 	}
 
+	close(fds[0]);
+	close(fds[1]);
 	return 0;
 err:
 	return 1;
@@ -713,6 +715,8 @@ static int test_timeout_link_chain2(struct io_uring *ring)
 		io_uring_cqe_seen(ring, cqe);
 	}
 
+	close(fds[0]);
+	close(fds[1]);
 	return 0;
 err:
 	return 1;
@@ -833,6 +837,8 @@ static int test_timeout_link_chain3(struct io_uring *ring)
 		io_uring_cqe_seen(ring, cqe);
 	}
 
+	close(fds[0]);
+	close(fds[1]);
 	return 0;
 err:
 	return 1;
@@ -917,6 +923,8 @@ static int test_timeout_link_chain4(struct io_uring *ring)
 		io_uring_cqe_seen(ring, cqe);
 	}
 
+	close(fds[0]);
+	close(fds[1]);
 	return 0;
 err:
 	return 1;
Signature · 1 line
2.32.0
#2 lore raw

PATCH 2/2 tests: fail early invalid linked setups

In reply to Pavel Begunkov

We're going to fail links with invalid timeout combinations early. E.g. op1 -> link timeout -> link timeout

Update tests to handle it.

---
 test/link-timeout.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
test/link-timeout.c +10 -7
index 8c3e203..c8c289c 100644
@@ -63,7 +63,7 @@ static int test_fail_two_link_timeouts(struct io_uring *ring)
 	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 @@ static int test_fail_two_link_timeouts(struct io_uring *ring)
 	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 @@ static int test_timeout_link_chain5(struct io_uring *ring)
 		}
 		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;
 			}
Signature · 1 line
2.32.0
maintainer Applied
#3 lore raw
In reply to Pavel Begunkov
Quoted 6 lines · Pavel Begunkov

The main part is 2/2, which prepares the tests for early fail of invalid linked timeout SQE sequences.

Pavel Begunkov (2):
tests: close pipes in link-timeout
tests: fail early invalid linked setups

Applied, thanks.

Signature · 1 line
Jens Axboe