[CRIU] [PATCH 3/3] zdtm/static: wait when processes complete a preparation stage

Andrey Vagin avagin at openvz.org
Thu Jun 2 20:41:21 PDT 2016


From: Andrew Vagin <avagin at virtuozzo.com>

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 test/zdtm/static/tty00.c | 6 ++++++
 test/zdtm/static/tty03.c | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/test/zdtm/static/tty00.c b/test/zdtm/static/tty00.c
index 749b9bc..3408557 100644
--- a/test/zdtm/static/tty00.c
+++ b/test/zdtm/static/tty00.c
@@ -23,11 +23,14 @@ static void sighup_handler(int signo)
 int main(int argc, char ** argv)
 {
 	int fdm, fds, status;
+	task_waiter_t t;
 	char *slavename;
 	pid_t pid;
 
 	test_init(argc, argv);
 
+	task_waiter_init(&t);
+
 	fdm = open("/dev/ptmx", O_RDWR);
 	if (fdm == -1) {
 		pr_perror("Can't open a master pseudoterminal");
@@ -64,12 +67,15 @@ int main(int argc, char ** argv)
 		}
 		close(fds);
 
+		task_waiter_complete_current(&t);
+
 		test_waitsig();
 		if (sighup)
 			return 0;
 		return 1;
 	}
 
+	task_waiter_wait4(&t, pid);
 
 	test_daemon();
 
diff --git a/test/zdtm/static/tty03.c b/test/zdtm/static/tty03.c
index c9d4a25..741b871 100644
--- a/test/zdtm/static/tty03.c
+++ b/test/zdtm/static/tty03.c
@@ -15,11 +15,13 @@ const char *test_author	= "Andrey Vagin <avagin at openvz.org>";
 int main(int argc, char ** argv)
 {
 	int fdm, fds, exit_code = 1, status;
+	task_waiter_t t;
 	char *slavename;
 	pid_t sid_b, sid_a, pid;
 	int pfd[2];
 
 	test_init(argc, argv);
+	task_waiter_init(&t);
 
 	if (pipe(pfd) == -1) {
 		pr_perror("pipe");
@@ -62,6 +64,7 @@ int main(int argc, char ** argv)
 
 			close(pfd[1]);
 
+			task_waiter_complete(&t, 1);
 			test_waitsig();
 			exit(0);
 		}
@@ -69,6 +72,9 @@ int main(int argc, char ** argv)
 		close(fds);
 		close(pfd[1]);
 
+		task_waiter_wait4(&t, 1);
+		task_waiter_complete(&t, 0);
+
 		test_waitsig();
 
 		kill(pid, SIGTERM);
@@ -88,6 +94,7 @@ int main(int argc, char ** argv)
 		goto out;
 	}
 
+	task_waiter_wait4(&t, 0);
 	test_daemon();
 	test_waitsig();
 
-- 
2.7.4



More information about the CRIU mailing list