#include "testsuite.h"
static const char *progname;
-int oneshot = 0;
+static int oneshot = 0;
static const char options_short[] = "lhn";
static const struct option options[] = {
{ "list", no_argument, 0, 'l' },
return NULL;
}
-int test_spawn_test(const struct test *t)
+static int test_spawn_test(const struct test *t)
{
const char *const args[] = { progname, "-n", t->name, NULL };
return EXIT_FAILURE;
}
+static int test_run_spawned(const struct test *t)
+{
+ int err = t->func(t);
+ exit(err);
+
+ return EXIT_FAILURE;
+}
+
int test_spawn_prog(const char *prog, const char *args[])
{
execv(prog, (char *const *) args);
return EXIT_FAILURE;
}
-int test_run_spawned(const struct test *t)
{
- int err = t->func(t);
- exit(err);
}
int test_run(const struct test *t)
int err;
pid_t pid;
+ if (t->need_spawn && oneshot)
+ test_run_spawned(t);
+
LOG("running %s, in forked context\n", t->name);
pid = fork();
/* kill child if parent dies */
prctl(PR_SET_PDEATHSIG, SIGTERM);
- test_run_spawned(t);
+
+ if (t->need_spawn)
+ return test_spawn_test(t);
+ else
+ return test_run_spawned(t);
}
const char *description;
testfunc func;
const char *config[_TC_LAST];
+ bool need_spawn;
};
const struct test *test_find(const struct test *tests[], const char *name);
int test_init(int argc, char *const argv[], const struct test *tests[]);
-int test_spawn_test(const struct test *t);
int test_spawn_prog(const char *prog, const char *args[]);
int test_run(const struct test *t);
-__attribute__((noreturn)) int test_run_spawned(const struct test *t);
-
-extern int oneshot;
#define TS_EXPORT __attribute__ ((visibility("default")))