[CRIU] [PATCH 1/3] zdtm: Get dir of init.pid file
Pavel Emelyanov
xemul at virtuozzo.com
Wed Mar 2 07:22:08 PST 2016
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: Pavel Emelyanov <xemul at virtuozzo.com>
---
test/zdtm.py | 8 ++------
test/zdtm/lib/groups.c | 1 -
test/zdtm/lib/ns.c | 11 +++++------
test/zdtm/static/Makefile | 2 +-
test/zdtm/transition/Makefile | 2 +-
5 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/test/zdtm.py b/test/zdtm.py
index 1ace919..8e59388 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -312,10 +312,7 @@ class zdtm_test:
self.__freezer.freeze()
def __pidfile(self):
- if self.__flavor.ns:
- return self.__name + '.init.pid'
- else:
- return self.__name + '.pid'
+ return self.__name + '.pid'
def __wait_task_die(self):
wait_pid_die(int(self.__pid), self.__name)
@@ -346,7 +343,6 @@ class zdtm_test:
if self.__flavor.ns:
env['ZDTM_NEWNS'] = "1"
- env['ZDTM_PIDFILE'] = os.path.realpath(self.__name + '.init.pid')
env['ZDTM_ROOT'] = self.__flavor.root
if self.__flavor.uns:
@@ -408,7 +404,7 @@ class zdtm_test:
self.__wait_task_die()
self.__pid = 0
- if force or self.__flavor.ns:
+ if force:
os.unlink(self.__pidfile())
def print_output(self):
diff --git a/test/zdtm/lib/groups.c b/test/zdtm/lib/groups.c
index 4160cd1..83b0938 100644
--- a/test/zdtm/lib/groups.c
+++ b/test/zdtm/lib/groups.c
@@ -22,7 +22,6 @@ int main(int argc, char **argv)
unsetenv("ZDTM_UID");
unsetenv("ZDTM_GID");
unsetenv("ZDTM_ROOT");
- unsetenv("ZDTM_PIDFILE");
test_msg("List: [%s]\n", env);
sprintf(sh, "sh /%s.start", env);
diff --git a/test/zdtm/lib/ns.c b/test/zdtm/lib/ns.c
index bc5c395..78cc91c 100644
--- a/test/zdtm/lib/ns.c
+++ b/test/zdtm/lib/ns.c
@@ -239,7 +239,7 @@ int ns_init(int argc, char **argv)
.sa_flags = SA_RESTART,
};
int ret, fd, status_pipe = STATUS_FD;
- char buf[128];
+ char buf[128], *x;
pid_t pid;
ret = fcntl(status_pipe, F_SETFD, FD_CLOEXEC);
@@ -257,6 +257,10 @@ int ns_init(int argc, char **argv)
exit(1);
}
+ x = malloc(strlen(pidfile) + 3);
+ sprintf(x, "%sns", pidfile);
+ pidfile = x;
+
/* Start test */
pid = fork();
if (pid < 0) {
@@ -404,11 +408,6 @@ void ns_create(int argc, char **argv)
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);
if (fd == -1) {
fprintf(stderr, "Can't create the file %s: %m\n", pidfile);
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index f5b9e67..36dd890 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -392,7 +392,7 @@ cleanout:
$(RM) -f -r *.pid *.out* *.test* *.state
%.cleanout: %
- $(Q) $(RM) -f -r $<.pid $<.out* *$<.test* $<.*.test $<.state $<.init.pid
+ $(Q) $(RM) -f -r $<.pid* $<.out* *$<.test* $<.*.test $<.state
realclean: cleandep cleanout
diff --git a/test/zdtm/transition/Makefile b/test/zdtm/transition/Makefile
index f0cad38..2f3b6e8 100644
--- a/test/zdtm/transition/Makefile
+++ b/test/zdtm/transition/Makefile
@@ -96,7 +96,7 @@ cleandep: clean
$(RM) -f $(DEP)
%.cleanout: %
- $(Q) $(RM) -f -r $<.pid $<.init.pid $<.out* $<.test chew_$<.test*
+ $(Q) $(RM) -f -r $<.pid* $<.out* $<.test chew_$<.test*
cleanout:
$(RM) -f *.pid *.out* *.test chew*
--
2.5.0
More information about the CRIU
mailing list