[CRIU] [PATCH 3/4] zdtm: Remove test_init_ns()
Pavel Emelyanov
xemul at parallels.com
Mon Nov 30 11:38:56 PST 2015
The ns and uns flavors are MUCH better ways of launching tests in namespaces.
Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
test/zdtm/lib/test.c | 115 ------------------------------------------------
test/zdtm/lib/zdtmtst.h | 1 -
2 files changed, 116 deletions(-)
diff --git a/test/zdtm/lib/test.c b/test/zdtm/lib/test.c
index 0eedbf4..bb1f0b6 100644
--- a/test/zdtm/lib/test.c
+++ b/test/zdtm/lib/test.c
@@ -229,121 +229,6 @@ skip_pid:
srand48(time(NULL)); /* just in case we need it */
}
-#define STACK_SIZE 4096
-
-struct zdtm_clone_arg {
- char stack[STACK_SIZE];
- char stack_ptr[0];
- FILE *pidf;
- int argc;
- char **argv;
- int (*fn)(int argc, char **argv);
-};
-
-static int do_test_fn(void *_arg)
-{
- struct zdtm_clone_arg *ca = _arg;
- struct sigaction sa = {
- .sa_handler = SIG_DFL,
- .sa_flags = SA_RESTART,
- };
-
- /* record the test pid to remember the ownership of the pidfile */
- master_pid = getpid();
-
- fclose(ca->pidf);
-
- sigemptyset(&sa.sa_mask);
- if (sigaction(SIGCHLD, &sa, NULL)) {
- pr_perror("Can't reset SIGCHLD handler");
- exit(1);
- }
-
- if (setsid() < 0) {
- pr_perror("Can't become session group leader");
- exit(1);
- }
-
- srand48(time(NULL)); /* just in case we need it */
-
- if (ca->fn(ca->argc, ca->argv))
- exit(1);
- exit(0);
-}
-
-void test_init_ns(int argc, char **argv, unsigned long clone_flags,
- int (*fn)(int , char **))
-{
- extern void parseargs(int, char **);
-
- pid_t pid;
- static FILE *pidf;
- struct sigaction sa = {
- .sa_handler = sig_hand,
- .sa_flags = SA_RESTART,
- };
- struct zdtm_clone_arg ca;
-
- sigemptyset(&sa.sa_mask);
-
- if (sigaction(SIGTERM, &sa, NULL)) {
- fprintf(stderr, "Can't set SIGTERM handler: %m\n");
- exit(1);
- }
-
- if (sigaction(SIGCHLD, &sa, NULL)) {
- fprintf(stderr, "Can't set SIGCHLD handler: %m\n");
- exit(1);
- }
-
- parseargs(argc, argv);
-
- /* setup_outfile() should be called in a target mount namespace */
- if (!(clone_flags & CLONE_NEWNS))
- setup_outfile();
- redir_stdfds();
-
- pidf = fopen(pidfile, "wx");
- if (!pidf) {
- pr_perror("Can't create pid file %s", pidfile);
- exit(1);
- }
-
- ca.pidf = pidf;
- ca.fn = fn;
- ca.argc = argc;
- ca.argv = argv;
- pid = clone(do_test_fn, ca.stack_ptr, clone_flags | SIGCHLD, &ca);
- if (pid < 0) {
- pr_perror("Daemonizing failed");
- exit(1);
- }
-
- /* parent will exit when the child is ready */
- test_waitsig();
-
- if (futex_get(&sig_received) == SIGCHLD) {
- int ret;
- if (waitpid(pid, &ret, 0) != pid) {
- pr_perror("Unable to wait %d", pid);
- exit(1);
- }
-
- if (WIFEXITED(ret)) {
- pr_err("Test exited unexpectedly with code %d\n", WEXITSTATUS(ret));
- exit(1);
- }
- if (WIFSIGNALED(ret)) {
- pr_err("Test exited on unexpected signal %d\n", WTERMSIG(ret));
- exit(1);
- }
- }
-
- fprintf(pidf, "%d\n", pid);
- fclose(pidf);
- _exit(0);
-}
-
void test_daemon()
{
pid_t ppid;
diff --git a/test/zdtm/lib/zdtmtst.h b/test/zdtm/lib/zdtmtst.h
index 12f170e..c9f1064 100644
--- a/test/zdtm/lib/zdtmtst.h
+++ b/test/zdtm/lib/zdtmtst.h
@@ -15,7 +15,6 @@
/* set up test */
extern void test_ext_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, int (*fn)(int , char **));
#ifndef CLONE_NEWUTS
#define CLONE_NEWUTS 0x04000000
--
1.9.3
More information about the CRIU
mailing list