[CRIU] [PATCH 2/2] zdtm: Static pstree test

Pavel Emelyanov xemul at parallels.com
Wed Feb 1 08:05:11 EST 2012


I'm waiting for Andrey's

* pthread join fix
* infrastructure for fokring in zdtm

to extend it with threads.

Besides, we/me need to fix the seizing of dynamically forking tasks
to write a transition pstree test.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>

---
-------------- next part --------------
 test/zdtm.sh                   |    1 +
 test/zdtm/live/static/Makefile |    1 +
 test/zdtm/live/static/pstree.c |   74 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 76 insertions(+), 0 deletions(-)
 create mode 100644 test/zdtm/live/static/pstree.c

diff --git a/test/zdtm.sh b/test/zdtm.sh
index 5b6f1ae..e64aeb5 100644
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -26,6 +26,7 @@ $ZP/transition/fork
 $ZP/static/zombie00
 $ZP/static/sockets00
 $ZP/static/pid00
+$ZP/static/pstree
 $ZP/static/caps00
 $ZP/static/cmdlinenv00
 $ZP/static/socket_listen"
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index e177ca3..490f504 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -29,6 +29,7 @@ TST_NOFILE	=				\
 		pthread00			\
 		vdso00				\
 		utsname				\
+		pstree				\
 		sockets00			\
 		ipc_namespace			\
 #		jobctl00			\
diff --git a/test/zdtm/live/static/pstree.c b/test/zdtm/live/static/pstree.c
new file mode 100644
index 0000000..1b2508b
--- /dev/null
+++ b/test/zdtm/live/static/pstree.c
@@ -0,0 +1,74 @@
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "zdtmtst.h"
+
+const char *test_doc	= "Check that environment didn't change";
+const char *test_author	= "Pavel Emelianov <xemul at parallels.com>";
+
+int main(int argc, char **argv)
+{
+	char x;
+	int pid, ppid;
+	int sp[2], fp[2], rp[2];
+
+	test_init(argc, argv);
+
+	pipe(sp);
+	pipe(fp);
+	pipe(rp);
+
+	pid = fork();
+	if (pid == 0) {
+		close(sp[0]);
+		close(fp[1]);
+		close(rp[0]);
+
+		pid = getpid();
+		ppid = getppid();
+
+		close(sp[1]);
+		read(fp[0], &x, 1);
+		close(fp[0]);
+
+		if (pid != getpid())
+			x = 'p';
+		else if (ppid != getppid())
+			x = 'P';
+		else
+			x = '0';
+
+		write(rp[1], &x, 1);
+		close(rp[1]);
+		_exit(0);
+	}
+
+	x = 'X';
+	close(sp[1]);
+	close(fp[0]);
+	close(rp[1]);
+
+	read(sp[1], &x, 1);
+
+	test_daemon();
+	test_waitsig();
+
+	close(fp[1]);
+	read(rp[0], &x, 1);
+	close(rp[0]);
+
+	if (x == 'X')
+		fail("Sync failed");
+	else if (x == 'p')
+		fail("Pid failed");
+	else if (x == 'P')
+		fail("PPid failed");
+	else if (x != '0')
+		fail("Shit happened");
+	else
+		pass();
+
+	return 0;
+}
-- 
1.6.5.2


More information about the CRIU mailing list