diff options
author | Alice Frosi <afrosi@redhat.com> | 2023-02-16 08:53:15 +0100 |
---|---|---|
committer | Alice Frosi <afrosi@redhat.com> | 2023-02-16 09:01:08 +0100 |
commit | 6df6465884e5192d8512b952fb412f2ea80439b0 (patch) | |
tree | 632174516d5a9742419691c1f5111f1358d11da8 | |
parent | 0bb82809d89cd4fcf664ff5f0477657c9db75ae4 (diff) | |
download | seitan-6df6465884e5192d8512b952fb412f2ea80439b0.tar seitan-6df6465884e5192d8512b952fb412f2ea80439b0.tar.gz seitan-6df6465884e5192d8512b952fb412f2ea80439b0.tar.bz2 seitan-6df6465884e5192d8512b952fb412f2ea80439b0.tar.lz seitan-6df6465884e5192d8512b952fb412f2ea80439b0.tar.xz seitan-6df6465884e5192d8512b952fb412f2ea80439b0.tar.zst seitan-6df6465884e5192d8512b952fb412f2ea80439b0.zip |
test: interrupt test on target process exit
Catch if the target process has exited due to an error and interrupt
the tests.
Signed-off-by: Alice Frosi <afrosi@redhat.com>
-rw-r--r-- | tests/unit/test_actions.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/unit/test_actions.c b/tests/unit/test_actions.c index 08799ef..756c4cd 100644 --- a/tests/unit/test_actions.c +++ b/tests/unit/test_actions.c @@ -9,6 +9,7 @@ #include <sys/prctl.h> #include <sys/syscall.h> #include <sys/ioctl.h> +#include <sys/wait.h> #include <linux/audit.h> #include <linux/filter.h> #include <linux/seccomp.h> @@ -125,10 +126,22 @@ static void check_target_result(long ret, int err) ck_assert_int_eq(close(pipefd[0]), 0); } +void target_exit() +{ + int status; + + waitpid(-1, &status, WUNTRACED | WNOHANG); + if (WEXITSTATUS(status) != 0) { + fprintf(stderr, "target process exited with an error\n"); + exit(-1); + } +} + void setup() { int ret; + signal (SIGCHLD, target_exit); ck_assert_int_ne(pipe(pipefd), -1); at = mmap(NULL, sizeof(struct args_target), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); |