mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 05:18:00 +00:00
test: add processes tree restoring test
This test makes sure, that processes tree is restored before opened files. This is guaranteed by holding child's "/proc/<pid>/stat" file opened by parent. It was inspired by OpenVZ bug: #2404 IOW, OpenVZ can't restore container with such test inside. v2: 1) Test renamed + carefull cleanup + minor updates. Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org> Acked-by: Andrew Vagin <avagin@parallels.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
f33df79e1e
commit
a08f2030a1
@ -66,6 +66,7 @@ static/pty00
|
||||
static/pty01
|
||||
static/pty04
|
||||
static/tty02
|
||||
static/child_opened_proc
|
||||
"
|
||||
# Duplicate list with ns/ prefix
|
||||
TEST_LIST=$TEST_LIST$(echo $TEST_LIST | tr ' ' '\n' | sed 's#^#ns/#')
|
||||
|
@ -74,6 +74,7 @@ TST_NOFILE = \
|
||||
socket-ext \
|
||||
unhashed_proc \
|
||||
cow00 \
|
||||
child_opened_proc \
|
||||
posix_timers \
|
||||
# jobctl00 \
|
||||
|
||||
|
63
test/zdtm/live/static/child_opened_proc.c
Normal file
63
test/zdtm/live/static/child_opened_proc.c
Normal file
@ -0,0 +1,63 @@
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "zdtmtst.h"
|
||||
|
||||
const char *test_doc = "Check that tree prior to files opening";
|
||||
const char *test_author = "Stanislav Kinsbursky <skinsbursky@paralles.com";
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
int pid, err = 0;
|
||||
int proc_fd;
|
||||
char name[64];
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
pid = test_fork();
|
||||
if (pid < 0) {
|
||||
err("Can't fork");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!pid) {
|
||||
test_waitsig();
|
||||
return 0;
|
||||
}
|
||||
|
||||
sprintf(name, "/proc/%d/stat", pid);
|
||||
proc_fd = open(name, O_RDONLY);
|
||||
if (proc_fd == -1) {
|
||||
err("can't open %s: %m\n", name);
|
||||
err++;
|
||||
goto out;
|
||||
}
|
||||
test_daemon();
|
||||
test_waitsig();
|
||||
|
||||
if (close(proc_fd) == -1) {
|
||||
err("Failed to close %s\n", name);
|
||||
err++;
|
||||
}
|
||||
out:
|
||||
if (kill(pid, SIGTERM) == -1) {
|
||||
err("Failed to terminate child\n");
|
||||
err++;
|
||||
} else {
|
||||
if (waitpid(pid, NULL, 0) != pid) {
|
||||
err("Failed to collect killed child\n");
|
||||
err++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!err)
|
||||
pass();
|
||||
|
||||
return err;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user