diff options
author | Jiri Olsa <jolsa@kernel.org> | 2014-05-10 11:22:30 -0400 |
---|---|---|
committer | Jiri Olsa <jolsa@kernel.org> | 2014-06-12 10:53:22 -0400 |
commit | 0d8a5faaf5a1087c7212a6f0d81920a93396414a (patch) | |
tree | 63f760578fbdd470df1820c45773ddd3658db6a9 /tools/perf/tests/builtin-test.c | |
parent | c1f9aa0a61bde512a68060883d1c3c1955a546ea (diff) |
perf tests: Spawn child for each test
In upcoming tests we will setup process limits, which
might affect other tests. Spawning child for each test
to prevent this.
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jean Pihet <jean.pihet@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Reviewed-by: David Ahern <dsahern@gmail.com>
Link: http://lkml.kernel.org/r/1401892622-30848-11-git-send-email-jolsa@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Diffstat (limited to 'tools/perf/tests/builtin-test.c')
-rw-r--r-- | tools/perf/tests/builtin-test.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 802e3cd50f6f..9677a5c6a366 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c | |||
@@ -3,6 +3,8 @@ | |||
3 | * | 3 | * |
4 | * Builtin regression testing command: ever growing number of sanity tests | 4 | * Builtin regression testing command: ever growing number of sanity tests |
5 | */ | 5 | */ |
6 | #include <unistd.h> | ||
7 | #include <string.h> | ||
6 | #include "builtin.h" | 8 | #include "builtin.h" |
7 | #include "intlist.h" | 9 | #include "intlist.h" |
8 | #include "tests.h" | 10 | #include "tests.h" |
@@ -172,6 +174,34 @@ static bool perf_test__matches(int curr, int argc, const char *argv[]) | |||
172 | return false; | 174 | return false; |
173 | } | 175 | } |
174 | 176 | ||
177 | static int run_test(struct test *test) | ||
178 | { | ||
179 | int status, err = -1, child = fork(); | ||
180 | |||
181 | if (child < 0) { | ||
182 | pr_err("failed to fork test: %s\n", strerror(errno)); | ||
183 | return -1; | ||
184 | } | ||
185 | |||
186 | if (!child) { | ||
187 | pr_debug("test child forked, pid %d\n", getpid()); | ||
188 | err = test->func(); | ||
189 | exit(err); | ||
190 | } | ||
191 | |||
192 | wait(&status); | ||
193 | |||
194 | if (WIFEXITED(status)) { | ||
195 | err = WEXITSTATUS(status); | ||
196 | pr_debug("test child finished with %d\n", err); | ||
197 | } else if (WIFSIGNALED(status)) { | ||
198 | err = -1; | ||
199 | pr_debug("test child interrupted\n"); | ||
200 | } | ||
201 | |||
202 | return err; | ||
203 | } | ||
204 | |||
175 | static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) | 205 | static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) |
176 | { | 206 | { |
177 | int i = 0; | 207 | int i = 0; |
@@ -200,7 +230,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) | |||
200 | } | 230 | } |
201 | 231 | ||
202 | pr_debug("\n--- start ---\n"); | 232 | pr_debug("\n--- start ---\n"); |
203 | err = tests[curr].func(); | 233 | err = run_test(&tests[curr]); |
204 | pr_debug("---- end ----\n%s:", tests[curr].desc); | 234 | pr_debug("---- end ----\n%s:", tests[curr].desc); |
205 | 235 | ||
206 | switch (err) { | 236 | switch (err) { |