Merge branch 'test-io-after-child-exit' of https://github.com/anarazel/liburing
* 'test-io-after-child-exit' of https://github.com/anarazel/liburing:
tests: add test for using ring after a forked child exits.
diff --git a/test/500f9fbadef8-test.c b/test/500f9fbadef8-test.c
index 51081c5..dbd5751 100644
--- a/test/500f9fbadef8-test.c
+++ b/test/500f9fbadef8-test.c
@@ -29,7 +29,7 @@
if (argc > 1)
return 0;
- io_uring_posix_memalign(&iov.iov_base, 4096, 4096);
+ t_posix_memalign(&iov.iov_base, 4096, 4096);
iov.iov_len = 4096;
ret = io_uring_queue_init(1, &ring, IORING_SETUP_IOPOLL);
diff --git a/test/Makefile b/test/Makefile
index 69de572..f02bbd1 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -137,13 +137,13 @@
all: ${helpers} $(test_targets)
helpers.o: helpers.c helpers.c
- $(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
+ $(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $< -luring
%: %.c ${helpers} helpers.h
- $(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< -luring $(XCFLAGS) ${helpers}
+ $(QUIET_CC)$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< ${helpers} -luring $(XCFLAGS)
%: %.cc ${helpers} helpers.h
- $(QUIET_CXX)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< -luring $(XCFLAGS) ${helpers}
+ $(QUIET_CXX)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $< ${helpers} -luring $(XCFLAGS)
test_srcs := \
helpers.c \
diff --git a/test/accept.c b/test/accept.c
index a0a8ae6..f096f8a 100644
--- a/test/accept.c
+++ b/test/accept.c
@@ -33,7 +33,7 @@
struct io_uring_sqe *sqe;
struct data *d;
- d = io_uring_malloc(sizeof(*d));
+ d = t_malloc(sizeof(*d));
d->iov.iov_base = d->buf;
d->iov.iov_len = sizeof(d->buf);
@@ -46,7 +46,7 @@
struct io_uring_sqe *sqe;
struct data *d;
- d = io_uring_malloc(sizeof(*d));
+ d = t_malloc(sizeof(*d));
d->iov.iov_base = d->buf;
d->iov.iov_len = sizeof(d->buf);
@@ -247,7 +247,7 @@
ret = io_uring_queue_init(2 * nr, &m_io_uring, 0);
assert(ret >= 0);
- fds = io_uring_calloc(nr, sizeof(int));
+ fds = t_calloc(nr, sizeof(int));
for (i = 0; i < nr; i++)
fds[i] = start_accept_listen(NULL, i);
@@ -367,11 +367,10 @@
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 @@
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/cq-overflow.c b/test/cq-overflow.c
index f116678..274a815 100644
--- a/test/cq-overflow.c
+++ b/test/cq-overflow.c
@@ -460,9 +460,9 @@
return ret;
}
- io_uring_create_file(".basic-rw", FILE_SIZE);
+ t_create_file(".basic-rw", FILE_SIZE);
- vecs = io_uring_create_buffers(BUFFERS, BS);
+ vecs = t_create_buffers(BUFFERS, BS);
iters = 0;
usecs = 1000;
diff --git a/test/d4ae271dfaae-test.c b/test/d4ae271dfaae-test.c
index 06ec268..80d3f71 100644
--- a/test/d4ae271dfaae-test.c
+++ b/test/d4ae271dfaae-test.c
@@ -34,17 +34,17 @@
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];
} else {
fname = ".sqpoll.tmp";
- io_uring_create_file(fname, FILE_SIZE);
+ t_create_file(fname, FILE_SIZE);
}
fd = open(fname, O_RDONLY | O_DIRECT);
@@ -53,9 +53,9 @@
goto out;
}
- iovecs = io_uring_calloc(10, sizeof(struct iovec));
+ iovecs = t_calloc(10, sizeof(struct iovec));
for (i = 0; i < 10; i++) {
- io_uring_posix_memalign(&buf, 4096, 4096);
+ t_posix_memalign(&buf, 4096, 4096);
iovecs[i].iov_base = buf;
iovecs[i].iov_len = 4096;
}
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 @@
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 4151ff9..885cf5c 100644
--- a/test/defer.c
+++ b/test/defer.c
@@ -33,8 +33,8 @@
memset(ctx, 0, sizeof(*ctx));
ctx->nr = nr;
ctx->ring = ring;
- ctx->sqes = io_uring_malloc(nr * sizeof(*ctx->sqes));
- ctx->cqes = io_uring_malloc(nr * sizeof(*ctx->cqes));
+ ctx->sqes = t_malloc(nr * sizeof(*ctx->sqes));
+ ctx->cqes = t_malloc(nr * sizeof(*ctx->cqes));
if (!ctx->sqes || !ctx->cqes)
goto err;
@@ -261,16 +261,12 @@
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/eeed8b54e0df-test.c b/test/eeed8b54e0df-test.c
index a9c48ab..b6e27cc 100644
--- a/test/eeed8b54e0df-test.c
+++ b/test/eeed8b54e0df-test.c
@@ -31,7 +31,7 @@
return -1;
}
- buf = io_uring_malloc(BLOCK);
+ buf = t_malloc(BLOCK);
ret = write(fd, buf, BLOCK);
if (ret != BLOCK) {
if (ret < 0)
@@ -71,7 +71,7 @@
if (argc > 1)
return 0;
- iov.iov_base = io_uring_malloc(4096);
+ iov.iov_base = t_malloc(4096);
iov.iov_len = 4096;
ret = io_uring_queue_init(2, &ring, 0);
diff --git a/test/fadvise.c b/test/fadvise.c
index 69dc985..b6d4462 100644
--- a/test/fadvise.c
+++ b/test/fadvise.c
@@ -119,7 +119,7 @@
return 1;
}
- buf = io_uring_malloc(FILE_SIZE);
+ buf = t_malloc(FILE_SIZE);
cached_read = do_read(fd, buf);
if (cached_read == -1)
@@ -164,7 +164,7 @@
fname = argv[1];
} else {
fname = ".fadvise.tmp";
- io_uring_create_file(fname, FILE_SIZE);
+ t_create_file(fname, FILE_SIZE);
}
if (io_uring_queue_init(8, &ring, 0)) {
fprintf(stderr, "ring creation failed\n");
diff --git a/test/file-register.c b/test/file-register.c
index 2e08eca..c5c5507 100644
--- a/test/file-register.c
+++ b/test/file-register.c
@@ -39,7 +39,7 @@
int *files;
int i;
- files = io_uring_calloc(nr_files + extra, sizeof(int));
+ files = t_calloc(nr_files + extra, sizeof(int));
for (i = 0; i < nr_files; i++) {
if (!add)
@@ -157,7 +157,7 @@
goto err;
}
- fds = io_uring_malloc(100 * sizeof(int));
+ fds = t_malloc(100 * sizeof(int));
for (i = 0; i < 100; i++)
fds[i] = -1;
@@ -232,7 +232,7 @@
goto err;
}
- fds = io_uring_calloc(10, sizeof(int));
+ fds = t_calloc(10, sizeof(int));
for (i = 0; i < 10; i++)
fds[i] = -1;
@@ -424,11 +424,11 @@
struct iovec iov[2];
int ret;
- iov[0].iov_base = io_uring_malloc(4096);
+ iov[0].iov_base = t_malloc(4096);
iov[0].iov_len = 4096;
memset(iov[0].iov_base, 0x5a, 4096);
- iov[1].iov_base = io_uring_malloc(4096);
+ iov[1].iov_base = t_malloc(4096);
iov[1].iov_len = 4096;
sqe = io_uring_get_sqe(ring);
@@ -603,7 +603,7 @@
return ret;
}
- fds = io_uring_malloc(256 * sizeof(int));
+ fds = t_malloc(256 * sizeof(int));
for (i = 0; i < 256; i++)
fds[i] = -1;
diff --git a/test/file-update.c b/test/file-update.c
index 341005c..38059d4 100644
--- a/test/file-update.c
+++ b/test/file-update.c
@@ -37,7 +37,7 @@
int *files;
int i;
- files = io_uring_calloc(nr_files + extra, sizeof(int));
+ files = t_calloc(nr_files + extra, sizeof(int));
for (i = 0; i < nr_files; i++) {
if (!add)
@@ -108,7 +108,7 @@
struct io_uring_cqe *cqe;
int *fds, i, ret;
- fds = io_uring_malloc(sizeof(int) * 10);
+ fds = t_malloc(sizeof(int) * 10);
for (i = 0; i < 10; i++)
fds[i] = -1;
diff --git a/test/fixed-link.c b/test/fixed-link.c
index a7c3a5e..60d96ec 100644
--- a/test/fixed-link.c
+++ b/test/fixed-link.c
@@ -34,7 +34,7 @@
}
for (i = 0; i < IOVECS_LEN; ++i) {
- iovecs[i].iov_base = io_uring_malloc(64);
+ iovecs[i].iov_base = t_malloc(64);
iovecs[i].iov_len = 64;
};
diff --git a/test/fsync.c b/test/fsync.c
index 5aa5a83..7e93ecc 100644
--- a/test/fsync.c
+++ b/test/fsync.c
@@ -70,7 +70,7 @@
}
for (i = 0; i < 4; i++) {
- iovecs[i].iov_base = io_uring_malloc(4096);
+ iovecs[i].iov_base = t_malloc(4096);
iovecs[i].iov_len = 4096;
}
@@ -144,7 +144,7 @@
struct io_uring_sqe *sqe;
struct io_uring_cqe *cqe;
- io_uring_create_file(".sync_file_range", FILE_SIZE);
+ t_create_file(".sync_file_range", FILE_SIZE);
fd = open(".sync_file_range", O_RDWR);
save_errno = errno;
diff --git a/test/helpers.c b/test/helpers.c
index a2b98db..930d82a 100644
--- a/test/helpers.c
+++ b/test/helpers.c
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
+#include <sys/types.h>
#include "helpers.h"
#include "liburing.h"
@@ -15,7 +16,7 @@
/*
* Helper for allocating memory in tests.
*/
-void *io_uring_malloc(size_t size)
+void *t_malloc(size_t size)
{
void *ret;
ret = malloc(size);
@@ -26,7 +27,7 @@
/*
* Helper for allocating size bytes aligned on a boundary.
*/
-void io_uring_posix_memalign(void **memptr, size_t alignment, size_t size)
+void t_posix_memalign(void **memptr, size_t alignment, size_t size)
{
int ret;
ret = posix_memalign(memptr, alignment, size);
@@ -37,7 +38,7 @@
* Helper for allocating space for an array of nmemb elements
* with size bytes for each element.
*/
-void *io_uring_calloc(size_t nmemb, size_t size)
+void *t_calloc(size_t nmemb, size_t size)
{
void *ret;
ret = calloc(nmemb, size);
@@ -48,13 +49,13 @@
/*
* Helper for creating file and write @size byte buf with 0xaa value in the file.
*/
-void io_uring_create_file(const char *file, size_t size)
+void t_create_file(const char *file, size_t size)
{
ssize_t ret;
char *buf;
int fd;
- buf = io_uring_malloc(size);
+ buf = t_malloc(size);
memset(buf, 0xaa, size);
fd = open(file, O_WRONLY | O_CREAT, 0644);
@@ -71,15 +72,45 @@
* Helper for creating @buf_num number of iovec
* with @buf_size bytes buffer of each iovec.
*/
-struct iovec *io_uring_create_buffers(size_t buf_num, size_t buf_size)
+struct iovec *t_create_buffers(size_t buf_num, size_t buf_size)
{
struct iovec *vecs;
int i;
- vecs = io_uring_malloc(buf_num * sizeof(struct iovec));
+ vecs = t_malloc(buf_num * sizeof(struct iovec));
for (i = 0; i < buf_num; i++) {
- io_uring_posix_memalign(&vecs[i].iov_base, buf_size, buf_size);
+ t_posix_memalign(&vecs[i].iov_base, buf_size, buf_size);
vecs[i].iov_len = buf_size;
}
return vecs;
}
+
+/*
+ * Helper for setting up an io_uring instance, skipping if the given user isn't
+ * allowed to.
+ */
+enum t_setup_ret t_create_ring_params(int depth, struct io_uring *ring,
+ struct io_uring_params *p)
+{
+ int ret;
+
+ ret = io_uring_queue_init_params(depth, ring, p);
+ if (!ret)
+ return T_SETUP_OK;
+ if ((p->flags & IORING_SETUP_SQPOLL) && ret == -EPERM && geteuid()) {
+ fprintf(stdout, "SQPOLL skipped for regular user\n");
+ return T_SETUP_SKIP;
+ }
+
+ fprintf(stderr, "queue_init: %s\n", strerror(-ret));
+ return ret;
+}
+
+enum t_setup_ret t_create_ring(int depth, struct io_uring *ring,
+ unsigned int flags)
+{
+ struct io_uring_params p = { };
+
+ p.flags = flags;
+ return t_create_ring_params(depth, ring, &p);
+}
diff --git a/test/helpers.h b/test/helpers.h
index e6190ac..74fe162 100644
--- a/test/helpers.h
+++ b/test/helpers.h
@@ -9,35 +9,51 @@
extern "C" {
#endif
+#include "liburing.h"
+
+enum t_setup_ret {
+ T_SETUP_OK = 0,
+ T_SETUP_SKIP,
+};
+
/*
* Helper for allocating memory in tests.
*/
-void *io_uring_malloc(size_t size);
+void *t_malloc(size_t size);
/*
* Helper for allocating size bytes aligned on a boundary.
*/
-void io_uring_posix_memalign(void **memptr, size_t alignment, size_t size);
+void t_posix_memalign(void **memptr, size_t alignment, size_t size);
/*
* Helper for allocating space for an array of nmemb elements
* with size bytes for each element.
*/
-void *io_uring_calloc(size_t nmemb, size_t size);
+void *t_calloc(size_t nmemb, size_t size);
/*
* Helper for creating file and write @size byte buf with 0xaa value in the file.
*/
-void io_uring_create_file(const char *file, size_t size);
+void t_create_file(const char *file, size_t size);
/*
* Helper for creating @buf_num number of iovec
* with @buf_size bytes buffer of each iovec.
*/
-struct iovec *io_uring_create_buffers(size_t buf_num, size_t buf_size);
+struct iovec *t_create_buffers(size_t buf_num, size_t buf_size);
+
+/*
+ * Helper for setting up a ring and checking for user privs
+ */
+enum t_setup_ret t_create_ring_params(int depth, struct io_uring *ring,
+ struct io_uring_params *p);
+enum t_setup_ret t_create_ring(int depth, struct io_uring *ring,
+ unsigned int flags);
+
#ifdef __cplusplus
}
#endif
diff --git a/test/io-cancel.c b/test/io-cancel.c
index 1deb430..72ac971 100644
--- a/test/io-cancel.c
+++ b/test/io-cancel.c
@@ -203,9 +203,9 @@
if (argc > 1)
return 0;
- io_uring_create_file(".basic-rw", FILE_SIZE);
+ t_create_file(".basic-rw", FILE_SIZE);
- vecs = io_uring_create_buffers(BUFFERS, BS);
+ vecs = t_create_buffers(BUFFERS, BS);
for (i = 0; i < 4; i++) {
int v1 = (i & 1) != 0;
diff --git a/test/io_uring_enter.c b/test/io_uring_enter.c
index 698e37c..a6bb8f5 100644
--- a/test/io_uring_enter.c
+++ b/test/io_uring_enter.c
@@ -126,10 +126,10 @@
{
struct iovec *iov;
- iov = io_uring_malloc(sizeof(*iov));
+ iov = t_malloc(sizeof(*iov));
assert(iov);
- iov->iov_base = io_uring_malloc(len);
+ iov->iov_base = t_malloc(len);
assert(iov->iov_base);
iov->iov_len = len;
diff --git a/test/io_uring_register.c b/test/io_uring_register.c
index a45967b..7bcb036 100644
--- a/test/io_uring_register.c
+++ b/test/io_uring_register.c
@@ -242,7 +242,7 @@
return 0;
iov.iov_len = mlock_limit * 2;
- buf = io_uring_malloc(iov.iov_len);
+ buf = t_malloc(iov.iov_len);
iov.iov_base = buf;
while (iov.iov_len) {
@@ -284,8 +284,8 @@
struct iovec *iovs;
void *buf;
- buf = io_uring_malloc(pagesize);
- iovs = io_uring_malloc(nr * sizeof(struct iovec));
+ buf = t_malloc(pagesize);
+ iovs = t_malloc(nr * sizeof(struct iovec));
for (i = 0; i < nr; i++) {
iovs[i].iov_base = buf;
diff --git a/test/iopoll.c b/test/iopoll.c
index 4ddc646..3d94dfe 100644
--- a/test/iopoll.c
+++ b/test/iopoll.c
@@ -334,10 +334,10 @@
fname = argv[1];
} else {
fname = ".iopoll-rw";
- io_uring_create_file(fname, FILE_SIZE);
+ t_create_file(fname, FILE_SIZE);
}
- vecs = io_uring_create_buffers(BUFFERS, BS);
+ vecs = t_create_buffers(BUFFERS, BS);
nr = 16;
if (no_buf_select)
diff --git a/test/link_drain.c b/test/link_drain.c
index 45b1469..a50fe88 100644
--- a/test/link_drain.c
+++ b/test/link_drain.c
@@ -29,7 +29,7 @@
return 1;
}
- iovecs.iov_base = io_uring_malloc(4096);
+ iovecs.iov_base = t_malloc(4096);
iovecs.iov_len = 4096;
for (i = 0; i < 5; i++) {
@@ -112,7 +112,7 @@
return 1;
}
- iovecs.iov_base = io_uring_malloc(4096);
+ iovecs.iov_base = t_malloc(4096);
iovecs.iov_len = 4096;
for (i = 0; i < 9; i++) {
diff --git a/test/madvise.c b/test/madvise.c
index c06465f..89057af 100644
--- a/test/madvise.c
+++ b/test/madvise.c
@@ -104,7 +104,7 @@
return 1;
}
- buf = io_uring_malloc(FILE_SIZE);
+ buf = t_malloc(FILE_SIZE);
ptr = mmap(NULL, FILE_SIZE, PROT_READ, MAP_PRIVATE, fd, 0);
if (ptr == MAP_FAILED) {
@@ -159,7 +159,7 @@
fname = argv[1];
} else {
fname = ".madvise.tmp";
- io_uring_create_file(fname, FILE_SIZE);
+ t_create_file(fname, FILE_SIZE);
}
if (io_uring_queue_init(8, &ring, 0)) {
diff --git a/test/open-close.c b/test/open-close.c
index 6d44c6a..648737c 100644
--- a/test/open-close.c
+++ b/test/open-close.c
@@ -100,10 +100,10 @@
do_unlink = 1;
}
- io_uring_create_file(path, 4096);
+ t_create_file(path, 4096);
if (do_unlink)
- io_uring_create_file(path_rel, 4096);
+ t_create_file(path_rel, 4096);
ret = test_openat(&ring, path, -1);
if (ret < 0) {
diff --git a/test/openat2.c b/test/openat2.c
index 750a2b4..65f81b1 100644
--- a/test/openat2.c
+++ b/test/openat2.c
@@ -69,10 +69,10 @@
do_unlink = 1;
}
- io_uring_create_file(path, 4096);
+ t_create_file(path, 4096);
if (do_unlink)
- io_uring_create_file(path_rel, 4096);
+ t_create_file(path_rel, 4096);
ret = test_openat2(&ring, path, -1);
if (ret < 0) {
diff --git a/test/probe.c b/test/probe.c
index 0881240..c7fc053 100644
--- a/test/probe.c
+++ b/test/probe.c
@@ -68,7 +68,7 @@
int ret;
len = sizeof(*p) + 256 * sizeof(struct io_uring_probe_op);
- p = io_uring_calloc(1, len);
+ p = t_calloc(1, len);
ret = io_uring_register_probe(ring, p, 0);
if (ret == -EINVAL) {
fprintf(stdout, "Probe not supported, skipping\n");
diff --git a/test/read-write.c b/test/read-write.c
index 4a331d5..d0a77fa 100644
--- a/test/read-write.c
+++ b/test/read-write.c
@@ -29,9 +29,9 @@
{
int i;
- vecs = io_uring_malloc(BUFFERS * sizeof(struct iovec));
+ vecs = t_malloc(BUFFERS * sizeof(struct iovec));
for (i = 0; i < BUFFERS; i++) {
- char *p = io_uring_malloc(3 * BS);
+ char *p = t_malloc(3 * BS);
if (!p)
return 1;
@@ -332,7 +332,7 @@
exit(ret);
}
- p = io_uring_calloc(1, sizeof(*p) + 256 * sizeof(struct io_uring_probe_op));
+ p = t_calloc(1, sizeof(*p) + 256 * sizeof(struct io_uring_probe_op));
ret = io_uring_register_probe(&ring, p, 256);
/* if we don't have PROBE_REGISTER, we don't have OP_READ/WRITE */
if (ret == -EINVAL) {
@@ -752,10 +752,10 @@
fname = argv[1];
} else {
fname = ".basic-rw";
- io_uring_create_file(fname, FILE_SIZE);
+ t_create_file(fname, FILE_SIZE);
}
- vecs = io_uring_create_buffers(BUFFERS, BS);
+ vecs = t_create_buffers(BUFFERS, BS);
/* if we don't have nonvec read, skip testing that */
nr = has_nonvec_read() ? 32 : 16;
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 @@
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;
}
diff --git a/test/short-read.c b/test/short-read.c
index c839799..02eee04 100644
--- a/test/short-read.c
+++ b/test/short-read.c
@@ -26,10 +26,10 @@
if (argc > 1)
return 0;
- vec.iov_base = io_uring_malloc(BUF_SIZE);
+ vec.iov_base = t_malloc(BUF_SIZE);
vec.iov_len = BUF_SIZE;
- io_uring_create_file(".short-read", FILE_SIZE);
+ t_create_file(".short-read", FILE_SIZE);
fd = open(".short-read", O_RDONLY);
save_errno = errno;
diff --git a/test/splice.c b/test/splice.c
index 0834aa3..f4f0c9c 100644
--- a/test/splice.c
+++ b/test/splice.c
@@ -87,8 +87,8 @@
{
int ret, rnd_fd;
- ctx->buf_in = io_uring_calloc(BUF_SIZE, 1);
- ctx->buf_out = io_uring_calloc(BUF_SIZE, 1);
+ ctx->buf_in = t_calloc(BUF_SIZE, 1);
+ ctx->buf_out = t_calloc(BUF_SIZE, 1);
ctx->fd_in = create_file(".splice-test-in");
if (ctx->fd_in < 0) {
diff --git a/test/sq-poll-dup.c b/test/sq-poll-dup.c
index a6e50f0..eeb619c 100644
--- a/test/sq-poll-dup.c
+++ b/test/sq-poll-dup.c
@@ -161,10 +161,10 @@
fname = argv[1];
} else {
fname = ".basic-rw";
- io_uring_create_file(fname, FILE_SIZE);
+ t_create_file(fname, FILE_SIZE);
}
- vecs = io_uring_create_buffers(BUFFERS, BS);
+ vecs = t_create_buffers(BUFFERS, BS);
fd = open(fname, O_RDONLY | O_DIRECT);
if (fd < 0) {
diff --git a/test/sq-poll-share.c b/test/sq-poll-share.c
index 4f1192d..a46b94f 100644
--- a/test/sq-poll-share.c
+++ b/test/sq-poll-share.c
@@ -83,10 +83,10 @@
fname = argv[1];
} else {
fname = ".basic-rw";
- io_uring_create_file(fname, FILE_SIZE);
+ t_create_file(fname, FILE_SIZE);
}
- vecs = io_uring_create_buffers(BUFFERS, BS);
+ vecs = t_create_buffers(BUFFERS, BS);
fd = open(fname, O_RDONLY | O_DIRECT);
if (fd < 0) {
diff --git a/test/statx.c b/test/statx.c
index bd8b5a3..c0f9e9c 100644
--- a/test/statx.c
+++ b/test/statx.c
@@ -143,7 +143,7 @@
fname = argv[1];
} else {
fname = "/tmp/.statx";
- io_uring_create_file(fname, 4096);
+ t_create_file(fname, 4096);
}
ret = test_statx(&ring, fname);
diff --git a/test/stdout.c b/test/stdout.c
index 6380e1b..ade100a 100644
--- a/test/stdout.c
+++ b/test/stdout.c
@@ -21,7 +21,7 @@
char buffer[128];
int i, ret, fds[2];
- io_uring_posix_memalign(&vecs[0].iov_base, 4096, 4096);
+ t_posix_memalign(&vecs[0].iov_base, 4096, 4096);
memcpy(vecs[0].iov_base, str, strlen(str));
vecs[0].iov_len = strlen(str);
@@ -102,7 +102,7 @@
struct iovec vecs;
int ret;
- io_uring_posix_memalign(&vecs.iov_base, 4096, 4096);
+ t_posix_memalign(&vecs.iov_base, 4096, 4096);
memcpy(vecs.iov_base, str, strlen(str));
vecs.iov_len = strlen(str);
diff --git a/test/submit-reuse.c b/test/submit-reuse.c
index 3c09d8d..74ba769 100644
--- a/test/submit-reuse.c
+++ b/test/submit-reuse.c
@@ -158,9 +158,9 @@
}
if (do_unlink)
- io_uring_create_file(fname1, FILE_SIZE);
+ t_create_file(fname1, FILE_SIZE);
- io_uring_create_file(".reuse.2", FILE_SIZE);
+ t_create_file(".reuse.2", FILE_SIZE);
fd1 = open(fname1, O_RDONLY);
if (fd1 < 0) {
diff --git a/test/thread-exit.c b/test/thread-exit.c
index dc9bfaf..c2f2148 100644
--- a/test/thread-exit.c
+++ b/test/thread-exit.c
@@ -35,7 +35,7 @@
char *buffer;
int ret;
- buffer = io_uring_malloc(WSIZE);
+ buffer = t_malloc(WSIZE);
memset(buffer, 0x5a, WSIZE);
sqe = io_uring_get_sqe(d->ring);
if (!sqe) {
@@ -89,7 +89,7 @@
}
if (do_unlink)
- io_uring_create_file(fname, 4096);
+ t_create_file(fname, 4096);
fd = open(fname, O_WRONLY);
if (fd < 0) {