* [PATCH liburing 0/3] test poll missing events
@ 2022-11-23 11:35 Pavel Begunkov
2022-11-23 11:35 ` [PATCH liburing 1/3] tests: remove sigalarm from poll.c Pavel Begunkov
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-11-23 11:35 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
Pavel Begunkov (3):
tests: remove sigalarm from poll.c
tests: refactor poll.c
tests: check for missing multipoll events
test/poll.c | 146 ++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 120 insertions(+), 26 deletions(-)
--
2.38.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH liburing 1/3] tests: remove sigalarm from poll.c
2022-11-23 11:35 [PATCH liburing 0/3] test poll missing events Pavel Begunkov
@ 2022-11-23 11:35 ` Pavel Begunkov
2022-11-23 11:35 ` [PATCH liburing 2/3] tests: refactor poll.c Pavel Begunkov
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-11-23 11:35 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
Test loop handles timeouting and killing stuck tests, no need to have a
separate sigalarm in poll.c
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
test/poll.c | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/test/poll.c b/test/poll.c
index 1cd57ba..42123bd 100644
--- a/test/poll.c
+++ b/test/poll.c
@@ -14,12 +14,6 @@
#include "liburing.h"
-static void sig_alrm(int sig)
-{
- fprintf(stderr, "Timed out!\n");
- exit(1);
-}
-
int main(int argc, char *argv[])
{
struct io_uring_cqe *cqe;
@@ -43,20 +37,12 @@ int main(int argc, char *argv[])
perror("fork");
exit(2);
case 0: {
- struct sigaction act;
-
ret = io_uring_queue_init(1, &ring, 0);
if (ret) {
fprintf(stderr, "child: ring setup failed: %d\n", ret);
return 1;
}
- memset(&act, 0, sizeof(act));
- act.sa_handler = sig_alrm;
- act.sa_flags = SA_RESTART;
- sigaction(SIGALRM, &act, NULL);
- alarm(1);
-
sqe = io_uring_get_sqe(&ring);
if (!sqe) {
fprintf(stderr, "get sqe failed\n");
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH liburing 2/3] tests: refactor poll.c
2022-11-23 11:35 [PATCH liburing 0/3] test poll missing events Pavel Begunkov
2022-11-23 11:35 ` [PATCH liburing 1/3] tests: remove sigalarm from poll.c Pavel Begunkov
@ 2022-11-23 11:35 ` Pavel Begunkov
2022-11-23 11:35 ` [PATCH liburing 3/3] tests: check for missing multipoll events Pavel Begunkov
2022-11-23 17:51 ` [PATCH liburing 0/3] test poll missing events Jens Axboe
3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-11-23 11:35 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
Extract all poll.c testing into a separate function
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
test/poll.c | 49 ++++++++++++++++++++++++++++++++-----------------
1 file changed, 32 insertions(+), 17 deletions(-)
diff --git a/test/poll.c b/test/poll.c
index 42123bd..f0c1c40 100644
--- a/test/poll.c
+++ b/test/poll.c
@@ -12,9 +12,10 @@
#include <poll.h>
#include <sys/wait.h>
+#include "helpers.h"
#include "liburing.h"
-int main(int argc, char *argv[])
+static int test_basic(void)
{
struct io_uring_cqe *cqe;
struct io_uring_sqe *sqe;
@@ -23,20 +24,16 @@ int main(int argc, char *argv[])
pid_t p;
int ret;
- if (argc > 1)
- return 0;
-
if (pipe(pipe1) != 0) {
perror("pipe");
return 1;
}
p = fork();
- switch (p) {
- case -1:
+ if (p == -1) {
perror("fork");
exit(2);
- case 0: {
+ } else if (p == 0) {
ret = io_uring_queue_init(1, &ring, 0);
if (ret) {
fprintf(stderr, "child: ring setup failed: %d\n", ret);
@@ -78,18 +75,36 @@ int main(int argc, char *argv[])
(long) cqe->res);
return 1;
}
+
+ io_uring_queue_exit(&ring);
exit(0);
- }
- default:
- do {
- errno = 0;
- ret = write(pipe1[1], "foo", 3);
- } while (ret == -1 && errno == EINTR);
+ }
- if (ret != 3) {
- fprintf(stderr, "parent: bad write return %d\n", ret);
- return 1;
- }
+ do {
+ errno = 0;
+ ret = write(pipe1[1], "foo", 3);
+ } while (ret == -1 && errno == EINTR);
+
+ if (ret != 3) {
+ fprintf(stderr, "parent: bad write return %d\n", ret);
+ return 1;
+ }
+ close(pipe1[0]);
+ close(pipe1[1]);
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret;
+
+ if (argc > 1)
return 0;
+
+ ret = test_basic();
+ if (ret) {
+ fprintf(stderr, "test_basic() failed %i\n", ret);
+ return T_EXIT_FAIL;
}
+ return 0;
}
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH liburing 3/3] tests: check for missing multipoll events
2022-11-23 11:35 [PATCH liburing 0/3] test poll missing events Pavel Begunkov
2022-11-23 11:35 ` [PATCH liburing 1/3] tests: remove sigalarm from poll.c Pavel Begunkov
2022-11-23 11:35 ` [PATCH liburing 2/3] tests: refactor poll.c Pavel Begunkov
@ 2022-11-23 11:35 ` Pavel Begunkov
2022-11-23 17:51 ` [PATCH liburing 0/3] test poll missing events Jens Axboe
3 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-11-23 11:35 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, asml.silence
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
test/poll.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 93 insertions(+)
diff --git a/test/poll.c b/test/poll.c
index f0c1c40..a7db7dc 100644
--- a/test/poll.c
+++ b/test/poll.c
@@ -11,10 +11,17 @@
#include <signal.h>
#include <poll.h>
#include <sys/wait.h>
+#include <error.h>
#include "helpers.h"
#include "liburing.h"
+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);
+}
+
static int test_basic(void)
{
struct io_uring_cqe *cqe;
@@ -94,6 +101,85 @@ static int test_basic(void)
return 0;
}
+static int test_missing_events(void)
+{
+ struct io_uring_cqe *cqe;
+ struct io_uring_sqe *sqe;
+ struct io_uring ring;
+ int i, ret, sp[2];
+ char buf[2] = {};
+ int res_mask = 0;
+
+ if (!t_probe_defer_taskrun())
+ return 0;
+
+ ret = io_uring_queue_init(8, &ring, IORING_SETUP_SINGLE_ISSUER |
+ IORING_SETUP_DEFER_TASKRUN);
+ if (ret) {
+ fprintf(stderr, "ring setup failed: %d\n", ret);
+ return 1;
+ }
+
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, sp) != 0) {
+ perror("Failed to create Unix-domain socket pair\n");
+ return 1;
+ }
+ do_setsockopt(sp[0], SOL_SOCKET, SO_SNDBUF, 1);
+ ret = send(sp[0], buf, sizeof(buf), 0);
+ if (ret != sizeof(buf)) {
+ perror("send failed\n");
+ return 1;
+ }
+
+ sqe = io_uring_get_sqe(&ring);
+ io_uring_prep_poll_multishot(sqe, sp[0], POLLIN|POLLOUT);
+ ret = io_uring_submit(&ring);
+ if (ret != 1) {
+ fprintf(stderr, "sqe submit failed: %d\n", ret);
+ return 1;
+ }
+
+ /* trigger EPOLLIN */
+ ret = send(sp[1], buf, sizeof(buf), 0);
+ if (ret != sizeof(buf)) {
+ fprintf(stderr, "send sp[1] failed %i %i\n", ret, errno);
+ return 1;
+ }
+
+ /* trigger EPOLLOUT */
+ ret = recv(sp[1], buf, sizeof(buf), 0);
+ if (ret != sizeof(buf)) {
+ perror("recv failed\n");
+ return 1;
+ }
+
+ for (i = 0; ; i++) {
+ if (i == 0)
+ ret = io_uring_wait_cqe(&ring, &cqe);
+ else
+ ret = io_uring_peek_cqe(&ring, &cqe);
+
+ if (i != 0 && ret == -EAGAIN) {
+ break;
+ }
+ if (ret) {
+ fprintf(stderr, "wait completion %d, %i\n", ret, i);
+ return 1;
+ }
+ res_mask |= cqe->res;
+ io_uring_cqe_seen(&ring, cqe);
+ }
+
+ if ((res_mask & (POLLIN|POLLOUT)) != (POLLIN|POLLOUT)) {
+ fprintf(stderr, "missing poll events %i\n", res_mask);
+ return 1;
+ }
+ io_uring_queue_exit(&ring);
+ close(sp[0]);
+ close(sp[1]);
+ return 0;
+}
+
int main(int argc, char *argv[])
{
int ret;
@@ -106,5 +192,12 @@ int main(int argc, char *argv[])
fprintf(stderr, "test_basic() failed %i\n", ret);
return T_EXIT_FAIL;
}
+
+ ret = test_missing_events();
+ if (ret) {
+ fprintf(stderr, "test_missing_events() failed %i\n", ret);
+ return T_EXIT_FAIL;
+ }
+
return 0;
}
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH liburing 0/3] test poll missing events
2022-11-23 11:35 [PATCH liburing 0/3] test poll missing events Pavel Begunkov
` (2 preceding siblings ...)
2022-11-23 11:35 ` [PATCH liburing 3/3] tests: check for missing multipoll events Pavel Begunkov
@ 2022-11-23 17:51 ` Jens Axboe
3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2022-11-23 17:51 UTC (permalink / raw)
To: Pavel Begunkov, io-uring
On Wed, 23 Nov 2022 11:35:07 +0000, Pavel Begunkov wrote:
> Pavel Begunkov (3):
> tests: remove sigalarm from poll.c
> tests: refactor poll.c
> tests: check for missing multipoll events
>
> test/poll.c | 146 ++++++++++++++++++++++++++++++++++++++++++----------
> 1 file changed, 120 insertions(+), 26 deletions(-)
>
> [...]
Applied, thanks!
[1/3] tests: remove sigalarm from poll.c
commit: b532e9cb82a320186d6f9860ee2fdf2af0012dec
[2/3] tests: refactor poll.c
commit: 81107fed5e17217caf7c6c51e6b468269de6403f
[3/3] tests: check for missing multipoll events
commit: b90a28636e5b5efe6dc1383acc90aec61814d9ba
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-11-23 17:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-23 11:35 [PATCH liburing 0/3] test poll missing events Pavel Begunkov
2022-11-23 11:35 ` [PATCH liburing 1/3] tests: remove sigalarm from poll.c Pavel Begunkov
2022-11-23 11:35 ` [PATCH liburing 2/3] tests: refactor poll.c Pavel Begunkov
2022-11-23 11:35 ` [PATCH liburing 3/3] tests: check for missing multipoll events Pavel Begunkov
2022-11-23 17:51 ` [PATCH liburing 0/3] test poll missing events Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.