diff options
author | Hao Xu <howeyxu@tencent.com> | 2022-05-14 22:35:33 +0800 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-05-14 09:15:38 -0600 |
commit | 70e40d8de2ce5e3196c84344f611ca70f34e8182 (patch) | |
tree | d8441492a0fa3363b1021d8d3406cc54994e062f | |
parent | 66cf84527c34acf8ea37b5cc048f04018b22ed2c (diff) | |
download | liburing-70e40d8de2ce5e3196c84344f611ca70f34e8182.tar.gz liburing-70e40d8de2ce5e3196c84344f611ca70f34e8182.tar.bz2 |
test/accept.c: test for multishot direct accept with wrong arg
Add a test for multishot direct accept, where don't set the file index
to IORING_FILE_INDEX_ALLOC.
Signed-off-by: Hao Xu <howeyxu@tencent.com>
Link: https://lore.kernel.org/r/20220514143534.59162-6-haoxu.linux@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | test/accept.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/accept.c b/test/accept.c index 897278a..921c79b 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"); |