Commit 8abf6d2d authored by Pavel Emelyanov's avatar Pavel Emelyanov

zdtm: Get dir of init.pid file

For the caller there should be only one pidfile -- the one
that should be fired with TERM signal on stop. All the other
stuff is test's internal business.
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent bb7d912e
...@@ -312,10 +312,7 @@ class zdtm_test: ...@@ -312,10 +312,7 @@ class zdtm_test:
self.__freezer.freeze() self.__freezer.freeze()
def __pidfile(self): def __pidfile(self):
if self.__flavor.ns: return self.__name + '.pid'
return self.__name + '.init.pid'
else:
return self.__name + '.pid'
def __wait_task_die(self): def __wait_task_die(self):
wait_pid_die(int(self.__pid), self.__name) wait_pid_die(int(self.__pid), self.__name)
...@@ -346,7 +343,6 @@ class zdtm_test: ...@@ -346,7 +343,6 @@ class zdtm_test:
if self.__flavor.ns: if self.__flavor.ns:
env['ZDTM_NEWNS'] = "1" env['ZDTM_NEWNS'] = "1"
env['ZDTM_PIDFILE'] = os.path.realpath(self.__name + '.init.pid')
env['ZDTM_ROOT'] = self.__flavor.root env['ZDTM_ROOT'] = self.__flavor.root
if self.__flavor.uns: if self.__flavor.uns:
...@@ -408,7 +404,7 @@ class zdtm_test: ...@@ -408,7 +404,7 @@ class zdtm_test:
self.__wait_task_die() self.__wait_task_die()
self.__pid = 0 self.__pid = 0
if force or self.__flavor.ns: if force:
os.unlink(self.__pidfile()) os.unlink(self.__pidfile())
def print_output(self): def print_output(self):
......
...@@ -22,7 +22,6 @@ int main(int argc, char **argv) ...@@ -22,7 +22,6 @@ int main(int argc, char **argv)
unsetenv("ZDTM_UID"); unsetenv("ZDTM_UID");
unsetenv("ZDTM_GID"); unsetenv("ZDTM_GID");
unsetenv("ZDTM_ROOT"); unsetenv("ZDTM_ROOT");
unsetenv("ZDTM_PIDFILE");
test_msg("List: [%s]\n", env); test_msg("List: [%s]\n", env);
sprintf(sh, "sh /%s.start", env); sprintf(sh, "sh /%s.start", env);
......
...@@ -239,7 +239,7 @@ int ns_init(int argc, char **argv) ...@@ -239,7 +239,7 @@ int ns_init(int argc, char **argv)
.sa_flags = SA_RESTART, .sa_flags = SA_RESTART,
}; };
int ret, fd, status_pipe = STATUS_FD; int ret, fd, status_pipe = STATUS_FD;
char buf[128]; char buf[128], *x;
pid_t pid; pid_t pid;
ret = fcntl(status_pipe, F_SETFD, FD_CLOEXEC); ret = fcntl(status_pipe, F_SETFD, FD_CLOEXEC);
...@@ -257,6 +257,10 @@ int ns_init(int argc, char **argv) ...@@ -257,6 +257,10 @@ int ns_init(int argc, char **argv)
exit(1); exit(1);
} }
x = malloc(strlen(pidfile) + 3);
sprintf(x, "%sns", pidfile);
pidfile = x;
/* Start test */ /* Start test */
pid = fork(); pid = fork();
if (pid < 0) { if (pid < 0) {
...@@ -404,11 +408,6 @@ void ns_create(int argc, char **argv) ...@@ -404,11 +408,6 @@ void ns_create(int argc, char **argv)
exit(1); exit(1);
} }
pidfile = getenv("ZDTM_PIDFILE");
if (pidfile == NULL) {
fprintf(stderr, "ZDTM_PIDFILE isn't defined");
exit(1);
}
fd = open(pidfile, O_CREAT | O_EXCL | O_WRONLY, 0666); fd = open(pidfile, O_CREAT | O_EXCL | O_WRONLY, 0666);
if (fd == -1) { if (fd == -1) {
fprintf(stderr, "Can't create the file %s: %m\n", pidfile); fprintf(stderr, "Can't create the file %s: %m\n", pidfile);
......
...@@ -392,7 +392,7 @@ cleanout: ...@@ -392,7 +392,7 @@ cleanout:
$(RM) -f -r *.pid *.out* *.test* *.state $(RM) -f -r *.pid *.out* *.test* *.state
%.cleanout: % %.cleanout: %
$(Q) $(RM) -f -r $<.pid $<.out* *$<.test* $<.*.test $<.state $<.init.pid $(Q) $(RM) -f -r $<.pid* $<.out* *$<.test* $<.*.test $<.state
realclean: cleandep cleanout realclean: cleandep cleanout
......
...@@ -96,7 +96,7 @@ cleandep: clean ...@@ -96,7 +96,7 @@ cleandep: clean
$(RM) -f $(DEP) $(RM) -f $(DEP)
%.cleanout: % %.cleanout: %
$(Q) $(RM) -f -r $<.pid $<.init.pid $<.out* $<.test chew_$<.test* $(Q) $(RM) -f -r $<.pid* $<.out* $<.test chew_$<.test*
cleanout: cleanout:
$(RM) -f *.pid *.out* *.test chew* $(RM) -f *.pid *.out* *.test chew*
......
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