Commit 0457c94c authored by Pavel Emelyanov's avatar Pavel Emelyanov

zdtm: Make it possible for test to get ZDTM_NEWNS variable

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: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 30e95be2
......@@ -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;
......
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment