Commit df225205 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf test: Make each test/suite its own struct.

By switching to an array of pointers to tests (later to be suites)
the definition of the tests can be moved to the file containing the
tests.

Committer notes:

It's "&vectors_page", not "&vectors_pages", noticed when cross building
to 32-bit ARM.

Also the DEFINE_SUITE(vectors_page) should be done where its function is
implemented, in tools/perf/arch/arm/tests/vectors-page.c, so that we can
make it static, as we don't have anymore its declaration in tests.h.
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarSohaib Mohamed <sohaib.amhmd@gmail.com>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Brendan Higgins <brendanhiggins@google.com>
Cc: Daniel Latypov <dlatypov@google.com>
Cc: David Gow <davidgow@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20211104064208.3156807-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 54df5c8e
......@@ -2,6 +2,6 @@
#ifndef ARCH_TESTS_H
#define ARCH_TESTS_H
extern struct test arch_tests[];
extern struct test *arch_tests[];
#endif
......@@ -3,18 +3,10 @@
#include "tests/tests.h"
#include "arch-tests.h"
struct test arch_tests[] = {
struct test *arch_tests[] = {
#ifdef HAVE_DWARF_UNWIND_SUPPORT
{
.desc = "DWARF unwind",
.func = test__dwarf_unwind,
},
&dwarf_unwind,
#endif
{
.desc = "Vectors page",
.func = test__vectors_page,
},
{
.func = NULL,
},
&vectors_page,
NULL,
};
......@@ -9,8 +9,7 @@
#define VECTORS__MAP_NAME "[vectors]"
int test__vectors_page(struct test *test __maybe_unused,
int subtest __maybe_unused)
static int test__vectors_page(struct test *test __maybe_unused, int subtest __maybe_unused)
{
void *start, *end;
......@@ -22,3 +21,5 @@ int test__vectors_page(struct test *test __maybe_unused,
return TEST_OK;
}
DEFINE_SUITE("Vectors page", vectors_page);
......@@ -2,6 +2,6 @@
#ifndef ARCH_TESTS_H
#define ARCH_TESTS_H
extern struct test arch_tests[];
extern struct test *arch_tests[];
#endif
......@@ -3,14 +3,9 @@
#include "tests/tests.h"
#include "arch-tests.h"
struct test arch_tests[] = {
struct test *arch_tests[] = {
#ifdef HAVE_DWARF_UNWIND_SUPPORT
{
.desc = "DWARF unwind",
.func = test__dwarf_unwind,
},
&dwarf_unwind,
#endif
{
.func = NULL,
},
NULL,
};
......@@ -2,6 +2,6 @@
#ifndef ARCH_TESTS_H
#define ARCH_TESTS_H
extern struct test arch_tests[];
extern struct test *arch_tests[];
#endif
......@@ -3,14 +3,9 @@
#include "tests/tests.h"
#include "arch-tests.h"
struct test arch_tests[] = {
struct test *arch_tests[] = {
#ifdef HAVE_DWARF_UNWIND_SUPPORT
{
.desc = "Test dwarf unwind",
.func = test__dwarf_unwind,
},
&dwarf_unwind,
#endif
{
.func = NULL,
},
NULL,
};
......@@ -11,6 +11,6 @@ int test__intel_pt_pkt_decoder(struct test *test, int subtest);
int test__bp_modify(struct test *test, int subtest);
int test__x86_sample_parsing(struct test *test, int subtest);
extern struct test arch_tests[];
extern struct test *arch_tests[];
#endif
......@@ -3,39 +3,28 @@
#include "tests/tests.h"
#include "arch-tests.h"
struct test arch_tests[] = {
{
.desc = "x86 rdpmc",
.func = test__rdpmc,
},
DEFINE_SUITE("x86 rdpmc", rdpmc);
#ifdef HAVE_AUXTRACE_SUPPORT
DEFINE_SUITE("x86 instruction decoder - new instructions", insn_x86);
DEFINE_SUITE("Intel PT packet decoder", intel_pt_pkt_decoder);
#endif
#if defined(__x86_64__)
DEFINE_SUITE("x86 bp modify", bp_modify);
#endif
DEFINE_SUITE("x86 Sample parsing", x86_sample_parsing);
struct test *arch_tests[] = {
&rdpmc,
#ifdef HAVE_DWARF_UNWIND_SUPPORT
{
.desc = "DWARF unwind",
.func = test__dwarf_unwind,
},
&dwarf_unwind,
#endif
#ifdef HAVE_AUXTRACE_SUPPORT
{
.desc = "x86 instruction decoder - new instructions",
.func = test__insn_x86,
},
{
.desc = "Intel PT packet decoder",
.func = test__intel_pt_pkt_decoder,
},
&insn_x86,
&intel_pt_pkt_decoder,
#endif
#if defined(__x86_64__)
{
.desc = "x86 bp modify",
.func = test__bp_modify,
},
&bp_modify,
#endif
{
.desc = "x86 Sample parsing",
.func = test__x86_sample_parsing,
},
{
.func = NULL,
},
&x86_sample_parsing,
NULL,
};
This diff is collapsed.
......@@ -195,7 +195,7 @@ NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_1(struct thread *th
return ret;
}
int test__dwarf_unwind(struct test *test __maybe_unused, int subtest __maybe_unused)
static int test__dwarf_unwind(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct machine *machine;
struct thread *thread;
......@@ -237,3 +237,8 @@ int test__dwarf_unwind(struct test *test __maybe_unused, int subtest __maybe_unu
machine__delete(machine);
return err;
}
struct test dwarf_unwind = {
.desc = "Test dwarf unwind",
.func = test__dwarf_unwind,
};
......@@ -43,6 +43,12 @@ struct test {
#define DECLARE_SUITE(name) \
int test__##name(struct test *test, int subtest)
#define DEFINE_SUITE(description, name) \
static struct test name = { \
.desc = description, \
.func = test__##name, \
}
/* Tests */
DECLARE_SUITE(vmlinux_matches_kallsyms);
DECLARE_SUITE(openat_syscall_event);
......@@ -78,7 +84,7 @@ DECLARE_SUITE(code_reading);
DECLARE_SUITE(sample_parsing);
DECLARE_SUITE(keep_tracking);
DECLARE_SUITE(parse_no_sample_id_all);
DECLARE_SUITE(dwarf_unwind);
extern struct test dwarf_unwind;
DECLARE_SUITE(expr);
DECLARE_SUITE(hists_filter);
DECLARE_SUITE(mmap_thread_lookup);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment