summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2021-02-24 07:48:36 -0700
committerJens Axboe <axboe@kernel.dk>2021-02-24 07:48:36 -0700
commit3512f9afc5538f1ddaa02f956527effccc089cb7 (patch)
tree9ffb7e79fddf050bf44dc185917e162d533b5706
parent382bec7ea2bbcc366d04c02f37929ec5176926d7 (diff)
downloadliburing-3512f9afc5538f1ddaa02f956527effccc089cb7.tar.gz
liburing-3512f9afc5538f1ddaa02f956527effccc089cb7.tar.bz2
test: use ring creation helpers where appropriate
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/accept.c7
-rw-r--r--test/ce593a6c480a-test.c12
-rw-r--r--test/d4ae271dfaae-test.c8
-rw-r--r--test/d77a67ed5f27-test.c13
-rw-r--r--test/defer.c14
-rw-r--r--test/send_recv.c17
6 files changed, 32 insertions, 39 deletions
diff --git a/test/accept.c b/test/accept.c
index 4305f77..f096f8a 100644
--- a/test/accept.c
+++ b/test/accept.c
@@ -367,11 +367,10 @@ static int test_accept_sqpoll(void)
int ret, should_fail;
p.flags = IORING_SETUP_SQPOLL;
- ret = io_uring_queue_init_params(32, &m_io_uring, &p);
- if (ret && geteuid()) {
- printf("%s: skipped, not root\n", __FUNCTION__);
+ ret = t_create_ring_params(32, &m_io_uring, &p);
+ if (ret == T_SETUP_SKIP)
return 0;
- } else if (ret)
+ else if (ret < 0)
return ret;
should_fail = 1;
diff --git a/test/ce593a6c480a-test.c b/test/ce593a6c480a-test.c
index 9aee2f2..c6949f0 100644
--- a/test/ce593a6c480a-test.c
+++ b/test/ce593a6c480a-test.c
@@ -10,6 +10,7 @@
#include <unistd.h>
#include <pthread.h>
#include "liburing.h"
+#include "helpers.h"
static int use_sqpoll = 0;
@@ -66,11 +67,12 @@ int main(int argc, char *argv[])
p.flags = IORING_SETUP_SQPOLL;
/* Setup the ring with a registered event fd to be notified on events */
- ret = io_uring_queue_init_params(8, &ring, &p);
- if (ret) {
- fprintf(stderr, "queue_init=%d\n", ret);
- return 1;
- }
+ ret = t_create_ring_params(8, &ring, &p);
+ if (ret == T_SETUP_SKIP)
+ return 0;
+ else if (ret < 0)
+ return ret;
+
ret = io_uring_register_eventfd(&ring, loop_fd);
if (ret < 0) {
fprintf(stderr, "register_eventfd=%d\n", ret);
diff --git a/test/d4ae271dfaae-test.c b/test/d4ae271dfaae-test.c
index 5c67d4e..80d3f71 100644
--- a/test/d4ae271dfaae-test.c
+++ b/test/d4ae271dfaae-test.c
@@ -34,11 +34,11 @@ int main(int argc, char *argv[])
memset(&p, 0, sizeof(p));
p.flags = IORING_SETUP_SQPOLL;
- ret = io_uring_queue_init_params(4, &ring, &p);
- if (ret < 0) {
- fprintf(stderr, "queue_init: %s\n", strerror(-ret));
+ ret = t_create_ring_params(4, &ring, &p);
+ if (ret == T_SETUP_SKIP)
+ return 0;
+ else if (ret < 0)
return 1;
- }
if (argc > 1) {
fname = argv[1];
diff --git a/test/d77a67ed5f27-test.c b/test/d77a67ed5f27-test.c
index f3ef071..e56fdcd 100644
--- a/test/d77a67ed5f27-test.c
+++ b/test/d77a67ed5f27-test.c
@@ -5,6 +5,7 @@
#include <signal.h>
#include <stdlib.h>
#include "liburing.h"
+#include "helpers.h"
static void sig_alrm(int sig)
{
@@ -28,15 +29,11 @@ int main(int argc, char *argv[])
memset(&p, 0, sizeof(p));
p.sq_thread_idle = 100;
p.flags = IORING_SETUP_SQPOLL;
- ret = io_uring_queue_init_params(4, &ring, &p);
- if (ret) {
- if (geteuid()) {
- fprintf(stdout, "SQPOLL requires root, skipped\n");
- return 0;
- }
- fprintf(stderr, "ring create failed: %d\n", ret);
+ ret = t_create_ring_params(4, &ring, &p);
+ if (ret == T_SETUP_SKIP)
+ return 0;
+ else if (ret < 0)
return 1;
- }
/* make sure sq thread is sleeping at this point */
usleep(150000);
diff --git a/test/defer.c b/test/defer.c
index a8fe8d2..885cf5c 100644
--- a/test/defer.c
+++ b/test/defer.c
@@ -261,16 +261,12 @@ int main(int argc, char *argv[])
return 1;
}
- ret = io_uring_queue_init(1000, &sqthread_ring,
+ ret = t_create_ring(1000, &sqthread_ring,
IORING_SETUP_SQPOLL | IORING_SETUP_IOPOLL);
- if (ret) {
- if (geteuid()) {
- no_sqthread = 1;
- } else {
- printf("poll_ring setup failed\n");
- return 1;
- }
- }
+ if (ret == T_SETUP_SKIP)
+ return 0;
+ else if (ret < 0)
+ return 1;
ret = test_cancelled_userdata(&poll_ring);
if (ret) {
diff --git a/test/send_recv.c b/test/send_recv.c
index 85f77e8..19adbdd 100644
--- a/test/send_recv.c
+++ b/test/send_recv.c
@@ -13,6 +13,7 @@
#include <pthread.h>
#include "liburing.h"
+#include "helpers.h"
static char str[] = "This is a test of send and recv over io_uring!";
@@ -138,15 +139,13 @@ static void *recv_fn(void *data)
if (rd->use_sqthread)
p.flags = IORING_SETUP_SQPOLL;
- ret = io_uring_queue_init_params(1, &ring, &p);
- if (ret) {
- if (rd->use_sqthread && geteuid()) {
- fprintf(stdout, "Skipping SQPOLL variant\n");
- pthread_mutex_unlock(&rd->mutex);
- ret = 0;
- goto err;
- }
- fprintf(stderr, "queue init failed: %d\n", ret);
+ ret = t_create_ring_params(1, &ring, &p);
+ if (ret == T_SETUP_SKIP) {
+ pthread_mutex_unlock(&rd->mutex);
+ ret = 0;
+ goto err;
+ } else if (ret < 0) {
+ pthread_mutex_unlock(&rd->mutex);
goto err;
}