mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 13:28:27 +00:00
test: add a test for remap_dead_pid
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
f020bef776
commit
e9d0499cd1
@ -179,6 +179,7 @@ static/cgroup00
|
|||||||
static/cgroup01
|
static/cgroup01
|
||||||
static/cgroup02
|
static/cgroup02
|
||||||
ns/static/clean_mntns
|
ns/static/clean_mntns
|
||||||
|
static/remap_dead_pid
|
||||||
"
|
"
|
||||||
|
|
||||||
TEST_CR_KERNEL="
|
TEST_CR_KERNEL="
|
||||||
|
1
test/zdtm/.gitignore
vendored
1
test/zdtm/.gitignore
vendored
@ -90,6 +90,7 @@
|
|||||||
/live/static/pty02
|
/live/static/pty02
|
||||||
/live/static/pty03
|
/live/static/pty03
|
||||||
/live/static/pty04
|
/live/static/pty04
|
||||||
|
/live/static/remap_dead_pid
|
||||||
/live/static/rlimits00
|
/live/static/rlimits00
|
||||||
/live/static/rmdir_open
|
/live/static/rmdir_open
|
||||||
/live/static/rtc
|
/live/static/rtc
|
||||||
|
@ -113,6 +113,7 @@ TST_NOFILE = \
|
|||||||
clean_mntns \
|
clean_mntns \
|
||||||
dumpable01 \
|
dumpable01 \
|
||||||
dumpable02 \
|
dumpable02 \
|
||||||
|
remap_dead_pid \
|
||||||
# jobctl00 \
|
# jobctl00 \
|
||||||
|
|
||||||
TST_FILE = \
|
TST_FILE = \
|
||||||
|
74
test/zdtm/live/static/remap_dead_pid.c
Normal file
74
test/zdtm/live/static/remap_dead_pid.c
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#define _GNU_SOURCE
|
||||||
|
#include <string.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include "zdtmtst.h"
|
||||||
|
|
||||||
|
#ifndef CLONE_NEWNS
|
||||||
|
#define CLONE_NEWNS 0x00020000
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char *test_doc = "Check that dead pid's /proc entries are remapped correctly";
|
||||||
|
const char *test_author = "Tycho Andersen <tycho.andersen@canonical.com>";
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
test_init(argc, argv);
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
if (pid < 0) {
|
||||||
|
fail("fork() failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pid == 0) {
|
||||||
|
test_msg("child is %d\n", pid);
|
||||||
|
/* Child process just sleeps until it is killed. All we need
|
||||||
|
* here is a process to open the mountinfo of. */
|
||||||
|
while(1)
|
||||||
|
sleep(10);
|
||||||
|
} else {
|
||||||
|
int fd, ret;
|
||||||
|
char path[PATH_MAX];
|
||||||
|
pid_t result;
|
||||||
|
|
||||||
|
sprintf(path, "/proc/%d/mountinfo", pid);
|
||||||
|
|
||||||
|
fd = open(path, O_RDONLY);
|
||||||
|
|
||||||
|
/* no matter what, we should kill the child */
|
||||||
|
kill(pid, SIGINT);
|
||||||
|
result = waitpid(pid, NULL, 0);
|
||||||
|
if (result < 0) {
|
||||||
|
fail("failed waitpid()");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fd < 0) {
|
||||||
|
fail("failed opening %s", path);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
test_daemon();
|
||||||
|
test_waitsig();
|
||||||
|
|
||||||
|
ret = fcntl(fd, F_GETFD);
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
fail("bad fd after restore");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pass();
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user