diff options
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/arch/x86/Build | 2 | ||||
-rw-r--r-- | tools/perf/arch/x86/include/arch-tests.h | 6 | ||||
-rw-r--r-- | tools/perf/arch/x86/tests/Build | 6 | ||||
-rw-r--r-- | tools/perf/arch/x86/tests/arch-tests.c | 10 | ||||
-rw-r--r-- | tools/perf/tests/builtin-test.c | 28 | ||||
-rw-r--r-- | tools/perf/tests/tests.h | 5 |
6 files changed, 46 insertions, 11 deletions
diff --git a/tools/perf/arch/x86/Build b/tools/perf/arch/x86/Build index 41bf61da476a..db52fa22d3a1 100644 --- a/tools/perf/arch/x86/Build +++ b/tools/perf/arch/x86/Build | |||
@@ -1,2 +1,2 @@ | |||
1 | libperf-y += util/ | 1 | libperf-y += util/ |
2 | libperf-$(CONFIG_DWARF_UNWIND) += tests/ | 2 | libperf-y += tests/ |
diff --git a/tools/perf/arch/x86/include/arch-tests.h b/tools/perf/arch/x86/include/arch-tests.h new file mode 100644 index 000000000000..4bd41d8e1ca4 --- /dev/null +++ b/tools/perf/arch/x86/include/arch-tests.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef ARCH_TESTS_H | ||
2 | #define ARCH_TESTS_H | ||
3 | |||
4 | extern struct test arch_tests[]; | ||
5 | |||
6 | #endif | ||
diff --git a/tools/perf/arch/x86/tests/Build b/tools/perf/arch/x86/tests/Build index b30eff9bcc83..d827ef384b33 100644 --- a/tools/perf/arch/x86/tests/Build +++ b/tools/perf/arch/x86/tests/Build | |||
@@ -1,2 +1,4 @@ | |||
1 | libperf-y += regs_load.o | 1 | libperf-$(CONFIG_DWARF_UNWIND) += regs_load.o |
2 | libperf-y += dwarf-unwind.o | 2 | libperf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o |
3 | |||
4 | libperf-y += arch-tests.o | ||
diff --git a/tools/perf/arch/x86/tests/arch-tests.c b/tools/perf/arch/x86/tests/arch-tests.c new file mode 100644 index 000000000000..fca9eb9d39a2 --- /dev/null +++ b/tools/perf/arch/x86/tests/arch-tests.c | |||
@@ -0,0 +1,10 @@ | |||
1 | #include <string.h> | ||
2 | #include "tests/tests.h" | ||
3 | #include "arch-tests.h" | ||
4 | |||
5 | struct test arch_tests[] = { | ||
6 | { | ||
7 | .func = NULL, | ||
8 | }, | ||
9 | |||
10 | }; | ||
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index d9bf51dc8cf5..2b6c1bf13456 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c | |||
@@ -14,10 +14,13 @@ | |||
14 | #include "parse-options.h" | 14 | #include "parse-options.h" |
15 | #include "symbol.h" | 15 | #include "symbol.h" |
16 | 16 | ||
17 | static struct test { | 17 | struct test __weak arch_tests[] = { |
18 | const char *desc; | 18 | { |
19 | int (*func)(void); | 19 | .func = NULL, |
20 | } tests[] = { | 20 | }, |
21 | }; | ||
22 | |||
23 | static struct test generic_tests[] = { | ||
21 | { | 24 | { |
22 | .desc = "vmlinux symtab matches kallsyms", | 25 | .desc = "vmlinux symtab matches kallsyms", |
23 | .func = test__vmlinux_matches_kallsyms, | 26 | .func = test__vmlinux_matches_kallsyms, |
@@ -195,6 +198,11 @@ static struct test { | |||
195 | }, | 198 | }, |
196 | }; | 199 | }; |
197 | 200 | ||
201 | static struct test *tests[] = { | ||
202 | generic_tests, | ||
203 | arch_tests, | ||
204 | }; | ||
205 | |||
198 | static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[]) | 206 | static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[]) |
199 | { | 207 | { |
200 | int i; | 208 | int i; |
@@ -249,22 +257,25 @@ static int run_test(struct test *test) | |||
249 | return err; | 257 | return err; |
250 | } | 258 | } |
251 | 259 | ||
252 | #define for_each_test(t) for (t = &tests[0]; t->func; t++) | 260 | #define for_each_test(j, t) \ |
261 | for (j = 0; j < ARRAY_SIZE(tests); j++) \ | ||
262 | for (t = &tests[j][0]; t->func; t++) | ||
253 | 263 | ||
254 | static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) | 264 | static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) |
255 | { | 265 | { |
256 | struct test *t; | 266 | struct test *t; |
267 | unsigned int j; | ||
257 | int i = 0; | 268 | int i = 0; |
258 | int width = 0; | 269 | int width = 0; |
259 | 270 | ||
260 | for_each_test(t) { | 271 | for_each_test(j, t) { |
261 | int len = strlen(t->desc); | 272 | int len = strlen(t->desc); |
262 | 273 | ||
263 | if (width < len) | 274 | if (width < len) |
264 | width = len; | 275 | width = len; |
265 | } | 276 | } |
266 | 277 | ||
267 | for_each_test(t) { | 278 | for_each_test(j, t) { |
268 | int curr = i++, err; | 279 | int curr = i++, err; |
269 | 280 | ||
270 | if (!perf_test__matches(t, curr, argc, argv)) | 281 | if (!perf_test__matches(t, curr, argc, argv)) |
@@ -300,10 +311,11 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) | |||
300 | 311 | ||
301 | static int perf_test__list(int argc, const char **argv) | 312 | static int perf_test__list(int argc, const char **argv) |
302 | { | 313 | { |
314 | unsigned int j; | ||
303 | struct test *t; | 315 | struct test *t; |
304 | int i = 0; | 316 | int i = 0; |
305 | 317 | ||
306 | for_each_test(t) { | 318 | for_each_test(j, t) { |
307 | if (argc > 1 && !strstr(t->desc, argv[1])) | 319 | if (argc > 1 && !strstr(t->desc, argv[1])) |
308 | continue; | 320 | continue; |
309 | 321 | ||
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 0b3549672c16..b1cb1c081e3c 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h | |||
@@ -24,6 +24,11 @@ enum { | |||
24 | TEST_SKIP = -2, | 24 | TEST_SKIP = -2, |
25 | }; | 25 | }; |
26 | 26 | ||
27 | struct test { | ||
28 | const char *desc; | ||
29 | int (*func)(void); | ||
30 | }; | ||
31 | |||
27 | /* Tests */ | 32 | /* Tests */ |
28 | int test__vmlinux_matches_kallsyms(void); | 33 | int test__vmlinux_matches_kallsyms(void); |
29 | int test__openat_syscall_event(void); | 34 | int test__openat_syscall_event(void); |