From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752648AbbJFHQl (ORCPT ); Tue, 6 Oct 2015 03:16:41 -0400 Received: from terminus.zytor.com ([198.137.202.10]:55907 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751986AbbJFHQj (ORCPT ); Tue, 6 Oct 2015 03:16:39 -0400 Date: Tue, 6 Oct 2015 00:16:02 -0700 From: tip-bot for Matt Fleming Message-ID: Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, acme@redhat.com, peterz@infradead.org, fenghua.yu@intel.com, jolsa@redhat.com, ak@linux.intel.com, vikas.shivappa@intel.com, kanaka.d.juvva@intel.com, adrian.hunter@intel.com, matt.fleming@intel.com, tglx@linutronix.de, vince@deater.net, hpa@zytor.com Reply-To: peterz@infradead.org, acme@redhat.com, mingo@kernel.org, fenghua.yu@intel.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, hpa@zytor.com, vince@deater.net, ak@linux.intel.com, jolsa@redhat.com, matt.fleming@intel.com, vikas.shivappa@intel.com, adrian.hunter@intel.com, kanaka.d.juvva@intel.com To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tests: Add arch tests Git-Commit-ID: 31b6753f95320260b160935d0e9c0b29f096ab57 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 31b6753f95320260b160935d0e9c0b29f096ab57 Gitweb: http://git.kernel.org/tip/31b6753f95320260b160935d0e9c0b29f096ab57 Author: Matt Fleming AuthorDate: Mon, 5 Oct 2015 15:40:19 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 5 Oct 2015 16:55:38 -0300 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 Cc: Adrian Hunter Cc: Andi Kleen Cc: Fenghua Yu Cc: Jiri Olsa Cc: Kanaka Juvva Cc: Peter Zijlstra Cc: Vikas Shivappa Cc: Vince Weaver Link: http://lkml.kernel.org/n/tip-p4uc1c15ssbj8xj7ku5slpa6@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/x86/Build | 2 +- tools/perf/arch/x86/include/arch-tests.h | 6 ++++++ tools/perf/arch/x86/tests/Build | 6 ++++-- tools/perf/arch/x86/tests/arch-tests.c | 10 ++++++++++ tools/perf/tests/builtin-test.c | 28 ++++++++++++++++++++-------- 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 41bf61d..db52fa2 100644 --- a/tools/perf/arch/x86/Build +++ b/tools/perf/arch/x86/Build @@ -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 index 0000000..4bd41d8 --- /dev/null +++ b/tools/perf/arch/x86/include/arch-tests.h @@ -0,0 +1,6 @@ +#ifndef ARCH_TESTS_H +#define ARCH_TESTS_H + +extern struct test arch_tests[]; + +#endif diff --git a/tools/perf/arch/x86/tests/Build b/tools/perf/arch/x86/tests/Build index b30eff9..d827ef3 100644 --- a/tools/perf/arch/x86/tests/Build +++ b/tools/perf/arch/x86/tests/Build @@ -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 index 0000000..fca9eb9 --- /dev/null +++ b/tools/perf/arch/x86/tests/arch-tests.c @@ -0,0 +1,10 @@ +#include +#include "tests/tests.h" +#include "arch-tests.h" + +struct test arch_tests[] = { + { + .func = NULL, + }, + +}; diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index d9bf51d..2b6c1bf 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -14,10 +14,13 @@ #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; diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 0b35496..b1cb1c0 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -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);