From: Dylan Yudaken <[email protected]>
To: <[email protected]>, <[email protected]>
Cc: <[email protected]>, <[email protected]>,
Dylan Yudaken <[email protected]>
Subject: [PATCH liburing 2/2] test: have poll-mshot-update run with both big and small cqe
Date: Thu, 21 Jul 2022 09:04:06 -0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Run the test twice, with and without overflow to make sure more codepaths
are tested.
Signed-off-by: Dylan Yudaken <[email protected]>
---
test/poll-mshot-update.c | 90 +++++++++++++++++++++++++---------------
1 file changed, 57 insertions(+), 33 deletions(-)
diff --git a/test/poll-mshot-update.c b/test/poll-mshot-update.c
index e01befcfa7eb..eeb725437cc8 100644
--- a/test/poll-mshot-update.c
+++ b/test/poll-mshot-update.c
@@ -213,52 +213,23 @@ static int arm_polls(struct io_uring *ring)
return 0;
}
-int main(int argc, char *argv[])
+static int run(int cqe)
{
struct io_uring ring;
struct io_uring_params params = { };
- struct rlimit rlim;
pthread_t thread;
int i, j, ret;
- if (argc > 1)
- return 0;
-
- ret = has_poll_update();
- if (ret < 0) {
- fprintf(stderr, "poll update check failed %i\n", ret);
- return -1;
- } else if (!ret) {
- fprintf(stderr, "no poll update, skip\n");
- return 0;
- }
-
- if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
- perror("getrlimit");
- goto err_noring;
- }
-
- if (rlim.rlim_cur < (2 * NFILES + 5)) {
- rlim.rlim_cur = (2 * NFILES + 5);
- rlim.rlim_max = rlim.rlim_cur;
- if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) {
- if (errno == EPERM)
- goto err_nofail;
- perror("setrlimit");
- goto err_noring;
- }
- }
-
for (i = 0; i < NFILES; i++) {
if (pipe(p[i].fd) < 0) {
perror("pipe");
- goto err_noring;
+ return 1;
}
fcntl(p[i].fd[0], F_SETFL, O_NONBLOCK);
}
params.flags = IORING_SETUP_CQSIZE;
- params.cq_entries = 4096;
+ params.cq_entries = cqe;
ret = io_uring_queue_init_params(RING_SIZE, &ring, ¶ms);
if (ret) {
if (ret == -EINVAL) {
@@ -286,10 +257,63 @@ int main(int argc, char *argv[])
}
io_uring_queue_exit(&ring);
+ for (i = 0; i < NFILES; i++) {
+ close(p[i].fd[0]);
+ close(p[i].fd[1]);
+ }
return 0;
err:
io_uring_queue_exit(&ring);
-err_noring:
+ return 1;
+}
+
+int main(int argc, char *argv[])
+{
+ struct rlimit rlim;
+ int ret;
+
+ if (argc > 1)
+ return 0;
+
+ ret = has_poll_update();
+ if (ret < 0) {
+ fprintf(stderr, "poll update check failed %i\n", ret);
+ return -1;
+ } else if (!ret) {
+ fprintf(stderr, "no poll update, skip\n");
+ return 0;
+ }
+
+ if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
+ perror("getrlimit");
+ goto err;
+ }
+
+ if (rlim.rlim_cur < (2 * NFILES + 5)) {
+ rlim.rlim_cur = (2 * NFILES + 5);
+ rlim.rlim_max = rlim.rlim_cur;
+ if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) {
+ if (errno == EPERM)
+ goto err_nofail;
+ perror("setrlimit");
+ goto err;
+ }
+ }
+
+ ret = run(1024);
+ if (ret) {
+ fprintf(stderr, "run(1024) failed\n");
+ goto err;
+ }
+
+ ret = run(8192);
+ if (ret) {
+ fprintf(stderr, "run(8192) failed\n");
+ goto err;
+ }
+
+ return 0;
+err:
fprintf(stderr, "poll-many failed\n");
return 1;
err_nofail:
--
2.30.2
next prev parent reply other threads:[~2022-07-21 16:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-21 16:04 [PATCH liburing 0/2] test: fix poll-mshot-update tests Dylan Yudaken
2022-07-21 16:04 ` [PATCH liburing 1/2] fixup poll-mshot-update Dylan Yudaken
2022-07-21 16:04 ` Dylan Yudaken [this message]
2022-07-21 16:50 ` [PATCH liburing 0/2] test: fix poll-mshot-update 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 \
[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