From: Ammar Faizi <[email protected]>
To: Jens Axboe <[email protected]>
Cc: Pavel Begunkov <[email protected]>,
Sam James <[email protected]>,
io-uring Mailing List <[email protected]>,
Linux Kernel Mailing List <[email protected]>,
GNU/Weeb Mailing List <[email protected]>,
Ammar Faizi <[email protected]>
Subject: [PATCH liburing] tests: Don't use error.h because it's not portable
Date: Mon, 13 Feb 2023 06:40:46 +0700 [thread overview]
Message-ID: <[email protected]> (raw)
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 <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
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(-)
diff --git a/test/defer-taskrun.c b/test/defer-taskrun.c
index 4ae79792274ac723..bcc59a47b24c3e24 100644
--- a/test/defer-taskrun.c
+++ b/test/defer-taskrun.c
@@ -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>
diff --git a/test/poll.c b/test/poll.c
index 1b8b416887a9c44f..325c4f57cfc1b1c4 100644
--- a/test/poll.c
+++ b/test/poll.c
@@ -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)
diff --git a/test/send-zerocopy.c b/test/send-zerocopy.c
index ab56397aca230dcc..86a31cd6403283a8 100644
--- a/test/send-zerocopy.c
+++ b/test/send-zerocopy.c
@@ -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>
diff --git a/test/single-issuer.c b/test/single-issuer.c
index a014baabc758f4fa..2b3e8d50e615e705 100644
--- a/test/single-issuer.c
+++ b/test/single-issuer.c
@@ -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);
base-commit: 7b09481f27fa86e8828f774ddca92ce14f14fafe
--
Ammar Faizi
reply other threads:[~2023-02-12 23:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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] \
[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