2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

zdtm: check, that stopped tasks are restored correctly

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Andrey Vagin
2013-10-01 11:22:17 +04:00
committed by Pavel Emelyanov
parent 79d47a939d
commit d92874697b
3 changed files with 69 additions and 0 deletions

View File

@@ -94,6 +94,7 @@ static/sk-netlink
static/proc-self
static/grow_map
static/grow_map02
static/stopped
static/chroot
static/chroot-file
"

View File

@@ -102,6 +102,7 @@ TST_NOFILE = \
grow_map \
grow_map02 \
tun \
stopped \
# jobctl00 \
TST_FILE = \

View File

@@ -0,0 +1,67 @@
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include "zdtmtst.h"
const char *test_doc = "Check, that stopped tasts are restored correctly";
const char *test_author = "Andrew Vagin <avagin@parallels.com>";
int main(int argc, char **argv)
{
pid_t pid;
int p[2], ret, status;
test_init(argc, argv);
if (pipe(p)) {
err("Unable to create pipe");
return 1;
}
pid = test_fork();
if (pid < 0)
return -1;
else if (pid == 0) {
char c;
close(p[1]);
ret = read(p[0], &c, 1);
if (ret != 1) {
err("Unable to read: %d", ret);
return 1;
}
ret = read(p[0], &c, 1);
if (ret != 0) {
err("Unable to read: %d", ret);
return 1;
}
return 0;
}
close(p[0]);
kill(pid, SIGSTOP);
write(p[1], "0", 1);
test_daemon();
test_waitsig();
kill(pid, SIGCONT);
if (waitpid(pid, &status, WCONTINUED) == -1) {
err("Unable to wait child");
goto out;
}
if (WIFCONTINUED(status))
pass();
else
fail("The process doesn't continue");
out:
close(p[1]);
waitpid(pid, &status, 0);
return 0;
}