2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 13:28:27 +00:00

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: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Kirill Tkhai 2017-12-28 13:51:03 +03:00 committed by Andrei Vagin
parent 0699dd583a
commit 76b8ab3500
3 changed files with 82 additions and 0 deletions

View File

@ -10,6 +10,7 @@ TST_NOFILE := \
caps00 \ caps00 \
wait00 \ wait00 \
zombie00 \ zombie00 \
zombie01 \
fpu00 \ fpu00 \
fpu01 \ fpu01 \
arm-neon00 \ arm-neon00 \

View File

@ -0,0 +1,80 @@
#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;
}

View File

@ -0,0 +1 @@
{'flags': 'suid'}