diff options
Diffstat (limited to 'tools/perf/tests/builtin-test.c')
-rw-r--r-- | tools/perf/tests/builtin-test.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 802e3cd50f6f..6f8b01bc6033 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" |
@@ -50,10 +52,18 @@ static struct test { | |||
50 | .func = test__pmu, | 52 | .func = test__pmu, |
51 | }, | 53 | }, |
52 | { | 54 | { |
53 | .desc = "Test dso data interface", | 55 | .desc = "Test dso data read", |
54 | .func = test__dso_data, | 56 | .func = test__dso_data, |
55 | }, | 57 | }, |
56 | { | 58 | { |
59 | .desc = "Test dso data cache", | ||
60 | .func = test__dso_data_cache, | ||
61 | }, | ||
62 | { | ||
63 | .desc = "Test dso data reopen", | ||
64 | .func = test__dso_data_reopen, | ||
65 | }, | ||
66 | { | ||
57 | .desc = "roundtrip evsel->name check", | 67 | .desc = "roundtrip evsel->name check", |
58 | .func = test__perf_evsel__roundtrip_name_test, | 68 | .func = test__perf_evsel__roundtrip_name_test, |
59 | }, | 69 | }, |
@@ -172,6 +182,34 @@ static bool perf_test__matches(int curr, int argc, const char *argv[]) | |||
172 | return false; | 182 | return false; |
173 | } | 183 | } |
174 | 184 | ||
185 | static int run_test(struct test *test) | ||
186 | { | ||
187 | int status, err = -1, child = fork(); | ||
188 | |||
189 | if (child < 0) { | ||
190 | pr_err("failed to fork test: %s\n", strerror(errno)); | ||
191 | return -1; | ||
192 | } | ||
193 | |||
194 | if (!child) { | ||
195 | pr_debug("test child forked, pid %d\n", getpid()); | ||
196 | err = test->func(); | ||
197 | exit(err); | ||
198 | } | ||
199 | |||
200 | wait(&status); | ||
201 | |||
202 | if (WIFEXITED(status)) { | ||
203 | err = WEXITSTATUS(status); | ||
204 | pr_debug("test child finished with %d\n", err); | ||
205 | } else if (WIFSIGNALED(status)) { | ||
206 | err = -1; | ||
207 | pr_debug("test child interrupted\n"); | ||
208 | } | ||
209 | |||
210 | return err; | ||
211 | } | ||
212 | |||
175 | static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) | 213 | static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) |
176 | { | 214 | { |
177 | int i = 0; | 215 | int i = 0; |
@@ -200,7 +238,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) | |||
200 | } | 238 | } |
201 | 239 | ||
202 | pr_debug("\n--- start ---\n"); | 240 | pr_debug("\n--- start ---\n"); |
203 | err = tests[curr].func(); | 241 | err = run_test(&tests[curr]); |
204 | pr_debug("---- end ----\n%s:", tests[curr].desc); | 242 | pr_debug("---- end ----\n%s:", tests[curr].desc); |
205 | 243 | ||
206 | switch (err) { | 244 | switch (err) { |