diff --git a/test/zdtm.sh b/test/zdtm.sh index 75b357628..d273844d4 100644 --- a/test/zdtm.sh +++ b/test/zdtm.sh @@ -21,6 +21,7 @@ static/vdso00 static/file_shared static/timers static/futex +static/xids00 streaming/pipe_loop00 streaming/pipe_shared00 transition/file_read diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile index 3b36a2cc3..ea63895d6 100644 --- a/test/zdtm/live/static/Makefile +++ b/test/zdtm/live/static/Makefile @@ -38,6 +38,7 @@ TST_NOFILE = \ selfexe00 \ sem \ maps01 \ + xids00 \ # jobctl00 \ TST_FILE = \ diff --git a/test/zdtm/live/static/xids00.c b/test/zdtm/live/static/xids00.c new file mode 100644 index 000000000..756fd6848 --- /dev/null +++ b/test/zdtm/live/static/xids00.c @@ -0,0 +1,121 @@ +#include +#include +#include +#include +#include +#include + +#include "zdtmtst.h" + +const char *test_doc = "Check that environment didn't change"; +const char *test_author = "Pavel Emelianov "; + +int main(int argc, char **argv) +{ + int tmp_pipe[2]; + int pids[2], syncfd[2], stat, fail = 0; + + test_init(argc, argv); + + pipe(tmp_pipe); + pids[0] = test_fork(); + if (pids[0] == 0) { + close(tmp_pipe[0]); + + setsid(); + + close(tmp_pipe[1]); + test_waitsig(); + + if (getpid() != getsid(0)) + exit(1); + + if (getpid() != getpgid(0)) + exit(2); + + test_msg("P1 OK\n"); + exit(0); + } + close(tmp_pipe[1]); + syncfd[0] = tmp_pipe[0]; + + pipe(tmp_pipe); + pids[1] = test_fork(); + if (pids[1] == 0) { + int tmp_pipe_sub[2], pid; + + close(tmp_pipe[0]); + + setsid(); + + pipe(tmp_pipe_sub); + pid = test_fork(); + if (pid == 0) { + close(tmp_pipe[1]); + close(tmp_pipe_sub[0]); + + setpgid(0, 0); + + close(tmp_pipe_sub[1]); + test_waitsig(); + + if (getsid(0) != getppid()) + exit(1); + if (getpgid(0) != getpid()) + exit(1); + + exit(0); + } + close(tmp_pipe_sub[1]); + + read(tmp_pipe_sub[0], &stat, 1); + close(tmp_pipe_sub[0]); + + close(tmp_pipe[1]); + + test_waitsig(); + + if (getpid() != getsid(0)) + exit(1); + + if (getpid() != getpgid(0)) + exit(2); + + kill(pid, SIGTERM); + wait(&stat); + if (!WIFEXITED(stat) || WEXITSTATUS(stat)) + exit(3); + + exit(0); + } + close(tmp_pipe[1]); + syncfd[1] = tmp_pipe[0]; + + read(syncfd[0], &stat, 1); + close(syncfd[0]); + read(syncfd[1], &stat, 1); + close(syncfd[1]); + + test_daemon(); + test_waitsig(); + + kill(pids[0], SIGTERM); + wait(&stat); + if (!WIFEXITED(stat) || WEXITSTATUS(stat)) { + test_msg("P1 stat %d/%d\n", WIFEXITED(stat), WEXITSTATUS(stat)); + fail = 1; + } + kill(pids[1], SIGTERM); + wait(&stat); + if (!WIFEXITED(stat) || WEXITSTATUS(stat)) { + test_msg("P1 stat %d/%d\n", WIFEXITED(stat), WEXITSTATUS(stat)); + fail = 1; + } + + if (fail) + fail("Something failed"); + else + pass(); + + return 0; +}