aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/tests/builtin-test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/tests/builtin-test.c')
-rw-r--r--tools/perf/tests/builtin-test.c28
1 files changed, 20 insertions, 8 deletions
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
17static struct test { 17struct test __weak arch_tests[] = {
18 const char *desc; 18 {
19 int (*func)(void); 19 .func = NULL,
20} tests[] = { 20 },
21};
22
23static 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
201static struct test *tests[] = {
202 generic_tests,
203 arch_tests,
204};
205
198static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[]) 206static 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
254static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) 264static 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
301static int perf_test__list(int argc, const char **argv) 312static 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