perf tests: Add arch tests
authorMatt Fleming <matt.fleming@intel.com>
Mon, 5 Oct 2015 14:40:19 +0000 (15:40 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 5 Oct 2015 19:55:38 +0000 (16:55 -0300)
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>
tools/perf/arch/x86/Build
tools/perf/arch/x86/include/arch-tests.h [new file with mode: 0644]
tools/perf/arch/x86/tests/Build
tools/perf/arch/x86/tests/arch-tests.c [new file with mode: 0644]
tools/perf/tests/builtin-test.c
tools/perf/tests/tests.h

index 41bf61da476a4ce3150fc0184c84718d807be894..db52fa22d3a1d64a6fe62cffd4b34cd9ffe066f9 100644 (file)
@@ -1,2 +1,2 @@
 libperf-y += util/
-libperf-$(CONFIG_DWARF_UNWIND) += tests/
+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 (file)
index 0000000..4bd41d8
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef ARCH_TESTS_H
+#define ARCH_TESTS_H
+
+extern struct test arch_tests[];
+
+#endif
index b30eff9bcc83fd14026100f8626e913fd8f954e9..d827ef384b333be9846854da1838d29714a1b4d2 100644 (file)
@@ -1,2 +1,4 @@
-libperf-y += regs_load.o
-libperf-y += dwarf-unwind.o
+libperf-$(CONFIG_DWARF_UNWIND) += regs_load.o
+libperf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o
+
+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 (file)
index 0000000..fca9eb9
--- /dev/null
@@ -0,0 +1,10 @@
+#include <string.h>
+#include "tests/tests.h"
+#include "arch-tests.h"
+
+struct test arch_tests[] = {
+       {
+               .func = NULL,
+       },
+
+};
index d9bf51dc8cf5fc73cefa19c23911c9584465c526..2b6c1bf134564011466bc890a277c2529d071358 100644 (file)
 #include "parse-options.h"
 #include "symbol.h"
 
-static struct test {
-       const char *desc;
-       int (*func)(void);
-} tests[] = {
+struct test __weak arch_tests[] = {
+       {
+               .func = NULL,
+       },
+};
+
+static struct test generic_tests[] = {
        {
                .desc = "vmlinux symtab matches kallsyms",
                .func = test__vmlinux_matches_kallsyms,
@@ -195,6 +198,11 @@ static struct test {
        },
 };
 
+static struct test *tests[] = {
+       generic_tests,
+       arch_tests,
+};
+
 static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[])
 {
        int i;
@@ -249,22 +257,25 @@ static int run_test(struct test *test)
        return err;
 }
 
-#define for_each_test(t)        for (t = &tests[0]; t->func; t++)
+#define for_each_test(j, t)                                    \
+       for (j = 0; j < ARRAY_SIZE(tests); j++) \
+               for (t = &tests[j][0]; t->func; t++)
 
 static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
 {
        struct test *t;
+       unsigned int j;
        int i = 0;
        int width = 0;
 
-       for_each_test(t) {
+       for_each_test(j, t) {
                int len = strlen(t->desc);
 
                if (width < len)
                        width = len;
        }
 
-       for_each_test(t) {
+       for_each_test(j, t) {
                int curr = i++, err;
 
                if (!perf_test__matches(t, curr, argc, argv))
@@ -300,10 +311,11 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
 
 static int perf_test__list(int argc, const char **argv)
 {
+       unsigned int j;
        struct test *t;
        int i = 0;
 
-       for_each_test(t) {
+       for_each_test(j, t) {
                if (argc > 1 && !strstr(t->desc, argv[1]))
                        continue;
 
index 0b3549672c163a3f355c15d9518ce532dacff261..b1cb1c081e3ca80ad516698c3512795fb6e002af 100644 (file)
@@ -24,6 +24,11 @@ enum {
        TEST_SKIP = -2,
 };
 
+struct test {
+       const char *desc;
+       int (*func)(void);
+};
+
 /* Tests */
 int test__vmlinux_matches_kallsyms(void);
 int test__openat_syscall_event(void);
This page took 0.028429 seconds and 5 git commands to generate.