* [PATCH liburing v2 0/2] exec + timeout cancellation
@ 2021-09-11 11:11 Pavel Begunkov
2021-09-11 11:11 ` [PATCH liburing v2 1/2] tests: add no-op executable for exec Pavel Begunkov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Pavel Begunkov @ 2021-09-11 11:11 UTC (permalink / raw)
To: Jens Axboe, io-uring
Add some infra to test exec(), hopefully we will get more
tests using it. And also add a timeout test, which uses exec.
v2: rebase
Pavel Begunkov (2):
tests: add no-op executable for exec
tests: test timeout cancellation fails links
.gitignore | 1 +
test/Makefile | 2 ++
test/exec-target.c | 4 +++
test/timeout.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 91 insertions(+)
create mode 100644 test/exec-target.c
--
2.33.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH liburing v2 1/2] tests: add no-op executable for exec
2021-09-11 11:11 [PATCH liburing v2 0/2] exec + timeout cancellation Pavel Begunkov
@ 2021-09-11 11:11 ` Pavel Begunkov
2021-09-11 11:11 ` [PATCH liburing v2 2/2] tests: test timeout cancellation fails links Pavel Begunkov
2021-09-11 14:25 ` [PATCH liburing v2 0/2] exec + timeout cancellation Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2021-09-11 11:11 UTC (permalink / raw)
To: Jens Axboe, io-uring
There are differences between close and exec from io_uring perspective,
so we want to test exec as well. For that we need a program doing
nothing to exec into.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
.gitignore | 1 +
test/Makefile | 2 ++
test/exec-target.c | 4 ++++
3 files changed, 7 insertions(+)
create mode 100644 test/exec-target.c
diff --git a/.gitignore b/.gitignore
index df0f740..0213bfa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -129,6 +129,7 @@
/test/sqpoll-cancel-hang
/test/testfile
/test/submit-link-fail
+/test/exec-target
/test/*.dmesg
config-host.h
diff --git a/test/Makefile b/test/Makefile
index 2313fcc..54ee730 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -135,6 +135,7 @@ test_targets += \
wakeup-hang \
sendmsg_fs_cve \
rsrc_tags \
+ exec-target \
# EOL
all_targets += $(test_targets)
@@ -276,6 +277,7 @@ test_srcs := \
wakeup-hang.c \
sendmsg_fs_cve.c \
rsrc_tags.c \
+ exec-target.c \
# EOL
test_objs := $(patsubst %.c,%.ol,$(patsubst %.cc,%.ol,$(test_srcs)))
diff --git a/test/exec-target.c b/test/exec-target.c
new file mode 100644
index 0000000..50bc2c9
--- /dev/null
+++ b/test/exec-target.c
@@ -0,0 +1,4 @@
+int main(int argc, char *argv[])
+{
+ return 0;
+}
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH liburing v2 2/2] tests: test timeout cancellation fails links
2021-09-11 11:11 [PATCH liburing v2 0/2] exec + timeout cancellation Pavel Begunkov
2021-09-11 11:11 ` [PATCH liburing v2 1/2] tests: add no-op executable for exec Pavel Begunkov
@ 2021-09-11 11:11 ` Pavel Begunkov
2021-09-11 14:25 ` [PATCH liburing v2 0/2] exec + timeout cancellation Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Begunkov @ 2021-09-11 11:11 UTC (permalink / raw)
To: Jens Axboe, io-uring
Test that we appropriately fail linked requests when we cancel a
normal timeout.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
test/timeout.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 84 insertions(+)
diff --git a/test/timeout.c b/test/timeout.c
index d2e4930..cef6846 100644
--- a/test/timeout.c
+++ b/test/timeout.c
@@ -10,6 +10,8 @@
#include <string.h>
#include <fcntl.h>
#include <sys/time.h>
+#include <sys/wait.h>
+#include <sys/types.h>
#include "liburing.h"
#include "../src/syscall.h"
@@ -1171,6 +1173,82 @@ err:
return 1;
}
+static int test_timeout_link_cancel(void)
+{
+ struct io_uring ring;
+ struct io_uring_cqe *cqe;
+ pid_t p;
+ int ret, i, wstatus;
+
+ ret = io_uring_queue_init(8, &ring, 0);
+ if (ret) {
+ fprintf(stderr, "ring create failed: %d\n", ret);
+ return 1;
+ }
+
+ p = fork();
+ if (p == -1) {
+ fprintf(stderr, "fork() failed\n");
+ return 1;
+ }
+
+ if (p == 0) {
+ struct io_uring_sqe *sqe;
+ struct __kernel_timespec ts;
+ const char *prog_path = "./exec-target";
+
+ msec_to_ts(&ts, 10000);
+ sqe = io_uring_get_sqe(&ring);
+ io_uring_prep_timeout(sqe, &ts, 0, 0);
+ sqe->flags |= IOSQE_IO_LINK;
+ sqe->user_data = 0;
+
+ sqe = io_uring_get_sqe(&ring);
+ io_uring_prep_nop(sqe);
+ sqe->user_data = 1;
+
+ ret = io_uring_submit(&ring);
+ if (ret != 2) {
+ fprintf(stderr, "%s: got %d, wanted 1\n", __FUNCTION__, ret);
+ exit(1);
+ }
+
+ /* trigger full cancellation */
+ ret = execl(prog_path, prog_path, NULL);
+ if (ret) {
+ fprintf(stderr, "exec failed %i\n", errno);
+ exit(1);
+ }
+ exit(0);
+ }
+
+ if (waitpid(p, &wstatus, 0) == (pid_t)-1) {
+ perror("waitpid()");
+ return 1;
+ }
+ if (!WIFEXITED(wstatus) || WEXITSTATUS(wstatus)) {
+ fprintf(stderr, "child failed %i\n", WEXITSTATUS(wstatus));
+ return 1;
+ }
+
+ for (i = 0; i < 2; ++i) {
+ ret = io_uring_wait_cqe(&ring, &cqe);
+ if (ret) {
+ fprintf(stderr, "wait_cqe=%d\n", ret);
+ return 1;
+ }
+ if (cqe->res != -ECANCELED) {
+ fprintf(stderr, "invalid result, user_data: %i res: %i\n",
+ (int)cqe->user_data, cqe->res);
+ return 1;
+ }
+ io_uring_cqe_seen(&ring, cqe);
+ }
+
+ io_uring_queue_exit(&ring);
+ return 0;
+}
+
int main(int argc, char *argv[])
{
struct io_uring ring, sqpoll_ring;
@@ -1348,6 +1426,12 @@ int main(int argc, char *argv[])
return ret;
}
+ ret = test_timeout_link_cancel();
+ if (ret) {
+ fprintf(stderr, "test_timeout_link_cancel failed\n");
+ return ret;
+ }
+
if (sqpoll)
io_uring_queue_exit(&sqpoll_ring);
return 0;
--
2.33.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH liburing v2 0/2] exec + timeout cancellation
2021-09-11 11:11 [PATCH liburing v2 0/2] exec + timeout cancellation Pavel Begunkov
2021-09-11 11:11 ` [PATCH liburing v2 1/2] tests: add no-op executable for exec Pavel Begunkov
2021-09-11 11:11 ` [PATCH liburing v2 2/2] tests: test timeout cancellation fails links Pavel Begunkov
@ 2021-09-11 14:25 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2021-09-11 14:25 UTC (permalink / raw)
To: Pavel Begunkov, io-uring
On 9/11/21 5:11 AM, Pavel Begunkov wrote:
> Add some infra to test exec(), hopefully we will get more
> tests using it. And also add a timeout test, which uses exec.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-11 14:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-11 11:11 [PATCH liburing v2 0/2] exec + timeout cancellation Pavel Begunkov
2021-09-11 11:11 ` [PATCH liburing v2 1/2] tests: add no-op executable for exec Pavel Begunkov
2021-09-11 11:11 ` [PATCH liburing v2 2/2] tests: test timeout cancellation fails links Pavel Begunkov
2021-09-11 14:25 ` [PATCH liburing v2 0/2] exec + timeout cancellation 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.