io-uring.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH liburing 0/2] update linked timeout tests
@ 2021-08-15  9:43 Pavel Begunkov
  2021-08-15  9:43 ` [PATCH liburing 1/2] tests: close pipes in link-timeout Pavel Begunkov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Pavel Begunkov @ 2021-08-15  9:43 UTC (permalink / raw)
  To: Jens Axboe, io-uring

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(-)

-- 
2.32.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH liburing 1/2] tests: close pipes in link-timeout
  2021-08-15  9:43 [PATCH liburing 0/2] update linked timeout tests Pavel Begunkov
@ 2021-08-15  9:43 ` Pavel Begunkov
  2021-08-15  9:43 ` [PATCH liburing 2/2] tests: fail early invalid linked setups Pavel Begunkov
  2021-08-15 15:15 ` [PATCH liburing 0/2] update linked timeout tests Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2021-08-15  9:43 UTC (permalink / raw)
  To: Jens Axboe, io-uring

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

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 test/link-timeout.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/test/link-timeout.c b/test/link-timeout.c
index 5d8417f..8c3e203 100644
--- a/test/link-timeout.c
+++ b/test/link-timeout.c
@@ -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;
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH liburing 2/2] tests: fail early invalid linked setups
  2021-08-15  9:43 [PATCH liburing 0/2] update linked timeout tests Pavel Begunkov
  2021-08-15  9:43 ` [PATCH liburing 1/2] tests: close pipes in link-timeout Pavel Begunkov
@ 2021-08-15  9:43 ` Pavel Begunkov
  2021-08-15 15:15 ` [PATCH liburing 0/2] update linked timeout tests Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2021-08-15  9:43 UTC (permalink / raw)
  To: Jens Axboe, io-uring

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>
---
 test/link-timeout.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

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 @@ 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;
 			}
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH liburing 0/2] update linked timeout tests
  2021-08-15  9:43 [PATCH liburing 0/2] update linked timeout tests Pavel Begunkov
  2021-08-15  9:43 ` [PATCH liburing 1/2] tests: close pipes in link-timeout Pavel Begunkov
  2021-08-15  9:43 ` [PATCH liburing 2/2] tests: fail early invalid linked setups Pavel Begunkov
@ 2021-08-15 15:15 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2021-08-15 15:15 UTC (permalink / raw)
  To: Pavel Begunkov, io-uring

On 8/15/21 3:43 AM, Pavel Begunkov wrote:
> 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.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-15 15:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-15  9:43 [PATCH liburing 0/2] update linked timeout tests Pavel Begunkov
2021-08-15  9:43 ` [PATCH liburing 1/2] tests: close pipes in link-timeout Pavel Begunkov
2021-08-15  9:43 ` [PATCH liburing 2/2] tests: fail early invalid linked setups Pavel Begunkov
2021-08-15 15:15 ` [PATCH liburing 0/2] update linked timeout tests Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).