[CRIU] [PATCH] zdtm: Make it possible for test to get ZDTM_NEWNS variable
Pavel Emelyanov
xemul at parallels.com
Thu May 29 04:47:19 PDT 2014
I will need to make cgroup test behave slightly differently
when it's in and out of ns/ run. To do so it's handy to use
the ZDTM_NEWNS variable set by zdtm.sh
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
diff --git a/test/zdtm/lib/ns.c b/test/zdtm/lib/ns.c
index 5c36933..a216715 100644
--- a/test/zdtm/lib/ns.c
+++ b/test/zdtm/lib/ns.c
@@ -169,7 +169,7 @@ int ns_exec(void *_arg)
if (prepare_mntns())
return -1;
- setenv("ZDTM_EXE", "1", 0);
+ setenv("ZDTM_NEWNS", "2", 1);
execvp(args->argv[0], args->argv);
fprintf(stderr, "exec(%s) failed: %m\n", args->argv[0]);
return -1;
@@ -206,6 +206,7 @@ int ns_init(int argc, char **argv)
fprintf(stderr, "fork() failed: %m\n");
exit(1);
} else if (pid == 0) {
+ setenv("ZDTM_NEWNS", "3", 1);
ret = execvp(argv[0], argv);
fprintf(stderr, "exec(%s) failed: %m\n", argv[0]);
return ret;
diff --git a/test/zdtm/lib/test.c b/test/zdtm/lib/test.c
index 585cee2..5d2a05d 100644
--- a/test/zdtm/lib/test.c
+++ b/test/zdtm/lib/test.c
@@ -105,18 +105,19 @@ void test_init(int argc, char **argv)
val = getenv("ZDTM_NEWNS");
if (val) {
- unsetenv("ZDTM_NEWNS");
- ns_create(argc, argv);
- exit(1);
- }
+ if (!strcmp(val, "1")) {
+ ns_create(argc, argv);
+ exit(1);
+ }
- val = getenv("ZDTM_EXE");
- if (val) {
- test_log_init(outfile, "ns");
- redir_stdfds();
- unsetenv("ZDTM_EXE");
- ns_init(argc, argv);
- exit(1);
+ if (!strcmp(val, "2")) {
+ test_log_init(outfile, "ns");
+ redir_stdfds();
+ ns_init(argc, argv);
+ exit(1);
+ }
+
+ /* "3" -- run the test */
}
val = getenv("ZDTM_GID");
More information about the CRIU
mailing list