From: Dylan Yudaken <[email protected]>
To: <[email protected]>
Cc: <[email protected]>, <[email protected]>, <[email protected]>,
Dylan Yudaken <[email protected]>
Subject: [PATCH liburing v2 7/7] test: use remove_buffers instead of nop to generate error codes
Date: Fri, 22 Apr 2022 09:01:32 -0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
This is in prep for allwoing NOP to be used in IOPOLL mode. remove_buffers
will consistently return ENOENT if asked to remove buffers from a
nonexistent group, and so this is a suitable replacement. Other opcodes
return -EINVAL in IOPOLL from the prep stage, which has slightly different
behaviour.
Signed-off-by: Dylan Yudaken <[email protected]>
---
test/defer.c | 28 ++++++++++++++++++++--------
test/link.c | 6 +++---
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/test/defer.c b/test/defer.c
index 825b69f..68ee4b4 100644
--- a/test/defer.c
+++ b/test/defer.c
@@ -12,6 +12,10 @@
#include "liburing.h"
#define RING_SIZE 128
+enum {
+ OP_NOP,
+ OP_REMOVE_BUFFERS
+};
struct test_context {
struct io_uring *ring;
@@ -27,7 +31,8 @@ static void free_context(struct test_context *ctx)
memset(ctx, 0, sizeof(*ctx));
}
-static int init_context(struct test_context *ctx, struct io_uring *ring, int nr)
+static int init_context(struct test_context *ctx, struct io_uring *ring, int nr,
+ int op)
{
struct io_uring_sqe *sqe;
int i;
@@ -45,7 +50,14 @@ static int init_context(struct test_context *ctx, struct io_uring *ring, int nr)
sqe = io_uring_get_sqe(ring);
if (!sqe)
goto err;
- io_uring_prep_nop(sqe);
+ switch (op) {
+ case OP_NOP:
+ io_uring_prep_nop(sqe);
+ break;
+ case OP_REMOVE_BUFFERS:
+ io_uring_prep_remove_buffers(sqe, 10, 1);
+ break;
+ };
sqe->user_data = i;
ctx->sqes[i] = sqe;
}
@@ -81,7 +93,7 @@ static int test_cancelled_userdata(struct io_uring *ring)
struct test_context ctx;
int ret, i, nr = 100;
- if (init_context(&ctx, ring, nr))
+ if (init_context(&ctx, ring, nr, OP_NOP))
return 1;
for (i = 0; i < nr; i++)
@@ -115,7 +127,7 @@ static int test_thread_link_cancel(struct io_uring *ring)
struct test_context ctx;
int ret, i, nr = 100;
- if (init_context(&ctx, ring, nr))
+ if (init_context(&ctx, ring, nr, OP_REMOVE_BUFFERS))
return 1;
for (i = 0; i < nr; i++)
@@ -134,12 +146,12 @@ static int test_thread_link_cancel(struct io_uring *ring)
bool fail = false;
if (i == 0)
- fail = (ctx.cqes[i].res != -EINVAL);
+ fail = (ctx.cqes[i].res != -ENOENT);
else
fail = (ctx.cqes[i].res != -ECANCELED);
if (fail) {
- printf("invalid status\n");
+ printf("invalid status %d\n", ctx.cqes[i].res);
goto err;
}
}
@@ -158,7 +170,7 @@ static int test_drain_with_linked_timeout(struct io_uring *ring)
struct test_context ctx;
int ret, i;
- if (init_context(&ctx, ring, nr * 2))
+ if (init_context(&ctx, ring, nr * 2, OP_NOP))
return 1;
for (i = 0; i < nr; i++) {
@@ -188,7 +200,7 @@ static int run_drained(struct io_uring *ring, int nr)
struct test_context ctx;
int ret, i;
- if (init_context(&ctx, ring, nr))
+ if (init_context(&ctx, ring, nr, OP_NOP))
return 1;
for (i = 0; i < nr; i++)
diff --git a/test/link.c b/test/link.c
index c89d6b2..41d3899 100644
--- a/test/link.c
+++ b/test/link.c
@@ -178,7 +178,7 @@ static int test_single_link_fail(struct io_uring *ring)
goto err;
}
- io_uring_prep_nop(sqe);
+ io_uring_prep_remove_buffers(sqe, 10, 1);
sqe->flags |= IOSQE_IO_LINK;
sqe = io_uring_get_sqe(ring);
@@ -205,8 +205,8 @@ static int test_single_link_fail(struct io_uring *ring)
printf("failed to get cqe\n");
goto err;
}
- if (i == 0 && cqe->res != -EINVAL) {
- printf("sqe0 failed with %d, wanted -EINVAL\n", cqe->res);
+ if (i == 0 && cqe->res != -ENOENT) {
+ printf("sqe0 failed with %d, wanted -ENOENT\n", cqe->res);
goto err;
}
if (i == 1 && cqe->res != -ECANCELED) {
--
2.30.2
next prev parent reply other threads:[~2022-04-22 16:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-22 16:01 [PATCH liburing v2 0/7] run tests in parallel Dylan Yudaken
2022-04-22 16:01 ` [PATCH liburing v2 1/7] test: handle mmap return failures in pollfree test Dylan Yudaken
2022-04-22 16:01 ` [PATCH liburing v2 2/7] test: use unique path for socket Dylan Yudaken
2022-04-22 16:01 ` [PATCH liburing v2 3/7] test: use unique ports Dylan Yudaken
2022-04-22 16:01 ` [PATCH liburing v2 4/7] test: use unique filenames Dylan Yudaken
2022-04-22 16:01 ` [PATCH liburing v2 5/7] test: mkdir -p output folder Dylan Yudaken
2022-04-22 16:01 ` [PATCH liburing v2 6/7] test: add make targets for each test Dylan Yudaken
2022-04-22 16:01 ` Dylan Yudaken [this message]
2022-04-22 17:30 ` [PATCH liburing v2 0/7] run tests in parallel 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] \
[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