From: Pavel Begunkov <[email protected]>
To: [email protected]
Cc: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH liburing 2/3] tests/zc: add control flags tests
Date: Fri, 4 Nov 2022 11:05:52 +0000 [thread overview]
Message-ID: <49b3b714bce66a056b645afe894748f7cabd548d.1667559818.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Signed-off-by: Pavel Begunkov <[email protected]>
---
test/send-zerocopy.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index 30b50e1..6e637f4 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -123,7 +123,7 @@ static int test_send_faults(int sock_tx, int sock_rx)
int msg_flags = 0;
unsigned zc_flags = 0;
int payload_size = 100;
- int ret, i, nr_cqes = 2;
+ int ret, i, nr_cqes, nr_reqs = 3;
struct io_uring ring;
ret = io_uring_queue_init(32, &ring, IORING_SETUP_SUBMIT_ALL);
@@ -132,28 +132,44 @@ static int test_send_faults(int sock_tx, int sock_rx)
return -1;
}
+ /* invalid buffer */
sqe = io_uring_get_sqe(&ring);
io_uring_prep_send_zc(sqe, sock_tx, (void *)1UL, payload_size,
msg_flags, zc_flags);
sqe->user_data = 1;
+ /* invalid address */
sqe = io_uring_get_sqe(&ring);
io_uring_prep_send_zc(sqe, sock_tx, tx_buffer, payload_size,
msg_flags, zc_flags);
- sqe->user_data = 2;
io_uring_prep_send_set_addr(sqe, (const struct sockaddr *)1UL,
sizeof(struct sockaddr_in6));
+ sqe->user_data = 2;
+
+ /* invalid send/recv flags */
+ sqe = io_uring_get_sqe(&ring);
+ io_uring_prep_send_zc(sqe, sock_tx, tx_buffer, payload_size,
+ msg_flags, ~0U);
+ sqe->user_data = 3;
ret = io_uring_submit(&ring);
- assert(ret == 2);
+ assert(ret == nr_reqs);
+ nr_cqes = nr_reqs;
for (i = 0; i < nr_cqes; i++) {
ret = io_uring_wait_cqe(&ring, &cqe);
assert(!ret);
- assert(cqe->user_data <= 2);
+ assert(cqe->user_data <= nr_reqs);
if (!(cqe->flags & IORING_CQE_F_NOTIF)) {
- assert(cqe->res == -EFAULT);
+ int expected = (cqe->user_data == 3) ? -EINVAL : -EFAULT;
+
+ if (cqe->res != expected) {
+ fprintf(stderr, "invalid cqe res %i vs expected %i, "
+ "user_data %i\n",
+ cqe->res, expected, (int)cqe->user_data);
+ return -1;
+ }
if (cqe->flags & IORING_CQE_F_MORE)
nr_cqes++;
}
--
2.38.0
next prev parent reply other threads:[~2022-11-04 11:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-04 11:05 [PATCH liburing 0/3] some extra zc tests Pavel Begunkov
2022-11-04 11:05 ` [PATCH liburing 1/3] tests/zc: create a new ring for test_send_faults() Pavel Begunkov
2022-11-04 11:05 ` Pavel Begunkov [this message]
2022-11-04 11:05 ` [PATCH liburing 3/3] tests/zc: extra verification for notif completions Pavel Begunkov
2022-11-05 15:20 ` [PATCH liburing 0/3] some extra zc tests 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 \
--in-reply-to=49b3b714bce66a056b645afe894748f7cabd548d.1667559818.git.asml.silence@gmail.com \
[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