public inbox for [email protected]
 help / color / mirror / Atom feed
From: Hao Xu <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, Pavel Begunkov <[email protected]>
Subject: [PATCH 5/6] test/accept.c: test for multishot direct accept with wrong arg
Date: Sat, 14 May 2022 22:35:33 +0800	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

From: Hao Xu <[email protected]>

Add a test for multishot direct accept, where don't set the file index
to IORING_FILE_INDEX_ALLOC.

Signed-off-by: Hao Xu <[email protected]>
---
 test/accept.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/test/accept.c b/test/accept.c
index 897278a2a3c3..921c79b862db 100644
--- a/test/accept.c
+++ b/test/accept.c
@@ -541,6 +541,43 @@ static int test_multishot_accept(int count, bool before)
 	return ret;
 }
 
+static int test_accept_multishot_wrong_arg()
+{
+	struct io_uring m_io_uring;
+	struct io_uring_cqe *cqe;
+	struct io_uring_sqe *sqe;
+	int fd, ret;
+
+	ret = io_uring_queue_init(4, &m_io_uring, 0);
+	assert(ret >= 0);
+
+	fd = start_accept_listen(NULL, 0, 0);
+
+	sqe = io_uring_get_sqe(&m_io_uring);
+	io_uring_prep_multishot_accept_direct(sqe, fd, NULL, NULL, 0);
+	sqe->file_index = 1;
+	ret = io_uring_submit(&m_io_uring);
+	assert(ret == 1);
+
+	ret = io_uring_wait_cqe(&m_io_uring, &cqe);
+	assert(!ret);
+	if (cqe->res != -EINVAL) {
+		fprintf(stderr, "file index should be IORING_FILE_INDEX_ALLOC \
+				if its accept in multishot direct mode\n");
+		goto err;
+	}
+	io_uring_cqe_seen(&m_io_uring, cqe);
+
+	io_uring_queue_exit(&m_io_uring);
+	close(fd);
+	return 0;
+err:
+	io_uring_queue_exit(&m_io_uring);
+	close(fd);
+	return 1;
+}
+
+
 static int test_accept_nonblock(bool queue_before_connect, int count)
 {
 	struct io_uring m_io_uring;
@@ -673,6 +710,12 @@ int main(int argc, char *argv[])
 		return ret;
 	}
 
+	ret = test_accept_multishot_wrong_arg();
+	if (ret) {
+		fprintf(stderr, "test_accept_multishot_wrong_arg failed\n");
+		return ret;
+	}
+
 	ret = test_accept_sqpoll();
 	if (ret) {
 		fprintf(stderr, "test_accept_sqpoll failed\n");
-- 
2.36.0


  parent reply	other threads:[~2022-05-14 14:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-14 14:35 [PATCH liburing 0/6] liburing changes for multishot accept Hao Xu
2022-05-14 14:35 ` [PATCH 1/6] test/accept.c: close the listen fd at the end of the test Hao Xu
2022-05-14 14:35 ` [PATCH 2/6] liburing.h: support multishot accept Hao Xu
2022-05-14 14:35 ` [PATCH 3/6] liburing.h: add api to support multishot accept direct Hao Xu
2022-05-14 14:35 ` [PATCH 4/6] test/accept.c: add test for multishot mode accept Hao Xu
2022-05-14 14:35 ` Hao Xu [this message]
2022-05-14 14:35 ` [PATCH 6/6] man/io_uring_prep_accept.3: add man info for multishot accept Hao Xu
2022-05-14 15:32 ` [PATCH liburing 0/6] liburing changes " Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox