diff options
author | Andrey Vagin <avagin@openvz.org> | 2015-08-24 01:26:23 +0300 |
---|---|---|
committer | Pavel Emelyanov <xemul@parallels.com> | 2015-08-25 15:59:59 +0300 |
commit | f837310e135c5b69b3d097dc439579f60f2c4818 (patch) | |
tree | bf1c651081866b97c5743a05770b252ec0dfe606 | |
parent | e6e56a629451c43ceaddd2817c7de023ed0f8e1f (diff) |
zdtm/fdt_shared: wait until children finish the preparation stage
Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
-rw-r--r-- | test/zdtm/live/static/fdt_shared.c | 37 | ||||
-rw-r--r-- | test/zdtm/live/static/file_locks02.c | 1 |
2 files changed, 37 insertions, 1 deletions
diff --git a/test/zdtm/live/static/fdt_shared.c b/test/zdtm/live/static/fdt_shared.c index 35555a6f2..ee195c2f2 100644 --- a/test/zdtm/live/static/fdt_shared.c +++ b/test/zdtm/live/static/fdt_shared.c @@ -6,6 +6,7 @@ #include <sched.h> #include <signal.h> #include <sys/wait.h> +#include <stdlib.h> #include "zdtmtst.h" @@ -19,6 +20,32 @@ TEST_OPTION(filename, string, "file name", 1); #define TEST_FD 128 #define TEST_STRING "Hello World!" +#define CHILDREN 4 +static int fork_pfd[2]; + +static void forked() +{ + char c = 0; + + if (write(fork_pfd[1], &c, 1) != 1) { + err("Unable to send a signal to the parent"); + exit(5); + } +} + +static void wait_children() +{ + int i; + char c; + + for (i = 0; i < CHILDREN; i++) { + if (read(fork_pfd[0], &c, 1) != 1) { + err("Unable to read a signal from a child"); + exit(5); + } + } +} + static pid_t clone_child(int (*fn)(void *), int flags) { char stack[STACK_SIZE]; @@ -38,6 +65,7 @@ static int child2(void *_arg) { char buf[10]; + forked(); test_waitsig(); if (read(TEST_FD, buf, sizeof(TEST_STRING)) != sizeof(TEST_STRING)) { @@ -50,6 +78,7 @@ static int child2(void *_arg) static int child3(void *_arg) { + forked(); test_waitsig(); if (close(TEST_FD) != -1) { @@ -74,6 +103,7 @@ static int child(void *_arg) if (pid < 0) return 1; + forked(); test_waitsig(); kill(pid2, SIGTERM); @@ -113,6 +143,11 @@ int main(int argc, char ** argv) test_init(argc, argv); + if (pipe(fork_pfd)) { + err("pipe"); + return 1; + } + pid = clone_child(child, CLONE_FILES); if (pid < 0) return 1; @@ -121,6 +156,8 @@ int main(int argc, char ** argv) if (pid2 < 0) return 1; + wait_children(); + test_daemon(); test_waitsig(); diff --git a/test/zdtm/live/static/file_locks02.c b/test/zdtm/live/static/file_locks02.c index ef4371ccb..b16cb064a 100644 --- a/test/zdtm/live/static/file_locks02.c +++ b/test/zdtm/live/static/file_locks02.c @@ -80,7 +80,6 @@ int main(int argc, char **argv) pid = fork(); if (pid == 0) { - close(pf[1]); read(pf[0], &pid, sizeof(pid)); exit(0); } |