summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2020-02-14 10:15:28 -0700
committerJens Axboe <axboe@kernel.dk>2020-02-14 10:15:28 -0700
commit728244b0cecce34a65eaad0fd7ea9dcc4cca7f99 (patch)
tree9a7fa6500f01901bf131d3853676e043b50935a9
parent2454d6301d83a714d0775662b512fd46dbf82a0d (diff)
parent6cf7678decfc58afce28ca9f2afe44510b0c5963 (diff)
downloadliburing-728244b0cecce34a65eaad0fd7ea9dcc4cca7f99.tar.gz
liburing-728244b0cecce34a65eaad0fd7ea9dcc4cca7f99.tar.bz2
Merge branch 'pu/test-suite' of https://github.com/guillemj/liburing
* 'pu/test-suite' of https://github.com/guillemj/liburing: test: Initialize the data struct to set stop member to 0 test: Distinguish failure messages for accept-link test: Expect fail values from io_uring calls to be -errno instead of -1 test: Handle NULL sqe and cqe in tests test: Unify queue init failed error message test: Cleanup file artifacts on early exits test: Skip tests where the kernel lacks support Add src/include/liburing/compat.h to .gitignore
-rw-r--r--.gitignore1
-rw-r--r--test/accept-link.c3
-rw-r--r--test/connect.c6
-rw-r--r--test/fadvise.c1
-rw-r--r--test/madvise.c1
-rw-r--r--test/poll-v-poll.c7
-rw-r--r--test/read-write.c6
-rw-r--r--test/send_recv.c26
-rw-r--r--test/send_recvmsg.c17
-rw-r--r--test/short-read.c5
10 files changed, 59 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore
index 645e944..1ab4075 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@
/src/liburing.a
/src/liburing.so*
+/src/include/liburing/compat.h
/examples/io_uring-cp
/examples/io_uring-test
diff --git a/test/accept-link.c b/test/accept-link.c
index 759d980..a6c2aef 100644
--- a/test/accept-link.c
+++ b/test/accept-link.c
@@ -176,6 +176,7 @@ static int test_accept_timeout(int do_connect, unsigned long timeout)
recv_thread_ready = 0;
recv_thread_done = 0;
+ memset(&d, 0, sizeof(d));
d.timeout = timeout;
if (!do_connect) {
d.expected[0] = -EINTR;
@@ -212,7 +213,7 @@ int main(int argc, char *argv[])
}
if (test_accept_timeout(1, 1000000000)) {
- fprintf(stderr, "accept timeout 0 failed\n");
+ fprintf(stderr, "accept and connect timeout 0 failed\n");
return 1;
}
diff --git a/test/connect.c b/test/connect.c
index 96aac97..90f53e5 100644
--- a/test/connect.c
+++ b/test/connect.c
@@ -42,7 +42,7 @@ static int submit_and_wait(struct io_uring *ring, int *res)
}
ret = io_uring_peek_cqe(ring, &cqe);
- if (ret == -1) {
+ if (ret) {
fprintf(stderr, "io_uring_peek_cqe(): no cqe returned");
return 1;
}
@@ -233,8 +233,8 @@ int main(int argc, char *argv[])
int ret;
ret = io_uring_queue_init(8, &ring, 0);
- if (ret == -1) {
- perror("io_uring_queue_setup()");
+ if (ret) {
+ fprintf(stderr, "io_uring_queue_setup() = %d\n", ret);
return 1;
}
diff --git a/test/fadvise.c b/test/fadvise.c
index cb18adc..7484c7b 100644
--- a/test/fadvise.c
+++ b/test/fadvise.c
@@ -91,6 +91,7 @@ static int do_fadvise(struct io_uring *ring, int fd, off_t offset, off_t len,
ret = cqe->res;
if (ret == -EINVAL || ret == -EBADF) {
fprintf(stdout, "Fadvise not supported, skipping\n");
+ unlink(".fadvise.tmp");
exit(0);
} else if (ret) {
fprintf(stderr, "cqe->res=%d\n", cqe->res);
diff --git a/test/madvise.c b/test/madvise.c
index 1b11092..e9101c0 100644
--- a/test/madvise.c
+++ b/test/madvise.c
@@ -92,6 +92,7 @@ static int do_madvise(struct io_uring *ring, void *addr, off_t len, int advice)
ret = cqe->res;
if (ret == -EINVAL || ret == -EBADF) {
fprintf(stdout, "Madvise not supported, skipping\n");
+ unlink(".madvise.tmp");
exit(0);
} else if (ret) {
fprintf(stderr, "cqe->res=%d\n", cqe->res);
diff --git a/test/poll-v-poll.c b/test/poll-v-poll.c
index 61d40dd..c8ba6f1 100644
--- a/test/poll-v-poll.c
+++ b/test/poll-v-poll.c
@@ -259,8 +259,13 @@ static int do_test_epoll(struct io_uring *ring, int iou_epoll_add)
return 1;
}
} else {
- if (iou_epoll_ctl(ring, fd, pipe1[0], &ev))
+ ret = iou_epoll_ctl(ring, fd, pipe1[0], &ev);
+ if (ret == -EINVAL) {
+ fprintf(stdout, "epoll not supported, skipping\n");
+ return 0;
+ } else if (ret < 0) {
return 1;
+ }
}
td.ring = ring;
diff --git a/test/read-write.c b/test/read-write.c
index c3c10f9..c18993c 100644
--- a/test/read-write.c
+++ b/test/read-write.c
@@ -288,7 +288,7 @@ static int has_nonvec_read(void)
ret = io_uring_queue_init(1, &ring, 0);
if (ret) {
- fprintf(stderr, "queue init: %d\n", ret);
+ fprintf(stderr, "queue init failed: %d\n", ret);
exit(ret);
}
@@ -344,7 +344,9 @@ static int test_eventfd_read(void)
fprintf(stderr, "wait_cqe=%d\n", ret);
return 1;
}
- if (cqe->res != sizeof(eventfd_t)) {
+ if (cqe->res == -EINVAL) {
+ fprintf(stdout, "eventfd IO not supported, skipping\n");
+ } else if (cqe->res != sizeof(eventfd_t)) {
fprintf(stderr, "cqe res %d, wanted %ld\n", cqe->res, sizeof(eventfd_t));
return 1;
}
diff --git a/test/send_recv.c b/test/send_recv.c
index 2455163..000dad7 100644
--- a/test/send_recv.c
+++ b/test/send_recv.c
@@ -2,6 +2,7 @@
/*
* Simple test case showing using send and recv through io_uring
*/
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -69,6 +70,10 @@ static int do_recv(struct io_uring *ring, struct iovec *iov)
struct io_uring_cqe *cqe;
io_uring_wait_cqe(ring, &cqe);
+ if (cqe->res == -EINVAL) {
+ fprintf(stdout, "recv not supported, skipping\n");
+ return 0;
+ }
if (cqe->res < 0) {
fprintf(stderr, "failed cqe: %d\n", cqe->res);
goto err;
@@ -101,13 +106,23 @@ static void *recv_fn(void *data)
struct io_uring ring;
int ret;
- io_uring_queue_init(1, &ring, 0);
+ ret = io_uring_queue_init(1, &ring, 0);
+ if (ret) {
+ fprintf(stderr, "queue init failed: %d\n", ret);
+ goto err;
+ }
- recv_prep(&ring, &iov);
+ ret = recv_prep(&ring, &iov);
+ if (ret) {
+ fprintf(stderr, "recv_prep failed: %d\n", ret);
+ goto err;
+ }
pthread_mutex_unlock(mutex);
ret = do_recv(&ring, &iov);
io_uring_queue_exit(&ring);
+
+err:
return (void *)(intptr_t)ret;
}
@@ -125,7 +140,7 @@ static int do_send(void)
ret = io_uring_queue_init(1, &ring, 0);
if (ret) {
- fprintf(stderr, "queue init fail: %d\n", ret);
+ fprintf(stderr, "queue init failed: %d\n", ret);
return 1;
}
@@ -157,6 +172,11 @@ static int do_send(void)
}
ret = io_uring_wait_cqe(&ring, &cqe);
+ if (cqe->res == -EINVAL) {
+ fprintf(stdout, "send not supported, skipping\n");
+ close(sockfd);
+ return 0;
+ }
if (cqe->res != iov.iov_len) {
fprintf(stderr, "failed cqe: %d\n", cqe->res);
goto err;
diff --git a/test/send_recvmsg.c b/test/send_recvmsg.c
index b208749..444d6a8 100644
--- a/test/send_recvmsg.c
+++ b/test/send_recvmsg.c
@@ -101,13 +101,24 @@ static void *recv_fn(void *data)
struct io_uring ring;
int ret;
- io_uring_queue_init(1, &ring, 0);
+ ret = io_uring_queue_init(1, &ring, 0);
+ if (ret) {
+ fprintf(stderr, "queue init failed: %d\n", ret);
+ goto err;
+ }
+
+ ret = recv_prep(&ring, &iov);
+ if (ret) {
+ fprintf(stderr, "recv_prep failed: %d\n", ret);
+ goto err;
+ }
- recv_prep(&ring, &iov);
pthread_mutex_unlock(mutex);
ret = do_recvmsg(&ring, &iov);
io_uring_queue_exit(&ring);
+
+err:
return (void *)(intptr_t)ret;
}
@@ -126,7 +137,7 @@ static int do_sendmsg(void)
ret = io_uring_queue_init(1, &ring, 0);
if (ret) {
- fprintf(stderr, "queue init fail: %d\n", ret);
+ fprintf(stderr, "queue init failed: %d\n", ret);
return 1;
}
diff --git a/test/short-read.c b/test/short-read.c
index 94a148f..2519a74 100644
--- a/test/short-read.c
+++ b/test/short-read.c
@@ -34,7 +34,7 @@ static int create_file(const char *file)
int main(int argc, char *argv[])
{
- int ret, fd;
+ int ret, fd, save_errno;
struct io_uring ring;
struct io_uring_sqe *sqe;
struct io_uring_cqe *cqe;
@@ -49,6 +49,9 @@ int main(int argc, char *argv[])
}
fd = open(".short-read", O_RDONLY);
+ save_errno = errno;
+ unlink(".short-read");
+ errno = save_errno;
if (fd < 0) {
perror("file open");
return 1;