Commit 7b87f163 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Andrei Vagin

zdtm: Add zombie01 test

Create a zombie with specific pgid and check that
pgid remains the same after restore.

This test hangs criu restore without any of two previous patches:
1)without "restore: Call prepare_fds() in restore_one_zombie()"
  in 100% cases;

2)without "restore: Split restore_one_helper() and wait exiting
  zombie children" fail is racy, but you can add something like

criu/cr-restore.c:
## -1130,6 +1130,8 @@ static int restore_one_zombie(CoreEntry *core)

        if (task_entries != NULL) {
                restore_finish_stage(task_entries, CR_STATE_RESTORE);
+               if (current->parent->pid->state == TASK_ALIVE)
+                       sleep(2);
                zombie_prepare_signals();
        }

and it will fail with almost 100% probability.
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent fa098801
...@@ -10,6 +10,7 @@ TST_NOFILE := \ ...@@ -10,6 +10,7 @@ TST_NOFILE := \
caps00 \ caps00 \
wait00 \ wait00 \
zombie00 \ zombie00 \
zombie01 \
fpu00 \ fpu00 \
fpu01 \ fpu01 \
arm-neon00 \ arm-neon00 \
......
#include <sched.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include "zdtmtst.h"
const char *test_doc = "Check that zombie pgid is restored";
const char *test_author = "Kirill Tkhai <ktkhai@virtuozzo.com>";
int main(int argc, char **argv)
{
pid_t pid, pgrp;
siginfo_t info;
int status;
test_init(argc, argv);
pid = fork();
if (pid < 0) {
fail("fork");
exit(1);
}
if (!pid) {
/* Child */
if (setpgid(0, 0) < 0) {
fail("setpgid");
exit(1);
}
pid = sys_clone_unified(CLONE_PARENT|SIGCHLD, NULL, NULL, NULL, 0);
if (pid < 0) {
fail("fork");
exit(1);
}
exit(0);
}
if (waitpid(pid, &status, 0) < 0) {
fail("waitpid");
exit(1);
}
if (!WIFEXITED(status) || WEXITSTATUS(status)) {
pr_err("Exited with problems: status=%d\n", status);
fail("fail");
exit(1);
}
if (waitid(P_ALL, 0, &info, WEXITED|WNOWAIT) < 0) {
fail("waitpid");
exit(1);
}
test_daemon();
test_waitsig();
if (waitid(P_ALL, 0, &info, WEXITED|WNOWAIT) < 0) {
fail("waitpid");
exit(1);
}
pgrp = getpgid(info.si_pid);
if (pgrp < 0) {
fail("getpgrp");
exit(1);
}
if (pgrp != pid) {
pr_err("Wrong pgrp: %d != %d\n", pgrp, pid);
fail("fail");
exit(1);
}
pass();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment