diff --git a/test/zdtm.sh b/test/zdtm.sh index ea50841b1..24c74a305 100644 --- a/test/zdtm.sh +++ b/test/zdtm.sh @@ -22,6 +22,7 @@ $ZP/static/file_shared $ZP/streaming/pipe_loop00 $ZP/streaming/pipe_shared00 $ZP/transition/file_read +$ZP/transition/fork $ZP/static/socket_listen" CRTOOLS=`pwd`/`dirname $0`/../crtools diff --git a/test/zdtm/live/transition/Makefile b/test/zdtm/live/transition/Makefile index 855514d88..eb265a201 100644 --- a/test/zdtm/live/transition/Makefile +++ b/test/zdtm/live/transition/Makefile @@ -8,6 +8,7 @@ TST_NOFILE = \ ipc \ ptrace \ epoll \ + fork \ TST_FILE = \ diff --git a/test/zdtm/live/transition/fork.c b/test/zdtm/live/transition/fork.c new file mode 100644 index 000000000..ec8471338 --- /dev/null +++ b/test/zdtm/live/transition/fork.c @@ -0,0 +1,56 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "zdtmtst.h" + +const char *test_doc = "Tests that forking tasks are handled properly"; +const char *test_author = "Pavel Emelyanov "; + +int main(int argc, char **argv) +{ + int pid, wpid, status; + + test_init(argc, argv); + test_daemon(); + + while (test_go()) { + pid = fork(); + if (pid < 0) { + fail("Can't fork"); + goto out; + } + + if (pid == 0) + exit(0); + + wpid = wait(&status); + if (wpid != pid) { + fail("Pids do not match"); + goto out; + } + + if (!WIFEXITED(status)) { + fail("Task didn't exit"); + goto out; + } + + if (WEXITSTATUS(status) != 0) { + fail("Task exited with wrong code"); + goto out; + } + } + test_waitsig(); + pass(); +out: + return 0; +}