[CRIU] [PATCH 1/3] zdtm: enhance namespaces isolation environment

Kinsbursky Stanislav skinsbursky at openvz.org
Tue Feb 7 09:21:40 EST 2012


1) pass cmd line args to function to clone to - required for parametrized
tests.
2) handle function result  - required for multi-process tests.

Signed-off-by: Stanislav Kinsbursky <skinsbursky at parallels.com>

---
 test/zdtm/lib/test.c    |   12 ++++++++----
 test/zdtm/lib/zdtmtst.h |    2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/test/zdtm/lib/test.c b/test/zdtm/lib/test.c
index 4490f02..9c5c6e8 100644
--- a/test/zdtm/lib/test.c
+++ b/test/zdtm/lib/test.c
@@ -161,7 +161,9 @@ void test_init(int argc, char **argv)
 
 struct zdtm_clone_arg {
 	FILE *pidf;
-	void (*fn)(void);
+	int argc;
+	char **argv;
+	int (*fn)(int argc, char **argv);
 };
 
 static int do_test_fn(void *_arg)
@@ -190,11 +192,11 @@ static int do_test_fn(void *_arg)
 
 	srand48(time(NULL));	/* just in case we need it */
 
-	ca->fn();
-	exit(0);
+	exit(ca->fn(ca->argc, ca->argv));
 }
 
-void test_init_ns(int argc, char **argv, unsigned long clone_flags, void (*fn)(void))
+void test_init_ns(int argc, char **argv, unsigned long clone_flags,
+		  int (*fn)(int , char **))
 {
 	extern void parseargs(int, char **);
 
@@ -239,6 +241,8 @@ void test_init_ns(int argc, char **argv, unsigned long clone_flags, void (*fn)(v
 
 	ca.pidf = pidf;
 	ca.fn = fn;
+	ca.argc = argc;
+	ca.argv = argv;
 	pid = clone(do_test_fn, stack + STACK_SIZE, clone_flags | SIGCHLD, &ca);
 	if (pid < 0) {
 		err("Daemonizing failed: %m\n");
diff --git a/test/zdtm/lib/zdtmtst.h b/test/zdtm/lib/zdtmtst.h
index fe329b0..6ef7804 100644
--- a/test/zdtm/lib/zdtmtst.h
+++ b/test/zdtm/lib/zdtmtst.h
@@ -5,7 +5,7 @@
 
 /* set up test */
 extern void test_init(int argc, char **argv);
-extern void test_init_ns(int argc, char **argv, unsigned long clone_flags, void (*fn)(void));
+extern void test_init_ns(int argc, char **argv, unsigned long clone_flags, int (*fn)(int , char **));
 
 #ifndef CLONE_NEWUTS
 #define CLONE_NEWUTS 0x04000000



More information about the CRIU mailing list