Commit f5f931f0 authored by Kinsbursky Stanislav's avatar Kinsbursky Stanislav Committed by Andrey Vagin

zdtm: enhance namespaces isolation environment

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: 's avatarStanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: 's avatarAndrey Vagin <avagin@gmail.com>
parent c79532b4
...@@ -161,7 +161,9 @@ void test_init(int argc, char **argv) ...@@ -161,7 +161,9 @@ void test_init(int argc, char **argv)
struct zdtm_clone_arg { struct zdtm_clone_arg {
FILE *pidf; FILE *pidf;
void (*fn)(void); int argc;
char **argv;
int (*fn)(int argc, char **argv);
}; };
static int do_test_fn(void *_arg) static int do_test_fn(void *_arg)
...@@ -190,12 +192,13 @@ static int do_test_fn(void *_arg) ...@@ -190,12 +192,13 @@ static int do_test_fn(void *_arg)
srand48(time(NULL)); /* just in case we need it */ srand48(time(NULL)); /* just in case we need it */
if (ca->fn()) if (ca->fn(ca->argc, ca->argv))
exit(1); exit(1);
exit(0); exit(0);
} }
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 **); extern void parseargs(int, char **);
...@@ -240,6 +243,8 @@ void test_init_ns(int argc, char **argv, unsigned long clone_flags, void (*fn)(v ...@@ -240,6 +243,8 @@ void test_init_ns(int argc, char **argv, unsigned long clone_flags, void (*fn)(v
ca.pidf = pidf; ca.pidf = pidf;
ca.fn = fn; ca.fn = fn;
ca.argc = argc;
ca.argv = argv;
pid = clone(do_test_fn, stack + STACK_SIZE, clone_flags | SIGCHLD, &ca); pid = clone(do_test_fn, stack + STACK_SIZE, clone_flags | SIGCHLD, &ca);
if (pid < 0) { if (pid < 0) {
err("Daemonizing failed: %m\n"); err("Daemonizing failed: %m\n");
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* set up test */ /* set up test */
extern void test_init(int argc, char **argv); 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 #ifndef CLONE_NEWUTS
#define CLONE_NEWUTS 0x04000000 #define CLONE_NEWUTS 0x04000000
......
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