aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2015-10-05 10:40:19 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-10-05 15:55:38 -0400
commit31b6753f95320260b160935d0e9c0b29f096ab57 (patch)
treee5e388b26be17aab71c912664b24e7fdb69ceeef
parenta1853e2c6f8ed488adcd84fb162c5b3f0b674d9b (diff)
perf tests: Add arch tests
Tests that only make sense for some architectures currently live in the same place as the generic tests. Move out the x86-specific tests into tools/perf/arch/x86/tests and define an 'arch_tests' array, which is the list of tests that only apply to the build architecture. The main idea is to encourage developers to add arch tests to build out perf's test coverage, without dumping everything in tools/perf/tests. Signed-off-by: Matt Fleming <matt.fleming@intel.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Kanaka Juvva <kanaka.d.juvva@intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Vikas Shivappa <vikas.shivappa@intel.com> Cc: Vince Weaver <vince@deater.net> Link: http://lkml.kernel.org/n/tip-p4uc1c15ssbj8xj7ku5slpa6@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/arch/x86/Build2
-rw-r--r--tools/perf/arch/x86/include/arch-tests.h6
-rw-r--r--tools/perf/arch/x86/tests/Build6
-rw-r--r--tools/perf/arch/x86/tests/arch-tests.c10
-rw-r--r--tools/perf/tests/builtin-test.c28
-rw-r--r--tools/perf/tests/tests.h5
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 @@
1libperf-y += util/ 1libperf-y += util/
2libperf-$(CONFIG_DWARF_UNWIND) += tests/ 2libperf-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
4extern 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 @@
1libperf-y += regs_load.o 1libperf-$(CONFIG_DWARF_UNWIND) += regs_load.o
2libperf-y += dwarf-unwind.o 2libperf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
3
4libperf-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
5struct 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
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
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
27struct test {
28 const char *desc;
29 int (*func)(void);
30};
31
27/* Tests */ 32/* Tests */
28int test__vmlinux_matches_kallsyms(void); 33int test__vmlinux_matches_kallsyms(void);
29int test__openat_syscall_event(void); 34int test__openat_syscall_event(void);