[CRIU] [PATCH 12/16] zdtm: reexec the mountpoints test in a target mntns
Andrey Vagin
avagin at openvz.org
Tue Apr 8 16:35:04 PDT 2014
Otherwise it will have external files (from another namespace,
which isn't dumped).
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
test/zdtm.sh | 1 +
test/zdtm/lib/test.c | 18 +++++++++++-------
test/zdtm/live/static/mountpoints.c | 12 ++++++++++--
3 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/test/zdtm.sh b/test/zdtm.sh
index 7653fdb..7eabc61 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -159,6 +159,7 @@ rtc
tempfs
maps007
tempfs
+mountpoints
"
source $(readlink -f `dirname $0`/env.sh) || exit 1
diff --git a/test/zdtm/lib/test.c b/test/zdtm/lib/test.c
index b492545..585cee2 100644
--- a/test/zdtm/lib/test.c
+++ b/test/zdtm/lib/test.c
@@ -149,6 +149,9 @@ void test_init(int argc, char **argv)
setup_outfile();
redir_stdfds();
+ if (getenv("ZDTM_REEXEC"))
+ goto skip_pid;
+
pidf = fopen(pidfile, "wx");
if (!pidf) {
err("Can't create pid file %s: %m\n", pidfile);
@@ -183,22 +186,23 @@ void test_init(int argc, char **argv)
_exit(0);
}
+ fclose(pidf);
+
+ if (setsid() < 0) {
+ err("Can't become session group leader: %m\n");
+ exit(1);
+ }
+
+skip_pid:
/* record the test pid to remember the ownership of the pidfile */
master_pid = getpid();
- fclose(pidf);
-
sa.sa_handler = SIG_DFL;
if (sigaction(SIGCHLD, &sa, NULL)) {
err("Can't reset SIGCHLD handler: %m\n");
exit(1);
}
- if (setsid() < 0) {
- err("Can't become session group leader: %m\n");
- exit(1);
- }
-
srand48(time(NULL)); /* just in case we need it */
}
diff --git a/test/zdtm/live/static/mountpoints.c b/test/zdtm/live/static/mountpoints.c
index 7200544..620115c 100644
--- a/test/zdtm/live/static/mountpoints.c
+++ b/test/zdtm/live/static/mountpoints.c
@@ -8,6 +8,7 @@
#include <sys/stat.h>
#include <sched.h>
#include <sys/wait.h>
+#include <stdlib.h>
#include "zdtmtst.h"
@@ -69,6 +70,13 @@ static int test_fn(int argc, char **argv)
mode_t old_mask;
pid_t pid;
+ if (!getenv("ZDTM_REEXEC")) {
+ setenv("ZDTM_REEXEC", "1", 0);
+ return execv(argv[0], argv);
+ } else
+ test_init(argc, argv);
+
+ close(0); /* /dev/null */
again:
fs_cnt = 0;
f = fopen("/proc/self/mountinfo", "r");
@@ -264,8 +272,6 @@ done:
mknod("/dev/null", 0777 | S_IFCHR, makedev(1, 3));
umask(old_mask);
- setup_outfile();
-
fd = open(MPTS_ROOT"/kernel/meminfo", O_RDONLY);
if (fd == -1)
return 1;
@@ -346,6 +352,8 @@ done:
int main(int argc, char **argv)
{
+ if (getenv("ZDTM_REEXEC"))
+ return test_fn(argc, argv);
test_init_ns(argc, argv, CLONE_NEWNS, test_fn);
return 0;
}
--
1.8.5.3
More information about the CRIU
mailing list