@@ -4,7 +4,6 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
-#include <error.h>
#include <sys/eventfd.h>
#include <signal.h>
#include <poll.h>
@@ -11,7 +11,6 @@
#include <signal.h>
#include <poll.h>
#include <sys/wait.h>
-#include <error.h>
#include <assert.h>
#include "helpers.h"
@@ -19,8 +18,10 @@
static void do_setsockopt(int fd, int level, int optname, int val)
{
- if (setsockopt(fd, level, optname, &val, sizeof(val)))
- error(1, errno, "setsockopt %d.%d: %d", level, optname, val);
+ if (setsockopt(fd, level, optname, &val, sizeof(val))) {
+ fprintf(stderr, "setsockopt %d.%d: %d\n", level, optname, val);
+ exit(T_EXIT_FAIL);
+ }
}
static bool check_cq_empty(struct io_uring *ring)
@@ -4,7 +4,6 @@
#include <stdint.h>
#include <assert.h>
#include <errno.h>
-#include <error.h>
#include <limits.h>
#include <fcntl.h>
#include <unistd.h>
@@ -5,7 +5,6 @@
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
-#include <error.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -55,14 +54,20 @@ static int try_submit(struct io_uring *ring)
if (ret < 0)
return ret;
- if (ret != 1)
- error(1, ret, "submit %i", ret);
+ if (ret != 1) {
+ fprintf(stderr, "submit %i\n", ret);
+ exit(T_EXIT_FAIL);
+ }
ret = io_uring_wait_cqe(ring, &cqe);
- if (ret)
- error(1, ret, "wait fail %i", ret);
+ if (ret) {
+ fprintf(stderr, "wait fail %i\n", ret);
+ exit(T_EXIT_FAIL);
+ }
- if (cqe->res || cqe->user_data != 42)
- error(1, ret, "invalid cqe");
+ if (cqe->res || cqe->user_data != 42) {
+ fprintf(stderr, "invalid cqe %i\n", cqe->res);
+ exit(T_EXIT_FAIL);
+ }
io_uring_cqe_seen(ring, cqe);
return 0;
@@ -104,8 +109,10 @@ int main(int argc, char *argv[])
/* test that the first submitter but not creator can submit */
ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER |
IORING_SETUP_R_DISABLED);
- if (ret)
- error(1, ret, "ring init (2) %i", ret);
+ if (ret) {
+ fprintf(stderr, "ring init (2) %i\n", ret);
+ exit(T_EXIT_FAIL);
+ }
if (!fork_t()) {
io_uring_enable_rings(&ring);
@@ -120,8 +127,10 @@ int main(int argc, char *argv[])
/* test that only the first enabler can submit */
ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER |
IORING_SETUP_R_DISABLED);
- if (ret)
- error(1, ret, "ring init (3) %i", ret);
+ if (ret) {
+ fprintf(stderr, "ring init (3) %i\n", ret);
+ exit(T_EXIT_FAIL);
+ }
io_uring_enable_rings(&ring);
if (!fork_t()) {
@@ -135,8 +144,10 @@ int main(int argc, char *argv[])
/* test that anyone can submit to a SQPOLL|SINGLE_ISSUER ring */
ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER|IORING_SETUP_SQPOLL);
- if (ret)
- error(1, ret, "ring init (4) %i", ret);
+ if (ret) {
+ fprintf(stderr, "ring init (4) %i\n", ret);
+ exit(T_EXIT_FAIL);
+ }
ret = try_submit(&ring);
if (ret) {
@@ -155,8 +166,10 @@ int main(int argc, char *argv[])
/* test that IORING_ENTER_REGISTERED_RING doesn't break anything */
ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER);
- if (ret)
- error(1, ret, "ring init (5) %i", ret);
+ if (ret) {
+ fprintf(stderr, "ring init (5) %i\n", ret);
+ exit(T_EXIT_FAIL);
+ }
if (!fork_t()) {
ret = try_submit(&ring);
Sam reports that building liburing tests on Gentoo is broken due to '#include <error.h>': ``` x86_64-gentoo-linux-musl-gcc -D_GNU_SOURCE -D__SANE_USERSPACE_TYPES__ \ -I../src/include/ -include ../config-host.h -pipe -march=native \ -fno-diagnostics-color -O2 -Wno-unused-parameter -Wno-sign-compare \ -Wstringop-overflow=0 -Warray-bounds=0 -DLIBURING_BUILD_TEST -o \ single-issuer.t single-issuer.c helpers.o -Wl,-O1 -Wl,--as-needed \ -Wl,--defsym=__gentoo_check_ldflags__=0 -L../src/ -luring -lpthread single-issuer.c:8:10: fatal error: error.h: No such file or directory 8 | #include <error.h> | ^~~~~~~~~ ``` This header is a GNU extension for glibc. It doesn't exist in musl libc. Don't use error.h to make it portable. Fixes: https://github.com/axboe/liburing/issues/786 Bug: https://bugs.gentoo.org/888956 Reported-by: Sam James <sam@gentoo.org> Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> --- test/defer-taskrun.c | 1 - test/poll.c | 7 ++++--- test/send-zerocopy.c | 1 - test/single-issuer.c | 43 ++++++++++++++++++++++++++++--------------- 4 files changed, 32 insertions(+), 20 deletions(-) base-commit: 7b09481f27fa86e8828f774ddca92ce14f14fafe