2021-10-13 17:48:17

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 00/22] Start aligning perf test with kunit style

Perf test uses its own structs and code layout that differs from kunit
that was more recently introduced to the kernel. Besides consistency,
it is hoped that moving in the direction of kunit style will enable
reuse of infrastructure like test output formatting for continuous
testing systems. For example:
https://lore.kernel.org/linux-kselftest/CA+GJov6tdjvY9x12JsJT14qn6c7NViJxqaJk+r-K1YJzPggFDQ@mail.gmail.com/

The motivation for this restructuring comes from wanting to be able to
tag tests with a size:
https://lore.kernel.org/linux-perf-users/CAP-5=fWmGyuqFKc-EMP3rbmTkjZ3MS+YSajGZfeRMc38HS82gw@mail.gmail.com/
To have more exhaustive and slower running tests. This isn't
something kunit currently supports, nor is the execution of python and
shell tests, but it seems sensible to work on an approach with kunit
rather to invent a new wheel inside of perf.

These initial patches are just refactoring the main test suite
definitions to be in a more kunit style. Kunit isn't depended upon, it
is hoped that this can be done in later patches for the sake of
consistency.

v2. Gets to a point of the perf test test suite/case structs being
close facsimiles of the kunit ones. It also addresses feedback on
the v1 RFC, in particular from Jiri Olsa <[email protected]>.

v1. Built/tested on x86.

Ian Rogers (22):
perf test: Use macro for "suite" declarations
perf test: Use macro for "suite" definitions
perf test: Make each test/suite its own struct.
perf test: Move each test suite struct to its test
perf test: Rename struct test to test_suite
perf test: Add helper functions for abstraction.
perf test: Add test case struct.
perf test: Add skip reason to test case.
perf test: Convert pfm tests to use test cases.
perf test: Convert pmu event tests to test cases.
perf test: Convert watch point tests to test cases.
perf test: Convert clang tests to test cases.
perf test: Convert bpf tests to test cases.
perf test: Convert llvm tests to test cases.
perf test: Remove now unused subtest helpers
perf test: bp tests use test case
perf test: Convert time to tsc test to test case.
perf test: Remove non test case style support.
perf test: BP tests, remove is_supported use
perf test: TSC test, remove is_supported use
perf test: Remove is_supported function
perf test: Remove skip_if_fail

tools/perf/arch/arm/include/arch-tests.h | 2 +-
tools/perf/arch/arm/tests/arch-tests.c | 18 +-
tools/perf/arch/arm/tests/vectors-page.c | 2 +-
tools/perf/arch/arm64/include/arch-tests.h | 2 +-
tools/perf/arch/arm64/tests/arch-tests.c | 11 +-
tools/perf/arch/powerpc/include/arch-tests.h | 2 +-
tools/perf/arch/powerpc/tests/arch-tests.c | 12 +-
tools/perf/arch/x86/include/arch-tests.h | 14 +-
tools/perf/arch/x86/tests/arch-tests.c | 46 +-
tools/perf/arch/x86/tests/bp-modify.c | 2 +-
tools/perf/arch/x86/tests/insn-x86.c | 2 +-
tools/perf/arch/x86/tests/intel-cqm.c | 2 +-
.../x86/tests/intel-pt-pkt-decoder-test.c | 2 +-
tools/perf/arch/x86/tests/rdpmc.c | 2 +-
tools/perf/arch/x86/tests/sample-parsing.c | 2 +-
tools/perf/tests/api-io.c | 6 +-
tools/perf/tests/attr.c | 4 +-
tools/perf/tests/backward-ring-buffer.c | 4 +-
tools/perf/tests/bitmap.c | 4 +-
tools/perf/tests/bp_account.c | 36 +-
tools/perf/tests/bp_signal.c | 34 +-
tools/perf/tests/bp_signal_overflow.c | 9 +-
tools/perf/tests/bpf.c | 69 ++-
tools/perf/tests/builtin-test.c | 578 ++++++------------
tools/perf/tests/clang.c | 54 +-
tools/perf/tests/code-reading.c | 4 +-
tools/perf/tests/cpumap.c | 10 +-
tools/perf/tests/demangle-java-test.c | 4 +-
tools/perf/tests/demangle-ocaml-test.c | 4 +-
tools/perf/tests/dlfilter-test.c | 4 +-
tools/perf/tests/dso-data.c | 10 +-
tools/perf/tests/dwarf-unwind.c | 5 +-
tools/perf/tests/event-times.c | 4 +-
tools/perf/tests/event_update.c | 4 +-
tools/perf/tests/evsel-roundtrip-name.c | 5 +-
tools/perf/tests/evsel-tp-sched.c | 5 +-
tools/perf/tests/expand-cgroup.c | 6 +-
tools/perf/tests/expr.c | 4 +-
tools/perf/tests/fdarray.c | 7 +-
tools/perf/tests/genelf.c | 6 +-
tools/perf/tests/hists_cumulate.c | 4 +-
tools/perf/tests/hists_filter.c | 4 +-
tools/perf/tests/hists_link.c | 4 +-
tools/perf/tests/hists_output.c | 4 +-
tools/perf/tests/is_printable_array.c | 4 +-
tools/perf/tests/keep-tracking.c | 4 +-
tools/perf/tests/kmod-path.c | 4 +-
tools/perf/tests/llvm.c | 74 ++-
tools/perf/tests/maps.c | 4 +-
tools/perf/tests/mem.c | 4 +-
tools/perf/tests/mem2node.c | 4 +-
tools/perf/tests/mmap-basic.c | 4 +-
tools/perf/tests/mmap-thread-lookup.c | 4 +-
tools/perf/tests/openat-syscall-all-cpus.c | 5 +-
tools/perf/tests/openat-syscall-tp-fields.c | 5 +-
tools/perf/tests/openat-syscall.c | 5 +-
tools/perf/tests/parse-events.c | 4 +-
tools/perf/tests/parse-metric.c | 4 +-
tools/perf/tests/parse-no-sample-id-all.c | 5 +-
tools/perf/tests/pe-file-parsing.c | 6 +-
tools/perf/tests/perf-hooks.c | 4 +-
tools/perf/tests/perf-record.c | 4 +-
tools/perf/tests/perf-time-to-tsc.c | 30 +-
tools/perf/tests/pfm.c | 63 +-
tools/perf/tests/pmu-events.c | 73 +--
tools/perf/tests/pmu.c | 4 +-
tools/perf/tests/python-use.c | 4 +-
tools/perf/tests/sample-parsing.c | 4 +-
tools/perf/tests/sdt.c | 6 +-
tools/perf/tests/stat.c | 11 +-
tools/perf/tests/sw-clock.c | 4 +-
tools/perf/tests/switch-tracking.c | 4 +-
tools/perf/tests/task-exit.c | 4 +-
tools/perf/tests/tests.h | 238 ++++----
tools/perf/tests/thread-map.c | 10 +-
tools/perf/tests/thread-maps-share.c | 4 +-
tools/perf/tests/time-utils-test.c | 4 +-
tools/perf/tests/topology.c | 4 +-
tools/perf/tests/unit_number__scnprintf.c | 4 +-
tools/perf/tests/vmlinux-kallsyms.c | 5 +-
tools/perf/tests/wp.c | 122 +---
tools/perf/util/c++/clang-c.h | 8 +-
tools/perf/util/c++/clang-test.cpp | 6 +-
83 files changed, 811 insertions(+), 966 deletions(-)

--
2.33.0.882.g93a45727a2-goog


2021-10-13 17:48:35

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 02/22] perf test: Use macro for "suite" definitions

Add a macro to simplify later refactoring. No functional change.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/builtin-test.c | 479 ++++++++++----------------------
1 file changed, 149 insertions(+), 330 deletions(-)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index da7dc5e45d0c..820fc1ae2210 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -36,337 +36,156 @@ struct test __weak arch_tests[] = {
},
};

-static struct test generic_tests[] = {
- {
- .desc = "vmlinux symtab matches kallsyms",
- .func = test__vmlinux_matches_kallsyms,
- },
- {
- .desc = "Detect openat syscall event",
- .func = test__openat_syscall_event,
- },
- {
- .desc = "Detect openat syscall event on all cpus",
- .func = test__openat_syscall_event_on_all_cpus,
- },
- {
- .desc = "Read samples using the mmap interface",
- .func = test__basic_mmap,
- },
- {
- .desc = "Test data source output",
- .func = test__mem,
- },
- {
- .desc = "Parse event definition strings",
- .func = test__parse_events,
- },
- {
- .desc = "Simple expression parser",
- .func = test__expr,
- },
- {
- .desc = "PERF_RECORD_* events & perf_sample fields",
- .func = test__PERF_RECORD,
- },
- {
- .desc = "Parse perf pmu format",
- .func = test__pmu,
- },
- {
- .desc = "PMU events",
- .func = test__pmu_events,
- .subtest = {
- .skip_if_fail = false,
- .get_nr = test__pmu_events_subtest_get_nr,
- .get_desc = test__pmu_events_subtest_get_desc,
- .skip_reason = test__pmu_events_subtest_skip_reason,
- },
-
- },
- {
- .desc = "DSO data read",
- .func = test__dso_data,
- },
- {
- .desc = "DSO data cache",
- .func = test__dso_data_cache,
- },
- {
- .desc = "DSO data reopen",
- .func = test__dso_data_reopen,
- },
- {
- .desc = "Roundtrip evsel->name",
- .func = test__perf_evsel__roundtrip_name_test,
- },
- {
- .desc = "Parse sched tracepoints fields",
- .func = test__perf_evsel__tp_sched_test,
- },
- {
- .desc = "syscalls:sys_enter_openat event fields",
- .func = test__syscall_openat_tp_fields,
- },
- {
- .desc = "Setup struct perf_event_attr",
- .func = test__attr,
- },
- {
- .desc = "Match and link multiple hists",
- .func = test__hists_link,
- },
- {
- .desc = "'import perf' in python",
- .func = test__python_use,
- },
- {
- .desc = "Breakpoint overflow signal handler",
- .func = test__bp_signal,
- .is_supported = test__bp_signal_is_supported,
- },
- {
- .desc = "Breakpoint overflow sampling",
- .func = test__bp_signal_overflow,
- .is_supported = test__bp_signal_is_supported,
- },
- {
- .desc = "Breakpoint accounting",
- .func = test__bp_accounting,
- .is_supported = test__bp_account_is_supported,
- },
- {
- .desc = "Watchpoint",
- .func = test__wp,
- .is_supported = test__wp_is_supported,
- .subtest = {
- .skip_if_fail = false,
- .get_nr = test__wp_subtest_get_nr,
- .get_desc = test__wp_subtest_get_desc,
- .skip_reason = test__wp_subtest_skip_reason,
- },
- },
- {
- .desc = "Number of exit events of a simple workload",
- .func = test__task_exit,
- },
- {
- .desc = "Software clock events period values",
- .func = test__sw_clock_freq,
- },
- {
- .desc = "Object code reading",
- .func = test__code_reading,
- },
- {
- .desc = "Sample parsing",
- .func = test__sample_parsing,
- },
- {
- .desc = "Use a dummy software event to keep tracking",
- .func = test__keep_tracking,
- },
- {
- .desc = "Parse with no sample_id_all bit set",
- .func = test__parse_no_sample_id_all,
- },
- {
- .desc = "Filter hist entries",
- .func = test__hists_filter,
- },
- {
- .desc = "Lookup mmap thread",
- .func = test__mmap_thread_lookup,
- },
- {
- .desc = "Share thread maps",
- .func = test__thread_maps_share,
- },
- {
- .desc = "Sort output of hist entries",
- .func = test__hists_output,
- },
- {
- .desc = "Cumulate child hist entries",
- .func = test__hists_cumulate,
- },
- {
- .desc = "Track with sched_switch",
- .func = test__switch_tracking,
- },
- {
- .desc = "Filter fds with revents mask in a fdarray",
- .func = test__fdarray__filter,
- },
- {
- .desc = "Add fd to a fdarray, making it autogrow",
- .func = test__fdarray__add,
- },
- {
- .desc = "kmod_path__parse",
- .func = test__kmod_path__parse,
- },
- {
- .desc = "Thread map",
- .func = test__thread_map,
- },
- {
- .desc = "LLVM search and compile",
- .func = test__llvm,
- .subtest = {
- .skip_if_fail = true,
- .get_nr = test__llvm_subtest_get_nr,
- .get_desc = test__llvm_subtest_get_desc,
- },
- },
- {
- .desc = "Session topology",
- .func = test__session_topology,
- },
- {
- .desc = "BPF filter",
- .func = test__bpf,
- .subtest = {
- .skip_if_fail = true,
- .get_nr = test__bpf_subtest_get_nr,
- .get_desc = test__bpf_subtest_get_desc,
- },
- },
- {
- .desc = "Synthesize thread map",
- .func = test__thread_map_synthesize,
- },
- {
- .desc = "Remove thread map",
- .func = test__thread_map_remove,
- },
- {
- .desc = "Synthesize cpu map",
- .func = test__cpu_map_synthesize,
- },
- {
- .desc = "Synthesize stat config",
- .func = test__synthesize_stat_config,
- },
- {
- .desc = "Synthesize stat",
- .func = test__synthesize_stat,
- },
- {
- .desc = "Synthesize stat round",
- .func = test__synthesize_stat_round,
- },
- {
- .desc = "Synthesize attr update",
- .func = test__event_update,
- },
- {
- .desc = "Event times",
- .func = test__event_times,
- },
- {
- .desc = "Read backward ring buffer",
- .func = test__backward_ring_buffer,
- },
- {
- .desc = "Print cpu map",
- .func = test__cpu_map_print,
- },
- {
- .desc = "Merge cpu map",
- .func = test__cpu_map_merge,
- },
+#define DEFINE_SUITE(description, name) \
+ { \
+ .desc = description, \
+ .func = test__##name, \
+ }

- {
- .desc = "Probe SDT events",
- .func = test__sdt_event,
- },
- {
- .desc = "is_printable_array",
- .func = test__is_printable_array,
- },
- {
- .desc = "Print bitmap",
- .func = test__bitmap_print,
- },
- {
- .desc = "perf hooks",
- .func = test__perf_hooks,
- },
- {
- .desc = "builtin clang support",
- .func = test__clang,
- .subtest = {
- .skip_if_fail = true,
- .get_nr = test__clang_subtest_get_nr,
- .get_desc = test__clang_subtest_get_desc,
- }
- },
- {
- .desc = "unit_number__scnprintf",
- .func = test__unit_number__scnprint,
- },
- {
- .desc = "mem2node",
- .func = test__mem2node,
- },
- {
- .desc = "time utils",
- .func = test__time_utils,
- },
- {
- .desc = "Test jit_write_elf",
- .func = test__jit_write_elf,
- },
- {
- .desc = "Test libpfm4 support",
- .func = test__pfm,
- .subtest = {
- .skip_if_fail = true,
- .get_nr = test__pfm_subtest_get_nr,
- .get_desc = test__pfm_subtest_get_desc,
- }
- },
- {
- .desc = "Test api io",
- .func = test__api_io,
- },
- {
- .desc = "maps__merge_in",
- .func = test__maps__merge_in,
- },
- {
- .desc = "Demangle Java",
- .func = test__demangle_java,
- },
- {
- .desc = "Demangle OCaml",
- .func = test__demangle_ocaml,
- },
- {
- .desc = "Parse and process metrics",
- .func = test__parse_metric,
- },
- {
- .desc = "PE file support",
- .func = test__pe_file_parsing,
- },
- {
- .desc = "Event expansion for cgroups",
- .func = test__expand_cgroup_events,
- },
- {
- .desc = "Convert perf time to TSC",
- .func = test__perf_time_to_tsc,
- .is_supported = test__tsc_is_supported,
- },
- {
- .desc = "dlfilter C API",
- .func = test__dlfilter,
- },
- {
- .func = NULL,
- },
+static struct test generic_tests[] = {
+DEFINE_SUITE("vmlinux symtab matches kallsyms", vmlinux_matches_kallsyms),
+DEFINE_SUITE("Detect openat syscall event", openat_syscall_event),
+DEFINE_SUITE("Detect openat syscall event on all cpus", openat_syscall_event_on_all_cpus),
+DEFINE_SUITE("Read samples using the mmap interface", basic_mmap),
+DEFINE_SUITE("Test data source output", mem),
+DEFINE_SUITE("Parse event definition strings", parse_events),
+DEFINE_SUITE("Simple expression parser", expr),
+DEFINE_SUITE("PERF_RECORD_* events & perf_sample fields", PERF_RECORD),
+DEFINE_SUITE("Parse perf pmu format", pmu),
+{
+ .desc = "PMU events",
+ .func = test__pmu_events,
+ .subtest = {
+ .skip_if_fail = false,
+ .get_nr = test__pmu_events_subtest_get_nr,
+ .get_desc = test__pmu_events_subtest_get_desc,
+ .skip_reason = test__pmu_events_subtest_skip_reason,
+ },
+
+},
+DEFINE_SUITE("DSO data read", dso_data),
+DEFINE_SUITE("DSO data cache", dso_data_cache),
+DEFINE_SUITE("DSO data reopen", dso_data_reopen),
+DEFINE_SUITE("Roundtrip evsel->name", perf_evsel__roundtrip_name_test),
+DEFINE_SUITE("Parse sched tracepoints fields", perf_evsel__tp_sched_test),
+DEFINE_SUITE("syscalls:sys_enter_openat event fields", syscall_openat_tp_fields),
+DEFINE_SUITE("Setup struct perf_event_attr", attr),
+DEFINE_SUITE("Match and link multiple hists", hists_link),
+DEFINE_SUITE("'import perf' in python", python_use),
+{
+ .desc = "Breakpoint overflow signal handler",
+ .func = test__bp_signal,
+ .is_supported = test__bp_signal_is_supported,
+},
+{
+ .desc = "Breakpoint overflow sampling",
+ .func = test__bp_signal_overflow,
+ .is_supported = test__bp_signal_is_supported,
+},
+{
+ .desc = "Breakpoint accounting",
+ .func = test__bp_accounting,
+ .is_supported = test__bp_account_is_supported,
+},
+{
+ .desc = "Watchpoint",
+ .func = test__wp,
+ .is_supported = test__wp_is_supported,
+ .subtest = {
+ .skip_if_fail = false,
+ .get_nr = test__wp_subtest_get_nr,
+ .get_desc = test__wp_subtest_get_desc,
+ .skip_reason = test__wp_subtest_skip_reason,
+ },
+},
+DEFINE_SUITE("Number of exit events of a simple workload", task_exit),
+DEFINE_SUITE("Software clock events period values", sw_clock_freq),
+DEFINE_SUITE("Object code reading", code_reading),
+DEFINE_SUITE("Sample parsing", sample_parsing),
+DEFINE_SUITE("Use a dummy software event to keep tracking", keep_tracking),
+DEFINE_SUITE("Parse with no sample_id_all bit set", parse_no_sample_id_all),
+DEFINE_SUITE("Filter hist entries", hists_filter),
+DEFINE_SUITE("Lookup mmap thread", mmap_thread_lookup),
+DEFINE_SUITE("Share thread maps", thread_maps_share),
+DEFINE_SUITE("Sort output of hist entries", hists_output),
+DEFINE_SUITE("Cumulate child hist entries", hists_cumulate),
+DEFINE_SUITE("Track with sched_switch", switch_tracking),
+DEFINE_SUITE("Filter fds with revents mask in a fdarray", fdarray__filter),
+DEFINE_SUITE("Add fd to a fdarray, making it autogrow", fdarray__add),
+DEFINE_SUITE("kmod_path__parse", kmod_path__parse),
+DEFINE_SUITE("Thread map", thread_map),
+{
+ .desc = "LLVM search and compile",
+ .func = test__llvm,
+ .subtest = {
+ .skip_if_fail = true,
+ .get_nr = test__llvm_subtest_get_nr,
+ .get_desc = test__llvm_subtest_get_desc,
+ },
+},
+DEFINE_SUITE("Session topology", session_topology),
+{
+ .desc = "BPF filter",
+ .func = test__bpf,
+ .subtest = {
+ .skip_if_fail = true,
+ .get_nr = test__bpf_subtest_get_nr,
+ .get_desc = test__bpf_subtest_get_desc,
+ },
+},
+DEFINE_SUITE("Synthesize thread map", thread_map_synthesize),
+DEFINE_SUITE("Remove thread map", thread_map_remove),
+DEFINE_SUITE("Synthesize cpu map", cpu_map_synthesize),
+DEFINE_SUITE("Synthesize stat config", synthesize_stat_config),
+DEFINE_SUITE("Synthesize stat", synthesize_stat),
+DEFINE_SUITE("Synthesize stat round", synthesize_stat_round),
+DEFINE_SUITE("Synthesize attr update", event_update),
+DEFINE_SUITE("Event times", event_times),
+DEFINE_SUITE("Read backward ring buffer", backward_ring_buffer),
+DEFINE_SUITE("Print cpu map", cpu_map_print),
+DEFINE_SUITE("Merge cpu map", cpu_map_merge),
+DEFINE_SUITE("Probe SDT events", sdt_event),
+DEFINE_SUITE("is_printable_array", is_printable_array),
+DEFINE_SUITE("Print bitmap", bitmap_print),
+DEFINE_SUITE("perf hooks", perf_hooks),
+{
+ .desc = "builtin clang support",
+ .func = test__clang,
+ .subtest = {
+ .skip_if_fail = true,
+ .get_nr = test__clang_subtest_get_nr,
+ .get_desc = test__clang_subtest_get_desc,
+ }
+},
+DEFINE_SUITE("unit_number__scnprintf", unit_number__scnprint),
+DEFINE_SUITE("mem2node", mem2node),
+DEFINE_SUITE("time utils", time_utils),
+DEFINE_SUITE("Test jit_write_elf", jit_write_elf),
+{
+ .desc = "Test libpfm4 support",
+ .func = test__pfm,
+ .subtest = {
+ .skip_if_fail = true,
+ .get_nr = test__pfm_subtest_get_nr,
+ .get_desc = test__pfm_subtest_get_desc,
+ }
+},
+DEFINE_SUITE("Test api io", api_io),
+DEFINE_SUITE("maps__merge_in", maps__merge_in),
+DEFINE_SUITE("Demangle Java", demangle_java),
+DEFINE_SUITE("Demangle OCaml", demangle_ocaml),
+DEFINE_SUITE("Parse and process metrics", parse_metric),
+DEFINE_SUITE("PE file support", pe_file_parsing),
+DEFINE_SUITE("Event expansion for cgroups", expand_cgroup_events),
+{
+ .desc = "Convert perf time to TSC",
+ .func = test__perf_time_to_tsc,
+ .is_supported = test__tsc_is_supported,
+},
+DEFINE_SUITE("dlfilter C API", dlfilter),
+{
+ .func = NULL,
+},
};

static struct test *tests[] = {
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:48:39

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 01/22] perf test: Use macro for "suite" declarations

Currently tests are setup in builtin-test with function pointers. Kunit
exposes tests as a kunit_suite with a null terminated array of test
cases. Use a macro to aid transition from one to the other in later
changes.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/tests.h | 151 ++++++++++++++++++++-------------------
1 file changed, 77 insertions(+), 74 deletions(-)

diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index fe1306f58495..0846f66d67f9 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -40,94 +40,97 @@ struct test {
void *priv;
};

+#define DECLARE_SUITE(name) \
+ int test__##name(struct test *test, int subtest)
+
/* Tests */
-int test__vmlinux_matches_kallsyms(struct test *test, int subtest);
-int test__openat_syscall_event(struct test *test, int subtest);
-int test__openat_syscall_event_on_all_cpus(struct test *test, int subtest);
-int test__basic_mmap(struct test *test, int subtest);
-int test__PERF_RECORD(struct test *test, int subtest);
-int test__perf_evsel__roundtrip_name_test(struct test *test, int subtest);
-int test__perf_evsel__tp_sched_test(struct test *test, int subtest);
-int test__syscall_openat_tp_fields(struct test *test, int subtest);
-int test__pmu(struct test *test, int subtest);
-int test__pmu_events(struct test *test, int subtest);
+DECLARE_SUITE(vmlinux_matches_kallsyms);
+DECLARE_SUITE(openat_syscall_event);
+DECLARE_SUITE(openat_syscall_event_on_all_cpus);
+DECLARE_SUITE(basic_mmap);
+DECLARE_SUITE(PERF_RECORD);
+DECLARE_SUITE(perf_evsel__roundtrip_name_test);
+DECLARE_SUITE(perf_evsel__tp_sched_test);
+DECLARE_SUITE(syscall_openat_tp_fields);
+DECLARE_SUITE(pmu);
+DECLARE_SUITE(pmu_events);
const char *test__pmu_events_subtest_get_desc(int subtest);
const char *test__pmu_events_subtest_skip_reason(int subtest);
int test__pmu_events_subtest_get_nr(void);
-int test__attr(struct test *test, int subtest);
-int test__dso_data(struct test *test, int subtest);
-int test__dso_data_cache(struct test *test, int subtest);
-int test__dso_data_reopen(struct test *test, int subtest);
-int test__parse_events(struct test *test, int subtest);
-int test__hists_link(struct test *test, int subtest);
-int test__python_use(struct test *test, int subtest);
-int test__bp_signal(struct test *test, int subtest);
-int test__bp_signal_overflow(struct test *test, int subtest);
-int test__bp_accounting(struct test *test, int subtest);
-int test__wp(struct test *test, int subtest);
+DECLARE_SUITE(attr);
+DECLARE_SUITE(dso_data);
+DECLARE_SUITE(dso_data_cache);
+DECLARE_SUITE(dso_data_reopen);
+DECLARE_SUITE(parse_events);
+DECLARE_SUITE(hists_link);
+DECLARE_SUITE(python_use);
+DECLARE_SUITE(bp_signal);
+DECLARE_SUITE(bp_signal_overflow);
+DECLARE_SUITE(bp_accounting);
+DECLARE_SUITE(wp);
const char *test__wp_subtest_get_desc(int subtest);
const char *test__wp_subtest_skip_reason(int subtest);
int test__wp_subtest_get_nr(void);
-int test__task_exit(struct test *test, int subtest);
-int test__mem(struct test *test, int subtest);
-int test__sw_clock_freq(struct test *test, int subtest);
-int test__code_reading(struct test *test, int subtest);
-int test__sample_parsing(struct test *test, int subtest);
-int test__keep_tracking(struct test *test, int subtest);
-int test__parse_no_sample_id_all(struct test *test, int subtest);
-int test__dwarf_unwind(struct test *test, int subtest);
-int test__expr(struct test *test, int subtest);
-int test__hists_filter(struct test *test, int subtest);
-int test__mmap_thread_lookup(struct test *test, int subtest);
-int test__thread_maps_share(struct test *test, int subtest);
-int test__hists_output(struct test *test, int subtest);
-int test__hists_cumulate(struct test *test, int subtest);
-int test__switch_tracking(struct test *test, int subtest);
-int test__fdarray__filter(struct test *test, int subtest);
-int test__fdarray__add(struct test *test, int subtest);
-int test__kmod_path__parse(struct test *test, int subtest);
-int test__thread_map(struct test *test, int subtest);
-int test__llvm(struct test *test, int subtest);
+DECLARE_SUITE(task_exit);
+DECLARE_SUITE(mem);
+DECLARE_SUITE(sw_clock_freq);
+DECLARE_SUITE(code_reading);
+DECLARE_SUITE(sample_parsing);
+DECLARE_SUITE(keep_tracking);
+DECLARE_SUITE(parse_no_sample_id_all);
+DECLARE_SUITE(dwarf_unwind);
+DECLARE_SUITE(expr);
+DECLARE_SUITE(hists_filter);
+DECLARE_SUITE(mmap_thread_lookup);
+DECLARE_SUITE(thread_maps_share);
+DECLARE_SUITE(hists_output);
+DECLARE_SUITE(hists_cumulate);
+DECLARE_SUITE(switch_tracking);
+DECLARE_SUITE(fdarray__filter);
+DECLARE_SUITE(fdarray__add);
+DECLARE_SUITE(kmod_path__parse);
+DECLARE_SUITE(thread_map);
+DECLARE_SUITE(llvm);
const char *test__llvm_subtest_get_desc(int subtest);
int test__llvm_subtest_get_nr(void);
-int test__bpf(struct test *test, int subtest);
+DECLARE_SUITE(bpf);
const char *test__bpf_subtest_get_desc(int subtest);
int test__bpf_subtest_get_nr(void);
-int test__session_topology(struct test *test, int subtest);
-int test__thread_map_synthesize(struct test *test, int subtest);
-int test__thread_map_remove(struct test *test, int subtest);
-int test__cpu_map_synthesize(struct test *test, int subtest);
-int test__synthesize_stat_config(struct test *test, int subtest);
-int test__synthesize_stat(struct test *test, int subtest);
-int test__synthesize_stat_round(struct test *test, int subtest);
-int test__event_update(struct test *test, int subtest);
-int test__event_times(struct test *test, int subtest);
-int test__backward_ring_buffer(struct test *test, int subtest);
-int test__cpu_map_print(struct test *test, int subtest);
-int test__cpu_map_merge(struct test *test, int subtest);
-int test__sdt_event(struct test *test, int subtest);
-int test__is_printable_array(struct test *test, int subtest);
-int test__bitmap_print(struct test *test, int subtest);
-int test__perf_hooks(struct test *test, int subtest);
-int test__clang(struct test *test, int subtest);
+DECLARE_SUITE(session_topology);
+DECLARE_SUITE(thread_map_synthesize);
+DECLARE_SUITE(thread_map_remove);
+DECLARE_SUITE(cpu_map_synthesize);
+DECLARE_SUITE(synthesize_stat_config);
+DECLARE_SUITE(synthesize_stat);
+DECLARE_SUITE(synthesize_stat_round);
+DECLARE_SUITE(event_update);
+DECLARE_SUITE(event_times);
+DECLARE_SUITE(backward_ring_buffer);
+DECLARE_SUITE(cpu_map_print);
+DECLARE_SUITE(cpu_map_merge);
+DECLARE_SUITE(sdt_event);
+DECLARE_SUITE(is_printable_array);
+DECLARE_SUITE(bitmap_print);
+DECLARE_SUITE(perf_hooks);
+DECLARE_SUITE(clang);
const char *test__clang_subtest_get_desc(int subtest);
int test__clang_subtest_get_nr(void);
-int test__unit_number__scnprint(struct test *test, int subtest);
-int test__mem2node(struct test *t, int subtest);
-int test__maps__merge_in(struct test *t, int subtest);
-int test__time_utils(struct test *t, int subtest);
-int test__jit_write_elf(struct test *test, int subtest);
-int test__api_io(struct test *test, int subtest);
-int test__demangle_java(struct test *test, int subtest);
-int test__demangle_ocaml(struct test *test, int subtest);
-int test__pfm(struct test *test, int subtest);
+DECLARE_SUITE(unit_number__scnprint);
+DECLARE_SUITE(mem2node);
+DECLARE_SUITE(maps__merge_in);
+DECLARE_SUITE(time_utils);
+DECLARE_SUITE(jit_write_elf);
+DECLARE_SUITE(api_io);
+DECLARE_SUITE(demangle_java);
+DECLARE_SUITE(demangle_ocaml);
+DECLARE_SUITE(pfm);
const char *test__pfm_subtest_get_desc(int subtest);
int test__pfm_subtest_get_nr(void);
-int test__parse_metric(struct test *test, int subtest);
-int test__pe_file_parsing(struct test *test, int subtest);
-int test__expand_cgroup_events(struct test *test, int subtest);
-int test__perf_time_to_tsc(struct test *test, int subtest);
-int test__dlfilter(struct test *test, int subtest);
+DECLARE_SUITE(parse_metric);
+DECLARE_SUITE(pe_file_parsing);
+DECLARE_SUITE(expand_cgroup_events);
+DECLARE_SUITE(perf_time_to_tsc);
+DECLARE_SUITE(dlfilter);

bool test__bp_signal_is_supported(void);
bool test__bp_account_is_supported(void);
@@ -142,7 +145,7 @@ int test__arch_unwind_sample(struct perf_sample *sample,
#endif

#if defined(__arm__)
-int test__vectors_page(struct test *test, int subtest);
+DECLARE_SUITE(vectors_page);
#endif

#endif /* TESTS_H */
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:48:44

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 09/22] perf test: Convert pfm tests to use test cases.

Use null terminated array of test cases rather than the previous sub
test functions.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/pfm.c | 66 ++++++++++++------------------------------
1 file changed, 19 insertions(+), 47 deletions(-)

diff --git a/tools/perf/tests/pfm.c b/tools/perf/tests/pfm.c
index f55e4ecdda71..651fee4ef819 100644
--- a/tools/perf/tests/pfm.c
+++ b/tools/perf/tests/pfm.c
@@ -11,27 +11,6 @@

#include <linux/kernel.h>

-#ifdef HAVE_LIBPFM
-static int test__pfm_events(void);
-static int test__pfm_group(void);
-#endif
-
-static const struct {
- int (*func)(void);
- const char *desc;
-} pfm_testcase_table[] = {
-#ifdef HAVE_LIBPFM
- {
- .func = test__pfm_events,
- .desc = "test of individual --pfm-events",
- },
- {
- .func = test__pfm_group,
- .desc = "test groups of --pfm-events",
- },
-#endif
-};
-
#ifdef HAVE_LIBPFM
static int count_pfm_events(struct perf_evlist *evlist)
{
@@ -44,7 +23,8 @@ static int count_pfm_events(struct perf_evlist *evlist)
return count;
}

-static int test__pfm_events(void)
+static int test__pfm_events(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
struct evlist *evlist;
struct option opt;
@@ -104,7 +84,8 @@ static int test__pfm_events(void)
return 0;
}

-static int test__pfm_group(void)
+static int test__pfm_group(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
struct evlist *evlist;
struct option opt;
@@ -187,37 +168,28 @@ static int test__pfm_group(void)
}
return 0;
}
-#endif
-
-static const char *test__pfm_subtest_get_desc(int i)
-{
- if (i < 0 || i >= (int)ARRAY_SIZE(pfm_testcase_table))
- return NULL;
- return pfm_testcase_table[i].desc;
-}
-
-static int test__pfm_subtest_get_nr(void)
+#else
+static int test__pfm_events(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
- return (int)ARRAY_SIZE(pfm_testcase_table);
+ return TEST_SKIP;
}

-static int test__pfm(struct test_suite *test __maybe_unused, int i __maybe_unused)
+static int test__pfm_group(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
-#ifdef HAVE_LIBPFM
- if (i < 0 || i >= (int)ARRAY_SIZE(pfm_testcase_table))
- return TEST_FAIL;
- return pfm_testcase_table[i].func();
-#else
return TEST_SKIP;
-#endif
}
+#endif
+
+static struct test_case pfm_tests[] = {
+ TEST_CASE_REASON("test of individual --pfm-events", pfm_events, "not compiled in"),
+ TEST_CASE_REASON("test groups of --pfm-events", pfm_group, "not compiled in"),
+ { .name = NULL, }
+};

struct test_suite suite__pfm = {
.desc = "Test libpfm4 support",
- .func = test__pfm,
- .subtest = {
- .skip_if_fail = true,
- .get_nr = test__pfm_subtest_get_nr,
- .get_desc = test__pfm_subtest_get_desc,
- }
+ .test_cases = pfm_tests,
+ .subtest = { .skip_if_fail = true }
};
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:48:45

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 03/22] 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.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/arch/arm/include/arch-tests.h | 2 +-
tools/perf/arch/arm/tests/arch-tests.c | 18 +-
tools/perf/arch/arm64/include/arch-tests.h | 2 +-
tools/perf/arch/arm64/tests/arch-tests.c | 11 +-
tools/perf/arch/powerpc/include/arch-tests.h | 2 +-
tools/perf/arch/powerpc/tests/arch-tests.c | 11 +-
tools/perf/arch/x86/include/arch-tests.h | 2 +-
tools/perf/arch/x86/tests/arch-tests.c | 46 ++--
tools/perf/tests/builtin-test.c | 273 ++++++++++++-------
tools/perf/tests/dwarf-unwind.c | 7 +-
tools/perf/tests/tests.h | 8 +-
11 files changed, 214 insertions(+), 168 deletions(-)

diff --git a/tools/perf/arch/arm/include/arch-tests.h b/tools/perf/arch/arm/include/arch-tests.h
index c62538052404..37039e80f18b 100644
--- a/tools/perf/arch/arm/include/arch-tests.h
+++ b/tools/perf/arch/arm/include/arch-tests.h
@@ -2,6 +2,6 @@
#ifndef ARCH_TESTS_H
#define ARCH_TESTS_H

-extern struct test arch_tests[];
+extern struct test *arch_tests[];

#endif
diff --git a/tools/perf/arch/arm/tests/arch-tests.c b/tools/perf/arch/arm/tests/arch-tests.c
index 6848101a855f..5287729026ab 100644
--- a/tools/perf/arch/arm/tests/arch-tests.c
+++ b/tools/perf/arch/arm/tests/arch-tests.c
@@ -3,18 +3,12 @@
#include "tests/tests.h"
#include "arch-tests.h"

-struct test arch_tests[] = {
+DEFINE_SUITE("Vectors page", vectors_page);
+
+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_pages,
+ NULL,
};
diff --git a/tools/perf/arch/arm64/include/arch-tests.h b/tools/perf/arch/arm64/include/arch-tests.h
index c62538052404..37039e80f18b 100644
--- a/tools/perf/arch/arm64/include/arch-tests.h
+++ b/tools/perf/arch/arm64/include/arch-tests.h
@@ -2,6 +2,6 @@
#ifndef ARCH_TESTS_H
#define ARCH_TESTS_H

-extern struct test arch_tests[];
+extern struct test *arch_tests[];

#endif
diff --git a/tools/perf/arch/arm64/tests/arch-tests.c b/tools/perf/arch/arm64/tests/arch-tests.c
index 5b1543c98022..bc327048b807 100644
--- a/tools/perf/arch/arm64/tests/arch-tests.c
+++ b/tools/perf/arch/arm64/tests/arch-tests.c
@@ -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,
};
diff --git a/tools/perf/arch/powerpc/include/arch-tests.h b/tools/perf/arch/powerpc/include/arch-tests.h
index c62538052404..37039e80f18b 100644
--- a/tools/perf/arch/powerpc/include/arch-tests.h
+++ b/tools/perf/arch/powerpc/include/arch-tests.h
@@ -2,6 +2,6 @@
#ifndef ARCH_TESTS_H
#define ARCH_TESTS_H

-extern struct test arch_tests[];
+extern struct test *arch_tests[];

#endif
diff --git a/tools/perf/arch/powerpc/tests/arch-tests.c b/tools/perf/arch/powerpc/tests/arch-tests.c
index 8c3fbd4af817..bc327048b807 100644
--- a/tools/perf/arch/powerpc/tests/arch-tests.c
+++ b/tools/perf/arch/powerpc/tests/arch-tests.c
@@ -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,
};
diff --git a/tools/perf/arch/x86/include/arch-tests.h b/tools/perf/arch/x86/include/arch-tests.h
index 9599e7a3f1af..d6db9f72b6af 100644
--- a/tools/perf/arch/x86/include/arch-tests.h
+++ b/tools/perf/arch/x86/include/arch-tests.h
@@ -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
diff --git a/tools/perf/arch/x86/tests/arch-tests.c b/tools/perf/arch/x86/tests/arch-tests.c
index 71aa67367ad6..48ddc754bf74 100644
--- a/tools/perf/arch/x86/tests/arch-tests.c
+++ b/tools/perf/arch/x86/tests/arch-tests.c
@@ -3,39 +3,27 @@
#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,
};
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 820fc1ae2210..b2cbc12a70a2 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -30,29 +30,20 @@

static bool dont_fork;

-struct test __weak arch_tests[] = {
- {
- .func = NULL,
- },
+struct test *__weak arch_tests[] = {
+ NULL,
};

-#define DEFINE_SUITE(description, name) \
- { \
- .desc = description, \
- .func = test__##name, \
- }
-
-static struct test generic_tests[] = {
-DEFINE_SUITE("vmlinux symtab matches kallsyms", vmlinux_matches_kallsyms),
-DEFINE_SUITE("Detect openat syscall event", openat_syscall_event),
-DEFINE_SUITE("Detect openat syscall event on all cpus", openat_syscall_event_on_all_cpus),
-DEFINE_SUITE("Read samples using the mmap interface", basic_mmap),
-DEFINE_SUITE("Test data source output", mem),
-DEFINE_SUITE("Parse event definition strings", parse_events),
-DEFINE_SUITE("Simple expression parser", expr),
-DEFINE_SUITE("PERF_RECORD_* events & perf_sample fields", PERF_RECORD),
-DEFINE_SUITE("Parse perf pmu format", pmu),
-{
+DEFINE_SUITE("vmlinux symtab matches kallsyms", vmlinux_matches_kallsyms);
+DEFINE_SUITE("Detect openat syscall event", openat_syscall_event);
+DEFINE_SUITE("Detect openat syscall event on all cpus", openat_syscall_event_on_all_cpus);
+DEFINE_SUITE("Read samples using the mmap interface", basic_mmap);
+DEFINE_SUITE("Test data source output", mem);
+DEFINE_SUITE("Parse event definition strings", parse_events);
+DEFINE_SUITE("Simple expression parser", expr);
+DEFINE_SUITE("PERF_RECORD_* events & perf_sample fields", PERF_RECORD);
+DEFINE_SUITE("Parse perf pmu format", pmu);
+static struct test pmu_events = {
.desc = "PMU events",
.func = test__pmu_events,
.subtest = {
@@ -61,33 +52,32 @@ DEFINE_SUITE("Parse perf pmu format", pmu),
.get_desc = test__pmu_events_subtest_get_desc,
.skip_reason = test__pmu_events_subtest_skip_reason,
},
-
-},
-DEFINE_SUITE("DSO data read", dso_data),
-DEFINE_SUITE("DSO data cache", dso_data_cache),
-DEFINE_SUITE("DSO data reopen", dso_data_reopen),
-DEFINE_SUITE("Roundtrip evsel->name", perf_evsel__roundtrip_name_test),
-DEFINE_SUITE("Parse sched tracepoints fields", perf_evsel__tp_sched_test),
-DEFINE_SUITE("syscalls:sys_enter_openat event fields", syscall_openat_tp_fields),
-DEFINE_SUITE("Setup struct perf_event_attr", attr),
-DEFINE_SUITE("Match and link multiple hists", hists_link),
-DEFINE_SUITE("'import perf' in python", python_use),
-{
+};
+DEFINE_SUITE("DSO data read", dso_data);
+DEFINE_SUITE("DSO data cache", dso_data_cache);
+DEFINE_SUITE("DSO data reopen", dso_data_reopen);
+DEFINE_SUITE("Roundtrip evsel->name", perf_evsel__roundtrip_name_test);
+DEFINE_SUITE("Parse sched tracepoints fields", perf_evsel__tp_sched_test);
+DEFINE_SUITE("syscalls:sys_enter_openat event fields", syscall_openat_tp_fields);
+DEFINE_SUITE("Setup struct perf_event_attr", attr);
+DEFINE_SUITE("Match and link multiple hists", hists_link);
+DEFINE_SUITE("'import perf' in python", python_use);
+static struct test bp_signal = {
.desc = "Breakpoint overflow signal handler",
.func = test__bp_signal,
.is_supported = test__bp_signal_is_supported,
-},
-{
+};
+static struct test bp_signal_overflow = {
.desc = "Breakpoint overflow sampling",
.func = test__bp_signal_overflow,
.is_supported = test__bp_signal_is_supported,
-},
-{
+};
+static struct test bp_accounting = {
.desc = "Breakpoint accounting",
.func = test__bp_accounting,
.is_supported = test__bp_account_is_supported,
-},
-{
+};
+static struct test wp = {
.desc = "Watchpoint",
.func = test__wp,
.is_supported = test__wp_is_supported,
@@ -97,24 +87,24 @@ DEFINE_SUITE("'import perf' in python", python_use),
.get_desc = test__wp_subtest_get_desc,
.skip_reason = test__wp_subtest_skip_reason,
},
-},
-DEFINE_SUITE("Number of exit events of a simple workload", task_exit),
-DEFINE_SUITE("Software clock events period values", sw_clock_freq),
-DEFINE_SUITE("Object code reading", code_reading),
-DEFINE_SUITE("Sample parsing", sample_parsing),
-DEFINE_SUITE("Use a dummy software event to keep tracking", keep_tracking),
-DEFINE_SUITE("Parse with no sample_id_all bit set", parse_no_sample_id_all),
-DEFINE_SUITE("Filter hist entries", hists_filter),
-DEFINE_SUITE("Lookup mmap thread", mmap_thread_lookup),
-DEFINE_SUITE("Share thread maps", thread_maps_share),
-DEFINE_SUITE("Sort output of hist entries", hists_output),
-DEFINE_SUITE("Cumulate child hist entries", hists_cumulate),
-DEFINE_SUITE("Track with sched_switch", switch_tracking),
-DEFINE_SUITE("Filter fds with revents mask in a fdarray", fdarray__filter),
-DEFINE_SUITE("Add fd to a fdarray, making it autogrow", fdarray__add),
-DEFINE_SUITE("kmod_path__parse", kmod_path__parse),
-DEFINE_SUITE("Thread map", thread_map),
-{
+};
+DEFINE_SUITE("Number of exit events of a simple workload", task_exit);
+DEFINE_SUITE("Software clock events period values", sw_clock_freq);
+DEFINE_SUITE("Object code reading", code_reading);
+DEFINE_SUITE("Sample parsing", sample_parsing);
+DEFINE_SUITE("Use a dummy software event to keep tracking", keep_tracking);
+DEFINE_SUITE("Parse with no sample_id_all bit set", parse_no_sample_id_all);
+DEFINE_SUITE("Filter hist entries", hists_filter);
+DEFINE_SUITE("Lookup mmap thread", mmap_thread_lookup);
+DEFINE_SUITE("Share thread maps", thread_maps_share);
+DEFINE_SUITE("Sort output of hist entries", hists_output);
+DEFINE_SUITE("Cumulate child hist entries", hists_cumulate);
+DEFINE_SUITE("Track with sched_switch", switch_tracking);
+DEFINE_SUITE("Filter fds with revents mask in a fdarray", fdarray__filter);
+DEFINE_SUITE("Add fd to a fdarray, making it autogrow", fdarray__add);
+DEFINE_SUITE("kmod_path__parse", kmod_path__parse);
+DEFINE_SUITE("Thread map", thread_map);
+static struct test llvm = {
.desc = "LLVM search and compile",
.func = test__llvm,
.subtest = {
@@ -122,9 +112,9 @@ DEFINE_SUITE("Thread map", thread_map),
.get_nr = test__llvm_subtest_get_nr,
.get_desc = test__llvm_subtest_get_desc,
},
-},
-DEFINE_SUITE("Session topology", session_topology),
-{
+};
+DEFINE_SUITE("Session topology", session_topology);
+static struct test bpf = {
.desc = "BPF filter",
.func = test__bpf,
.subtest = {
@@ -132,23 +122,23 @@ DEFINE_SUITE("Session topology", session_topology),
.get_nr = test__bpf_subtest_get_nr,
.get_desc = test__bpf_subtest_get_desc,
},
-},
-DEFINE_SUITE("Synthesize thread map", thread_map_synthesize),
-DEFINE_SUITE("Remove thread map", thread_map_remove),
-DEFINE_SUITE("Synthesize cpu map", cpu_map_synthesize),
-DEFINE_SUITE("Synthesize stat config", synthesize_stat_config),
-DEFINE_SUITE("Synthesize stat", synthesize_stat),
-DEFINE_SUITE("Synthesize stat round", synthesize_stat_round),
-DEFINE_SUITE("Synthesize attr update", event_update),
-DEFINE_SUITE("Event times", event_times),
-DEFINE_SUITE("Read backward ring buffer", backward_ring_buffer),
-DEFINE_SUITE("Print cpu map", cpu_map_print),
-DEFINE_SUITE("Merge cpu map", cpu_map_merge),
-DEFINE_SUITE("Probe SDT events", sdt_event),
-DEFINE_SUITE("is_printable_array", is_printable_array),
-DEFINE_SUITE("Print bitmap", bitmap_print),
-DEFINE_SUITE("perf hooks", perf_hooks),
-{
+};
+DEFINE_SUITE("Synthesize thread map", thread_map_synthesize);
+DEFINE_SUITE("Remove thread map", thread_map_remove);
+DEFINE_SUITE("Synthesize cpu map", cpu_map_synthesize);
+DEFINE_SUITE("Synthesize stat config", synthesize_stat_config);
+DEFINE_SUITE("Synthesize stat", synthesize_stat);
+DEFINE_SUITE("Synthesize stat round", synthesize_stat_round);
+DEFINE_SUITE("Synthesize attr update", event_update);
+DEFINE_SUITE("Event times", event_times);
+DEFINE_SUITE("Read backward ring buffer", backward_ring_buffer);
+DEFINE_SUITE("Print cpu map", cpu_map_print);
+DEFINE_SUITE("Merge cpu map", cpu_map_merge);
+DEFINE_SUITE("Probe SDT events", sdt_event);
+DEFINE_SUITE("is_printable_array", is_printable_array);
+DEFINE_SUITE("Print bitmap", bitmap_print);
+DEFINE_SUITE("perf hooks", perf_hooks);
+static struct test clang = {
.desc = "builtin clang support",
.func = test__clang,
.subtest = {
@@ -156,12 +146,12 @@ DEFINE_SUITE("perf hooks", perf_hooks),
.get_nr = test__clang_subtest_get_nr,
.get_desc = test__clang_subtest_get_desc,
}
-},
-DEFINE_SUITE("unit_number__scnprintf", unit_number__scnprint),
-DEFINE_SUITE("mem2node", mem2node),
-DEFINE_SUITE("time utils", time_utils),
-DEFINE_SUITE("Test jit_write_elf", jit_write_elf),
-{
+};
+DEFINE_SUITE("unit_number__scnprintf", unit_number__scnprint);
+DEFINE_SUITE("mem2node", mem2node);
+DEFINE_SUITE("time utils", time_utils);
+DEFINE_SUITE("Test jit_write_elf", jit_write_elf);
+static struct test pfm = {
.desc = "Test libpfm4 support",
.func = test__pfm,
.subtest = {
@@ -169,26 +159,99 @@ DEFINE_SUITE("Test jit_write_elf", jit_write_elf),
.get_nr = test__pfm_subtest_get_nr,
.get_desc = test__pfm_subtest_get_desc,
}
-},
-DEFINE_SUITE("Test api io", api_io),
-DEFINE_SUITE("maps__merge_in", maps__merge_in),
-DEFINE_SUITE("Demangle Java", demangle_java),
-DEFINE_SUITE("Demangle OCaml", demangle_ocaml),
-DEFINE_SUITE("Parse and process metrics", parse_metric),
-DEFINE_SUITE("PE file support", pe_file_parsing),
-DEFINE_SUITE("Event expansion for cgroups", expand_cgroup_events),
-{
+};
+DEFINE_SUITE("Test api io", api_io);
+DEFINE_SUITE("maps__merge_in", maps__merge_in);
+DEFINE_SUITE("Demangle Java", demangle_java);
+DEFINE_SUITE("Demangle OCaml", demangle_ocaml);
+DEFINE_SUITE("Parse and process metrics", parse_metric);
+DEFINE_SUITE("PE file support", pe_file_parsing);
+DEFINE_SUITE("Event expansion for cgroups", expand_cgroup_events);
+static struct test perf_time_to_tsc = {
.desc = "Convert perf time to TSC",
.func = test__perf_time_to_tsc,
.is_supported = test__tsc_is_supported,
-},
-DEFINE_SUITE("dlfilter C API", dlfilter),
-{
- .func = NULL,
-},
+};
+DEFINE_SUITE("dlfilter C API", dlfilter);
+
+
+static struct test *generic_tests[] = {
+ &vmlinux_matches_kallsyms,
+ &openat_syscall_event,
+ &openat_syscall_event_on_all_cpus,
+ &basic_mmap,
+ &mem,
+ &parse_events,
+ &expr,
+ &PERF_RECORD,
+ &pmu,
+ &pmu_events,
+ &dso_data,
+ &dso_data_cache,
+ &dso_data_reopen,
+ &perf_evsel__roundtrip_name_test,
+ &perf_evsel__tp_sched_test,
+ &syscall_openat_tp_fields,
+ &attr,
+ &hists_link,
+ &python_use,
+ &bp_signal,
+ &bp_signal_overflow,
+ &bp_accounting,
+ &wp,
+ &task_exit,
+ &sw_clock_freq,
+ &code_reading,
+ &sample_parsing,
+ &keep_tracking,
+ &parse_no_sample_id_all,
+ &hists_filter,
+ &mmap_thread_lookup,
+ &thread_maps_share,
+ &hists_output,
+ &hists_cumulate,
+ &switch_tracking,
+ &fdarray__filter,
+ &fdarray__add,
+ &kmod_path__parse,
+ &thread_map,
+ &llvm,
+ &session_topology,
+ &bpf,
+ &thread_map_synthesize,
+ &thread_map_remove,
+ &cpu_map_synthesize,
+ &synthesize_stat_config,
+ &synthesize_stat,
+ &synthesize_stat_round,
+ &event_update,
+ &event_times,
+ &backward_ring_buffer,
+ &cpu_map_print,
+ &cpu_map_merge,
+ &sdt_event,
+ &is_printable_array,
+ &bitmap_print,
+ &perf_hooks,
+ &clang,
+ &unit_number__scnprint,
+ &mem2node,
+ &time_utils,
+ &jit_write_elf,
+ &pfm,
+ &api_io,
+ &maps__merge_in,
+ &demangle_java,
+ &demangle_ocaml,
+ &parse_metric,
+ &pe_file_parsing,
+ &expand_cgroup_events,
+ &perf_time_to_tsc,
+ &dlfilter,
+ NULL,
};

-static struct test *tests[] = {
+static struct test **tests[] = {
generic_tests,
arch_tests,
};
@@ -269,9 +332,9 @@ static int run_test(struct test *test, int subtest)
return err;
}

-#define for_each_test(j, t) \
+#define for_each_test(j, k, t) \
for (j = 0; j < ARRAY_SIZE(tests); j++) \
- for (t = &tests[j][0]; t->func; t++)
+ for (k = 0, t = tests[j][k]; tests[j][k]; k++, t = tests[j][k])

static int test_and_print(struct test *t, bool force_skip, int subtest)
{
@@ -470,18 +533,18 @@ static int run_shell_tests(int argc, const char *argv[], int i, int width,
static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
{
struct test *t;
- unsigned int j;
+ unsigned int j, k;
int i = 0;
int width = shell_tests__max_desc_width();

- for_each_test(j, t) {
+ for_each_test(j, k, t) {
int len = strlen(t->desc);

if (width < len)
width = len;
}

- for_each_test(j, t) {
+ for_each_test(j, k, t) {
int curr = i++, err;
int subi;

@@ -597,11 +660,11 @@ static int perf_test__list_shell(int argc, const char **argv, int i)

static int perf_test__list(int argc, const char **argv)
{
- unsigned int j;
+ unsigned int j, k;
struct test *t;
int i = 0;

- for_each_test(j, t) {
+ for_each_test(j, k, t) {
int curr = i++;

if (!perf_test__matches(t->desc, curr, argc, argv) ||
diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
index a288035eb362..78b5a71957b7 100644
--- a/tools/perf/tests/dwarf-unwind.c
+++ b/tools/perf/tests/dwarf-unwind.c
@@ -170,7 +170,7 @@ noinline int test_dwarf_unwind__krava_1(struct thread *thread)
return test_dwarf_unwind__krava_2(thread);
}

-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;
@@ -212,3 +212,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,
+};
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 0846f66d67f9..8323a3c88284 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -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);
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:48:54

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 07/22] perf test: Add test case struct.

Add a test case struct mirroring the 'struct kunit_case'. Use the struct
with the DEFINE_SUITE macro, where the single test is turned into a test
case. Update the helpers in builtin-test to handle test cases.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/builtin-test.c | 30 ++++++++++++++++++++++++------
tools/perf/tests/tests.h | 26 ++++++++++++++++++++++----
2 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 96eb486ffbc9..a6d84feba483 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -117,10 +117,19 @@ static struct test_suite **tests[] = {

static int num_subtests(const struct test_suite *t)
{
+ int num;
+
if (t->subtest.get_nr)
return t->subtest.get_nr();

- return 0;
+ if (!t->test_cases)
+ return 0;
+
+ num = 0;
+ while (t->test_cases[num].name)
+ num++;
+
+ return num;
}

static bool has_subtests(const struct test_suite *t)
@@ -138,10 +147,13 @@ static const char *skip_reason(const struct test_suite *t, int subtest)

static const char *test_description(const struct test_suite *t, int subtest)
{
- if (subtest < 0 || !t->subtest.get_desc)
- return t->desc;
+ if (t->test_cases && subtest >= 0)
+ return t->test_cases[subtest].desc;

- return t->subtest.get_desc(subtest);
+ if (t->subtest.get_desc && subtest >= 0)
+ return t->subtest.get_desc(subtest);
+
+ return t->desc;
}

static bool is_supported(const struct test_suite *t)
@@ -149,9 +161,15 @@ static bool is_supported(const struct test_suite *t)
return !t->is_supported || t->is_supported();
}

-static test_fnptr test_function(const struct test_suite *t, int subtest __maybe_unused)
+static test_fnptr test_function(const struct test_suite *t, int subtest)
{
- return t->func;
+ if (t->func)
+ return t->func;
+
+ if (subtest <= 0)
+ return t->test_cases[0].run_case;
+
+ return t->test_cases[subtest].run_case;
}

static bool perf_test__matches(const char *desc, int curr, int argc, const char *argv[])
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 5139e24973cc..71b8d2c88e5c 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -31,6 +31,12 @@ struct test_suite;

typedef int (*test_fnptr)(struct test_suite *, int);

+struct test_case {
+ const char *name;
+ const char *desc;
+ test_fnptr run_case;
+};
+
struct test_suite {
const char *desc;
test_fnptr func;
@@ -40,6 +46,7 @@ struct test_suite {
const char *(*get_desc)(int subtest);
const char *(*skip_reason)(int subtest);
} subtest;
+ struct test_case *test_cases;
bool (*is_supported)(void);
void *priv;
};
@@ -47,10 +54,21 @@ struct test_suite {
#define DECLARE_SUITE(name) \
extern struct test_suite suite__##name;

-#define DEFINE_SUITE(description, name) \
- struct test_suite suite__##name = { \
- .desc = description, \
- .func = test__##name, \
+#define TEST_CASE(description, _name) \
+ { \
+ .name = #_name, \
+ .desc = description, \
+ .run_case = test__##_name, \
+ }
+
+#define DEFINE_SUITE(description, _name) \
+ struct test_case tests__##_name[] = { \
+ TEST_CASE(description, _name), \
+ { .name = NULL, } \
+ }; \
+ struct test_suite suite__##_name = { \
+ .desc = description, \
+ .test_cases = tests__##_name, \
}

/* Tests */
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:48:58

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 10/22] perf test: Convert pmu event tests to test cases.

Use null terminated array of test cases rather than the previous sub
test functions.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/pmu-events.c | 78 +++++++----------------------------
1 file changed, 16 insertions(+), 62 deletions(-)

diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index fed399f76eaa..d568d9ff1b45 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -418,7 +418,8 @@ static int compare_alias_to_test_event(struct perf_pmu_alias *alias,
}

/* Verify generated events from pmu-events.c are as expected */
-static int test_pmu_event_table(void)
+static int test__pmu_event_table(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
struct pmu_event *sys_event_tables = __test_pmu_get_sys_events_table();
struct pmu_events_map *map = __test_pmu_get_events_map();
@@ -705,7 +706,8 @@ static struct perf_pmu_test_pmu test_pmus[] = {
};

/* Test that aliases generated are as expected */
-static int test_aliases(void)
+static int test__aliases(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
struct perf_pmu *pmu = NULL;
unsigned long i;
@@ -883,7 +885,8 @@ static int resolve_metric_simple(struct expr_parse_ctx *pctx,

}

-static int test_parsing(void)
+static int test__parsing(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
struct pmu_events_map *cpus_map = pmu_events_map__find();
struct pmu_events_map *map;
@@ -1025,7 +1028,8 @@ static int metric_parse_fake(const char *str)
* or all defined cpus via the 'fake_pmu'
* in parse_events.
*/
-static int test_parsing_fake(void)
+static int test__parsing_fake(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
struct pmu_events_map *map;
struct pmu_event *pe;
@@ -1059,66 +1063,16 @@ static int test_parsing_fake(void)
return 0;
}

-static const struct {
- int (*func)(void);
- const char *desc;
-} pmu_events_testcase_table[] = {
- {
- .func = test_pmu_event_table,
- .desc = "PMU event table sanity",
- },
- {
- .func = test_aliases,
- .desc = "PMU event map aliases",
- },
- {
- .func = test_parsing,
- .desc = "Parsing of PMU event table metrics",
- },
- {
- .func = test_parsing_fake,
- .desc = "Parsing of PMU event table metrics with fake PMUs",
- },
+static struct test_case pmu_events_tests[] = {
+ TEST_CASE("PMU event table sanity", pmu_event_table),
+ TEST_CASE("PMU event map aliases", aliases),
+ TEST_CASE_REASON("Parsing of PMU event table metrics", parsing,
+ "some metrics failed"),
+ TEST_CASE("Parsing of PMU event table metrics with fake PMUs", parsing_fake),
+ { .name = NULL, }
};

-static const char *test__pmu_events_subtest_get_desc(int subtest)
-{
- if (subtest < 0 ||
- subtest >= (int)ARRAY_SIZE(pmu_events_testcase_table))
- return NULL;
- return pmu_events_testcase_table[subtest].desc;
-}
-
-static const char *test__pmu_events_subtest_skip_reason(int subtest)
-{
- if (subtest < 0 ||
- subtest >= (int)ARRAY_SIZE(pmu_events_testcase_table))
- return NULL;
- if (pmu_events_testcase_table[subtest].func != test_parsing)
- return NULL;
- return "some metrics failed";
-}
-
-static int test__pmu_events_subtest_get_nr(void)
-{
- return (int)ARRAY_SIZE(pmu_events_testcase_table);
-}
-
-static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest)
-{
- if (subtest < 0 ||
- subtest >= (int)ARRAY_SIZE(pmu_events_testcase_table))
- return TEST_FAIL;
- return pmu_events_testcase_table[subtest].func();
-}
-
struct test_suite suite__pmu_events = {
.desc = "PMU events",
- .func = test__pmu_events,
- .subtest = {
- .skip_if_fail = false,
- .get_nr = test__pmu_events_subtest_get_nr,
- .get_desc = test__pmu_events_subtest_get_desc,
- .skip_reason = test__pmu_events_subtest_skip_reason,
- },
+ .test_cases = pmu_events_tests,
};
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:49:12

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 04/22] perf test: Move each test suite struct to its test

Rather than export test functions, export the test struct. Rename with a
suite__ prefix to avoid name collisions.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/arch/arm/tests/arch-tests.c | 4 +-
tools/perf/arch/arm64/tests/arch-tests.c | 2 +-
tools/perf/arch/powerpc/tests/arch-tests.c | 2 +-
tools/perf/arch/x86/tests/arch-tests.c | 12 +-
tools/perf/tests/api-io.c | 6 +-
tools/perf/tests/attr.c | 4 +-
tools/perf/tests/backward-ring-buffer.c | 4 +-
tools/perf/tests/bitmap.c | 4 +-
tools/perf/tests/bp_account.c | 10 +-
tools/perf/tests/bp_signal.c | 8 +-
tools/perf/tests/bp_signal_overflow.c | 8 +-
tools/perf/tests/bpf.c | 22 +-
tools/perf/tests/builtin-test.c | 285 +++++---------------
tools/perf/tests/clang.c | 18 +-
tools/perf/tests/code-reading.c | 4 +-
tools/perf/tests/cpumap.c | 10 +-
tools/perf/tests/demangle-java-test.c | 4 +-
tools/perf/tests/demangle-ocaml-test.c | 4 +-
tools/perf/tests/dlfilter-test.c | 4 +-
tools/perf/tests/dso-data.c | 10 +-
tools/perf/tests/dwarf-unwind.c | 5 +-
tools/perf/tests/event-times.c | 4 +-
tools/perf/tests/event_update.c | 4 +-
tools/perf/tests/evsel-roundtrip-name.c | 5 +-
tools/perf/tests/evsel-tp-sched.c | 5 +-
tools/perf/tests/expand-cgroup.c | 6 +-
tools/perf/tests/expr.c | 4 +-
tools/perf/tests/fdarray.c | 7 +-
tools/perf/tests/genelf.c | 6 +-
tools/perf/tests/hists_cumulate.c | 4 +-
tools/perf/tests/hists_filter.c | 4 +-
tools/perf/tests/hists_link.c | 4 +-
tools/perf/tests/hists_output.c | 4 +-
tools/perf/tests/is_printable_array.c | 4 +-
tools/perf/tests/keep-tracking.c | 4 +-
tools/perf/tests/kmod-path.c | 4 +-
tools/perf/tests/llvm.c | 22 +-
tools/perf/tests/maps.c | 4 +-
tools/perf/tests/mem.c | 4 +-
tools/perf/tests/mem2node.c | 4 +-
tools/perf/tests/mmap-basic.c | 4 +-
tools/perf/tests/mmap-thread-lookup.c | 4 +-
tools/perf/tests/openat-syscall-all-cpus.c | 5 +-
tools/perf/tests/openat-syscall-tp-fields.c | 5 +-
tools/perf/tests/openat-syscall.c | 5 +-
tools/perf/tests/parse-events.c | 4 +-
tools/perf/tests/parse-metric.c | 4 +-
tools/perf/tests/parse-no-sample-id-all.c | 5 +-
tools/perf/tests/pe-file-parsing.c | 6 +-
tools/perf/tests/perf-hooks.c | 4 +-
tools/perf/tests/perf-record.c | 4 +-
tools/perf/tests/perf-time-to-tsc.c | 10 +-
tools/perf/tests/pfm.c | 16 +-
tools/perf/tests/pmu-events.c | 19 +-
tools/perf/tests/pmu.c | 4 +-
tools/perf/tests/python-use.c | 4 +-
tools/perf/tests/sample-parsing.c | 4 +-
tools/perf/tests/sdt.c | 6 +-
tools/perf/tests/stat.c | 11 +-
tools/perf/tests/sw-clock.c | 4 +-
tools/perf/tests/switch-tracking.c | 4 +-
tools/perf/tests/task-exit.c | 4 +-
tools/perf/tests/tests.h | 23 +-
tools/perf/tests/thread-map.c | 10 +-
tools/perf/tests/thread-maps-share.c | 4 +-
tools/perf/tests/time-utils-test.c | 4 +-
tools/perf/tests/topology.c | 4 +-
tools/perf/tests/unit_number__scnprintf.c | 4 +-
tools/perf/tests/vmlinux-kallsyms.c | 5 +-
tools/perf/tests/wp.c | 22 +-
70 files changed, 397 insertions(+), 348 deletions(-)

diff --git a/tools/perf/arch/arm/tests/arch-tests.c b/tools/perf/arch/arm/tests/arch-tests.c
index 5287729026ab..0ae591f6c372 100644
--- a/tools/perf/arch/arm/tests/arch-tests.c
+++ b/tools/perf/arch/arm/tests/arch-tests.c
@@ -7,8 +7,8 @@ DEFINE_SUITE("Vectors page", vectors_page);

struct test *arch_tests[] = {
#ifdef HAVE_DWARF_UNWIND_SUPPORT
- &dwarf_unwind,
+ &suite__dwarf_unwind,
#endif
- &vectors_pages,
+ &suite__vectors_pages,
NULL,
};
diff --git a/tools/perf/arch/arm64/tests/arch-tests.c b/tools/perf/arch/arm64/tests/arch-tests.c
index bc327048b807..6d137138a2de 100644
--- a/tools/perf/arch/arm64/tests/arch-tests.c
+++ b/tools/perf/arch/arm64/tests/arch-tests.c
@@ -5,7 +5,7 @@

struct test *arch_tests[] = {
#ifdef HAVE_DWARF_UNWIND_SUPPORT
- &dwarf_unwind,
+ &suite__dwarf_unwind,
#endif
NULL,
};
diff --git a/tools/perf/arch/powerpc/tests/arch-tests.c b/tools/perf/arch/powerpc/tests/arch-tests.c
index bc327048b807..6d137138a2de 100644
--- a/tools/perf/arch/powerpc/tests/arch-tests.c
+++ b/tools/perf/arch/powerpc/tests/arch-tests.c
@@ -5,7 +5,7 @@

struct test *arch_tests[] = {
#ifdef HAVE_DWARF_UNWIND_SUPPORT
- &dwarf_unwind,
+ &suite__dwarf_unwind,
#endif
NULL,
};
diff --git a/tools/perf/arch/x86/tests/arch-tests.c b/tools/perf/arch/x86/tests/arch-tests.c
index 48ddc754bf74..585fbf8ebae6 100644
--- a/tools/perf/arch/x86/tests/arch-tests.c
+++ b/tools/perf/arch/x86/tests/arch-tests.c
@@ -14,16 +14,16 @@ DEFINE_SUITE("x86 bp modify", bp_modify);
DEFINE_SUITE("x86 Sample parsing", x86_sample_parsing);

struct test *arch_tests[] = {
- &rdpmc,
+ &suite__rdpmc,
#ifdef HAVE_DWARF_UNWIND_SUPPORT
- &dwarf_unwind,
+ &suite__dwarf_unwind,
#endif
#ifdef HAVE_AUXTRACE_SUPPORT
- &insn_x86,
- &intel_pt_pkt_decoder,
+ &suite__insn_x86,
+ &suite__intel_pt_pkt_decoder,
#endif
#if defined(__x86_64__)
- &bp_modify,
+ &suite__bp_modify,
#endif
- &x86_sample_parsing,
+ &suite__x86_sample_parsing,
};
diff --git a/tools/perf/tests/api-io.c b/tools/perf/tests/api-io.c
index 2ada86ad6084..af4913967514 100644
--- a/tools/perf/tests/api-io.c
+++ b/tools/perf/tests/api-io.c
@@ -289,8 +289,8 @@ static int test_get_dec(void)
return ret;
}

-int test__api_io(struct test *test __maybe_unused,
- int subtest __maybe_unused)
+static int test__api_io(struct test *test __maybe_unused,
+ int subtest __maybe_unused)
{
int ret = 0;

@@ -302,3 +302,5 @@ int test__api_io(struct test *test __maybe_unused,
ret = TEST_FAIL;
return ret;
}
+
+DEFINE_SUITE("Test api io", api_io);
diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
index 9b40a25376ae..f1461051f579 100644
--- a/tools/perf/tests/attr.c
+++ b/tools/perf/tests/attr.c
@@ -178,7 +178,7 @@ static int run_dir(const char *d, const char *perf)
return system(cmd) ? TEST_FAIL : TEST_OK;
}

-int test__attr(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__attr(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct stat st;
char path_perf[PATH_MAX];
@@ -207,3 +207,5 @@ int test__attr(struct test *test __maybe_unused, int subtest __maybe_unused)

return TEST_SKIP;
}
+
+DEFINE_SUITE("Setup struct perf_event_attr", attr);
diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c
index b4b9a9488d51..180e16917658 100644
--- a/tools/perf/tests/backward-ring-buffer.c
+++ b/tools/perf/tests/backward-ring-buffer.c
@@ -82,7 +82,7 @@ static int do_test(struct evlist *evlist, int mmap_pages,
}


-int test__backward_ring_buffer(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__backward_ring_buffer(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int ret = TEST_SKIP, err, sample_count = 0, comm_count = 0;
char pid[16], sbuf[STRERR_BUFSIZE];
@@ -166,3 +166,5 @@ int test__backward_ring_buffer(struct test *test __maybe_unused, int subtest __m
evlist__delete(evlist);
return ret;
}
+
+DEFINE_SUITE("Read backward ring buffer", backward_ring_buffer);
diff --git a/tools/perf/tests/bitmap.c b/tools/perf/tests/bitmap.c
index 12b805efdca0..13d1d1d6774f 100644
--- a/tools/perf/tests/bitmap.c
+++ b/tools/perf/tests/bitmap.c
@@ -40,7 +40,7 @@ static int test_bitmap(const char *str)
return ret;
}

-int test__bitmap_print(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__bitmap_print(struct test *test __maybe_unused, int subtest __maybe_unused)
{
TEST_ASSERT_VAL("failed to convert map", test_bitmap("1"));
TEST_ASSERT_VAL("failed to convert map", test_bitmap("1,5"));
@@ -51,3 +51,5 @@ int test__bitmap_print(struct test *test __maybe_unused, int subtest __maybe_unu
TEST_ASSERT_VAL("failed to convert map", test_bitmap("1-10,12-20,22-30,32-40"));
return 0;
}
+
+DEFINE_SUITE("Print bitmap", bitmap_print);
diff --git a/tools/perf/tests/bp_account.c b/tools/perf/tests/bp_account.c
index 489b50604cf2..76cf356ba13f 100644
--- a/tools/perf/tests/bp_account.c
+++ b/tools/perf/tests/bp_account.c
@@ -173,7 +173,7 @@ static int detect_share(int wp_cnt, int bp_cnt)
* we create another watchpoint to ensure
* the slot accounting is correct
*/
-int test__bp_accounting(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__bp_accounting(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int has_ioctl = detect_ioctl();
int wp_cnt = detect_cnt(false);
@@ -189,7 +189,7 @@ int test__bp_accounting(struct test *test __maybe_unused, int subtest __maybe_un
return bp_accounting(wp_cnt, share);
}

-bool test__bp_account_is_supported(void)
+static bool test__bp_account_is_supported(void)
{
/*
* PowerPC and S390 do not support creation of instruction
@@ -204,3 +204,9 @@ bool test__bp_account_is_supported(void)
return true;
#endif
}
+
+struct test suite__bp_accounting = {
+ .desc = "Breakpoint accounting",
+ .func = test__bp_accounting,
+ .is_supported = test__bp_account_is_supported,
+};
diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c
index ef37353636d8..c19b05488cfb 100644
--- a/tools/perf/tests/bp_signal.c
+++ b/tools/perf/tests/bp_signal.c
@@ -161,7 +161,7 @@ static long long bp_count(int fd)
return count;
}

-int test__bp_signal(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__bp_signal(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct sigaction sa;
long long count1, count2, count3;
@@ -311,3 +311,9 @@ bool test__bp_signal_is_supported(void)
return true;
#endif
}
+
+struct test suite__bp_signal = {
+ .desc = "Breakpoint overflow signal handler",
+ .func = test__bp_signal,
+ .is_supported = test__bp_signal_is_supported,
+};
diff --git a/tools/perf/tests/bp_signal_overflow.c b/tools/perf/tests/bp_signal_overflow.c
index eb4dbbddf4ff..99c30d028f5e 100644
--- a/tools/perf/tests/bp_signal_overflow.c
+++ b/tools/perf/tests/bp_signal_overflow.c
@@ -59,7 +59,7 @@ static long long bp_count(int fd)
#define EXECUTIONS 10000
#define THRESHOLD 100

-int test__bp_signal_overflow(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__bp_signal_overflow(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct perf_event_attr pe;
struct sigaction sa;
@@ -133,3 +133,9 @@ int test__bp_signal_overflow(struct test *test __maybe_unused, int subtest __may

return fails ? TEST_FAIL : TEST_OK;
}
+
+struct test suite__bp_signal_overflow = {
+ .desc = "Breakpoint overflow sampling",
+ .func = test__bp_signal_overflow,
+ .is_supported = test__bp_signal_is_supported,
+};
diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index fa03ff0dc083..74496a0fc973 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -282,12 +282,12 @@ static int __test__bpf(int idx)
return ret;
}

-int test__bpf_subtest_get_nr(void)
+static int test__bpf_subtest_get_nr(void)
{
return (int)ARRAY_SIZE(bpf_testcase_table);
}

-const char *test__bpf_subtest_get_desc(int i)
+static const char *test__bpf_subtest_get_desc(int i)
{
if (i < 0 || i >= (int)ARRAY_SIZE(bpf_testcase_table))
return NULL;
@@ -324,7 +324,7 @@ static int check_env(void)
return 0;
}

-int test__bpf(struct test *test __maybe_unused, int i)
+static int test__bpf(struct test *test __maybe_unused, int i)
{
int err;

@@ -344,19 +344,29 @@ int test__bpf(struct test *test __maybe_unused, int i)
}

#else
-int test__bpf_subtest_get_nr(void)
+static int test__bpf_subtest_get_nr(void)
{
return 0;
}

-const char *test__bpf_subtest_get_desc(int i __maybe_unused)
+static const char *test__bpf_subtest_get_desc(int i __maybe_unused)
{
return NULL;
}

-int test__bpf(struct test *test __maybe_unused, int i __maybe_unused)
+static int test__bpf(struct test *test __maybe_unused, int i __maybe_unused)
{
pr_debug("Skip BPF test because BPF support is not compiled\n");
return TEST_SKIP;
}
#endif
+
+struct test suite__bpf = {
+ .desc = "BPF filter",
+ .func = test__bpf,
+ .subtest = {
+ .skip_if_fail = true,
+ .get_nr = test__bpf_subtest_get_nr,
+ .get_desc = test__bpf_subtest_get_desc,
+ },
+};
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index b2cbc12a70a2..07467ec43100 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -34,220 +34,79 @@ struct test *__weak arch_tests[] = {
NULL,
};

-DEFINE_SUITE("vmlinux symtab matches kallsyms", vmlinux_matches_kallsyms);
-DEFINE_SUITE("Detect openat syscall event", openat_syscall_event);
-DEFINE_SUITE("Detect openat syscall event on all cpus", openat_syscall_event_on_all_cpus);
-DEFINE_SUITE("Read samples using the mmap interface", basic_mmap);
-DEFINE_SUITE("Test data source output", mem);
-DEFINE_SUITE("Parse event definition strings", parse_events);
-DEFINE_SUITE("Simple expression parser", expr);
-DEFINE_SUITE("PERF_RECORD_* events & perf_sample fields", PERF_RECORD);
-DEFINE_SUITE("Parse perf pmu format", pmu);
-static struct test pmu_events = {
- .desc = "PMU events",
- .func = test__pmu_events,
- .subtest = {
- .skip_if_fail = false,
- .get_nr = test__pmu_events_subtest_get_nr,
- .get_desc = test__pmu_events_subtest_get_desc,
- .skip_reason = test__pmu_events_subtest_skip_reason,
- },
-};
-DEFINE_SUITE("DSO data read", dso_data);
-DEFINE_SUITE("DSO data cache", dso_data_cache);
-DEFINE_SUITE("DSO data reopen", dso_data_reopen);
-DEFINE_SUITE("Roundtrip evsel->name", perf_evsel__roundtrip_name_test);
-DEFINE_SUITE("Parse sched tracepoints fields", perf_evsel__tp_sched_test);
-DEFINE_SUITE("syscalls:sys_enter_openat event fields", syscall_openat_tp_fields);
-DEFINE_SUITE("Setup struct perf_event_attr", attr);
-DEFINE_SUITE("Match and link multiple hists", hists_link);
-DEFINE_SUITE("'import perf' in python", python_use);
-static struct test bp_signal = {
- .desc = "Breakpoint overflow signal handler",
- .func = test__bp_signal,
- .is_supported = test__bp_signal_is_supported,
-};
-static struct test bp_signal_overflow = {
- .desc = "Breakpoint overflow sampling",
- .func = test__bp_signal_overflow,
- .is_supported = test__bp_signal_is_supported,
-};
-static struct test bp_accounting = {
- .desc = "Breakpoint accounting",
- .func = test__bp_accounting,
- .is_supported = test__bp_account_is_supported,
-};
-static struct test wp = {
- .desc = "Watchpoint",
- .func = test__wp,
- .is_supported = test__wp_is_supported,
- .subtest = {
- .skip_if_fail = false,
- .get_nr = test__wp_subtest_get_nr,
- .get_desc = test__wp_subtest_get_desc,
- .skip_reason = test__wp_subtest_skip_reason,
- },
-};
-DEFINE_SUITE("Number of exit events of a simple workload", task_exit);
-DEFINE_SUITE("Software clock events period values", sw_clock_freq);
-DEFINE_SUITE("Object code reading", code_reading);
-DEFINE_SUITE("Sample parsing", sample_parsing);
-DEFINE_SUITE("Use a dummy software event to keep tracking", keep_tracking);
-DEFINE_SUITE("Parse with no sample_id_all bit set", parse_no_sample_id_all);
-DEFINE_SUITE("Filter hist entries", hists_filter);
-DEFINE_SUITE("Lookup mmap thread", mmap_thread_lookup);
-DEFINE_SUITE("Share thread maps", thread_maps_share);
-DEFINE_SUITE("Sort output of hist entries", hists_output);
-DEFINE_SUITE("Cumulate child hist entries", hists_cumulate);
-DEFINE_SUITE("Track with sched_switch", switch_tracking);
-DEFINE_SUITE("Filter fds with revents mask in a fdarray", fdarray__filter);
-DEFINE_SUITE("Add fd to a fdarray, making it autogrow", fdarray__add);
-DEFINE_SUITE("kmod_path__parse", kmod_path__parse);
-DEFINE_SUITE("Thread map", thread_map);
-static struct test llvm = {
- .desc = "LLVM search and compile",
- .func = test__llvm,
- .subtest = {
- .skip_if_fail = true,
- .get_nr = test__llvm_subtest_get_nr,
- .get_desc = test__llvm_subtest_get_desc,
- },
-};
-DEFINE_SUITE("Session topology", session_topology);
-static struct test bpf = {
- .desc = "BPF filter",
- .func = test__bpf,
- .subtest = {
- .skip_if_fail = true,
- .get_nr = test__bpf_subtest_get_nr,
- .get_desc = test__bpf_subtest_get_desc,
- },
-};
-DEFINE_SUITE("Synthesize thread map", thread_map_synthesize);
-DEFINE_SUITE("Remove thread map", thread_map_remove);
-DEFINE_SUITE("Synthesize cpu map", cpu_map_synthesize);
-DEFINE_SUITE("Synthesize stat config", synthesize_stat_config);
-DEFINE_SUITE("Synthesize stat", synthesize_stat);
-DEFINE_SUITE("Synthesize stat round", synthesize_stat_round);
-DEFINE_SUITE("Synthesize attr update", event_update);
-DEFINE_SUITE("Event times", event_times);
-DEFINE_SUITE("Read backward ring buffer", backward_ring_buffer);
-DEFINE_SUITE("Print cpu map", cpu_map_print);
-DEFINE_SUITE("Merge cpu map", cpu_map_merge);
-DEFINE_SUITE("Probe SDT events", sdt_event);
-DEFINE_SUITE("is_printable_array", is_printable_array);
-DEFINE_SUITE("Print bitmap", bitmap_print);
-DEFINE_SUITE("perf hooks", perf_hooks);
-static struct test clang = {
- .desc = "builtin clang support",
- .func = test__clang,
- .subtest = {
- .skip_if_fail = true,
- .get_nr = test__clang_subtest_get_nr,
- .get_desc = test__clang_subtest_get_desc,
- }
-};
-DEFINE_SUITE("unit_number__scnprintf", unit_number__scnprint);
-DEFINE_SUITE("mem2node", mem2node);
-DEFINE_SUITE("time utils", time_utils);
-DEFINE_SUITE("Test jit_write_elf", jit_write_elf);
-static struct test pfm = {
- .desc = "Test libpfm4 support",
- .func = test__pfm,
- .subtest = {
- .skip_if_fail = true,
- .get_nr = test__pfm_subtest_get_nr,
- .get_desc = test__pfm_subtest_get_desc,
- }
-};
-DEFINE_SUITE("Test api io", api_io);
-DEFINE_SUITE("maps__merge_in", maps__merge_in);
-DEFINE_SUITE("Demangle Java", demangle_java);
-DEFINE_SUITE("Demangle OCaml", demangle_ocaml);
-DEFINE_SUITE("Parse and process metrics", parse_metric);
-DEFINE_SUITE("PE file support", pe_file_parsing);
-DEFINE_SUITE("Event expansion for cgroups", expand_cgroup_events);
-static struct test perf_time_to_tsc = {
- .desc = "Convert perf time to TSC",
- .func = test__perf_time_to_tsc,
- .is_supported = test__tsc_is_supported,
-};
-DEFINE_SUITE("dlfilter C API", dlfilter);
-
-
static struct test *generic_tests[] = {
- &vmlinux_matches_kallsyms,
- &openat_syscall_event,
- &openat_syscall_event_on_all_cpus,
- &basic_mmap,
- &mem,
- &parse_events,
- &expr,
- &PERF_RECORD,
- &pmu,
- &pmu_events,
- &dso_data,
- &dso_data_cache,
- &dso_data_reopen,
- &perf_evsel__roundtrip_name_test,
- &perf_evsel__tp_sched_test,
- &syscall_openat_tp_fields,
- &attr,
- &hists_link,
- &python_use,
- &bp_signal,
- &bp_signal_overflow,
- &bp_accounting,
- &wp,
- &task_exit,
- &sw_clock_freq,
- &code_reading,
- &sample_parsing,
- &keep_tracking,
- &parse_no_sample_id_all,
- &hists_filter,
- &mmap_thread_lookup,
- &thread_maps_share,
- &hists_output,
- &hists_cumulate,
- &switch_tracking,
- &fdarray__filter,
- &fdarray__add,
- &kmod_path__parse,
- &thread_map,
- &llvm,
- &session_topology,
- &bpf,
- &thread_map_synthesize,
- &thread_map_remove,
- &cpu_map_synthesize,
- &synthesize_stat_config,
- &synthesize_stat,
- &synthesize_stat_round,
- &event_update,
- &event_times,
- &backward_ring_buffer,
- &cpu_map_print,
- &cpu_map_merge,
- &sdt_event,
- &is_printable_array,
- &bitmap_print,
- &perf_hooks,
- &clang,
- &unit_number__scnprint,
- &mem2node,
- &time_utils,
- &jit_write_elf,
- &pfm,
- &api_io,
- &maps__merge_in,
- &demangle_java,
- &demangle_ocaml,
- &parse_metric,
- &pe_file_parsing,
- &expand_cgroup_events,
- &perf_time_to_tsc,
- &dlfilter,
+ &suite__vmlinux_matches_kallsyms,
+ &suite__openat_syscall_event,
+ &suite__openat_syscall_event_on_all_cpus,
+ &suite__basic_mmap,
+ &suite__mem,
+ &suite__parse_events,
+ &suite__expr,
+ &suite__PERF_RECORD,
+ &suite__pmu,
+ &suite__pmu_events,
+ &suite__dso_data,
+ &suite__dso_data_cache,
+ &suite__dso_data_reopen,
+ &suite__perf_evsel__roundtrip_name_test,
+ &suite__perf_evsel__tp_sched_test,
+ &suite__syscall_openat_tp_fields,
+ &suite__attr,
+ &suite__hists_link,
+ &suite__python_use,
+ &suite__bp_signal,
+ &suite__bp_signal_overflow,
+ &suite__bp_accounting,
+ &suite__wp,
+ &suite__task_exit,
+ &suite__sw_clock_freq,
+ &suite__code_reading,
+ &suite__sample_parsing,
+ &suite__keep_tracking,
+ &suite__parse_no_sample_id_all,
+ &suite__hists_filter,
+ &suite__mmap_thread_lookup,
+ &suite__thread_maps_share,
+ &suite__hists_output,
+ &suite__hists_cumulate,
+ &suite__switch_tracking,
+ &suite__fdarray__filter,
+ &suite__fdarray__add,
+ &suite__kmod_path__parse,
+ &suite__thread_map,
+ &suite__llvm,
+ &suite__session_topology,
+ &suite__bpf,
+ &suite__thread_map_synthesize,
+ &suite__thread_map_remove,
+ &suite__cpu_map_synthesize,
+ &suite__synthesize_stat_config,
+ &suite__synthesize_stat,
+ &suite__synthesize_stat_round,
+ &suite__event_update,
+ &suite__event_times,
+ &suite__backward_ring_buffer,
+ &suite__cpu_map_print,
+ &suite__cpu_map_merge,
+ &suite__sdt_event,
+ &suite__is_printable_array,
+ &suite__bitmap_print,
+ &suite__perf_hooks,
+ &suite__clang,
+ &suite__unit_number__scnprint,
+ &suite__mem2node,
+ &suite__time_utils,
+ &suite__jit_write_elf,
+ &suite__pfm,
+ &suite__api_io,
+ &suite__maps__merge_in,
+ &suite__demangle_java,
+ &suite__demangle_ocaml,
+ &suite__parse_metric,
+ &suite__pe_file_parsing,
+ &suite__expand_cgroup_events,
+ &suite__perf_time_to_tsc,
+ &suite__dlfilter,
NULL,
};

diff --git a/tools/perf/tests/clang.c b/tools/perf/tests/clang.c
index 2577d3ed1531..5052be1b5b20 100644
--- a/tools/perf/tests/clang.c
+++ b/tools/perf/tests/clang.c
@@ -19,12 +19,12 @@ static struct {
#endif
};

-int test__clang_subtest_get_nr(void)
+static int test__clang_subtest_get_nr(void)
{
return (int)ARRAY_SIZE(clang_testcase_table);
}

-const char *test__clang_subtest_get_desc(int i)
+static const char *test__clang_subtest_get_desc(int i)
{
if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table))
return NULL;
@@ -32,15 +32,25 @@ const char *test__clang_subtest_get_desc(int i)
}

#ifndef HAVE_LIBCLANGLLVM_SUPPORT
-int test__clang(struct test *test __maybe_unused, int i __maybe_unused)
+static int test__clang(struct test *test __maybe_unused, int i __maybe_unused)
{
return TEST_SKIP;
}
#else
-int test__clang(struct test *test __maybe_unused, int i)
+static int test__clang(struct test *test __maybe_unused, int i)
{
if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table))
return TEST_FAIL;
return clang_testcase_table[i].func();
}
#endif
+
+struct test suite__clang = {
+ .desc = "builtin clang support",
+ .func = test__clang,
+ .subtest = {
+ .skip_if_fail = true,
+ .get_nr = test__clang_subtest_get_nr,
+ .get_desc = test__clang_subtest_get_desc,
+ }
+};
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index 3a4d932e7ffc..4bdbc25f3750 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -716,7 +716,7 @@ static int do_test_code_reading(bool try_kcore)
return err;
}

-int test__code_reading(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__code_reading(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int ret;

@@ -743,3 +743,5 @@ int test__code_reading(struct test *test __maybe_unused, int subtest __maybe_unu
return -1;
};
}
+
+DEFINE_SUITE("Object code reading", code_reading);
diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c
index 0472b110fe65..6f2525fb9fd7 100644
--- a/tools/perf/tests/cpumap.c
+++ b/tools/perf/tests/cpumap.c
@@ -75,7 +75,7 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused,
}


-int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct perf_cpu_map *cpus;

@@ -111,7 +111,7 @@ static int cpu_map_print(const char *str)
return !strcmp(buf, str);
}

-int test__cpu_map_print(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__cpu_map_print(struct test *test __maybe_unused, int subtest __maybe_unused)
{
TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1"));
TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1,5"));
@@ -123,7 +123,7 @@ int test__cpu_map_print(struct test *test __maybe_unused, int subtest __maybe_un
return 0;
}

-int test__cpu_map_merge(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__cpu_map_merge(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct perf_cpu_map *a = perf_cpu_map__new("4,2,1");
struct perf_cpu_map *b = perf_cpu_map__new("4,5,7");
@@ -137,3 +137,7 @@ int test__cpu_map_merge(struct test *test __maybe_unused, int subtest __maybe_un
perf_cpu_map__put(c);
return 0;
}
+
+DEFINE_SUITE("Synthesize cpu map", cpu_map_synthesize);
+DEFINE_SUITE("Print cpu map", cpu_map_print);
+DEFINE_SUITE("Merge cpu map", cpu_map_merge);
diff --git a/tools/perf/tests/demangle-java-test.c b/tools/perf/tests/demangle-java-test.c
index 8f3b90832fb0..37f488e5c36d 100644
--- a/tools/perf/tests/demangle-java-test.c
+++ b/tools/perf/tests/demangle-java-test.c
@@ -7,7 +7,7 @@
#include "debug.h"
#include "demangle-java.h"

-int test__demangle_java(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__demangle_java(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int ret = TEST_OK;
char *buf = NULL;
@@ -40,3 +40,5 @@ int test__demangle_java(struct test *test __maybe_unused, int subtest __maybe_un

return ret;
}
+
+DEFINE_SUITE("Demangle Java", demangle_java);
diff --git a/tools/perf/tests/demangle-ocaml-test.c b/tools/perf/tests/demangle-ocaml-test.c
index 0043be812355..ee982cca7bbf 100644
--- a/tools/perf/tests/demangle-ocaml-test.c
+++ b/tools/perf/tests/demangle-ocaml-test.c
@@ -7,7 +7,7 @@
#include "debug.h"
#include "demangle-ocaml.h"

-int test__demangle_ocaml(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__demangle_ocaml(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int ret = TEST_OK;
char *buf = NULL;
@@ -41,3 +41,5 @@ int test__demangle_ocaml(struct test *test __maybe_unused, int subtest __maybe_u

return ret;
}
+
+DEFINE_SUITE("Demangle OCaml", demangle_ocaml);
diff --git a/tools/perf/tests/dlfilter-test.c b/tools/perf/tests/dlfilter-test.c
index bc03b5df6828..378f5afc6032 100644
--- a/tools/perf/tests/dlfilter-test.c
+++ b/tools/perf/tests/dlfilter-test.c
@@ -398,7 +398,7 @@ static void test_data__free(struct test_data *td)
}
}

-int test__dlfilter(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__dlfilter(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct test_data td = {.fd = -1};
int pid = getpid();
@@ -414,3 +414,5 @@ int test__dlfilter(struct test *test __maybe_unused, int subtest __maybe_unused)
test_data__free(&td);
return err;
}
+
+DEFINE_SUITE("dlfilter C API", dlfilter);
diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c
index 43e1b01e5afc..d9e060a7c1f6 100644
--- a/tools/perf/tests/dso-data.c
+++ b/tools/perf/tests/dso-data.c
@@ -113,7 +113,7 @@ static int dso__data_fd(struct dso *dso, struct machine *machine)
return fd;
}

-int test__dso_data(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__dso_data(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct machine machine;
struct dso *dso;
@@ -248,7 +248,7 @@ static int set_fd_limit(int n)
return setrlimit(RLIMIT_NOFILE, &rlim);
}

-int test__dso_data_cache(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__dso_data_cache(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct machine machine;
long nr_end, nr = open_files_cnt();
@@ -318,7 +318,7 @@ static long new_limit(int count)
return ret;
}

-int test__dso_data_reopen(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__dso_data_reopen(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct machine machine;
long nr_end, nr = open_files_cnt(), lim = new_limit(3);
@@ -393,3 +393,7 @@ int test__dso_data_reopen(struct test *test __maybe_unused, int subtest __maybe_
TEST_ASSERT_VAL("failed leaking files", nr == nr_end);
return 0;
}
+
+DEFINE_SUITE("DSO data read", dso_data);
+DEFINE_SUITE("DSO data cache", dso_data_cache);
+DEFINE_SUITE("DSO data reopen", dso_data_reopen);
diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
index 78b5a71957b7..74b500d42461 100644
--- a/tools/perf/tests/dwarf-unwind.c
+++ b/tools/perf/tests/dwarf-unwind.c
@@ -213,7 +213,4 @@ static int test__dwarf_unwind(struct test *test __maybe_unused, int subtest __ma
return err;
}

-struct test dwarf_unwind = {
- .desc = "Test dwarf unwind",
- .func = test__dwarf_unwind,
-};
+DEFINE_SUITE("Test dwarf unwind", dwarf_unwind);
diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-times.c
index 04ce4401f775..2ce8945931e7 100644
--- a/tools/perf/tests/event-times.c
+++ b/tools/perf/tests/event-times.c
@@ -216,7 +216,7 @@ static int test_times(int (attach)(struct evlist *),
* and checks that enabled and running times
* match.
*/
-int test__event_times(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__event_times(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int err, ret = 0;

@@ -239,3 +239,5 @@ int test__event_times(struct test *test __maybe_unused, int subtest __maybe_unus
#undef _T
return ret;
}
+
+DEFINE_SUITE("Event times", event_times);
diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_update.c
index 44a50527f9d9..9dfb665f8ac9 100644
--- a/tools/perf/tests/event_update.c
+++ b/tools/perf/tests/event_update.c
@@ -83,7 +83,7 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused,
return 0;
}

-int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct evsel *evsel;
struct event_name tmp;
@@ -123,3 +123,5 @@ int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unu
evlist__delete(evlist);
return 0;
}
+
+DEFINE_SUITE("Synthesize attr update", event_update);
diff --git a/tools/perf/tests/evsel-roundtrip-name.c b/tools/perf/tests/evsel-roundtrip-name.c
index 4e09f0a312af..82ff3c04d0bd 100644
--- a/tools/perf/tests/evsel-roundtrip-name.c
+++ b/tools/perf/tests/evsel-roundtrip-name.c
@@ -99,7 +99,8 @@ static int __perf_evsel__name_array_test(const char *names[], int nr_names,
#define perf_evsel__name_array_test(names, distance) \
__perf_evsel__name_array_test(names, ARRAY_SIZE(names), distance)

-int test__perf_evsel__roundtrip_name_test(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__perf_evsel__roundtrip_name_test(struct test *test __maybe_unused,
+ int subtest __maybe_unused)
{
int err = 0, ret = 0;

@@ -120,3 +121,5 @@ int test__perf_evsel__roundtrip_name_test(struct test *test __maybe_unused, int

return ret;
}
+
+DEFINE_SUITE("Roundtrip evsel->name", perf_evsel__roundtrip_name_test);
diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
index f9e34bd26cf3..58f17d18e4d5 100644
--- a/tools/perf/tests/evsel-tp-sched.c
+++ b/tools/perf/tests/evsel-tp-sched.c
@@ -32,7 +32,8 @@ static int evsel__test_field(struct evsel *evsel, const char *name, int size, bo
return ret;
}

-int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused,
+ int subtest __maybe_unused)
{
struct evsel *evsel = evsel__newtp("sched", "sched_switch");
int ret = 0;
@@ -87,3 +88,5 @@ int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtes
evsel__delete(evsel);
return ret;
}
+
+DEFINE_SUITE("Parse sched tracepoints fields", perf_evsel__tp_sched_test);
diff --git a/tools/perf/tests/expand-cgroup.c b/tools/perf/tests/expand-cgroup.c
index 0e46aeb843ce..577bc6c324b5 100644
--- a/tools/perf/tests/expand-cgroup.c
+++ b/tools/perf/tests/expand-cgroup.c
@@ -219,8 +219,8 @@ static int expand_metric_events(void)
return ret;
}

-int test__expand_cgroup_events(struct test *test __maybe_unused,
- int subtest __maybe_unused)
+static int test__expand_cgroup_events(struct test *test __maybe_unused,
+ int subtest __maybe_unused)
{
int ret;

@@ -238,3 +238,5 @@ int test__expand_cgroup_events(struct test *test __maybe_unused,

return ret;
}
+
+DEFINE_SUITE("Event expansion for cgroups", expand_cgroup_events);
diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c
index f1d8411fce12..b372e5cfa30c 100644
--- a/tools/perf/tests/expr.c
+++ b/tools/perf/tests/expr.c
@@ -62,7 +62,7 @@ static int test(struct expr_parse_ctx *ctx, const char *e, double val2)
return 0;
}

-int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)
+static int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)
{
struct expr_id_data *val_ptr;
const char *p;
@@ -154,3 +154,5 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)

return 0;
}
+
+DEFINE_SUITE("Simple expression parser", expr);
diff --git a/tools/perf/tests/fdarray.c b/tools/perf/tests/fdarray.c
index d9eca8e86a6b..7b2f6c2ad705 100644
--- a/tools/perf/tests/fdarray.c
+++ b/tools/perf/tests/fdarray.c
@@ -28,7 +28,7 @@ static int fdarray__fprintf_prefix(struct fdarray *fda, const char *prefix, FILE
return printed + fdarray__fprintf(fda, fp);
}

-int test__fdarray__filter(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__fdarray__filter(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int nr_fds, err = TEST_FAIL;
struct fdarray *fda = fdarray__new(5, 5);
@@ -89,7 +89,7 @@ int test__fdarray__filter(struct test *test __maybe_unused, int subtest __maybe_
return err;
}

-int test__fdarray__add(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__fdarray__add(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int err = TEST_FAIL;
struct fdarray *fda = fdarray__new(2, 2);
@@ -158,3 +158,6 @@ int test__fdarray__add(struct test *test __maybe_unused, int subtest __maybe_unu
out:
return err;
}
+
+DEFINE_SUITE("Filter fds with revents mask in a fdarray", fdarray__filter);
+DEFINE_SUITE("Add fd to a fdarray, making it autogrow", fdarray__add);
diff --git a/tools/perf/tests/genelf.c b/tools/perf/tests/genelf.c
index f797f9823e89..3c5ced5d9588 100644
--- a/tools/perf/tests/genelf.c
+++ b/tools/perf/tests/genelf.c
@@ -16,8 +16,8 @@

#define TEMPL "/tmp/perf-test-XXXXXX"

-int test__jit_write_elf(struct test *test __maybe_unused,
- int subtest __maybe_unused)
+static int test__jit_write_elf(struct test *test __maybe_unused,
+ int subtest __maybe_unused)
{
#ifdef HAVE_JITDUMP
static unsigned char x86_code[] = {
@@ -49,3 +49,5 @@ int test__jit_write_elf(struct test *test __maybe_unused,
return TEST_SKIP;
#endif
}
+
+DEFINE_SUITE("Test jit_write_elf", jit_write_elf);
diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c
index 890cb1f5bf53..f7a8d3d78389 100644
--- a/tools/perf/tests/hists_cumulate.c
+++ b/tools/perf/tests/hists_cumulate.c
@@ -689,7 +689,7 @@ static int test4(struct evsel *evsel, struct machine *machine)
return err;
}

-int test__hists_cumulate(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__hists_cumulate(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int err = TEST_FAIL;
struct machines machines;
@@ -736,3 +736,5 @@ int test__hists_cumulate(struct test *test __maybe_unused, int subtest __maybe_u

return err;
}
+
+DEFINE_SUITE("Cumulate child hist entries", hists_cumulate);
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c
index ca6120cd1d90..09e140191e5f 100644
--- a/tools/perf/tests/hists_filter.c
+++ b/tools/perf/tests/hists_filter.c
@@ -101,7 +101,7 @@ static int add_hist_entries(struct evlist *evlist,
return TEST_FAIL;
}

-int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int err = TEST_FAIL;
struct machines machines;
@@ -325,3 +325,5 @@ int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unu

return err;
}
+
+DEFINE_SUITE("Filter hist entries", hists_filter);
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index a024d3f3a412..08571f788884 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -264,7 +264,7 @@ static int validate_link(struct hists *leader, struct hists *other)
return __validate_link(leader, 0) || __validate_link(other, 1);
}

-int test__hists_link(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__hists_link(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int err = -1;
struct hists *hists, *first_hists;
@@ -339,3 +339,5 @@ int test__hists_link(struct test *test __maybe_unused, int subtest __maybe_unuse

return err;
}
+
+DEFINE_SUITE("Match and link multiple hists", hists_link);
diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c
index 8973f35df604..b427df8ee94a 100644
--- a/tools/perf/tests/hists_output.c
+++ b/tools/perf/tests/hists_output.c
@@ -575,7 +575,7 @@ static int test5(struct evsel *evsel, struct machine *machine)
return err;
}

-int test__hists_output(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__hists_output(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int err = TEST_FAIL;
struct machines machines;
@@ -623,3 +623,5 @@ int test__hists_output(struct test *test __maybe_unused, int subtest __maybe_unu

return err;
}
+
+DEFINE_SUITE("Sort output of hist entries", hists_output);
diff --git a/tools/perf/tests/is_printable_array.c b/tools/perf/tests/is_printable_array.c
index 9c7b3baca4fe..8891b10fac5c 100644
--- a/tools/perf/tests/is_printable_array.c
+++ b/tools/perf/tests/is_printable_array.c
@@ -5,7 +5,7 @@
#include "debug.h"
#include "print_binary.h"

-int test__is_printable_array(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__is_printable_array(struct test *test __maybe_unused, int subtest __maybe_unused)
{
char buf1[] = { 'k', 'r', 4, 'v', 'a', 0 };
char buf2[] = { 'k', 'r', 'a', 'v', 4, 0 };
@@ -36,3 +36,5 @@ int test__is_printable_array(struct test *test __maybe_unused, int subtest __may

return TEST_OK;
}
+
+DEFINE_SUITE("is_printable_array", is_printable_array);
diff --git a/tools/perf/tests/keep-tracking.c b/tools/perf/tests/keep-tracking.c
index a0438b0f0805..e723c976dc81 100644
--- a/tools/perf/tests/keep-tracking.c
+++ b/tools/perf/tests/keep-tracking.c
@@ -61,7 +61,7 @@ static int find_comm(struct evlist *evlist, const char *comm)
* when an event is disabled but a dummy software event is not disabled. If the
* test passes %0 is returned, otherwise %-1 is returned.
*/
-int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct record_opts opts = {
.mmap_pages = UINT_MAX,
@@ -160,3 +160,5 @@ int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_un

return err;
}
+
+DEFINE_SUITE("Use a dummy software event to keep tracking", keep_tracking);
diff --git a/tools/perf/tests/kmod-path.c b/tools/perf/tests/kmod-path.c
index e483210b176b..4935dd3182ed 100644
--- a/tools/perf/tests/kmod-path.c
+++ b/tools/perf/tests/kmod-path.c
@@ -47,7 +47,7 @@ static int test_is_kernel_module(const char *path, int cpumode, bool expect)
#define M(path, c, e) \
TEST_ASSERT_VAL("failed", !test_is_kernel_module(path, c, e))

-int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unused)
+static int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unused)
{
/* path alloc_name kmod comp name */
T("/xxxx/xxxx/x-x.ko", true , true, 0 , "[x_x]");
@@ -159,3 +159,5 @@ int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_un

return 0;
}
+
+DEFINE_SUITE("kmod_path__parse", kmod_path__parse);
diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
index 33e43cce9064..b605a71ad8d5 100644
--- a/tools/perf/tests/llvm.c
+++ b/tools/perf/tests/llvm.c
@@ -124,7 +124,7 @@ test_llvm__fetch_bpf_obj(void **p_obj_buf,
return ret;
}

-int test__llvm(struct test *test __maybe_unused, int subtest)
+static int test__llvm(struct test *test __maybe_unused, int subtest)
{
int ret;
void *obj_buf = NULL;
@@ -149,12 +149,12 @@ int test__llvm(struct test *test __maybe_unused, int subtest)
return ret;
}

-int test__llvm_subtest_get_nr(void)
+static int test__llvm_subtest_get_nr(void)
{
return __LLVM_TESTCASE_MAX;
}

-const char *test__llvm_subtest_get_desc(int subtest)
+static const char *test__llvm_subtest_get_desc(int subtest)
{
if ((subtest < 0) || (subtest >= __LLVM_TESTCASE_MAX))
return NULL;
@@ -162,18 +162,28 @@ const char *test__llvm_subtest_get_desc(int subtest)
return bpf_source_table[subtest].desc;
}
#else //HAVE_LIBBPF_SUPPORT
-int test__llvm(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__llvm(struct test *test __maybe_unused, int subtest __maybe_unused)
{
return TEST_SKIP;
}

-int test__llvm_subtest_get_nr(void)
+static int test__llvm_subtest_get_nr(void)
{
return 0;
}

-const char *test__llvm_subtest_get_desc(int subtest __maybe_unused)
+static const char *test__llvm_subtest_get_desc(int subtest __maybe_unused)
{
return NULL;
}
#endif // HAVE_LIBBPF_SUPPORT
+
+struct test suite__llvm = {
+ .desc = "LLVM search and compile",
+ .func = test__llvm,
+ .subtest = {
+ .skip_if_fail = true,
+ .get_nr = test__llvm_subtest_get_nr,
+ .get_desc = test__llvm_subtest_get_desc,
+ },
+};
diff --git a/tools/perf/tests/maps.c b/tools/perf/tests/maps.c
index 1ac72919fa35..4a2e6f312015 100644
--- a/tools/perf/tests/maps.c
+++ b/tools/perf/tests/maps.c
@@ -33,7 +33,7 @@ static int check_maps(struct map_def *merged, unsigned int size, struct maps *ma
return TEST_OK;
}

-int test__maps__merge_in(struct test *t __maybe_unused, int subtest __maybe_unused)
+static int test__maps__merge_in(struct test *t __maybe_unused, int subtest __maybe_unused)
{
struct maps maps;
unsigned int i;
@@ -120,3 +120,5 @@ int test__maps__merge_in(struct test *t __maybe_unused, int subtest __maybe_unus
maps__exit(&maps);
return TEST_OK;
}
+
+DEFINE_SUITE("maps__merge_in", maps__merge_in);
diff --git a/tools/perf/tests/mem.c b/tools/perf/tests/mem.c
index 673a11a6cd1b..3af082508653 100644
--- a/tools/perf/tests/mem.c
+++ b/tools/perf/tests/mem.c
@@ -23,7 +23,7 @@ static int check(union perf_mem_data_src data_src,
return 0;
}

-int test__mem(struct test *text __maybe_unused, int subtest __maybe_unused)
+static int test__mem(struct test *text __maybe_unused, int subtest __maybe_unused)
{
int ret = 0;
union perf_mem_data_src src;
@@ -56,3 +56,5 @@ int test__mem(struct test *text __maybe_unused, int subtest __maybe_unused)

return ret;
}
+
+DEFINE_SUITE("Test data source output", mem);
diff --git a/tools/perf/tests/mem2node.c b/tools/perf/tests/mem2node.c
index e4d0d58b97f8..0a90e6084d81 100644
--- a/tools/perf/tests/mem2node.c
+++ b/tools/perf/tests/mem2node.c
@@ -43,7 +43,7 @@ static unsigned long *get_bitmap(const char *str, int nbits)
return bm && map ? bm : NULL;
}

-int test__mem2node(struct test *t __maybe_unused, int subtest __maybe_unused)
+static int test__mem2node(struct test *t __maybe_unused, int subtest __maybe_unused)
{
struct mem2node map;
struct memory_node nodes[3];
@@ -77,3 +77,5 @@ int test__mem2node(struct test *t __maybe_unused, int subtest __maybe_unused)
mem2node__exit(&map);
return 0;
}
+
+DEFINE_SUITE("mem2node", mem2node);
diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
index d38757db2dc2..86f34631312d 100644
--- a/tools/perf/tests/mmap-basic.c
+++ b/tools/perf/tests/mmap-basic.c
@@ -29,7 +29,7 @@
* Then it checks if the number of syscalls reported as perf events by
* the kernel corresponds to the number of syscalls made.
*/
-int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int err = -1;
union perf_event *event;
@@ -164,3 +164,5 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unuse
perf_thread_map__put(threads);
return err;
}
+
+DEFINE_SUITE("Read samples using the mmap interface", basic_mmap);
diff --git a/tools/perf/tests/mmap-thread-lookup.c b/tools/perf/tests/mmap-thread-lookup.c
index 6f2da7a72f67..756a46c796f7 100644
--- a/tools/perf/tests/mmap-thread-lookup.c
+++ b/tools/perf/tests/mmap-thread-lookup.c
@@ -224,7 +224,7 @@ static int mmap_events(synth_cb synth)
*
* by using all thread objects.
*/
-int test__mmap_thread_lookup(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__mmap_thread_lookup(struct test *test __maybe_unused, int subtest __maybe_unused)
{
/* perf_event__synthesize_threads synthesize */
TEST_ASSERT_VAL("failed with sythesizing all",
@@ -236,3 +236,5 @@ int test__mmap_thread_lookup(struct test *test __maybe_unused, int subtest __may

return 0;
}
+
+DEFINE_SUITE("Lookup mmap thread", mmap_thread_lookup);
diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c
index f7dd6c463f04..28f3597ba531 100644
--- a/tools/perf/tests/openat-syscall-all-cpus.c
+++ b/tools/perf/tests/openat-syscall-all-cpus.c
@@ -19,7 +19,8 @@
#include "stat.h"
#include "util/counts.h"

-int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused,
+ int subtest __maybe_unused)
{
int err = -1, fd, cpu;
struct perf_cpu_map *cpus;
@@ -127,3 +128,5 @@ int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, int
perf_thread_map__put(threads);
return err;
}
+
+DEFINE_SUITE("Detect openat syscall event on all cpus", openat_syscall_event_on_all_cpus);
diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c
index 5e4af2f0f14a..cbb5c0fa40fe 100644
--- a/tools/perf/tests/openat-syscall-tp-fields.c
+++ b/tools/perf/tests/openat-syscall-tp-fields.c
@@ -22,7 +22,8 @@
#define AT_FDCWD -100
#endif

-int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__syscall_openat_tp_fields(struct test *test __maybe_unused,
+ int subtest __maybe_unused)
{
struct record_opts opts = {
.target = {
@@ -142,3 +143,5 @@ int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtest
out:
return err;
}
+
+DEFINE_SUITE("syscalls:sys_enter_openat event fields", syscall_openat_tp_fields);
diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c
index 85a8f0fe7aea..8f904fcebe6f 100644
--- a/tools/perf/tests/openat-syscall.c
+++ b/tools/perf/tests/openat-syscall.c
@@ -13,7 +13,8 @@
#include "tests.h"
#include "util/counts.h"

-int test__openat_syscall_event(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__openat_syscall_event(struct test *test __maybe_unused,
+ int subtest __maybe_unused)
{
int err = -1, fd;
struct evsel *evsel;
@@ -66,3 +67,5 @@ int test__openat_syscall_event(struct test *test __maybe_unused, int subtest __m
perf_thread_map__put(threads);
return err;
}
+
+DEFINE_SUITE("Detect openat syscall event", openat_syscall_event);
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 8875e388563e..b6232aa6975b 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -2276,7 +2276,7 @@ static int test_pmu_events_alias(char *event, char *alias)
return test_event(&e);
}

-int test__parse_events(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__parse_events(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int ret1, ret2 = 0;
char *event, *alias;
@@ -2319,3 +2319,5 @@ do { \

return ret2;
}
+
+DEFINE_SUITE("Parse event definition strings", parse_events);
diff --git a/tools/perf/tests/parse-metric.c b/tools/perf/tests/parse-metric.c
index 4f6f4904e852..86568cb937a9 100644
--- a/tools/perf/tests/parse-metric.c
+++ b/tools/perf/tests/parse-metric.c
@@ -369,7 +369,7 @@ static int test_metric_group(void)
return 0;
}

-int test__parse_metric(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__parse_metric(struct test *test __maybe_unused, int subtest __maybe_unused)
{
TEST_ASSERT_VAL("IPC failed", test_ipc() == 0);
TEST_ASSERT_VAL("frontend failed", test_frontend() == 0);
@@ -383,3 +383,5 @@ int test__parse_metric(struct test *test __maybe_unused, int subtest __maybe_unu
}
return 0;
}
+
+DEFINE_SUITE("Parse and process metrics", parse_metric);
diff --git a/tools/perf/tests/parse-no-sample-id-all.c b/tools/perf/tests/parse-no-sample-id-all.c
index 471273676701..2a5eec424a43 100644
--- a/tools/perf/tests/parse-no-sample-id-all.c
+++ b/tools/perf/tests/parse-no-sample-id-all.c
@@ -67,7 +67,8 @@ struct test_attr_event {
*
* Return: %0 on success, %-1 if the test fails.
*/
-int test__parse_no_sample_id_all(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__parse_no_sample_id_all(struct test *test __maybe_unused,
+ int subtest __maybe_unused)
{
int err;

@@ -103,3 +104,5 @@ int test__parse_no_sample_id_all(struct test *test __maybe_unused, int subtest _

return 0;
}
+
+DEFINE_SUITE("Parse with no sample_id_all bit set", parse_no_sample_id_all);
diff --git a/tools/perf/tests/pe-file-parsing.c b/tools/perf/tests/pe-file-parsing.c
index 58b90c42eb38..8d4fec99459a 100644
--- a/tools/perf/tests/pe-file-parsing.c
+++ b/tools/perf/tests/pe-file-parsing.c
@@ -68,7 +68,7 @@ static int run_dir(const char *d)
return TEST_OK;
}

-int test__pe_file_parsing(struct test *test __maybe_unused,
+static int test__pe_file_parsing(struct test *test __maybe_unused,
int subtest __maybe_unused)
{
struct stat st;
@@ -89,10 +89,12 @@ int test__pe_file_parsing(struct test *test __maybe_unused,

#else

-int test__pe_file_parsing(struct test *test __maybe_unused,
+static int test__pe_file_parsing(struct test *test __maybe_unused,
int subtest __maybe_unused)
{
return TEST_SKIP;
}

#endif
+
+DEFINE_SUITE("PE file support", pe_file_parsing);
diff --git a/tools/perf/tests/perf-hooks.c b/tools/perf/tests/perf-hooks.c
index dd865e0bea12..61cb1d0a6eb9 100644
--- a/tools/perf/tests/perf-hooks.c
+++ b/tools/perf/tests/perf-hooks.c
@@ -26,7 +26,7 @@ static void the_hook(void *_hook_flags)
raise(SIGSEGV);
}

-int test__perf_hooks(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__perf_hooks(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int hook_flags = 0;

@@ -45,3 +45,5 @@ int test__perf_hooks(struct test *test __maybe_unused, int subtest __maybe_unuse
return TEST_FAIL;
return TEST_OK;
}
+
+DEFINE_SUITE("perf hooks", perf_hooks);
diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
index 0df471bf1590..24faa8487d8c 100644
--- a/tools/perf/tests/perf-record.c
+++ b/tools/perf/tests/perf-record.c
@@ -41,7 +41,7 @@ static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t *maskp)
return cpu;
}

-int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct record_opts opts = {
.target = {
@@ -332,3 +332,5 @@ int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unus
out:
return (err < 0 || errs > 0) ? -1 : 0;
}
+
+DEFINE_SUITE("PERF_RECORD_* events & perf_sample fields", PERF_RECORD);
diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c
index 7c56bc1f4cff..dc2dcad7371f 100644
--- a/tools/perf/tests/perf-time-to-tsc.c
+++ b/tools/perf/tests/perf-time-to-tsc.c
@@ -45,7 +45,7 @@
* %0 is returned, otherwise %-1 is returned. If TSC conversion is not
* supported then then the test passes but " (not supported)" is printed.
*/
-int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct record_opts opts = {
.mmap_pages = UINT_MAX,
@@ -185,7 +185,7 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe
return err;
}

-bool test__tsc_is_supported(void)
+static bool test__tsc_is_supported(void)
{
/*
* Except x86_64/i386 and Arm64, other archs don't support TSC in perf.
@@ -197,3 +197,9 @@ bool test__tsc_is_supported(void)
return false;
#endif
}
+
+struct test suite__perf_time_to_tsc = {
+ .desc = "Convert perf time to TSC",
+ .func = test__perf_time_to_tsc,
+ .is_supported = test__tsc_is_supported,
+};
diff --git a/tools/perf/tests/pfm.c b/tools/perf/tests/pfm.c
index e8fd0da0762b..83dc9742813a 100644
--- a/tools/perf/tests/pfm.c
+++ b/tools/perf/tests/pfm.c
@@ -189,19 +189,19 @@ static int test__pfm_group(void)
}
#endif

-const char *test__pfm_subtest_get_desc(int i)
+static const char *test__pfm_subtest_get_desc(int i)
{
if (i < 0 || i >= (int)ARRAY_SIZE(pfm_testcase_table))
return NULL;
return pfm_testcase_table[i].desc;
}

-int test__pfm_subtest_get_nr(void)
+static int test__pfm_subtest_get_nr(void)
{
return (int)ARRAY_SIZE(pfm_testcase_table);
}

-int test__pfm(struct test *test __maybe_unused, int i __maybe_unused)
+static int test__pfm(struct test *test __maybe_unused, int i __maybe_unused)
{
#ifdef HAVE_LIBPFM
if (i < 0 || i >= (int)ARRAY_SIZE(pfm_testcase_table))
@@ -211,3 +211,13 @@ int test__pfm(struct test *test __maybe_unused, int i __maybe_unused)
return TEST_SKIP;
#endif
}
+
+struct test suite__pfm = {
+ .desc = "Test libpfm4 support",
+ .func = test__pfm,
+ .subtest = {
+ .skip_if_fail = true,
+ .get_nr = test__pfm_subtest_get_nr,
+ .get_desc = test__pfm_subtest_get_desc,
+ }
+};
diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index d3534960ed25..5d84cc92d3ce 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -1081,7 +1081,7 @@ static const struct {
},
};

-const char *test__pmu_events_subtest_get_desc(int subtest)
+static const char *test__pmu_events_subtest_get_desc(int subtest)
{
if (subtest < 0 ||
subtest >= (int)ARRAY_SIZE(pmu_events_testcase_table))
@@ -1089,7 +1089,7 @@ const char *test__pmu_events_subtest_get_desc(int subtest)
return pmu_events_testcase_table[subtest].desc;
}

-const char *test__pmu_events_subtest_skip_reason(int subtest)
+static const char *test__pmu_events_subtest_skip_reason(int subtest)
{
if (subtest < 0 ||
subtest >= (int)ARRAY_SIZE(pmu_events_testcase_table))
@@ -1099,15 +1099,26 @@ const char *test__pmu_events_subtest_skip_reason(int subtest)
return "some metrics failed";
}

-int test__pmu_events_subtest_get_nr(void)
+static int test__pmu_events_subtest_get_nr(void)
{
return (int)ARRAY_SIZE(pmu_events_testcase_table);
}

-int test__pmu_events(struct test *test __maybe_unused, int subtest)
+static int test__pmu_events(struct test *test __maybe_unused, int subtest)
{
if (subtest < 0 ||
subtest >= (int)ARRAY_SIZE(pmu_events_testcase_table))
return TEST_FAIL;
return pmu_events_testcase_table[subtest].func();
}
+
+struct test suite__pmu_events = {
+ .desc = "PMU events",
+ .func = test__pmu_events,
+ .subtest = {
+ .skip_if_fail = false,
+ .get_nr = test__pmu_events_subtest_get_nr,
+ .get_desc = test__pmu_events_subtest_get_desc,
+ .skip_reason = test__pmu_events_subtest_skip_reason,
+ },
+};
diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c
index 714e6830a758..9a58dad67b27 100644
--- a/tools/perf/tests/pmu.c
+++ b/tools/perf/tests/pmu.c
@@ -137,7 +137,7 @@ static struct list_head *test_terms_list(void)
return &terms;
}

-int test__pmu(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__pmu(struct test *test __maybe_unused, int subtest __maybe_unused)
{
char *format = test_format_dir_get();
LIST_HEAD(formats);
@@ -177,3 +177,5 @@ int test__pmu(struct test *test __maybe_unused, int subtest __maybe_unused)
test_format_dir_put(format);
return ret;
}
+
+DEFINE_SUITE("Parse perf pmu format", pmu);
diff --git a/tools/perf/tests/python-use.c b/tools/perf/tests/python-use.c
index 98c6d474aa6f..b667140688be 100644
--- a/tools/perf/tests/python-use.c
+++ b/tools/perf/tests/python-use.c
@@ -9,7 +9,7 @@
#include "tests.h"
#include "util/debug.h"

-int test__python_use(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__python_use(struct test *test __maybe_unused, int subtest __maybe_unused)
{
char *cmd;
int ret;
@@ -23,3 +23,5 @@ int test__python_use(struct test *test __maybe_unused, int subtest __maybe_unuse
free(cmd);
return ret;
}
+
+DEFINE_SUITE("'import perf' in python", python_use);
diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c
index 8fd8a4ef97da..667518df58a3 100644
--- a/tools/perf/tests/sample-parsing.c
+++ b/tools/perf/tests/sample-parsing.c
@@ -335,7 +335,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format)
* checks sample format bits separately and together. If the test passes %0 is
* returned, otherwise %-1 is returned.
*/
-int test__sample_parsing(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__sample_parsing(struct test *test __maybe_unused, int subtest __maybe_unused)
{
const u64 rf[] = {4, 5, 6, 7, 12, 13, 14, 15};
u64 sample_type;
@@ -393,3 +393,5 @@ int test__sample_parsing(struct test *test __maybe_unused, int subtest __maybe_u

return 0;
}
+
+DEFINE_SUITE("Sample parsing", sample_parsing);
diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c
index ed76c693f65e..307615f1b6a7 100644
--- a/tools/perf/tests/sdt.c
+++ b/tools/perf/tests/sdt.c
@@ -76,7 +76,7 @@ static int search_cached_probe(const char *target,
return ret;
}

-int test__sdt_event(struct test *test __maybe_unused, int subtests __maybe_unused)
+static int test__sdt_event(struct test *test __maybe_unused, int subtests __maybe_unused)
{
int ret = TEST_FAIL;
char __tempdir[] = "./test-buildid-XXXXXX";
@@ -114,9 +114,11 @@ int test__sdt_event(struct test *test __maybe_unused, int subtests __maybe_unuse
return ret;
}
#else
-int test__sdt_event(struct test *test __maybe_unused, int subtests __maybe_unused)
+static int test__sdt_event(struct test *test __maybe_unused, int subtests __maybe_unused)
{
pr_debug("Skip SDT event test because SDT support is not compiled\n");
return TEST_SKIP;
}
#endif
+
+DEFINE_SUITE("Probe SDT events", sdt_event);
diff --git a/tools/perf/tests/stat.c b/tools/perf/tests/stat.c
index c1911501c39c..2589f2f529ba 100644
--- a/tools/perf/tests/stat.c
+++ b/tools/perf/tests/stat.c
@@ -47,7 +47,8 @@ static int process_stat_config_event(struct perf_tool *tool __maybe_unused,
return 0;
}

-int test__synthesize_stat_config(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__synthesize_stat_config(struct test *test __maybe_unused,
+ int subtest __maybe_unused)
{
struct perf_stat_config stat_config = {
.aggr_mode = AGGR_CORE,
@@ -77,7 +78,7 @@ static int process_stat_event(struct perf_tool *tool __maybe_unused,
return 0;
}

-int test__synthesize_stat(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__synthesize_stat(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct perf_counts_values count;

@@ -103,7 +104,7 @@ static int process_stat_round_event(struct perf_tool *tool __maybe_unused,
return 0;
}

-int test__synthesize_stat_round(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__synthesize_stat_round(struct test *test __maybe_unused, int subtest __maybe_unused)
{
TEST_ASSERT_VAL("failed to synthesize stat_config",
!perf_event__synthesize_stat_round(NULL, 0xdeadbeef, PERF_STAT_ROUND_TYPE__INTERVAL,
@@ -111,3 +112,7 @@ int test__synthesize_stat_round(struct test *test __maybe_unused, int subtest __

return 0;
}
+
+DEFINE_SUITE("Synthesize stat config", synthesize_stat_config);
+DEFINE_SUITE("Synthesize stat", synthesize_stat);
+DEFINE_SUITE("Synthesize stat round", synthesize_stat_round);
diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c
index 74988846be1d..db1e339a0fbe 100644
--- a/tools/perf/tests/sw-clock.c
+++ b/tools/perf/tests/sw-clock.c
@@ -133,7 +133,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
return err;
}

-int test__sw_clock_freq(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__sw_clock_freq(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int ret;

@@ -143,3 +143,5 @@ int test__sw_clock_freq(struct test *test __maybe_unused, int subtest __maybe_un

return ret;
}
+
+DEFINE_SUITE("Software clock events period values", sw_clock_freq);
diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c
index 62c0ec21aaa8..9b379aaddce4 100644
--- a/tools/perf/tests/switch-tracking.c
+++ b/tools/perf/tests/switch-tracking.c
@@ -321,7 +321,7 @@ static int process_events(struct evlist *evlist,
* evsel->core.system_wide and evsel->tracking flags (respectively) with other events
* sometimes enabled or disabled.
*/
-int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_unused)
{
const char *sched_switch = "sched:sched_switch";
struct switch_tracking switch_tracking = { .tids = NULL, };
@@ -588,3 +588,5 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_
err = -1;
goto out;
}
+
+DEFINE_SUITE("Track with sched_switch", switch_tracking);
diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c
index 4c2969db59b0..197574230493 100644
--- a/tools/perf/tests/task-exit.c
+++ b/tools/perf/tests/task-exit.c
@@ -39,7 +39,7 @@ static void workload_exec_failed_signal(int signo __maybe_unused,
* if the number of exit event reported by the kernel is 1 or not
* in order to check the kernel returns correct number of event.
*/
-int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused)
{
int err = -1;
union perf_event *event;
@@ -151,3 +151,5 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused
evlist__delete(evlist);
return err;
}
+
+DEFINE_SUITE("Number of exit events of a simple workload", task_exit);
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 8323a3c88284..f2efa331b32f 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -41,10 +41,10 @@ struct test {
};

#define DECLARE_SUITE(name) \
- int test__##name(struct test *test, int subtest)
+ extern struct test suite__##name;

#define DEFINE_SUITE(description, name) \
- static struct test name = { \
+ struct test suite__##name = { \
.desc = description, \
.func = test__##name, \
}
@@ -60,9 +60,6 @@ DECLARE_SUITE(perf_evsel__tp_sched_test);
DECLARE_SUITE(syscall_openat_tp_fields);
DECLARE_SUITE(pmu);
DECLARE_SUITE(pmu_events);
-const char *test__pmu_events_subtest_get_desc(int subtest);
-const char *test__pmu_events_subtest_skip_reason(int subtest);
-int test__pmu_events_subtest_get_nr(void);
DECLARE_SUITE(attr);
DECLARE_SUITE(dso_data);
DECLARE_SUITE(dso_data_cache);
@@ -74,9 +71,6 @@ DECLARE_SUITE(bp_signal);
DECLARE_SUITE(bp_signal_overflow);
DECLARE_SUITE(bp_accounting);
DECLARE_SUITE(wp);
-const char *test__wp_subtest_get_desc(int subtest);
-const char *test__wp_subtest_skip_reason(int subtest);
-int test__wp_subtest_get_nr(void);
DECLARE_SUITE(task_exit);
DECLARE_SUITE(mem);
DECLARE_SUITE(sw_clock_freq);
@@ -84,7 +78,7 @@ DECLARE_SUITE(code_reading);
DECLARE_SUITE(sample_parsing);
DECLARE_SUITE(keep_tracking);
DECLARE_SUITE(parse_no_sample_id_all);
-extern struct test dwarf_unwind;
+DECLARE_SUITE(dwarf_unwind);
DECLARE_SUITE(expr);
DECLARE_SUITE(hists_filter);
DECLARE_SUITE(mmap_thread_lookup);
@@ -97,11 +91,7 @@ DECLARE_SUITE(fdarray__add);
DECLARE_SUITE(kmod_path__parse);
DECLARE_SUITE(thread_map);
DECLARE_SUITE(llvm);
-const char *test__llvm_subtest_get_desc(int subtest);
-int test__llvm_subtest_get_nr(void);
DECLARE_SUITE(bpf);
-const char *test__bpf_subtest_get_desc(int subtest);
-int test__bpf_subtest_get_nr(void);
DECLARE_SUITE(session_topology);
DECLARE_SUITE(thread_map_synthesize);
DECLARE_SUITE(thread_map_remove);
@@ -119,8 +109,6 @@ DECLARE_SUITE(is_printable_array);
DECLARE_SUITE(bitmap_print);
DECLARE_SUITE(perf_hooks);
DECLARE_SUITE(clang);
-const char *test__clang_subtest_get_desc(int subtest);
-int test__clang_subtest_get_nr(void);
DECLARE_SUITE(unit_number__scnprint);
DECLARE_SUITE(mem2node);
DECLARE_SUITE(maps__merge_in);
@@ -130,8 +118,6 @@ DECLARE_SUITE(api_io);
DECLARE_SUITE(demangle_java);
DECLARE_SUITE(demangle_ocaml);
DECLARE_SUITE(pfm);
-const char *test__pfm_subtest_get_desc(int subtest);
-int test__pfm_subtest_get_nr(void);
DECLARE_SUITE(parse_metric);
DECLARE_SUITE(pe_file_parsing);
DECLARE_SUITE(expand_cgroup_events);
@@ -139,9 +125,6 @@ DECLARE_SUITE(perf_time_to_tsc);
DECLARE_SUITE(dlfilter);

bool test__bp_signal_is_supported(void);
-bool test__bp_account_is_supported(void);
-bool test__wp_is_supported(void);
-bool test__tsc_is_supported(void);

#ifdef HAVE_DWARF_UNWIND_SUPPORT
struct thread;
diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c
index d1e208b4a571..7e2e8a72fa78 100644
--- a/tools/perf/tests/thread-map.c
+++ b/tools/perf/tests/thread-map.c
@@ -19,7 +19,7 @@ struct machine;
#define NAME (const char *) "perf"
#define NAMEUL (unsigned long) NAME

-int test__thread_map(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__thread_map(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct perf_thread_map *map;

@@ -86,7 +86,7 @@ static int process_event(struct perf_tool *tool __maybe_unused,
return 0;
}

-int test__thread_map_synthesize(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__thread_map_synthesize(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct perf_thread_map *threads;

@@ -106,7 +106,7 @@ int test__thread_map_synthesize(struct test *test __maybe_unused, int subtest __
return 0;
}

-int test__thread_map_remove(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__thread_map_remove(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct perf_thread_map *threads;
char *str;
@@ -145,3 +145,7 @@ int test__thread_map_remove(struct test *test __maybe_unused, int subtest __mayb
perf_thread_map__put(threads);
return 0;
}
+
+DEFINE_SUITE("Thread map", thread_map);
+DEFINE_SUITE("Synthesize thread map", thread_map_synthesize);
+DEFINE_SUITE("Remove thread map", thread_map_remove);
diff --git a/tools/perf/tests/thread-maps-share.c b/tools/perf/tests/thread-maps-share.c
index 9371484973f2..2821be0a9a05 100644
--- a/tools/perf/tests/thread-maps-share.c
+++ b/tools/perf/tests/thread-maps-share.c
@@ -4,7 +4,7 @@
#include "thread.h"
#include "debug.h"

-int test__thread_maps_share(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__thread_maps_share(struct test *test __maybe_unused, int subtest __maybe_unused)
{
struct machines machines;
struct machine *machine;
@@ -96,3 +96,5 @@ int test__thread_maps_share(struct test *test __maybe_unused, int subtest __mayb
machines__exit(&machines);
return 0;
}
+
+DEFINE_SUITE("Share thread maps", thread_maps_share);
diff --git a/tools/perf/tests/time-utils-test.c b/tools/perf/tests/time-utils-test.c
index fe57ca3b6e54..538100cb7541 100644
--- a/tools/perf/tests/time-utils-test.c
+++ b/tools/perf/tests/time-utils-test.c
@@ -131,7 +131,7 @@ static bool test__perf_time__parse_for_ranges(struct test_data *d)
return pass;
}

-int test__time_utils(struct test *t __maybe_unused, int subtest __maybe_unused)
+static int test__time_utils(struct test *t __maybe_unused, int subtest __maybe_unused)
{
bool pass = true;

@@ -249,3 +249,5 @@ int test__time_utils(struct test *t __maybe_unused, int subtest __maybe_unused)

return pass ? 0 : TEST_FAIL;
}
+
+DEFINE_SUITE("time utils", time_utils);
diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c
index b9028e304ddd..05fda3955f95 100644
--- a/tools/perf/tests/topology.c
+++ b/tools/perf/tests/topology.c
@@ -173,7 +173,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)
return 0;
}

-int test__session_topology(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__session_topology(struct test *test __maybe_unused, int subtest __maybe_unused)
{
char path[PATH_MAX];
struct perf_cpu_map *map;
@@ -199,3 +199,5 @@ int test__session_topology(struct test *test __maybe_unused, int subtest __maybe
unlink(path);
return ret;
}
+
+DEFINE_SUITE("Session topology", session_topology);
diff --git a/tools/perf/tests/unit_number__scnprintf.c b/tools/perf/tests/unit_number__scnprintf.c
index 3721757435da..2ad78a9473d4 100644
--- a/tools/perf/tests/unit_number__scnprintf.c
+++ b/tools/perf/tests/unit_number__scnprintf.c
@@ -7,7 +7,7 @@
#include "units.h"
#include "debug.h"

-int test__unit_number__scnprint(struct test *t __maybe_unused, int subtest __maybe_unused)
+static int test__unit_number__scnprint(struct test *t __maybe_unused, int subtest __maybe_unused)
{
struct {
u64 n;
@@ -38,3 +38,5 @@ int test__unit_number__scnprint(struct test *t __maybe_unused, int subtest __may

return TEST_OK;
}
+
+DEFINE_SUITE("unit_number__scnprintf", unit_number__scnprint);
diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index 4f884aabc7f4..7f1b74bf4f13 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -111,7 +111,8 @@ static bool is_ignored_symbol(const char *name, char type)
return false;
}

-int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused,
+ int subtest __maybe_unused)
{
int err = -1;
struct rb_node *nd;
@@ -352,3 +353,5 @@ int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused, int subtest
machine__exit(&vmlinux);
return err;
}
+
+DEFINE_SUITE("vmlinux symtab matches kallsyms", vmlinux_matches_kallsyms);
diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c
index 9387fa76faa5..16ab733cabce 100644
--- a/tools/perf/tests/wp.c
+++ b/tools/perf/tests/wp.c
@@ -209,19 +209,19 @@ static struct {
},
};

-int test__wp_subtest_get_nr(void)
+static int test__wp_subtest_get_nr(void)
{
return (int)ARRAY_SIZE(wp_testcase_table);
}

-const char *test__wp_subtest_get_desc(int i)
+static const char *test__wp_subtest_get_desc(int i)
{
if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
return NULL;
return wp_testcase_table[i].desc;
}

-const char *test__wp_subtest_skip_reason(int i)
+static const char *test__wp_subtest_skip_reason(int i)
{
if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
return NULL;
@@ -230,7 +230,7 @@ const char *test__wp_subtest_skip_reason(int i)
return wp_testcase_table[i].skip_msg();
}

-int test__wp(struct test *test __maybe_unused, int i)
+static int test__wp(struct test *test __maybe_unused, int i)
{
if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
return TEST_FAIL;
@@ -245,7 +245,7 @@ int test__wp(struct test *test __maybe_unused, int i)
/* The s390 so far does not have support for
* instruction breakpoint using the perf_event_open() system call.
*/
-bool test__wp_is_supported(void)
+static bool test__wp_is_supported(void)
{
#if defined(__s390x__)
return false;
@@ -253,3 +253,15 @@ bool test__wp_is_supported(void)
return true;
#endif
}
+
+struct test suite__wp = {
+ .desc = "Watchpoint",
+ .func = test__wp,
+ .is_supported = test__wp_is_supported,
+ .subtest = {
+ .skip_if_fail = false,
+ .get_nr = test__wp_subtest_get_nr,
+ .get_desc = test__wp_subtest_get_desc,
+ .skip_reason = test__wp_subtest_skip_reason,
+ },
+};
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:49:16

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 11/22] perf test: Convert watch point tests to test cases.

Use null terminated array of test cases rather than the previous sub
test functions.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/wp.c | 128 ++++++++++--------------------------------
1 file changed, 30 insertions(+), 98 deletions(-)

diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c
index 904bdf2dcf81..2c0513257b15 100644
--- a/tools/perf/tests/wp.c
+++ b/tools/perf/tests/wp.c
@@ -62,8 +62,12 @@ static int __event(int wp_type, void *wp_addr, unsigned long wp_len)
return fd;
}

-static int wp_ro_test(void)
+static int test__wp_ro(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
+#if defined(__s390x__) || defined(__x86_64__) || defined(__i386__)
+ return TEST_SKIP;
+#else
int fd;
unsigned long tmp, tmp1 = rand();

@@ -79,10 +83,15 @@ static int wp_ro_test(void)

close(fd);
return 0;
+#endif
}

-static int wp_wo_test(void)
+static int test__wp_wo(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
+#if defined(__s390x__)
+ return TEST_SKIP;
+#else
int fd;
unsigned long tmp, tmp1 = rand();

@@ -98,10 +107,15 @@ static int wp_wo_test(void)

close(fd);
return 0;
+#endif
}

-static int wp_rw_test(void)
+static int test__wp_rw(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
+#if defined(__s390x__)
+ return TEST_SKIP;
+#else
int fd;
unsigned long tmp, tmp1 = rand();

@@ -118,10 +132,15 @@ static int wp_rw_test(void)

close(fd);
return 0;
+#endif
}

-static int wp_modify_test(void)
+static int test__wp_modify(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
+#if defined(__s390x__)
+ return TEST_SKIP;
+#else
int fd, ret;
unsigned long tmp = rand();
struct perf_event_attr new_attr;
@@ -163,105 +182,18 @@ static int wp_modify_test(void)

close(fd);
return 0;
-}
-
-static bool wp_ro_supported(void)
-{
-#if defined (__x86_64__) || defined (__i386__)
- return false;
-#else
- return true;
-#endif
-}
-
-static const char *wp_ro_skip_msg(void)
-{
-#if defined (__x86_64__) || defined (__i386__)
- return "missing hardware support";
-#else
- return NULL;
#endif
}

-static struct {
- const char *desc;
- int (*target_func)(void);
- bool (*is_supported)(void);
- const char *(*skip_msg)(void);
-} wp_testcase_table[] = {
- {
- .desc = "Read Only Watchpoint",
- .target_func = &wp_ro_test,
- .is_supported = &wp_ro_supported,
- .skip_msg = &wp_ro_skip_msg,
- },
- {
- .desc = "Write Only Watchpoint",
- .target_func = &wp_wo_test,
- },
- {
- .desc = "Read / Write Watchpoint",
- .target_func = &wp_rw_test,
- },
- {
- .desc = "Modify Watchpoint",
- .target_func = &wp_modify_test,
- },
+static struct test_case wp_tests[] = {
+ TEST_CASE_REASON("Read Only Watchpoint", wp_ro, "missing hardware support"),
+ TEST_CASE_REASON("Write Only Watchpoint", wp_wo, "missing hardware support"),
+ TEST_CASE_REASON("Read / Write Watchpoint", wp_rw, "missing hardware support"),
+ TEST_CASE_REASON("Modify Watchpoint", wp_modify, "missing hardware support"),
+ { .name = NULL, }
};

-static int test__wp_subtest_get_nr(void)
-{
- return (int)ARRAY_SIZE(wp_testcase_table);
-}
-
-static const char *test__wp_subtest_get_desc(int i)
-{
- if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
- return NULL;
- return wp_testcase_table[i].desc;
-}
-
-static const char *test__wp_subtest_skip_reason(int i)
-{
- if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
- return NULL;
- if (!wp_testcase_table[i].skip_msg)
- return NULL;
- return wp_testcase_table[i].skip_msg();
-}
-
-static int test__wp(struct test_suite *test __maybe_unused, int i)
-{
- if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
- return TEST_FAIL;
-
- if (wp_testcase_table[i].is_supported &&
- !wp_testcase_table[i].is_supported())
- return TEST_SKIP;
-
- return !wp_testcase_table[i].target_func() ? TEST_OK : TEST_FAIL;
-}
-
-/* The s390 so far does not have support for
- * instruction breakpoint using the perf_event_open() system call.
- */
-static bool test__wp_is_supported(void)
-{
-#if defined(__s390x__)
- return false;
-#else
- return true;
-#endif
-}
-
struct test_suite suite__wp = {
.desc = "Watchpoint",
- .func = test__wp,
- .is_supported = test__wp_is_supported,
- .subtest = {
- .skip_if_fail = false,
- .get_nr = test__wp_subtest_get_nr,
- .get_desc = test__wp_subtest_get_desc,
- .skip_reason = test__wp_subtest_skip_reason,
- },
+ .test_cases = wp_tests,
};
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:49:22

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 13/22] perf test: Convert bpf tests to test cases.

Use null terminated array of test cases rather than the previous sub
test functions.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/bpf.c | 72 +++++++++++++++++++++++++-----------------
1 file changed, 43 insertions(+), 29 deletions(-)

diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index 274fdd5318a5..e86a77ce93ef 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -62,7 +62,6 @@ static int llseek_loop(void)

static struct {
enum test_llvm__testcase prog_id;
- const char *desc;
const char *name;
const char *msg_compile_fail;
const char *msg_load_fail;
@@ -72,7 +71,6 @@ static struct {
} bpf_testcase_table[] = {
{
.prog_id = LLVM_TESTCASE_BASE,
- .desc = "Basic BPF filtering",
.name = "[basic_bpf_test]",
.msg_compile_fail = "fix 'perf test LLVM' first",
.msg_load_fail = "load bpf object failed",
@@ -81,7 +79,6 @@ static struct {
},
{
.prog_id = LLVM_TESTCASE_BASE,
- .desc = "BPF pinning",
.name = "[bpf_pinning]",
.msg_compile_fail = "fix kbuild first",
.msg_load_fail = "check your vmlinux setting?",
@@ -92,7 +89,6 @@ static struct {
#ifdef HAVE_BPF_PROLOGUE
{
.prog_id = LLVM_TESTCASE_BPF_PROLOGUE,
- .desc = "BPF prologue generation",
.name = "[bpf_prologue_test]",
.msg_compile_fail = "fix kbuild first",
.msg_load_fail = "check your vmlinux setting?",
@@ -282,18 +278,6 @@ static int __test__bpf(int idx)
return ret;
}

-static int test__bpf_subtest_get_nr(void)
-{
- return (int)ARRAY_SIZE(bpf_testcase_table);
-}
-
-static const char *test__bpf_subtest_get_desc(int i)
-{
- if (i < 0 || i >= (int)ARRAY_SIZE(bpf_testcase_table))
- return NULL;
- return bpf_testcase_table[i].desc;
-}
-
static int check_env(void)
{
int err;
@@ -324,7 +308,7 @@ static int check_env(void)
return 0;
}

-static int test__bpf(struct test_suite *test __maybe_unused, int i)
+static int test__bpf(int i)
{
int err;

@@ -342,31 +326,61 @@ static int test__bpf(struct test_suite *test __maybe_unused, int i)
err = __test__bpf(i);
return err;
}
+#endif

-#else
-static int test__bpf_subtest_get_nr(void)
+static int test__basic_bpf_test(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
- return 0;
+#ifdef HAVE_LIBBPF_SUPPORT
+ return test__bpf(0);
+#else
+ pr_debug("Skip BPF test because BPF support is not compiled\n");
+ return TEST_SKIP;
+#endif
}

-static const char *test__bpf_subtest_get_desc(int i __maybe_unused)
+static int test__bpf_pinning(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
- return NULL;
+#ifdef HAVE_LIBBPF_SUPPORT
+ return test__bpf(1);
+#else
+ pr_debug("Skip BPF test because BPF support is not compiled\n");
+ return TEST_SKIP;
+#endif
}

-static int test__bpf(struct test_suite *test __maybe_unused, int i __maybe_unused)
+static int test__bpf_prologue_test(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
+#if defined(HAVE_LIBBPF_SUPPORT) && defined(HAVE_BPF_PROLOGUE)
+ return test__bpf(2);
+#else
pr_debug("Skip BPF test because BPF support is not compiled\n");
return TEST_SKIP;
+#endif
}
+
+
+static struct test_case bpf_tests[] = {
+#ifdef HAVE_LIBBPF_SUPPORT
+ TEST_CASE("Basic BPF filtering", basic_bpf_test),
+ TEST_CASE("BPF pinning", bpf_pinning),
+#ifdef HAVE_BPF_PROLOGUE
+ TEST_CASE("BPF prologue generation", bpf_prologue_test),
+#else
+ TEST_CASE_REASON("BPF prologue generation", bpf_prologue_test, "not compiled in"),
#endif
+#else
+ TEST_CASE_REASON("Basic BPF filtering", basic_bpf_test, "not compiled in"),
+ TEST_CASE_REASON("BPF pinning", bpf_pinning, "not compiled in"),
+ TEST_CASE_REASON("BPF prologue generation", bpf_prologue_test, "not compiled in"),
+#endif
+ { .name = NULL, }
+};

struct test_suite suite__bpf = {
.desc = "BPF filter",
- .func = test__bpf,
- .subtest = {
- .skip_if_fail = true,
- .get_nr = test__bpf_subtest_get_nr,
- .get_desc = test__bpf_subtest_get_desc,
- },
+ .test_cases = bpf_tests,
+ .subtest = { .skip_if_fail = true, },
};
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:49:43

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 05/22] perf test: Rename struct test to test_suite

This is to align with kunit's terminology.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/arch/arm/include/arch-tests.h | 2 +-
tools/perf/arch/arm/tests/arch-tests.c | 2 +-
tools/perf/arch/arm/tests/vectors-page.c | 2 +-
tools/perf/arch/arm64/include/arch-tests.h | 2 +-
tools/perf/arch/arm64/tests/arch-tests.c | 2 +-
tools/perf/arch/powerpc/include/arch-tests.h | 2 +-
tools/perf/arch/powerpc/tests/arch-tests.c | 3 ++-
tools/perf/arch/x86/include/arch-tests.h | 14 ++++++-------
tools/perf/arch/x86/tests/arch-tests.c | 2 +-
tools/perf/arch/x86/tests/bp-modify.c | 2 +-
tools/perf/arch/x86/tests/insn-x86.c | 2 +-
tools/perf/arch/x86/tests/intel-cqm.c | 2 +-
.../x86/tests/intel-pt-pkt-decoder-test.c | 2 +-
tools/perf/arch/x86/tests/rdpmc.c | 2 +-
tools/perf/arch/x86/tests/sample-parsing.c | 2 +-
tools/perf/tests/api-io.c | 2 +-
tools/perf/tests/attr.c | 2 +-
tools/perf/tests/backward-ring-buffer.c | 2 +-
tools/perf/tests/bitmap.c | 2 +-
tools/perf/tests/bp_account.c | 4 ++--
tools/perf/tests/bp_signal.c | 4 ++--
tools/perf/tests/bp_signal_overflow.c | 4 ++--
tools/perf/tests/bpf.c | 6 +++---
tools/perf/tests/builtin-test.c | 20 +++++++++----------
tools/perf/tests/clang.c | 6 +++---
tools/perf/tests/code-reading.c | 2 +-
tools/perf/tests/cpumap.c | 6 +++---
tools/perf/tests/demangle-java-test.c | 2 +-
tools/perf/tests/demangle-ocaml-test.c | 2 +-
tools/perf/tests/dlfilter-test.c | 2 +-
tools/perf/tests/dso-data.c | 6 +++---
tools/perf/tests/dwarf-unwind.c | 3 ++-
tools/perf/tests/event-times.c | 2 +-
tools/perf/tests/event_update.c | 2 +-
tools/perf/tests/evsel-roundtrip-name.c | 2 +-
tools/perf/tests/evsel-tp-sched.c | 2 +-
tools/perf/tests/expand-cgroup.c | 2 +-
tools/perf/tests/expr.c | 2 +-
tools/perf/tests/fdarray.c | 4 ++--
tools/perf/tests/genelf.c | 2 +-
tools/perf/tests/hists_cumulate.c | 2 +-
tools/perf/tests/hists_filter.c | 2 +-
tools/perf/tests/hists_link.c | 2 +-
tools/perf/tests/hists_output.c | 2 +-
tools/perf/tests/is_printable_array.c | 2 +-
tools/perf/tests/keep-tracking.c | 2 +-
tools/perf/tests/kmod-path.c | 2 +-
tools/perf/tests/llvm.c | 6 +++---
tools/perf/tests/maps.c | 2 +-
tools/perf/tests/mem.c | 2 +-
tools/perf/tests/mem2node.c | 2 +-
tools/perf/tests/mmap-basic.c | 2 +-
tools/perf/tests/mmap-thread-lookup.c | 2 +-
tools/perf/tests/openat-syscall-all-cpus.c | 2 +-
tools/perf/tests/openat-syscall-tp-fields.c | 2 +-
tools/perf/tests/openat-syscall.c | 2 +-
tools/perf/tests/parse-events.c | 2 +-
tools/perf/tests/parse-metric.c | 2 +-
tools/perf/tests/parse-no-sample-id-all.c | 2 +-
tools/perf/tests/pe-file-parsing.c | 4 ++--
tools/perf/tests/perf-hooks.c | 2 +-
tools/perf/tests/perf-record.c | 2 +-
tools/perf/tests/perf-time-to-tsc.c | 4 ++--
tools/perf/tests/pfm.c | 4 ++--
tools/perf/tests/pmu-events.c | 4 ++--
tools/perf/tests/pmu.c | 2 +-
tools/perf/tests/python-use.c | 2 +-
tools/perf/tests/sample-parsing.c | 2 +-
tools/perf/tests/sdt.c | 4 ++--
tools/perf/tests/stat.c | 6 +++---
tools/perf/tests/sw-clock.c | 2 +-
tools/perf/tests/switch-tracking.c | 2 +-
tools/perf/tests/task-exit.c | 2 +-
tools/perf/tests/tests.h | 8 ++++----
tools/perf/tests/thread-map.c | 6 +++---
tools/perf/tests/thread-maps-share.c | 2 +-
tools/perf/tests/time-utils-test.c | 2 +-
tools/perf/tests/topology.c | 2 +-
tools/perf/tests/unit_number__scnprintf.c | 2 +-
tools/perf/tests/vmlinux-kallsyms.c | 2 +-
tools/perf/tests/wp.c | 4 ++--
81 files changed, 125 insertions(+), 123 deletions(-)

diff --git a/tools/perf/arch/arm/include/arch-tests.h b/tools/perf/arch/arm/include/arch-tests.h
index 37039e80f18b..452b3d904521 100644
--- a/tools/perf/arch/arm/include/arch-tests.h
+++ b/tools/perf/arch/arm/include/arch-tests.h
@@ -2,6 +2,6 @@
#ifndef ARCH_TESTS_H
#define ARCH_TESTS_H

-extern struct test *arch_tests[];
+extern struct test_suite *arch_tests[];

#endif
diff --git a/tools/perf/arch/arm/tests/arch-tests.c b/tools/perf/arch/arm/tests/arch-tests.c
index 0ae591f6c372..2e8c90f34325 100644
--- a/tools/perf/arch/arm/tests/arch-tests.c
+++ b/tools/perf/arch/arm/tests/arch-tests.c
@@ -5,7 +5,7 @@

DEFINE_SUITE("Vectors page", vectors_page);

-struct test *arch_tests[] = {
+struct test_suite *arch_tests[] = {
#ifdef HAVE_DWARF_UNWIND_SUPPORT
&suite__dwarf_unwind,
#endif
diff --git a/tools/perf/arch/arm/tests/vectors-page.c b/tools/perf/arch/arm/tests/vectors-page.c
index 7ffdd79971c8..f339835558ca 100644
--- a/tools/perf/arch/arm/tests/vectors-page.c
+++ b/tools/perf/arch/arm/tests/vectors-page.c
@@ -9,7 +9,7 @@

#define VECTORS__MAP_NAME "[vectors]"

-int test__vectors_page(struct test *test __maybe_unused,
+int test__vectors_page(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
void *start, *end;
diff --git a/tools/perf/arch/arm64/include/arch-tests.h b/tools/perf/arch/arm64/include/arch-tests.h
index 37039e80f18b..452b3d904521 100644
--- a/tools/perf/arch/arm64/include/arch-tests.h
+++ b/tools/perf/arch/arm64/include/arch-tests.h
@@ -2,6 +2,6 @@
#ifndef ARCH_TESTS_H
#define ARCH_TESTS_H

-extern struct test *arch_tests[];
+extern struct test_suite *arch_tests[];

#endif
diff --git a/tools/perf/arch/arm64/tests/arch-tests.c b/tools/perf/arch/arm64/tests/arch-tests.c
index 6d137138a2de..ad16b4f8f63e 100644
--- a/tools/perf/arch/arm64/tests/arch-tests.c
+++ b/tools/perf/arch/arm64/tests/arch-tests.c
@@ -3,7 +3,7 @@
#include "tests/tests.h"
#include "arch-tests.h"

-struct test *arch_tests[] = {
+struct test_suite *arch_tests[] = {
#ifdef HAVE_DWARF_UNWIND_SUPPORT
&suite__dwarf_unwind,
#endif
diff --git a/tools/perf/arch/powerpc/include/arch-tests.h b/tools/perf/arch/powerpc/include/arch-tests.h
index 37039e80f18b..452b3d904521 100644
--- a/tools/perf/arch/powerpc/include/arch-tests.h
+++ b/tools/perf/arch/powerpc/include/arch-tests.h
@@ -2,6 +2,6 @@
#ifndef ARCH_TESTS_H
#define ARCH_TESTS_H

-extern struct test *arch_tests[];
+extern struct test_suite *arch_tests[];

#endif
diff --git a/tools/perf/arch/powerpc/tests/arch-tests.c b/tools/perf/arch/powerpc/tests/arch-tests.c
index 6d137138a2de..eb98c57b5aeb 100644
--- a/tools/perf/arch/powerpc/tests/arch-tests.c
+++ b/tools/perf/arch/powerpc/tests/arch-tests.c
@@ -3,7 +3,8 @@
#include "tests/tests.h"
#include "arch-tests.h"

-struct test *arch_tests[] = {
+
+struct test_suite *arch_tests[] = {
#ifdef HAVE_DWARF_UNWIND_SUPPORT
&suite__dwarf_unwind,
#endif
diff --git a/tools/perf/arch/x86/include/arch-tests.h b/tools/perf/arch/x86/include/arch-tests.h
index d6db9f72b6af..6a1a1b3c0827 100644
--- a/tools/perf/arch/x86/include/arch-tests.h
+++ b/tools/perf/arch/x86/include/arch-tests.h
@@ -2,15 +2,15 @@
#ifndef ARCH_TESTS_H
#define ARCH_TESTS_H

-struct test;
+struct test_suite;

/* Tests */
-int test__rdpmc(struct test *test, int subtest);
-int test__insn_x86(struct test *test, int subtest);
-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);
+int test__rdpmc(struct test_suite *test, int subtest);
+int test__insn_x86(struct test_suite *test, int subtest);
+int test__intel_pt_pkt_decoder(struct test_suite *test, int subtest);
+int test__bp_modify(struct test_suite *test, int subtest);
+int test__x86_sample_parsing(struct test_suite *test, int subtest);

-extern struct test *arch_tests[];
+extern struct test_suite *arch_tests[];

#endif
diff --git a/tools/perf/arch/x86/tests/arch-tests.c b/tools/perf/arch/x86/tests/arch-tests.c
index 585fbf8ebae6..bb1f3d334346 100644
--- a/tools/perf/arch/x86/tests/arch-tests.c
+++ b/tools/perf/arch/x86/tests/arch-tests.c
@@ -13,7 +13,7 @@ DEFINE_SUITE("x86 bp modify", bp_modify);
#endif
DEFINE_SUITE("x86 Sample parsing", x86_sample_parsing);

-struct test *arch_tests[] = {
+struct test_suite *arch_tests[] = {
&suite__rdpmc,
#ifdef HAVE_DWARF_UNWIND_SUPPORT
&suite__dwarf_unwind,
diff --git a/tools/perf/arch/x86/tests/bp-modify.c b/tools/perf/arch/x86/tests/bp-modify.c
index dffcf9b52153..0924ccd9e36d 100644
--- a/tools/perf/arch/x86/tests/bp-modify.c
+++ b/tools/perf/arch/x86/tests/bp-modify.c
@@ -204,7 +204,7 @@ static int bp_modify2(void)
return rip == (unsigned long) bp_1 ? TEST_OK : TEST_FAIL;
}

-int test__bp_modify(struct test *test __maybe_unused,
+int test__bp_modify(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
TEST_ASSERT_VAL("modify test 1 failed\n", !bp_modify1());
diff --git a/tools/perf/arch/x86/tests/insn-x86.c b/tools/perf/arch/x86/tests/insn-x86.c
index 0262b0d8ccf5..94b490c434d0 100644
--- a/tools/perf/arch/x86/tests/insn-x86.c
+++ b/tools/perf/arch/x86/tests/insn-x86.c
@@ -173,7 +173,7 @@ static int test_data_set(struct test_data *dat_set, int x86_64)
* verbose (-v) option to see all the instructions and whether or not they
* decoded successfully.
*/
-int test__insn_x86(struct test *test __maybe_unused, int subtest __maybe_unused)
+int test__insn_x86(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int ret = 0;

diff --git a/tools/perf/arch/x86/tests/intel-cqm.c b/tools/perf/arch/x86/tests/intel-cqm.c
index 27dd8cf9e060..cb5b2c6c3b3b 100644
--- a/tools/perf/arch/x86/tests/intel-cqm.c
+++ b/tools/perf/arch/x86/tests/intel-cqm.c
@@ -37,7 +37,7 @@ static pid_t spawn(void)
* the last read counter value to avoid triggering a WARN_ON_ONCE() in
* smp_call_function_many() caused by sending IPIs from NMI context.
*/
-int test__intel_cqm_count_nmi_context(struct test *test __maybe_unused, int subtest __maybe_unused)
+int test__intel_cqm_count_nmi_context(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct evlist *evlist = NULL;
struct evsel *evsel = NULL;
diff --git a/tools/perf/arch/x86/tests/intel-pt-pkt-decoder-test.c b/tools/perf/arch/x86/tests/intel-pt-pkt-decoder-test.c
index c933e3dcd0a8..2fc882ab24c1 100644
--- a/tools/perf/arch/x86/tests/intel-pt-pkt-decoder-test.c
+++ b/tools/perf/arch/x86/tests/intel-pt-pkt-decoder-test.c
@@ -289,7 +289,7 @@ static int test_one(struct test_data *d)
* This test feeds byte sequences to the Intel PT packet decoder and checks the
* results. Changes to the packet context are also checked.
*/
-int test__intel_pt_pkt_decoder(struct test *test __maybe_unused, int subtest __maybe_unused)
+int test__intel_pt_pkt_decoder(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct test_data *d = data;
int ret;
diff --git a/tools/perf/arch/x86/tests/rdpmc.c b/tools/perf/arch/x86/tests/rdpmc.c
index 1ea916656a2d..498413ad9c97 100644
--- a/tools/perf/arch/x86/tests/rdpmc.c
+++ b/tools/perf/arch/x86/tests/rdpmc.c
@@ -157,7 +157,7 @@ static int __test__rdpmc(void)
return 0;
}

-int test__rdpmc(struct test *test __maybe_unused, int subtest __maybe_unused)
+int test__rdpmc(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int status = 0;
int wret = 0;
diff --git a/tools/perf/arch/x86/tests/sample-parsing.c b/tools/perf/arch/x86/tests/sample-parsing.c
index c92db87e4479..bfbd3662b69e 100644
--- a/tools/perf/arch/x86/tests/sample-parsing.c
+++ b/tools/perf/arch/x86/tests/sample-parsing.c
@@ -115,7 +115,7 @@ static int do_test(u64 sample_type)
* For now, the PERF_SAMPLE_WEIGHT_STRUCT is the only X86 specific sample type.
* The test only checks the PERF_SAMPLE_WEIGHT_STRUCT type.
*/
-int test__x86_sample_parsing(struct test *test __maybe_unused, int subtest __maybe_unused)
+int test__x86_sample_parsing(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
return do_test(PERF_SAMPLE_WEIGHT_STRUCT);
}
diff --git a/tools/perf/tests/api-io.c b/tools/perf/tests/api-io.c
index af4913967514..e91cf2c127f1 100644
--- a/tools/perf/tests/api-io.c
+++ b/tools/perf/tests/api-io.c
@@ -289,7 +289,7 @@ static int test_get_dec(void)
return ret;
}

-static int test__api_io(struct test *test __maybe_unused,
+static int test__api_io(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
int ret = 0;
diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
index f1461051f579..0f73e300f207 100644
--- a/tools/perf/tests/attr.c
+++ b/tools/perf/tests/attr.c
@@ -178,7 +178,7 @@ static int run_dir(const char *d, const char *perf)
return system(cmd) ? TEST_FAIL : TEST_OK;
}

-static int test__attr(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__attr(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct stat st;
char path_perf[PATH_MAX];
diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c
index 180e16917658..79e51a260b15 100644
--- a/tools/perf/tests/backward-ring-buffer.c
+++ b/tools/perf/tests/backward-ring-buffer.c
@@ -82,7 +82,7 @@ static int do_test(struct evlist *evlist, int mmap_pages,
}


-static int test__backward_ring_buffer(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__backward_ring_buffer(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int ret = TEST_SKIP, err, sample_count = 0, comm_count = 0;
char pid[16], sbuf[STRERR_BUFSIZE];
diff --git a/tools/perf/tests/bitmap.c b/tools/perf/tests/bitmap.c
index 13d1d1d6774f..384856347236 100644
--- a/tools/perf/tests/bitmap.c
+++ b/tools/perf/tests/bitmap.c
@@ -40,7 +40,7 @@ static int test_bitmap(const char *str)
return ret;
}

-static int test__bitmap_print(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__bitmap_print(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
TEST_ASSERT_VAL("failed to convert map", test_bitmap("1"));
TEST_ASSERT_VAL("failed to convert map", test_bitmap("1,5"));
diff --git a/tools/perf/tests/bp_account.c b/tools/perf/tests/bp_account.c
index 76cf356ba13f..365120146d17 100644
--- a/tools/perf/tests/bp_account.c
+++ b/tools/perf/tests/bp_account.c
@@ -173,7 +173,7 @@ static int detect_share(int wp_cnt, int bp_cnt)
* we create another watchpoint to ensure
* the slot accounting is correct
*/
-static int test__bp_accounting(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__bp_accounting(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int has_ioctl = detect_ioctl();
int wp_cnt = detect_cnt(false);
@@ -205,7 +205,7 @@ static bool test__bp_account_is_supported(void)
#endif
}

-struct test suite__bp_accounting = {
+struct test_suite suite__bp_accounting = {
.desc = "Breakpoint accounting",
.func = test__bp_accounting,
.is_supported = test__bp_account_is_supported,
diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c
index c19b05488cfb..3c269f81818a 100644
--- a/tools/perf/tests/bp_signal.c
+++ b/tools/perf/tests/bp_signal.c
@@ -161,7 +161,7 @@ static long long bp_count(int fd)
return count;
}

-static int test__bp_signal(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__bp_signal(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct sigaction sa;
long long count1, count2, count3;
@@ -312,7 +312,7 @@ bool test__bp_signal_is_supported(void)
#endif
}

-struct test suite__bp_signal = {
+struct test_suite suite__bp_signal = {
.desc = "Breakpoint overflow signal handler",
.func = test__bp_signal,
.is_supported = test__bp_signal_is_supported,
diff --git a/tools/perf/tests/bp_signal_overflow.c b/tools/perf/tests/bp_signal_overflow.c
index 99c30d028f5e..5ac6e1393cf4 100644
--- a/tools/perf/tests/bp_signal_overflow.c
+++ b/tools/perf/tests/bp_signal_overflow.c
@@ -59,7 +59,7 @@ static long long bp_count(int fd)
#define EXECUTIONS 10000
#define THRESHOLD 100

-static int test__bp_signal_overflow(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__bp_signal_overflow(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct perf_event_attr pe;
struct sigaction sa;
@@ -134,7 +134,7 @@ static int test__bp_signal_overflow(struct test *test __maybe_unused, int subtes
return fails ? TEST_FAIL : TEST_OK;
}

-struct test suite__bp_signal_overflow = {
+struct test_suite suite__bp_signal_overflow = {
.desc = "Breakpoint overflow sampling",
.func = test__bp_signal_overflow,
.is_supported = test__bp_signal_is_supported,
diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index 74496a0fc973..274fdd5318a5 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -324,7 +324,7 @@ static int check_env(void)
return 0;
}

-static int test__bpf(struct test *test __maybe_unused, int i)
+static int test__bpf(struct test_suite *test __maybe_unused, int i)
{
int err;

@@ -354,14 +354,14 @@ static const char *test__bpf_subtest_get_desc(int i __maybe_unused)
return NULL;
}

-static int test__bpf(struct test *test __maybe_unused, int i __maybe_unused)
+static int test__bpf(struct test_suite *test __maybe_unused, int i __maybe_unused)
{
pr_debug("Skip BPF test because BPF support is not compiled\n");
return TEST_SKIP;
}
#endif

-struct test suite__bpf = {
+struct test_suite suite__bpf = {
.desc = "BPF filter",
.func = test__bpf,
.subtest = {
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 07467ec43100..7d52e2eb8147 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -30,11 +30,11 @@

static bool dont_fork;

-struct test *__weak arch_tests[] = {
+struct test_suite *__weak arch_tests[] = {
NULL,
};

-static struct test *generic_tests[] = {
+static struct test_suite *generic_tests[] = {
&suite__vmlinux_matches_kallsyms,
&suite__openat_syscall_event,
&suite__openat_syscall_event_on_all_cpus,
@@ -110,7 +110,7 @@ static struct test *generic_tests[] = {
NULL,
};

-static struct test **tests[] = {
+static struct test_suite **tests[] = {
generic_tests,
arch_tests,
};
@@ -139,7 +139,7 @@ static bool perf_test__matches(const char *desc, int curr, int argc, const char
return false;
}

-static int run_test(struct test *test, int subtest)
+static int run_test(struct test_suite *test, int subtest)
{
int status, err = -1, child = dont_fork ? 0 : fork();
char sbuf[STRERR_BUFSIZE];
@@ -195,7 +195,7 @@ static int run_test(struct test *test, int subtest)
for (j = 0; j < ARRAY_SIZE(tests); j++) \
for (k = 0, t = tests[j][k]; tests[j][k]; k++, t = tests[j][k])

-static int test_and_print(struct test *t, bool force_skip, int subtest)
+static int test_and_print(struct test_suite *t, bool force_skip, int subtest)
{
int err;

@@ -321,7 +321,7 @@ struct shell_test {
const char *file;
};

-static int shell_test__run(struct test *test, int subdir __maybe_unused)
+static int shell_test__run(struct test_suite *test, int subdir __maybe_unused)
{
int err;
char script[PATH_MAX];
@@ -363,7 +363,7 @@ static int run_shell_tests(int argc, const char *argv[], int i, int width,
for_each_shell_test(entlist, n_dirs, st.dir, ent) {
int curr = i++;
char desc[256];
- struct test test = {
+ struct test_suite test = {
.desc = shell_test__description(desc, sizeof(desc), st.dir, ent->d_name),
.func = shell_test__run,
.priv = &st,
@@ -391,7 +391,7 @@ static int run_shell_tests(int argc, const char *argv[], int i, int width,

static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
{
- struct test *t;
+ struct test_suite *t;
unsigned int j, k;
int i = 0;
int width = shell_tests__max_desc_width();
@@ -500,7 +500,7 @@ static int perf_test__list_shell(int argc, const char **argv, int i)
for_each_shell_test(entlist, n_dirs, path, ent) {
int curr = i++;
char bf[256];
- struct test t = {
+ struct test_suite t = {
.desc = shell_test__description(bf, sizeof(bf), path, ent->d_name),
};

@@ -520,7 +520,7 @@ static int perf_test__list_shell(int argc, const char **argv, int i)
static int perf_test__list(int argc, const char **argv)
{
unsigned int j, k;
- struct test *t;
+ struct test_suite *t;
int i = 0;

for_each_test(j, k, t) {
diff --git a/tools/perf/tests/clang.c b/tools/perf/tests/clang.c
index 5052be1b5b20..a499fcf37bf9 100644
--- a/tools/perf/tests/clang.c
+++ b/tools/perf/tests/clang.c
@@ -32,12 +32,12 @@ static const char *test__clang_subtest_get_desc(int i)
}

#ifndef HAVE_LIBCLANGLLVM_SUPPORT
-static int test__clang(struct test *test __maybe_unused, int i __maybe_unused)
+static int test__clang(struct test_suite *test __maybe_unused, int i __maybe_unused)
{
return TEST_SKIP;
}
#else
-static int test__clang(struct test *test __maybe_unused, int i)
+static int test__clang(struct test_suite *test __maybe_unused, int i)
{
if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table))
return TEST_FAIL;
@@ -45,7 +45,7 @@ static int test__clang(struct test *test __maybe_unused, int i)
}
#endif

-struct test suite__clang = {
+struct test_suite suite__clang = {
.desc = "builtin clang support",
.func = test__clang,
.subtest = {
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index 4bdbc25f3750..7d07b1fa9912 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -716,7 +716,7 @@ static int do_test_code_reading(bool try_kcore)
return err;
}

-static int test__code_reading(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__code_reading(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int ret;

diff --git a/tools/perf/tests/cpumap.c b/tools/perf/tests/cpumap.c
index 6f2525fb9fd7..89a155092f85 100644
--- a/tools/perf/tests/cpumap.c
+++ b/tools/perf/tests/cpumap.c
@@ -75,7 +75,7 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused,
}


-static int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__cpu_map_synthesize(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct perf_cpu_map *cpus;

@@ -111,7 +111,7 @@ static int cpu_map_print(const char *str)
return !strcmp(buf, str);
}

-static int test__cpu_map_print(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__cpu_map_print(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1"));
TEST_ASSERT_VAL("failed to convert map", cpu_map_print("1,5"));
@@ -123,7 +123,7 @@ static int test__cpu_map_print(struct test *test __maybe_unused, int subtest __m
return 0;
}

-static int test__cpu_map_merge(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__cpu_map_merge(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct perf_cpu_map *a = perf_cpu_map__new("4,2,1");
struct perf_cpu_map *b = perf_cpu_map__new("4,5,7");
diff --git a/tools/perf/tests/demangle-java-test.c b/tools/perf/tests/demangle-java-test.c
index 37f488e5c36d..44d1be303b67 100644
--- a/tools/perf/tests/demangle-java-test.c
+++ b/tools/perf/tests/demangle-java-test.c
@@ -7,7 +7,7 @@
#include "debug.h"
#include "demangle-java.h"

-static int test__demangle_java(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__demangle_java(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int ret = TEST_OK;
char *buf = NULL;
diff --git a/tools/perf/tests/demangle-ocaml-test.c b/tools/perf/tests/demangle-ocaml-test.c
index ee982cca7bbf..90a4285e2ad5 100644
--- a/tools/perf/tests/demangle-ocaml-test.c
+++ b/tools/perf/tests/demangle-ocaml-test.c
@@ -7,7 +7,7 @@
#include "debug.h"
#include "demangle-ocaml.h"

-static int test__demangle_ocaml(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__demangle_ocaml(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int ret = TEST_OK;
char *buf = NULL;
diff --git a/tools/perf/tests/dlfilter-test.c b/tools/perf/tests/dlfilter-test.c
index 378f5afc6032..84352d55347d 100644
--- a/tools/perf/tests/dlfilter-test.c
+++ b/tools/perf/tests/dlfilter-test.c
@@ -398,7 +398,7 @@ static void test_data__free(struct test_data *td)
}
}

-static int test__dlfilter(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__dlfilter(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct test_data td = {.fd = -1};
int pid = getpid();
diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c
index d9e060a7c1f6..3419a4ab5590 100644
--- a/tools/perf/tests/dso-data.c
+++ b/tools/perf/tests/dso-data.c
@@ -113,7 +113,7 @@ static int dso__data_fd(struct dso *dso, struct machine *machine)
return fd;
}

-static int test__dso_data(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__dso_data(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct machine machine;
struct dso *dso;
@@ -248,7 +248,7 @@ static int set_fd_limit(int n)
return setrlimit(RLIMIT_NOFILE, &rlim);
}

-static int test__dso_data_cache(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__dso_data_cache(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct machine machine;
long nr_end, nr = open_files_cnt();
@@ -318,7 +318,7 @@ static long new_limit(int count)
return ret;
}

-static int test__dso_data_reopen(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__dso_data_reopen(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct machine machine;
long nr_end, nr = open_files_cnt(), lim = new_limit(3);
diff --git a/tools/perf/tests/dwarf-unwind.c b/tools/perf/tests/dwarf-unwind.c
index 74b500d42461..7b847716deca 100644
--- a/tools/perf/tests/dwarf-unwind.c
+++ b/tools/perf/tests/dwarf-unwind.c
@@ -170,7 +170,8 @@ noinline int test_dwarf_unwind__krava_1(struct thread *thread)
return test_dwarf_unwind__krava_2(thread);
}

-static int test__dwarf_unwind(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__dwarf_unwind(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
struct machine *machine;
struct thread *thread;
diff --git a/tools/perf/tests/event-times.c b/tools/perf/tests/event-times.c
index 2ce8945931e7..7606eb3df92f 100644
--- a/tools/perf/tests/event-times.c
+++ b/tools/perf/tests/event-times.c
@@ -216,7 +216,7 @@ static int test_times(int (attach)(struct evlist *),
* and checks that enabled and running times
* match.
*/
-static int test__event_times(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__event_times(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int err, ret = 0;

diff --git a/tools/perf/tests/event_update.c b/tools/perf/tests/event_update.c
index 9dfb665f8ac9..fbb68deba59f 100644
--- a/tools/perf/tests/event_update.c
+++ b/tools/perf/tests/event_update.c
@@ -83,7 +83,7 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused,
return 0;
}

-static int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__event_update(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct evsel *evsel;
struct event_name tmp;
diff --git a/tools/perf/tests/evsel-roundtrip-name.c b/tools/perf/tests/evsel-roundtrip-name.c
index 82ff3c04d0bd..fdbf17642e45 100644
--- a/tools/perf/tests/evsel-roundtrip-name.c
+++ b/tools/perf/tests/evsel-roundtrip-name.c
@@ -99,7 +99,7 @@ static int __perf_evsel__name_array_test(const char *names[], int nr_names,
#define perf_evsel__name_array_test(names, distance) \
__perf_evsel__name_array_test(names, ARRAY_SIZE(names), distance)

-static int test__perf_evsel__roundtrip_name_test(struct test *test __maybe_unused,
+static int test__perf_evsel__roundtrip_name_test(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
int err = 0, ret = 0;
diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c
index 58f17d18e4d5..cf4da3d748c2 100644
--- a/tools/perf/tests/evsel-tp-sched.c
+++ b/tools/perf/tests/evsel-tp-sched.c
@@ -32,7 +32,7 @@ static int evsel__test_field(struct evsel *evsel, const char *name, int size, bo
return ret;
}

-static int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused,
+static int test__perf_evsel__tp_sched_test(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
struct evsel *evsel = evsel__newtp("sched", "sched_switch");
diff --git a/tools/perf/tests/expand-cgroup.c b/tools/perf/tests/expand-cgroup.c
index 577bc6c324b5..8ef9cd56fe4f 100644
--- a/tools/perf/tests/expand-cgroup.c
+++ b/tools/perf/tests/expand-cgroup.c
@@ -219,7 +219,7 @@ static int expand_metric_events(void)
return ret;
}

-static int test__expand_cgroup_events(struct test *test __maybe_unused,
+static int test__expand_cgroup_events(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
int ret;
diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c
index b372e5cfa30c..449b081cc7ef 100644
--- a/tools/perf/tests/expr.c
+++ b/tools/perf/tests/expr.c
@@ -62,7 +62,7 @@ static int test(struct expr_parse_ctx *ctx, const char *e, double val2)
return 0;
}

-static int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)
+static int test__expr(struct test_suite *t __maybe_unused, int subtest __maybe_unused)
{
struct expr_id_data *val_ptr;
const char *p;
diff --git a/tools/perf/tests/fdarray.c b/tools/perf/tests/fdarray.c
index 7b2f6c2ad705..40983c3574b1 100644
--- a/tools/perf/tests/fdarray.c
+++ b/tools/perf/tests/fdarray.c
@@ -28,7 +28,7 @@ static int fdarray__fprintf_prefix(struct fdarray *fda, const char *prefix, FILE
return printed + fdarray__fprintf(fda, fp);
}

-static int test__fdarray__filter(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__fdarray__filter(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int nr_fds, err = TEST_FAIL;
struct fdarray *fda = fdarray__new(5, 5);
@@ -89,7 +89,7 @@ static int test__fdarray__filter(struct test *test __maybe_unused, int subtest _
return err;
}

-static int test__fdarray__add(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__fdarray__add(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int err = TEST_FAIL;
struct fdarray *fda = fdarray__new(2, 2);
diff --git a/tools/perf/tests/genelf.c b/tools/perf/tests/genelf.c
index 3c5ced5d9588..95f3be1b683a 100644
--- a/tools/perf/tests/genelf.c
+++ b/tools/perf/tests/genelf.c
@@ -16,7 +16,7 @@

#define TEMPL "/tmp/perf-test-XXXXXX"

-static int test__jit_write_elf(struct test *test __maybe_unused,
+static int test__jit_write_elf(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
#ifdef HAVE_JITDUMP
diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cumulate.c
index f7a8d3d78389..17f4fcd6bdce 100644
--- a/tools/perf/tests/hists_cumulate.c
+++ b/tools/perf/tests/hists_cumulate.c
@@ -689,7 +689,7 @@ static int test4(struct evsel *evsel, struct machine *machine)
return err;
}

-static int test__hists_cumulate(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__hists_cumulate(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int err = TEST_FAIL;
struct machines machines;
diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filter.c
index 09e140191e5f..08cbeb9e39ae 100644
--- a/tools/perf/tests/hists_filter.c
+++ b/tools/perf/tests/hists_filter.c
@@ -101,7 +101,7 @@ static int add_hist_entries(struct evlist *evlist,
return TEST_FAIL;
}

-static int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__hists_filter(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int err = TEST_FAIL;
struct machines machines;
diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c
index 08571f788884..c575e13a850d 100644
--- a/tools/perf/tests/hists_link.c
+++ b/tools/perf/tests/hists_link.c
@@ -264,7 +264,7 @@ static int validate_link(struct hists *leader, struct hists *other)
return __validate_link(leader, 0) || __validate_link(other, 1);
}

-static int test__hists_link(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__hists_link(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int err = -1;
struct hists *hists, *first_hists;
diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_output.c
index b427df8ee94a..0bde4a768c15 100644
--- a/tools/perf/tests/hists_output.c
+++ b/tools/perf/tests/hists_output.c
@@ -575,7 +575,7 @@ static int test5(struct evsel *evsel, struct machine *machine)
return err;
}

-static int test__hists_output(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__hists_output(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int err = TEST_FAIL;
struct machines machines;
diff --git a/tools/perf/tests/is_printable_array.c b/tools/perf/tests/is_printable_array.c
index 8891b10fac5c..f72de2457ff1 100644
--- a/tools/perf/tests/is_printable_array.c
+++ b/tools/perf/tests/is_printable_array.c
@@ -5,7 +5,7 @@
#include "debug.h"
#include "print_binary.h"

-static int test__is_printable_array(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__is_printable_array(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
char buf1[] = { 'k', 'r', 4, 'v', 'a', 0 };
char buf2[] = { 'k', 'r', 'a', 'v', 4, 0 };
diff --git a/tools/perf/tests/keep-tracking.c b/tools/perf/tests/keep-tracking.c
index e723c976dc81..dd2067312452 100644
--- a/tools/perf/tests/keep-tracking.c
+++ b/tools/perf/tests/keep-tracking.c
@@ -61,7 +61,7 @@ static int find_comm(struct evlist *evlist, const char *comm)
* when an event is disabled but a dummy software event is not disabled. If the
* test passes %0 is returned, otherwise %-1 is returned.
*/
-static int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__keep_tracking(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct record_opts opts = {
.mmap_pages = UINT_MAX,
diff --git a/tools/perf/tests/kmod-path.c b/tools/perf/tests/kmod-path.c
index 4935dd3182ed..dfe1bd5dabaa 100644
--- a/tools/perf/tests/kmod-path.c
+++ b/tools/perf/tests/kmod-path.c
@@ -47,7 +47,7 @@ static int test_is_kernel_module(const char *path, int cpumode, bool expect)
#define M(path, c, e) \
TEST_ASSERT_VAL("failed", !test_is_kernel_module(path, c, e))

-static int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unused)
+static int test__kmod_path__parse(struct test_suite *t __maybe_unused, int subtest __maybe_unused)
{
/* path alloc_name kmod comp name */
T("/xxxx/xxxx/x-x.ko", true , true, 0 , "[x_x]");
diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
index b605a71ad8d5..057d6a59a8ea 100644
--- a/tools/perf/tests/llvm.c
+++ b/tools/perf/tests/llvm.c
@@ -124,7 +124,7 @@ test_llvm__fetch_bpf_obj(void **p_obj_buf,
return ret;
}

-static int test__llvm(struct test *test __maybe_unused, int subtest)
+static int test__llvm(struct test_suite *test __maybe_unused, int subtest)
{
int ret;
void *obj_buf = NULL;
@@ -162,7 +162,7 @@ static const char *test__llvm_subtest_get_desc(int subtest)
return bpf_source_table[subtest].desc;
}
#else //HAVE_LIBBPF_SUPPORT
-static int test__llvm(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__llvm(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
return TEST_SKIP;
}
@@ -178,7 +178,7 @@ static const char *test__llvm_subtest_get_desc(int subtest __maybe_unused)
}
#endif // HAVE_LIBBPF_SUPPORT

-struct test suite__llvm = {
+struct test_suite suite__llvm = {
.desc = "LLVM search and compile",
.func = test__llvm,
.subtest = {
diff --git a/tools/perf/tests/maps.c b/tools/perf/tests/maps.c
index 4a2e6f312015..e308a3296cef 100644
--- a/tools/perf/tests/maps.c
+++ b/tools/perf/tests/maps.c
@@ -33,7 +33,7 @@ static int check_maps(struct map_def *merged, unsigned int size, struct maps *ma
return TEST_OK;
}

-static int test__maps__merge_in(struct test *t __maybe_unused, int subtest __maybe_unused)
+static int test__maps__merge_in(struct test_suite *t __maybe_unused, int subtest __maybe_unused)
{
struct maps maps;
unsigned int i;
diff --git a/tools/perf/tests/mem.c b/tools/perf/tests/mem.c
index 3af082508653..56014ec7d49d 100644
--- a/tools/perf/tests/mem.c
+++ b/tools/perf/tests/mem.c
@@ -23,7 +23,7 @@ static int check(union perf_mem_data_src data_src,
return 0;
}

-static int test__mem(struct test *text __maybe_unused, int subtest __maybe_unused)
+static int test__mem(struct test_suite *text __maybe_unused, int subtest __maybe_unused)
{
int ret = 0;
union perf_mem_data_src src;
diff --git a/tools/perf/tests/mem2node.c b/tools/perf/tests/mem2node.c
index 0a90e6084d81..b17b86391383 100644
--- a/tools/perf/tests/mem2node.c
+++ b/tools/perf/tests/mem2node.c
@@ -43,7 +43,7 @@ static unsigned long *get_bitmap(const char *str, int nbits)
return bm && map ? bm : NULL;
}

-static int test__mem2node(struct test *t __maybe_unused, int subtest __maybe_unused)
+static int test__mem2node(struct test_suite *t __maybe_unused, int subtest __maybe_unused)
{
struct mem2node map;
struct memory_node nodes[3];
diff --git a/tools/perf/tests/mmap-basic.c b/tools/perf/tests/mmap-basic.c
index 86f34631312d..90b2feda31ac 100644
--- a/tools/perf/tests/mmap-basic.c
+++ b/tools/perf/tests/mmap-basic.c
@@ -29,7 +29,7 @@
* Then it checks if the number of syscalls reported as perf events by
* the kernel corresponds to the number of syscalls made.
*/
-static int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__basic_mmap(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int err = -1;
union perf_event *event;
diff --git a/tools/perf/tests/mmap-thread-lookup.c b/tools/perf/tests/mmap-thread-lookup.c
index 756a46c796f7..a4301fc7b770 100644
--- a/tools/perf/tests/mmap-thread-lookup.c
+++ b/tools/perf/tests/mmap-thread-lookup.c
@@ -224,7 +224,7 @@ static int mmap_events(synth_cb synth)
*
* by using all thread objects.
*/
-static int test__mmap_thread_lookup(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__mmap_thread_lookup(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
/* perf_event__synthesize_threads synthesize */
TEST_ASSERT_VAL("failed with sythesizing all",
diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c
index 28f3597ba531..cd3dd463783f 100644
--- a/tools/perf/tests/openat-syscall-all-cpus.c
+++ b/tools/perf/tests/openat-syscall-all-cpus.c
@@ -19,7 +19,7 @@
#include "stat.h"
#include "util/counts.h"

-static int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused,
+static int test__openat_syscall_event_on_all_cpus(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
int err = -1, fd, cpu;
diff --git a/tools/perf/tests/openat-syscall-tp-fields.c b/tools/perf/tests/openat-syscall-tp-fields.c
index cbb5c0fa40fe..a7b2800652e4 100644
--- a/tools/perf/tests/openat-syscall-tp-fields.c
+++ b/tools/perf/tests/openat-syscall-tp-fields.c
@@ -22,7 +22,7 @@
#define AT_FDCWD -100
#endif

-static int test__syscall_openat_tp_fields(struct test *test __maybe_unused,
+static int test__syscall_openat_tp_fields(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
struct record_opts opts = {
diff --git a/tools/perf/tests/openat-syscall.c b/tools/perf/tests/openat-syscall.c
index 8f904fcebe6f..7f4c13c4b14d 100644
--- a/tools/perf/tests/openat-syscall.c
+++ b/tools/perf/tests/openat-syscall.c
@@ -13,7 +13,7 @@
#include "tests.h"
#include "util/counts.h"

-static int test__openat_syscall_event(struct test *test __maybe_unused,
+static int test__openat_syscall_event(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
int err = -1, fd;
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index b6232aa6975b..3a3d39d7a5f7 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -2276,7 +2276,7 @@ static int test_pmu_events_alias(char *event, char *alias)
return test_event(&e);
}

-static int test__parse_events(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__parse_events(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int ret1, ret2 = 0;
char *event, *alias;
diff --git a/tools/perf/tests/parse-metric.c b/tools/perf/tests/parse-metric.c
index 86568cb937a9..fbbaae4a57be 100644
--- a/tools/perf/tests/parse-metric.c
+++ b/tools/perf/tests/parse-metric.c
@@ -369,7 +369,7 @@ static int test_metric_group(void)
return 0;
}

-static int test__parse_metric(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__parse_metric(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
TEST_ASSERT_VAL("IPC failed", test_ipc() == 0);
TEST_ASSERT_VAL("frontend failed", test_frontend() == 0);
diff --git a/tools/perf/tests/parse-no-sample-id-all.c b/tools/perf/tests/parse-no-sample-id-all.c
index 2a5eec424a43..d62e31595ab2 100644
--- a/tools/perf/tests/parse-no-sample-id-all.c
+++ b/tools/perf/tests/parse-no-sample-id-all.c
@@ -67,7 +67,7 @@ struct test_attr_event {
*
* Return: %0 on success, %-1 if the test fails.
*/
-static int test__parse_no_sample_id_all(struct test *test __maybe_unused,
+static int test__parse_no_sample_id_all(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
int err;
diff --git a/tools/perf/tests/pe-file-parsing.c b/tools/perf/tests/pe-file-parsing.c
index 8d4fec99459a..c09a9fae1689 100644
--- a/tools/perf/tests/pe-file-parsing.c
+++ b/tools/perf/tests/pe-file-parsing.c
@@ -68,7 +68,7 @@ static int run_dir(const char *d)
return TEST_OK;
}

-static int test__pe_file_parsing(struct test *test __maybe_unused,
+static int test__pe_file_parsing(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
struct stat st;
@@ -89,7 +89,7 @@ static int test__pe_file_parsing(struct test *test __maybe_unused,

#else

-static int test__pe_file_parsing(struct test *test __maybe_unused,
+static int test__pe_file_parsing(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
return TEST_SKIP;
diff --git a/tools/perf/tests/perf-hooks.c b/tools/perf/tests/perf-hooks.c
index 61cb1d0a6eb9..78cdeb89645e 100644
--- a/tools/perf/tests/perf-hooks.c
+++ b/tools/perf/tests/perf-hooks.c
@@ -26,7 +26,7 @@ static void the_hook(void *_hook_flags)
raise(SIGSEGV);
}

-static int test__perf_hooks(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__perf_hooks(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int hook_flags = 0;

diff --git a/tools/perf/tests/perf-record.c b/tools/perf/tests/perf-record.c
index 24faa8487d8c..6354465067b8 100644
--- a/tools/perf/tests/perf-record.c
+++ b/tools/perf/tests/perf-record.c
@@ -41,7 +41,7 @@ static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t *maskp)
return cpu;
}

-static int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__PERF_RECORD(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct record_opts opts = {
.target = {
diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c
index dc2dcad7371f..d23740f80c7d 100644
--- a/tools/perf/tests/perf-time-to-tsc.c
+++ b/tools/perf/tests/perf-time-to-tsc.c
@@ -45,7 +45,7 @@
* %0 is returned, otherwise %-1 is returned. If TSC conversion is not
* supported then then the test passes but " (not supported)" is printed.
*/
-static int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct record_opts opts = {
.mmap_pages = UINT_MAX,
@@ -198,7 +198,7 @@ static bool test__tsc_is_supported(void)
#endif
}

-struct test suite__perf_time_to_tsc = {
+struct test_suite suite__perf_time_to_tsc = {
.desc = "Convert perf time to TSC",
.func = test__perf_time_to_tsc,
.is_supported = test__tsc_is_supported,
diff --git a/tools/perf/tests/pfm.c b/tools/perf/tests/pfm.c
index 83dc9742813a..f55e4ecdda71 100644
--- a/tools/perf/tests/pfm.c
+++ b/tools/perf/tests/pfm.c
@@ -201,7 +201,7 @@ static int test__pfm_subtest_get_nr(void)
return (int)ARRAY_SIZE(pfm_testcase_table);
}

-static int test__pfm(struct test *test __maybe_unused, int i __maybe_unused)
+static int test__pfm(struct test_suite *test __maybe_unused, int i __maybe_unused)
{
#ifdef HAVE_LIBPFM
if (i < 0 || i >= (int)ARRAY_SIZE(pfm_testcase_table))
@@ -212,7 +212,7 @@ static int test__pfm(struct test *test __maybe_unused, int i __maybe_unused)
#endif
}

-struct test suite__pfm = {
+struct test_suite suite__pfm = {
.desc = "Test libpfm4 support",
.func = test__pfm,
.subtest = {
diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index 5d84cc92d3ce..fed399f76eaa 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -1104,7 +1104,7 @@ static int test__pmu_events_subtest_get_nr(void)
return (int)ARRAY_SIZE(pmu_events_testcase_table);
}

-static int test__pmu_events(struct test *test __maybe_unused, int subtest)
+static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest)
{
if (subtest < 0 ||
subtest >= (int)ARRAY_SIZE(pmu_events_testcase_table))
@@ -1112,7 +1112,7 @@ static int test__pmu_events(struct test *test __maybe_unused, int subtest)
return pmu_events_testcase_table[subtest].func();
}

-struct test suite__pmu_events = {
+struct test_suite suite__pmu_events = {
.desc = "PMU events",
.func = test__pmu_events,
.subtest = {
diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c
index 9a58dad67b27..8507bd615e97 100644
--- a/tools/perf/tests/pmu.c
+++ b/tools/perf/tests/pmu.c
@@ -137,7 +137,7 @@ static struct list_head *test_terms_list(void)
return &terms;
}

-static int test__pmu(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__pmu(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
char *format = test_format_dir_get();
LIST_HEAD(formats);
diff --git a/tools/perf/tests/python-use.c b/tools/perf/tests/python-use.c
index b667140688be..6b990ee38575 100644
--- a/tools/perf/tests/python-use.c
+++ b/tools/perf/tests/python-use.c
@@ -9,7 +9,7 @@
#include "tests.h"
#include "util/debug.h"

-static int test__python_use(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__python_use(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
char *cmd;
int ret;
diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c
index 667518df58a3..6df176a4ce21 100644
--- a/tools/perf/tests/sample-parsing.c
+++ b/tools/perf/tests/sample-parsing.c
@@ -335,7 +335,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format)
* checks sample format bits separately and together. If the test passes %0 is
* returned, otherwise %-1 is returned.
*/
-static int test__sample_parsing(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__sample_parsing(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
const u64 rf[] = {4, 5, 6, 7, 12, 13, 14, 15};
u64 sample_type;
diff --git a/tools/perf/tests/sdt.c b/tools/perf/tests/sdt.c
index 307615f1b6a7..919712899251 100644
--- a/tools/perf/tests/sdt.c
+++ b/tools/perf/tests/sdt.c
@@ -76,7 +76,7 @@ static int search_cached_probe(const char *target,
return ret;
}

-static int test__sdt_event(struct test *test __maybe_unused, int subtests __maybe_unused)
+static int test__sdt_event(struct test_suite *test __maybe_unused, int subtests __maybe_unused)
{
int ret = TEST_FAIL;
char __tempdir[] = "./test-buildid-XXXXXX";
@@ -114,7 +114,7 @@ static int test__sdt_event(struct test *test __maybe_unused, int subtests __mayb
return ret;
}
#else
-static int test__sdt_event(struct test *test __maybe_unused, int subtests __maybe_unused)
+static int test__sdt_event(struct test_suite *test __maybe_unused, int subtests __maybe_unused)
{
pr_debug("Skip SDT event test because SDT support is not compiled\n");
return TEST_SKIP;
diff --git a/tools/perf/tests/stat.c b/tools/perf/tests/stat.c
index 2589f2f529ba..2eb096b5e6da 100644
--- a/tools/perf/tests/stat.c
+++ b/tools/perf/tests/stat.c
@@ -47,7 +47,7 @@ static int process_stat_config_event(struct perf_tool *tool __maybe_unused,
return 0;
}

-static int test__synthesize_stat_config(struct test *test __maybe_unused,
+static int test__synthesize_stat_config(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
struct perf_stat_config stat_config = {
@@ -78,7 +78,7 @@ static int process_stat_event(struct perf_tool *tool __maybe_unused,
return 0;
}

-static int test__synthesize_stat(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__synthesize_stat(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct perf_counts_values count;

@@ -104,7 +104,7 @@ static int process_stat_round_event(struct perf_tool *tool __maybe_unused,
return 0;
}

-static int test__synthesize_stat_round(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__synthesize_stat_round(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
TEST_ASSERT_VAL("failed to synthesize stat_config",
!perf_event__synthesize_stat_round(NULL, 0xdeadbeef, PERF_STAT_ROUND_TYPE__INTERVAL,
diff --git a/tools/perf/tests/sw-clock.c b/tools/perf/tests/sw-clock.c
index db1e339a0fbe..9cd6fec375ee 100644
--- a/tools/perf/tests/sw-clock.c
+++ b/tools/perf/tests/sw-clock.c
@@ -133,7 +133,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id)
return err;
}

-static int test__sw_clock_freq(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__sw_clock_freq(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int ret;

diff --git a/tools/perf/tests/switch-tracking.c b/tools/perf/tests/switch-tracking.c
index 9b379aaddce4..0c0c2328bf4e 100644
--- a/tools/perf/tests/switch-tracking.c
+++ b/tools/perf/tests/switch-tracking.c
@@ -321,7 +321,7 @@ static int process_events(struct evlist *evlist,
* evsel->core.system_wide and evsel->tracking flags (respectively) with other events
* sometimes enabled or disabled.
*/
-static int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__switch_tracking(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
const char *sched_switch = "sched:sched_switch";
struct switch_tracking switch_tracking = { .tids = NULL, };
diff --git a/tools/perf/tests/task-exit.c b/tools/perf/tests/task-exit.c
index 197574230493..25f075fa9125 100644
--- a/tools/perf/tests/task-exit.c
+++ b/tools/perf/tests/task-exit.c
@@ -39,7 +39,7 @@ static void workload_exec_failed_signal(int signo __maybe_unused,
* if the number of exit event reported by the kernel is 1 or not
* in order to check the kernel returns correct number of event.
*/
-static int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__task_exit(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
int err = -1;
union perf_event *event;
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index f2efa331b32f..c95b0de9f822 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -27,9 +27,9 @@ enum {
TEST_SKIP = -2,
};

-struct test {
+struct test_suite {
const char *desc;
- int (*func)(struct test *test, int subtest);
+ int (*func)(struct test_suite *test, int subtest);
struct {
bool skip_if_fail;
int (*get_nr)(void);
@@ -41,10 +41,10 @@ struct test {
};

#define DECLARE_SUITE(name) \
- extern struct test suite__##name;
+ extern struct test_suite suite__##name;

#define DEFINE_SUITE(description, name) \
- struct test suite__##name = { \
+ struct test_suite suite__##name = { \
.desc = description, \
.func = test__##name, \
}
diff --git a/tools/perf/tests/thread-map.c b/tools/perf/tests/thread-map.c
index 7e2e8a72fa78..e413c1387fcb 100644
--- a/tools/perf/tests/thread-map.c
+++ b/tools/perf/tests/thread-map.c
@@ -19,7 +19,7 @@ struct machine;
#define NAME (const char *) "perf"
#define NAMEUL (unsigned long) NAME

-static int test__thread_map(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__thread_map(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct perf_thread_map *map;

@@ -86,7 +86,7 @@ static int process_event(struct perf_tool *tool __maybe_unused,
return 0;
}

-static int test__thread_map_synthesize(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__thread_map_synthesize(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct perf_thread_map *threads;

@@ -106,7 +106,7 @@ static int test__thread_map_synthesize(struct test *test __maybe_unused, int sub
return 0;
}

-static int test__thread_map_remove(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__thread_map_remove(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct perf_thread_map *threads;
char *str;
diff --git a/tools/perf/tests/thread-maps-share.c b/tools/perf/tests/thread-maps-share.c
index 2821be0a9a05..84edd82c519e 100644
--- a/tools/perf/tests/thread-maps-share.c
+++ b/tools/perf/tests/thread-maps-share.c
@@ -4,7 +4,7 @@
#include "thread.h"
#include "debug.h"

-static int test__thread_maps_share(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__thread_maps_share(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
struct machines machines;
struct machine *machine;
diff --git a/tools/perf/tests/time-utils-test.c b/tools/perf/tests/time-utils-test.c
index 538100cb7541..38df10373c1e 100644
--- a/tools/perf/tests/time-utils-test.c
+++ b/tools/perf/tests/time-utils-test.c
@@ -131,7 +131,7 @@ static bool test__perf_time__parse_for_ranges(struct test_data *d)
return pass;
}

-static int test__time_utils(struct test *t __maybe_unused, int subtest __maybe_unused)
+static int test__time_utils(struct test_suite *t __maybe_unused, int subtest __maybe_unused)
{
bool pass = true;

diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c
index 05fda3955f95..f998c10ca124 100644
--- a/tools/perf/tests/topology.c
+++ b/tools/perf/tests/topology.c
@@ -173,7 +173,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)
return 0;
}

-static int test__session_topology(struct test *test __maybe_unused, int subtest __maybe_unused)
+static int test__session_topology(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
{
char path[PATH_MAX];
struct perf_cpu_map *map;
diff --git a/tools/perf/tests/unit_number__scnprintf.c b/tools/perf/tests/unit_number__scnprintf.c
index 2ad78a9473d4..88bcada1c78f 100644
--- a/tools/perf/tests/unit_number__scnprintf.c
+++ b/tools/perf/tests/unit_number__scnprintf.c
@@ -7,7 +7,7 @@
#include "units.h"
#include "debug.h"

-static int test__unit_number__scnprint(struct test *t __maybe_unused, int subtest __maybe_unused)
+static int test__unit_number__scnprint(struct test_suite *t __maybe_unused, int subtest __maybe_unused)
{
struct {
u64 n;
diff --git a/tools/perf/tests/vmlinux-kallsyms.c b/tools/perf/tests/vmlinux-kallsyms.c
index 7f1b74bf4f13..e80df13c0420 100644
--- a/tools/perf/tests/vmlinux-kallsyms.c
+++ b/tools/perf/tests/vmlinux-kallsyms.c
@@ -111,7 +111,7 @@ static bool is_ignored_symbol(const char *name, char type)
return false;
}

-static int test__vmlinux_matches_kallsyms(struct test *test __maybe_unused,
+static int test__vmlinux_matches_kallsyms(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)
{
int err = -1;
diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c
index 16ab733cabce..904bdf2dcf81 100644
--- a/tools/perf/tests/wp.c
+++ b/tools/perf/tests/wp.c
@@ -230,7 +230,7 @@ static const char *test__wp_subtest_skip_reason(int i)
return wp_testcase_table[i].skip_msg();
}

-static int test__wp(struct test *test __maybe_unused, int i)
+static int test__wp(struct test_suite *test __maybe_unused, int i)
{
if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
return TEST_FAIL;
@@ -254,7 +254,7 @@ static bool test__wp_is_supported(void)
#endif
}

-struct test suite__wp = {
+struct test_suite suite__wp = {
.desc = "Watchpoint",
.func = test__wp,
.is_supported = test__wp_is_supported,
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:49:45

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 06/22] perf test: Add helper functions for abstraction.

Abstract certain test features so that they can be refactored in later
changes. No functional change.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/builtin-test.c | 94 +++++++++++++++++++++++----------
tools/perf/tests/tests.h | 6 ++-
2 files changed, 71 insertions(+), 29 deletions(-)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 7d52e2eb8147..96eb486ffbc9 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -115,6 +115,45 @@ static struct test_suite **tests[] = {
arch_tests,
};

+static int num_subtests(const struct test_suite *t)
+{
+ if (t->subtest.get_nr)
+ return t->subtest.get_nr();
+
+ return 0;
+}
+
+static bool has_subtests(const struct test_suite *t)
+{
+ return t->subtest.get_nr || num_subtests(t) > 1;
+}
+
+static const char *skip_reason(const struct test_suite *t, int subtest)
+{
+ if (t->subtest.skip_reason)
+ return t->subtest.skip_reason(subtest);
+
+ return NULL;
+}
+
+static const char *test_description(const struct test_suite *t, int subtest)
+{
+ if (subtest < 0 || !t->subtest.get_desc)
+ return t->desc;
+
+ return t->subtest.get_desc(subtest);
+}
+
+static bool is_supported(const struct test_suite *t)
+{
+ return !t->is_supported || t->is_supported();
+}
+
+static test_fnptr test_function(const struct test_suite *t, int subtest __maybe_unused)
+{
+ return t->func;
+}
+
static bool perf_test__matches(const char *desc, int curr, int argc, const char *argv[])
{
int i;
@@ -171,7 +210,7 @@ static int run_test(struct test_suite *test, int subtest)
}
}

- err = test->func(test, subtest);
+ err = test_function(test, subtest)(test, subtest);
if (!dont_fork)
exit(err);
}
@@ -208,7 +247,7 @@ static int test_and_print(struct test_suite *t, bool force_skip, int subtest)
err = TEST_SKIP;
}

- if (!t->subtest.get_nr)
+ if (!has_subtests(t))
pr_debug("%s:", t->desc);
else
pr_debug("%s subtest %d:", t->desc, subtest + 1);
@@ -218,11 +257,10 @@ static int test_and_print(struct test_suite *t, bool force_skip, int subtest)
pr_info(" Ok\n");
break;
case TEST_SKIP: {
- const char *skip_reason = NULL;
- if (t->subtest.skip_reason)
- skip_reason = t->subtest.skip_reason(subtest);
- if (skip_reason)
- color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (%s)\n", skip_reason);
+ const char *reason = skip_reason(t, subtest);
+
+ if (reason)
+ color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (%s)\n", reason);
else
color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n");
}
@@ -397,7 +435,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
int width = shell_tests__max_desc_width();

for_each_test(j, k, t) {
- int len = strlen(t->desc);
+ int len = strlen(test_description(t, -1));

if (width < len)
width = len;
@@ -407,17 +445,15 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
int curr = i++, err;
int subi;

- if (!perf_test__matches(t->desc, curr, argc, argv)) {
+ if (!perf_test__matches(test_description(t, -1), curr, argc, argv)) {
bool skip = true;
int subn;

- if (!t->subtest.get_nr)
- continue;
-
- subn = t->subtest.get_nr();
+ subn = num_subtests(t);

for (subi = 0; subi < subn; subi++) {
- if (perf_test__matches(t->subtest.get_desc(subi), curr, argc, argv))
+ if (perf_test__matches(test_description(t, subi),
+ curr, argc, argv))
skip = false;
}

@@ -425,22 +461,23 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
continue;
}

- if (t->is_supported && !t->is_supported()) {
- pr_debug("%2d: %-*s: Disabled\n", i, width, t->desc);
+ if (!is_supported(t)) {
+ pr_debug("%2d: %-*s: Disabled\n", i, width,
+ test_description(t, -1));
continue;
}

- pr_info("%2d: %-*s:", i, width, t->desc);
+ pr_info("%2d: %-*s:", i, width, test_description(t, -1));

if (intlist__find(skiplist, i)) {
color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n");
continue;
}

- if (!t->subtest.get_nr) {
+ if (!has_subtests(t)) {
test_and_print(t, false, -1);
} else {
- int subn = t->subtest.get_nr();
+ int subn = num_subtests(t);
/*
* minus 2 to align with normal testcases.
* For subtest we print additional '.x' in number.
@@ -460,18 +497,19 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
pr_info("\n");

for (subi = 0; subi < subn; subi++) {
- int len = strlen(t->subtest.get_desc(subi));
+ int len = strlen(test_description(t, subi));

if (subw < len)
subw = len;
}

for (subi = 0; subi < subn; subi++) {
- if (!perf_test__matches(t->subtest.get_desc(subi), curr, argc, argv))
+ if (!perf_test__matches(test_description(t, subi),
+ curr, argc, argv))
continue;

pr_info("%2d.%1d: %-*s:", i, subi + 1, subw,
- t->subtest.get_desc(subi));
+ test_description(t, subi));
err = test_and_print(t, skip, subi);
if (err != TEST_OK && t->subtest.skip_if_fail)
skip = true;
@@ -526,19 +564,19 @@ static int perf_test__list(int argc, const char **argv)
for_each_test(j, k, t) {
int curr = i++;

- if (!perf_test__matches(t->desc, curr, argc, argv) ||
- (t->is_supported && !t->is_supported()))
+ if (!perf_test__matches(test_description(t, -1), curr, argc, argv) ||
+ !is_supported(t))
continue;

- pr_info("%2d: %s\n", i, t->desc);
+ pr_info("%2d: %s\n", i, test_description(t, -1));

- if (t->subtest.get_nr) {
- int subn = t->subtest.get_nr();
+ if (has_subtests(t)) {
+ int subn = num_subtests(t);
int subi;

for (subi = 0; subi < subn; subi++)
pr_info("%2d:%1d: %s\n", i, subi + 1,
- t->subtest.get_desc(subi));
+ test_description(t, subi));
}
}

diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index c95b0de9f822..5139e24973cc 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -27,9 +27,13 @@ enum {
TEST_SKIP = -2,
};

+struct test_suite;
+
+typedef int (*test_fnptr)(struct test_suite *, int);
+
struct test_suite {
const char *desc;
- int (*func)(struct test_suite *test, int subtest);
+ test_fnptr func;
struct {
bool skip_if_fail;
int (*get_nr)(void);
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:49:46

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 16/22] perf test: bp tests use test case

Migration toward kunit style test cases.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/bp_account.c | 7 ++++++-
tools/perf/tests/bp_signal.c | 7 ++++++-
tools/perf/tests/bp_signal_overflow.c | 7 ++++++-
3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/tools/perf/tests/bp_account.c b/tools/perf/tests/bp_account.c
index 365120146d17..e4f7b635ffef 100644
--- a/tools/perf/tests/bp_account.c
+++ b/tools/perf/tests/bp_account.c
@@ -205,8 +205,13 @@ static bool test__bp_account_is_supported(void)
#endif
}

+static struct test_case bp_accounting_tests[] = {
+ TEST_CASE("Breakpoint accounting", bp_accounting),
+ { .name = NULL, }
+};
+
struct test_suite suite__bp_accounting = {
.desc = "Breakpoint accounting",
- .func = test__bp_accounting,
+ .test_cases = bp_accounting_tests,
.is_supported = test__bp_account_is_supported,
};
diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c
index 3c269f81818a..1676e3a11906 100644
--- a/tools/perf/tests/bp_signal.c
+++ b/tools/perf/tests/bp_signal.c
@@ -312,8 +312,13 @@ bool test__bp_signal_is_supported(void)
#endif
}

+static struct test_case bp_signal_tests[] = {
+ TEST_CASE("Breakpoint overflow signal handler", bp_signal),
+ { .name = NULL, }
+};
+
struct test_suite suite__bp_signal = {
.desc = "Breakpoint overflow signal handler",
- .func = test__bp_signal,
+ .test_cases = bp_signal_tests,
.is_supported = test__bp_signal_is_supported,
};
diff --git a/tools/perf/tests/bp_signal_overflow.c b/tools/perf/tests/bp_signal_overflow.c
index 5ac6e1393cf4..bc1f13851750 100644
--- a/tools/perf/tests/bp_signal_overflow.c
+++ b/tools/perf/tests/bp_signal_overflow.c
@@ -134,8 +134,13 @@ static int test__bp_signal_overflow(struct test_suite *test __maybe_unused, int
return fails ? TEST_FAIL : TEST_OK;
}

+static struct test_case bp_signal_overflow_tests[] = {
+ TEST_CASE("Breakpoint overflow sampling", bp_signal_overflow),
+ { .name = NULL, }
+};
+
struct test_suite suite__bp_signal_overflow = {
.desc = "Breakpoint overflow sampling",
- .func = test__bp_signal_overflow,
+ .test_cases = bp_signal_overflow_tests,
.is_supported = test__bp_signal_is_supported,
};
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:49:50

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 08/22] perf test: Add skip reason to test case.

This doesn't exist in kunit, but will ease the transition from perf
tests.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/builtin-test.c | 3 +++
tools/perf/tests/tests.h | 11 ++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index a6d84feba483..916faeee04ff 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -142,6 +142,9 @@ static const char *skip_reason(const struct test_suite *t, int subtest)
if (t->subtest.skip_reason)
return t->subtest.skip_reason(subtest);

+ if (t->test_cases)
+ return t->test_cases[subtest].skip_reason;
+
return NULL;
}

diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 71b8d2c88e5c..f87129b63d92 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -34,6 +34,7 @@ typedef int (*test_fnptr)(struct test_suite *, int);
struct test_case {
const char *name;
const char *desc;
+ const char *skip_reason;
test_fnptr run_case;
};

@@ -61,7 +62,15 @@ struct test_suite {
.run_case = test__##_name, \
}

-#define DEFINE_SUITE(description, _name) \
+#define TEST_CASE_REASON(description, _name, _reason) \
+ { \
+ .name = #_name, \
+ .desc = description, \
+ .run_case = test__##_name, \
+ .skip_reason = _reason, \
+ }
+
+#define DEFINE_SUITE(description, _name) \
struct test_case tests__##_name[] = { \
TEST_CASE(description, _name), \
{ .name = NULL, } \
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:49:52

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 17/22] perf test: Convert time to tsc test to test case.

Migration toward kunit style test cases.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/perf-time-to-tsc.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c
index d23740f80c7d..594013e94ed0 100644
--- a/tools/perf/tests/perf-time-to-tsc.c
+++ b/tools/perf/tests/perf-time-to-tsc.c
@@ -198,8 +198,13 @@ static bool test__tsc_is_supported(void)
#endif
}

+static struct test_case perf_time_to_tsc_tests[] = {
+ TEST_CASE("Convert perf time to TSC", perf_time_to_tsc),
+ { .name = NULL, }
+};
+
struct test_suite suite__perf_time_to_tsc = {
.desc = "Convert perf time to TSC",
- .func = test__perf_time_to_tsc,
+ .test_cases = perf_time_to_tsc_tests,
.is_supported = test__tsc_is_supported,
};
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:50:16

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 15/22] perf test: Remove now unused subtest helpers

Replaced by null terminated test case array.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/builtin-test.c | 11 +----------
tools/perf/tests/tests.h | 3 ---
2 files changed, 1 insertion(+), 13 deletions(-)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 916faeee04ff..c98c7134b552 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -119,9 +119,6 @@ static int num_subtests(const struct test_suite *t)
{
int num;

- if (t->subtest.get_nr)
- return t->subtest.get_nr();
-
if (!t->test_cases)
return 0;

@@ -134,14 +131,11 @@ static int num_subtests(const struct test_suite *t)

static bool has_subtests(const struct test_suite *t)
{
- return t->subtest.get_nr || num_subtests(t) > 1;
+ return num_subtests(t) > 1;
}

static const char *skip_reason(const struct test_suite *t, int subtest)
{
- if (t->subtest.skip_reason)
- return t->subtest.skip_reason(subtest);
-
if (t->test_cases)
return t->test_cases[subtest].skip_reason;

@@ -153,9 +147,6 @@ static const char *test_description(const struct test_suite *t, int subtest)
if (t->test_cases && subtest >= 0)
return t->test_cases[subtest].desc;

- if (t->subtest.get_desc && subtest >= 0)
- return t->subtest.get_desc(subtest);
-
return t->desc;
}

diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index f87129b63d92..9bf448f7429a 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -43,9 +43,6 @@ struct test_suite {
test_fnptr func;
struct {
bool skip_if_fail;
- int (*get_nr)(void);
- const char *(*get_desc)(int subtest);
- const char *(*skip_reason)(int subtest);
} subtest;
struct test_case *test_cases;
bool (*is_supported)(void);
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:50:22

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 22/22] perf test: Remove skip_if_fail

Remove optionality, always run tests in a suite even if one fails. This
brings perf's test more inline with kunit that lacks this notion.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/bpf.c | 1 -
tools/perf/tests/builtin-test.c | 24 ++++++++----------------
tools/perf/tests/clang.c | 1 -
tools/perf/tests/llvm.c | 1 -
tools/perf/tests/pfm.c | 1 -
tools/perf/tests/tests.h | 3 ---
6 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c
index e86a77ce93ef..c3d6eda8601e 100644
--- a/tools/perf/tests/bpf.c
+++ b/tools/perf/tests/bpf.c
@@ -382,5 +382,4 @@ static struct test_case bpf_tests[] = {
struct test_suite suite__bpf = {
.desc = "BPF filter",
.test_cases = bpf_tests,
- .subtest = { .skip_if_fail = true, },
};
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 086641f60015..14e49f51be10 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -238,18 +238,13 @@ static int run_test(struct test_suite *test, int subtest)
for (j = 0; j < ARRAY_SIZE(tests); j++) \
for (k = 0, t = tests[j][k]; tests[j][k]; k++, t = tests[j][k])

-static int test_and_print(struct test_suite *t, bool force_skip, int subtest)
+static int test_and_print(struct test_suite *t, int subtest)
{
int err;

- if (!force_skip) {
- pr_debug("\n--- start ---\n");
- err = run_test(t, subtest);
- pr_debug("---- end ----\n");
- } else {
- pr_debug("\n--- force skipped ---\n");
- err = TEST_SKIP;
- }
+ pr_debug("\n--- start ---\n");
+ err = run_test(t, subtest);
+ pr_debug("---- end ----\n");

if (!has_subtests(t))
pr_debug("%s:", t->desc);
@@ -432,7 +427,7 @@ static int run_shell_tests(int argc, const char *argv[], int i, int width,
continue;
}

- test_and_print(&test_suite, false, 0);
+ test_and_print(&test_suite, 0);
}

for (e = 0; e < n_dirs; e++)
@@ -456,7 +451,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
}

for_each_test(j, k, t) {
- int curr = i++, err;
+ int curr = i++;
int subi;

if (!perf_test__matches(test_description(t, -1), curr, argc, argv)) {
@@ -483,7 +478,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
}

if (!has_subtests(t)) {
- test_and_print(t, false, -1);
+ test_and_print(t, -1);
} else {
int subn = num_subtests(t);
/*
@@ -495,7 +490,6 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
* 35.1: Basic BPF llvm compiling test : Ok
*/
int subw = width > 2 ? width - 2 : width;
- bool skip = false;

if (subn <= 0) {
color_fprintf(stderr, PERF_COLOR_YELLOW,
@@ -518,9 +512,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)

pr_info("%2d.%1d: %-*s:", i, subi + 1, subw,
test_description(t, subi));
- err = test_and_print(t, skip, subi);
- if (err != TEST_OK && t->subtest.skip_if_fail)
- skip = true;
+ test_and_print(t, subi);
}
}
}
diff --git a/tools/perf/tests/clang.c b/tools/perf/tests/clang.c
index ba06a2257574..a7111005d5b9 100644
--- a/tools/perf/tests/clang.c
+++ b/tools/perf/tests/clang.c
@@ -29,5 +29,4 @@ static struct test_case clang_tests[] = {
struct test_suite suite__clang = {
.desc = "builtin clang support",
.test_cases = clang_tests,
- .subtest = { .skip_if_fail = true, },
};
diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
index f27ef00d65e9..8ac0a3a457ef 100644
--- a/tools/perf/tests/llvm.c
+++ b/tools/perf/tests/llvm.c
@@ -216,5 +216,4 @@ static struct test_case llvm_tests[] = {
struct test_suite suite__llvm = {
.desc = "LLVM search and compile",
.test_cases = llvm_tests,
- .subtest = { .skip_if_fail = true, },
};
diff --git a/tools/perf/tests/pfm.c b/tools/perf/tests/pfm.c
index 651fee4ef819..71b76deb1f92 100644
--- a/tools/perf/tests/pfm.c
+++ b/tools/perf/tests/pfm.c
@@ -191,5 +191,4 @@ static struct test_case pfm_tests[] = {
struct test_suite suite__pfm = {
.desc = "Test libpfm4 support",
.test_cases = pfm_tests,
- .subtest = { .skip_if_fail = true }
};
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 15051801c790..8f65098110fc 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -40,9 +40,6 @@ struct test_case {

struct test_suite {
const char *desc;
- struct {
- bool skip_if_fail;
- } subtest;
struct test_case *test_cases;
void *priv;
};
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:50:43

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 19/22] perf test: BP tests, remove is_supported use

Migrate the is_supported functionality to returning TEST_SKIP.
Motivation is kunit has no is_supported function.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/bp_account.c | 45 +++++++++++----------------
tools/perf/tests/bp_signal.c | 43 ++++---------------------
tools/perf/tests/bp_signal_overflow.c | 16 ++++------
tools/perf/tests/tests.h | 21 ++++++++++++-
4 files changed, 51 insertions(+), 74 deletions(-)

diff --git a/tools/perf/tests/bp_account.c b/tools/perf/tests/bp_account.c
index e4f7b635ffef..d1ebb5561e5b 100644
--- a/tools/perf/tests/bp_account.c
+++ b/tools/perf/tests/bp_account.c
@@ -19,6 +19,19 @@
#include "../perf-sys.h"
#include "cloexec.h"

+/*
+ * PowerPC and S390 do not support creation of instruction breakpoints using the
+ * perf_event interface.
+ *
+ * Just disable the test for these architectures until these issues are
+ * resolved.
+ */
+#if defined(__powerpc__) || defined(__s390x__)
+#define BP_ACCOUNT_IS_SUPPORTED 0
+#else
+#define BP_ACCOUNT_IS_SUPPORTED 1
+#endif
+
static volatile long the_var;

static noinline int test_function(void)
@@ -180,6 +193,11 @@ static int test__bp_accounting(struct test_suite *test __maybe_unused, int subte
int bp_cnt = detect_cnt(true);
int share = detect_share(wp_cnt, bp_cnt);

+ if (!BP_ACCOUNT_IS_SUPPORTED) {
+ pr_debug("Test not supported on this architecture");
+ return TEST_SKIP;
+ }
+
pr_debug("watchpoints count %d, breakpoints count %d, has_ioctl %d, share %d\n",
wp_cnt, bp_cnt, has_ioctl, share);

@@ -189,29 +207,4 @@ static int test__bp_accounting(struct test_suite *test __maybe_unused, int subte
return bp_accounting(wp_cnt, share);
}

-static bool test__bp_account_is_supported(void)
-{
- /*
- * PowerPC and S390 do not support creation of instruction
- * breakpoints using the perf_event interface.
- *
- * Just disable the test for these architectures until these
- * issues are resolved.
- */
-#if defined(__powerpc__) || defined(__s390x__)
- return false;
-#else
- return true;
-#endif
-}
-
-static struct test_case bp_accounting_tests[] = {
- TEST_CASE("Breakpoint accounting", bp_accounting),
- { .name = NULL, }
-};
-
-struct test_suite suite__bp_accounting = {
- .desc = "Breakpoint accounting",
- .test_cases = bp_accounting_tests,
- .is_supported = test__bp_account_is_supported,
-};
+DEFINE_SUITE("Breakpoint accounting", bp_accounting);
diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c
index 1676e3a11906..1f2908f02389 100644
--- a/tools/perf/tests/bp_signal.c
+++ b/tools/perf/tests/bp_signal.c
@@ -166,6 +166,11 @@ static int test__bp_signal(struct test_suite *test __maybe_unused, int subtest _
struct sigaction sa;
long long count1, count2, count3;

+ if (!BP_SIGNAL_IS_SUPPORTED) {
+ pr_debug("Test not supported on this architecture");
+ return TEST_SKIP;
+ }
+
/* setup SIGIO signal handler */
memset(&sa, 0, sizeof(struct sigaction));
sa.sa_sigaction = (void *) sig_handler;
@@ -285,40 +290,4 @@ static int test__bp_signal(struct test_suite *test __maybe_unused, int subtest _
TEST_OK : TEST_FAIL;
}

-bool test__bp_signal_is_supported(void)
-{
- /*
- * PowerPC and S390 do not support creation of instruction
- * breakpoints using the perf_event interface.
- *
- * ARM requires explicit rounding down of the instruction
- * pointer in Thumb mode, and then requires the single-step
- * to be handled explicitly in the overflow handler to avoid
- * stepping into the SIGIO handler and getting stuck on the
- * breakpointed instruction.
- *
- * Since arm64 has the same issue with arm for the single-step
- * handling, this case also gets stuck on the breakpointed
- * instruction.
- *
- * Just disable the test for these architectures until these
- * issues are resolved.
- */
-#if defined(__powerpc__) || defined(__s390x__) || defined(__arm__) || \
- defined(__aarch64__)
- return false;
-#else
- return true;
-#endif
-}
-
-static struct test_case bp_signal_tests[] = {
- TEST_CASE("Breakpoint overflow signal handler", bp_signal),
- { .name = NULL, }
-};
-
-struct test_suite suite__bp_signal = {
- .desc = "Breakpoint overflow signal handler",
- .test_cases = bp_signal_tests,
- .is_supported = test__bp_signal_is_supported,
-};
+DEFINE_SUITE("Breakpoint overflow signal handler", bp_signal);
diff --git a/tools/perf/tests/bp_signal_overflow.c b/tools/perf/tests/bp_signal_overflow.c
index bc1f13851750..4e897c2cf26b 100644
--- a/tools/perf/tests/bp_signal_overflow.c
+++ b/tools/perf/tests/bp_signal_overflow.c
@@ -66,6 +66,11 @@ static int test__bp_signal_overflow(struct test_suite *test __maybe_unused, int
long long count;
int fd, i, fails = 0;

+ if (!BP_SIGNAL_IS_SUPPORTED) {
+ pr_debug("Test not supported on this architecture");
+ return TEST_SKIP;
+ }
+
/* setup SIGIO signal handler */
memset(&sa, 0, sizeof(struct sigaction));
sa.sa_sigaction = (void *) sig_handler;
@@ -134,13 +139,4 @@ static int test__bp_signal_overflow(struct test_suite *test __maybe_unused, int
return fails ? TEST_FAIL : TEST_OK;
}

-static struct test_case bp_signal_overflow_tests[] = {
- TEST_CASE("Breakpoint overflow sampling", bp_signal_overflow),
- { .name = NULL, }
-};
-
-struct test_suite suite__bp_signal_overflow = {
- .desc = "Breakpoint overflow sampling",
- .test_cases = bp_signal_overflow_tests,
- .is_supported = test__bp_signal_is_supported,
-};
+DEFINE_SUITE("Breakpoint overflow sampling", bp_signal_overflow);
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index cae33c375d55..958f94dcc94c 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -151,7 +151,26 @@ DECLARE_SUITE(expand_cgroup_events);
DECLARE_SUITE(perf_time_to_tsc);
DECLARE_SUITE(dlfilter);

-bool test__bp_signal_is_supported(void);
+/*
+ * PowerPC and S390 do not support creation of instruction breakpoints using the
+ * perf_event interface.
+ *
+ * ARM requires explicit rounding down of the instruction pointer in Thumb mode,
+ * and then requires the single-step to be handled explicitly in the overflow
+ * handler to avoid stepping into the SIGIO handler and getting stuck on the
+ * breakpointed instruction.
+ *
+ * Since arm64 has the same issue with arm for the single-step handling, this
+ * case also gets stuck on the breakpointed instruction.
+ *
+ * Just disable the test for these architectures until these issues are
+ * resolved.
+ */
+#if defined(__powerpc__) || defined(__s390x__) || defined(__arm__) || defined(__aarch64__)
+#define BP_SIGNAL_IS_SUPPORTED 0
+#else
+#define BP_SIGNAL_IS_SUPPORTED 1
+#endif

#ifdef HAVE_DWARF_UNWIND_SUPPORT
struct thread;
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:50:44

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 18/22] perf test: Remove non test case style support.

Convert shell tests to also run using test case style.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/builtin-test.c | 25 ++++++++++++++++---------
tools/perf/tests/tests.h | 1 -
2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index c98c7134b552..966948cacba3 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -157,9 +157,6 @@ static bool is_supported(const struct test_suite *t)

static test_fnptr test_function(const struct test_suite *t, int subtest)
{
- if (t->func)
- return t->func;
-
if (subtest <= 0)
return t->test_cases[0].run_case;

@@ -413,24 +410,34 @@ static int run_shell_tests(int argc, const char *argv[], int i, int width,
for_each_shell_test(entlist, n_dirs, st.dir, ent) {
int curr = i++;
char desc[256];
- struct test_suite test = {
- .desc = shell_test__description(desc, sizeof(desc), st.dir, ent->d_name),
- .func = shell_test__run,
+ struct test_case test_cases[] = {
+ {
+ .desc = shell_test__description(desc,
+ sizeof(desc),
+ st.dir,
+ ent->d_name),
+ .run_case = shell_test__run,
+ },
+ { .name = NULL, }
+ };
+ struct test_suite test_suite = {
+ .desc = test_cases[0].desc,
+ .test_cases = test_cases,
.priv = &st,
};

- if (!perf_test__matches(test.desc, curr, argc, argv))
+ if (!perf_test__matches(test_suite.desc, curr, argc, argv))
continue;

st.file = ent->d_name;
- pr_info("%2d: %-*s:", i, width, test.desc);
+ pr_info("%2d: %-*s:", i, width, test_suite.desc);

if (intlist__find(skiplist, i)) {
color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n");
continue;
}

- test_and_print(&test, false, -1);
+ test_and_print(&test_suite, false, 0);
}

for (e = 0; e < n_dirs; e++)
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 9bf448f7429a..cae33c375d55 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -40,7 +40,6 @@ struct test_case {

struct test_suite {
const char *desc;
- test_fnptr func;
struct {
bool skip_if_fail;
} subtest;
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:50:44

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 12/22] perf test: Convert clang tests to test cases.

Use null terminated array of test cases rather than the previous sub
test functions.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/clang.c | 57 +++++++++---------------------
tools/perf/util/c++/clang-c.h | 8 ++---
tools/perf/util/c++/clang-test.cpp | 6 ++--
3 files changed, 24 insertions(+), 47 deletions(-)

diff --git a/tools/perf/tests/clang.c b/tools/perf/tests/clang.c
index a499fcf37bf9..ba06a2257574 100644
--- a/tools/perf/tests/clang.c
+++ b/tools/perf/tests/clang.c
@@ -3,54 +3,31 @@
#include "c++/clang-c.h"
#include <linux/kernel.h>

-static struct {
- int (*func)(void);
- const char *desc;
-} clang_testcase_table[] = {
-#ifdef HAVE_LIBCLANGLLVM_SUPPORT
- {
- .func = test__clang_to_IR,
- .desc = "builtin clang compile C source to IR",
- },
- {
- .func = test__clang_to_obj,
- .desc = "builtin clang compile C source to ELF object",
- },
-#endif
-};
-
-static int test__clang_subtest_get_nr(void)
-{
- return (int)ARRAY_SIZE(clang_testcase_table);
-}
-
-static const char *test__clang_subtest_get_desc(int i)
-{
- if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table))
- return NULL;
- return clang_testcase_table[i].desc;
-}
-
#ifndef HAVE_LIBCLANGLLVM_SUPPORT
-static int test__clang(struct test_suite *test __maybe_unused, int i __maybe_unused)
+static int test__clang_to_IR(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
return TEST_SKIP;
}
-#else
-static int test__clang(struct test_suite *test __maybe_unused, int i)
+
+static int test__clang_to_obj(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
- if (i < 0 || i >= (int)ARRAY_SIZE(clang_testcase_table))
- return TEST_FAIL;
- return clang_testcase_table[i].func();
+ return TEST_SKIP;
}
#endif

+static struct test_case clang_tests[] = {
+ TEST_CASE_REASON("builtin clang compile C source to IR", clang_to_IR,
+ "not compiled in"),
+ TEST_CASE_REASON("builtin clang compile C source to ELF object",
+ clang_to_obj,
+ "not compiled in"),
+ { .name = NULL, }
+};
+
struct test_suite suite__clang = {
.desc = "builtin clang support",
- .func = test__clang,
- .subtest = {
- .skip_if_fail = true,
- .get_nr = test__clang_subtest_get_nr,
- .get_desc = test__clang_subtest_get_desc,
- }
+ .test_cases = clang_tests,
+ .subtest = { .skip_if_fail = true, },
};
diff --git a/tools/perf/util/c++/clang-c.h b/tools/perf/util/c++/clang-c.h
index 2df8a45bd088..d3731a876b6c 100644
--- a/tools/perf/util/c++/clang-c.h
+++ b/tools/perf/util/c++/clang-c.h
@@ -12,8 +12,9 @@ extern "C" {
extern void perf_clang__init(void);
extern void perf_clang__cleanup(void);

-extern int test__clang_to_IR(void);
-extern int test__clang_to_obj(void);
+struct test_suite;
+extern int test__clang_to_IR(struct test_suite *test, int subtest);
+extern int test__clang_to_obj(struct test_suite *test, int subtest);

extern int perf_clang__compile_bpf(const char *filename,
void **p_obj_buf,
@@ -26,9 +27,6 @@ extern int perf_clang__compile_bpf(const char *filename,
static inline void perf_clang__init(void) { }
static inline void perf_clang__cleanup(void) { }

-static inline int test__clang_to_IR(void) { return -1; }
-static inline int test__clang_to_obj(void) { return -1;}
-
static inline int
perf_clang__compile_bpf(const char *filename __maybe_unused,
void **p_obj_buf __maybe_unused,
diff --git a/tools/perf/util/c++/clang-test.cpp b/tools/perf/util/c++/clang-test.cpp
index 21b23605f78b..a4683ca53697 100644
--- a/tools/perf/util/c++/clang-test.cpp
+++ b/tools/perf/util/c++/clang-test.cpp
@@ -35,7 +35,8 @@ __test__clang_to_IR(void)
}

extern "C" {
-int test__clang_to_IR(void)
+int test__clang_to_IR(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
perf_clang_scope _scope;

@@ -48,7 +49,8 @@ int test__clang_to_IR(void)
return -1;
}

-int test__clang_to_obj(void)
+int test__clang_to_obj(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
perf_clang_scope _scope;

--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:51:01

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 21/22] perf test: Remove is_supported function

All tests now return TEST_SKIP if not supported. Removing this function
brings perf's test_suite struct more inline with kunit.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/builtin-test.c | 14 +-------------
tools/perf/tests/tests.h | 1 -
2 files changed, 1 insertion(+), 14 deletions(-)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 966948cacba3..086641f60015 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -150,11 +150,6 @@ static const char *test_description(const struct test_suite *t, int subtest)
return t->desc;
}

-static bool is_supported(const struct test_suite *t)
-{
- return !t->is_supported || t->is_supported();
-}
-
static test_fnptr test_function(const struct test_suite *t, int subtest)
{
if (subtest <= 0)
@@ -480,12 +475,6 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
continue;
}

- if (!is_supported(t)) {
- pr_debug("%2d: %-*s: Disabled\n", i, width,
- test_description(t, -1));
- continue;
- }
-
pr_info("%2d: %-*s:", i, width, test_description(t, -1));

if (intlist__find(skiplist, i)) {
@@ -583,8 +572,7 @@ static int perf_test__list(int argc, const char **argv)
for_each_test(j, k, t) {
int curr = i++;

- if (!perf_test__matches(test_description(t, -1), curr, argc, argv) ||
- !is_supported(t))
+ if (!perf_test__matches(test_description(t, -1), curr, argc, argv))
continue;

pr_info("%2d: %s\n", i, test_description(t, -1));
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 958f94dcc94c..15051801c790 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -44,7 +44,6 @@ struct test_suite {
bool skip_if_fail;
} subtest;
struct test_case *test_cases;
- bool (*is_supported)(void);
void *priv;
};

--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:51:04

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 14/22] perf test: Convert llvm tests to test cases.

Use null terminated array of test cases rather than the previous sub
test functions.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/llvm.c | 77 +++++++++++++++++++++++++++++------------
1 file changed, 54 insertions(+), 23 deletions(-)

diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
index 057d6a59a8ea..f27ef00d65e9 100644
--- a/tools/perf/tests/llvm.c
+++ b/tools/perf/tests/llvm.c
@@ -124,7 +124,7 @@ test_llvm__fetch_bpf_obj(void **p_obj_buf,
return ret;
}

-static int test__llvm(struct test_suite *test __maybe_unused, int subtest)
+static int test__llvm(int subtest)
{
int ret;
void *obj_buf = NULL;
@@ -148,42 +148,73 @@ static int test__llvm(struct test_suite *test __maybe_unused, int subtest)

return ret;
}
+#endif //HAVE_LIBBPF_SUPPORT

-static int test__llvm_subtest_get_nr(void)
+static int test__llvm__bpf_base_prog(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
- return __LLVM_TESTCASE_MAX;
+#ifdef HAVE_LIBBPF_SUPPORT
+ return test__llvm(LLVM_TESTCASE_BASE);
+#else
+ pr_debug("Skip LLVM test because BPF support is not compiled\n");
+ return TEST_SKIP;
+#endif
}

-static const char *test__llvm_subtest_get_desc(int subtest)
-{
- if ((subtest < 0) || (subtest >= __LLVM_TESTCASE_MAX))
- return NULL;
-
- return bpf_source_table[subtest].desc;
-}
-#else //HAVE_LIBBPF_SUPPORT
-static int test__llvm(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
+static int test__llvm__bpf_test_kbuild_prog(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
+#ifdef HAVE_LIBBPF_SUPPORT
+ return test__llvm(LLVM_TESTCASE_KBUILD);
+#else
+ pr_debug("Skip LLVM test because BPF support is not compiled\n");
return TEST_SKIP;
+#endif
}

-static int test__llvm_subtest_get_nr(void)
+static int test__llvm__bpf_test_prologue_prog(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
- return 0;
+#ifdef HAVE_LIBBPF_SUPPORT
+ return test__llvm(LLVM_TESTCASE_BPF_PROLOGUE);
+#else
+ pr_debug("Skip LLVM test because BPF support is not compiled\n");
+ return TEST_SKIP;
+#endif
}

-static const char *test__llvm_subtest_get_desc(int subtest __maybe_unused)
+static int test__llvm__bpf_test_relocation(struct test_suite *test __maybe_unused,
+ int subtest __maybe_unused)
{
- return NULL;
+#ifdef HAVE_LIBBPF_SUPPORT
+ return test__llvm(LLVM_TESTCASE_BPF_RELOCATION);
+#else
+ pr_debug("Skip LLVM test because BPF support is not compiled\n");
+ return TEST_SKIP;
+#endif
}
-#endif // HAVE_LIBBPF_SUPPORT
+
+
+static struct test_case llvm_tests[] = {
+#ifdef HAVE_LIBBPF_SUPPORT
+ TEST_CASE("Basic BPF llvm compile", llvm__bpf_base_prog),
+ TEST_CASE("kbuild searching", llvm__bpf_test_kbuild_prog),
+ TEST_CASE("Compile source for BPF prologue generation",
+ llvm__bpf_test_prologue_prog),
+ TEST_CASE("Compile source for BPF relocation", llvm__bpf_test_relocation),
+#else
+ TEST_CASE_REASON("Basic BPF llvm compile", llvm__bpf_base_prog, "not compiled in"),
+ TEST_CASE_REASON("kbuild searching", llvm__bpf_test_kbuild_prog, "not compiled in"),
+ TEST_CASE_REASON("Compile source for BPF prologue generation",
+ llvm__bpf_test_prologue_prog, "not compiled in"),
+ TEST_CASE_REASON("Compile source for BPF relocation",
+ llvm__bpf_test_relocation, "not compiled in"),
+#endif
+ { .name = NULL, }
+};

struct test_suite suite__llvm = {
.desc = "LLVM search and compile",
- .func = test__llvm,
- .subtest = {
- .skip_if_fail = true,
- .get_nr = test__llvm_subtest_get_nr,
- .get_desc = test__llvm_subtest_get_desc,
- },
+ .test_cases = llvm_tests,
+ .subtest = { .skip_if_fail = true, },
};
--
2.33.0.882.g93a45727a2-goog

2021-10-13 17:52:21

by Ian Rogers

[permalink] [raw]
Subject: [PATCH v2 20/22] perf test: TSC test, remove is_supported use

Migrate the is_supported functionality to returning TEST_SKIP.
Motivation is kunit has no is_supported function.

Signed-off-by: Ian Rogers <[email protected]>
---
tools/perf/tests/perf-time-to-tsc.c | 39 ++++++++++++-----------------
1 file changed, 16 insertions(+), 23 deletions(-)

diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c
index 594013e94ed0..d12d0ad81801 100644
--- a/tools/perf/tests/perf-time-to-tsc.c
+++ b/tools/perf/tests/perf-time-to-tsc.c
@@ -23,6 +23,16 @@
#include "pmu.h"
#include "pmu-hybrid.h"

+/*
+ * Except x86_64/i386 and Arm64, other archs don't support TSC in perf. Just
+ * enable the test for x86_64/i386 and Arm64 archs.
+ */
+#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__)
+#define TSC_IS_SUPPORTED 1
+#else
+#define TSC_IS_SUPPORTED 0
+#endif
+
#define CHECK__(x) { \
while ((x) < 0) { \
pr_debug(#x " failed!\n"); \
@@ -69,6 +79,11 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su
u64 test_time, comm1_time = 0, comm2_time = 0;
struct mmap *md;

+ if (!TSC_IS_SUPPORTED) {
+ pr_debug("Test not supported on this architecture");
+ return TEST_SKIP;
+ }
+
threads = thread_map__new(-1, getpid(), UINT_MAX);
CHECK_NOT_NULL__(threads);

@@ -185,26 +200,4 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su
return err;
}

-static bool test__tsc_is_supported(void)
-{
- /*
- * Except x86_64/i386 and Arm64, other archs don't support TSC in perf.
- * Just enable the test for x86_64/i386 and Arm64 archs.
- */
-#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__)
- return true;
-#else
- return false;
-#endif
-}
-
-static struct test_case perf_time_to_tsc_tests[] = {
- TEST_CASE("Convert perf time to TSC", perf_time_to_tsc),
- { .name = NULL, }
-};
-
-struct test_suite suite__perf_time_to_tsc = {
- .desc = "Convert perf time to TSC",
- .test_cases = perf_time_to_tsc_tests,
- .is_supported = test__tsc_is_supported,
-};
+DEFINE_SUITE("Convert perf time to TSC", perf_time_to_tsc);
--
2.33.0.882.g93a45727a2-goog

2021-10-20 12:18:25

by Jiri Olsa

[permalink] [raw]
Subject: Re: [PATCH v2 00/22] Start aligning perf test with kunit style

On Wed, Oct 13, 2021 at 10:45:42AM -0700, Ian Rogers wrote:
> Perf test uses its own structs and code layout that differs from kunit
> that was more recently introduced to the kernel. Besides consistency,
> it is hoped that moving in the direction of kunit style will enable
> reuse of infrastructure like test output formatting for continuous
> testing systems. For example:
> https://lore.kernel.org/linux-kselftest/CA+GJov6tdjvY9x12JsJT14qn6c7NViJxqaJk+r-K1YJzPggFDQ@mail.gmail.com/
>
> The motivation for this restructuring comes from wanting to be able to
> tag tests with a size:
> https://lore.kernel.org/linux-perf-users/CAP-5=fWmGyuqFKc-EMP3rbmTkjZ3MS+YSajGZfeRMc38HS82gw@mail.gmail.com/
> To have more exhaustive and slower running tests. This isn't
> something kunit currently supports, nor is the execution of python and
> shell tests, but it seems sensible to work on an approach with kunit
> rather to invent a new wheel inside of perf.
>
> These initial patches are just refactoring the main test suite
> definitions to be in a more kunit style. Kunit isn't depended upon, it
> is hoped that this can be done in later patches for the sake of
> consistency.
>
> v2. Gets to a point of the perf test test suite/case structs being
> close facsimiles of the kunit ones. It also addresses feedback on
> the v1 RFC, in particular from Jiri Olsa <[email protected]>.

hi,
when I compile with DEBUG=1 it's ok, but with just make:

[root@krava perf]# ./perf test
Segmentation fault (core dumped)
[root@krava perf]# gdb ./perf
GNU gdb (GDB) Fedora 10.2-4.fc33
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./perf...
(gdb) r test
Starting program: /home/jolsa/kernel/linux-perf/tools/perf/perf test
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
__strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:96
96 VPCMPEQ (%rdi), %ymm0, %ymm1
Missing separate debuginfos, use: dnf debuginfo-install bzip2-libs-1.0.8-4.fc33.x86_64 cyrus-sasl-lib-2.1.27-6.fc33.x86_64 elfutils-debuginfod-client-0.185-2.fc33.x86_64 elfutils-libelf-0.185-2.fc33.x86_64 elfutils-libs-0.185-2.fc33.x86_64 keyutils-libs-1.6.1-1.fc33.x86_64 krb5-libs-1.18.2-31.fc33.x86_64 libbabeltrace-1.5.8-3.fc33.x86_64 libbrotli-1.0.9-3.fc33.x86_64 libcap-2.48-2.fc33.x86_64 libcom_err-1.45.6-4.fc33.x86_64 libgcc-10.3.1-1.fc33.x86_64 libidn2-2.3.2-1.fc33.x86_64 libnghttp2-1.43.0-1.fc33.x86_64 libpsl-0.21.1-2.fc33.x86_64 libselinux-3.1-2.fc33.x86_64 libssh-0.9.6-1.fc33.x86_64 libunistring-0.9.10-9.fc33.x86_64 libunwind-1.4.0-4.fc33.x86_64 libuuid-2.36.1-1.fc33.x86_64 libxcrypt-4.4.26-2.fc33.x86_64 numactl-libs-2.0.14-1.fc33.x86_64 openldap-2.4.50-5.fc33.x86_64 openssl-libs-1.1.1l-2.fc33.x86_64 pcre-8.44-2.fc33.x86_64 perl-libs-5.32.1-471.fc33.x86_64 popt-1.18-2.fc33.x86_64 python2.7-2.7.18-15.fc33.x86_64 slang-2.3.2-8.fc33.x86_64 xz-libs-5.2.5-4.fc33.x86_64 zlib-1.2.11-23.fc33.x86_64
(gdb) bt
#0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:96
#1 0x00000000004a3848 in __cmd_test (skiplist=0x0, argv=0x7fffffffd6c0, argc=0) at tests/builtin-test.c:150
#2 cmd_test (argc=0, argv=0x7fffffffd6c0) at tests/builtin-test.c:628
#3 0x00000000004cc47b in run_builtin (p=p@entry=0xa7cda8 <commands+552>, argc=argc@entry=1, argv=argv@entry=0x7fffffffd6c0) at perf.c:313
#4 0x00000000004397ae in handle_internal_command (argv=0x7fffffffd6c0, argc=1) at perf.c:365
#5 run_argv (argv=<synthetic pointer>, argcp=<synthetic pointer>) at perf.c:409
#6 main (argc=1, argv=0x7fffffffd6c0) at perf.c:539
(gdb)

also during the metric test (in make DEBUG=1 build) it runs the
perf bench synthesize and it takes forever ;-)

89: perf all metrics test

that might be another patchset I haven't checked,
but I thought we already agreed not to do that ;-)

jirka

>
> v1. Built/tested on x86.
>
> Ian Rogers (22):
> perf test: Use macro for "suite" declarations
> perf test: Use macro for "suite" definitions
> perf test: Make each test/suite its own struct.
> perf test: Move each test suite struct to its test
> perf test: Rename struct test to test_suite
> perf test: Add helper functions for abstraction.
> perf test: Add test case struct.
> perf test: Add skip reason to test case.
> perf test: Convert pfm tests to use test cases.
> perf test: Convert pmu event tests to test cases.
> perf test: Convert watch point tests to test cases.
> perf test: Convert clang tests to test cases.
> perf test: Convert bpf tests to test cases.
> perf test: Convert llvm tests to test cases.
> perf test: Remove now unused subtest helpers
> perf test: bp tests use test case
> perf test: Convert time to tsc test to test case.
> perf test: Remove non test case style support.
> perf test: BP tests, remove is_supported use
> perf test: TSC test, remove is_supported use
> perf test: Remove is_supported function
> perf test: Remove skip_if_fail
>
> tools/perf/arch/arm/include/arch-tests.h | 2 +-
> tools/perf/arch/arm/tests/arch-tests.c | 18 +-
> tools/perf/arch/arm/tests/vectors-page.c | 2 +-
> tools/perf/arch/arm64/include/arch-tests.h | 2 +-
> tools/perf/arch/arm64/tests/arch-tests.c | 11 +-
> tools/perf/arch/powerpc/include/arch-tests.h | 2 +-
> tools/perf/arch/powerpc/tests/arch-tests.c | 12 +-
> tools/perf/arch/x86/include/arch-tests.h | 14 +-
> tools/perf/arch/x86/tests/arch-tests.c | 46 +-
> tools/perf/arch/x86/tests/bp-modify.c | 2 +-
> tools/perf/arch/x86/tests/insn-x86.c | 2 +-
> tools/perf/arch/x86/tests/intel-cqm.c | 2 +-
> .../x86/tests/intel-pt-pkt-decoder-test.c | 2 +-
> tools/perf/arch/x86/tests/rdpmc.c | 2 +-
> tools/perf/arch/x86/tests/sample-parsing.c | 2 +-
> tools/perf/tests/api-io.c | 6 +-
> tools/perf/tests/attr.c | 4 +-
> tools/perf/tests/backward-ring-buffer.c | 4 +-
> tools/perf/tests/bitmap.c | 4 +-
> tools/perf/tests/bp_account.c | 36 +-
> tools/perf/tests/bp_signal.c | 34 +-
> tools/perf/tests/bp_signal_overflow.c | 9 +-
> tools/perf/tests/bpf.c | 69 ++-
> tools/perf/tests/builtin-test.c | 578 ++++++------------
> tools/perf/tests/clang.c | 54 +-
> tools/perf/tests/code-reading.c | 4 +-
> tools/perf/tests/cpumap.c | 10 +-
> tools/perf/tests/demangle-java-test.c | 4 +-
> tools/perf/tests/demangle-ocaml-test.c | 4 +-
> tools/perf/tests/dlfilter-test.c | 4 +-
> tools/perf/tests/dso-data.c | 10 +-
> tools/perf/tests/dwarf-unwind.c | 5 +-
> tools/perf/tests/event-times.c | 4 +-
> tools/perf/tests/event_update.c | 4 +-
> tools/perf/tests/evsel-roundtrip-name.c | 5 +-
> tools/perf/tests/evsel-tp-sched.c | 5 +-
> tools/perf/tests/expand-cgroup.c | 6 +-
> tools/perf/tests/expr.c | 4 +-
> tools/perf/tests/fdarray.c | 7 +-
> tools/perf/tests/genelf.c | 6 +-
> tools/perf/tests/hists_cumulate.c | 4 +-
> tools/perf/tests/hists_filter.c | 4 +-
> tools/perf/tests/hists_link.c | 4 +-
> tools/perf/tests/hists_output.c | 4 +-
> tools/perf/tests/is_printable_array.c | 4 +-
> tools/perf/tests/keep-tracking.c | 4 +-
> tools/perf/tests/kmod-path.c | 4 +-
> tools/perf/tests/llvm.c | 74 ++-
> tools/perf/tests/maps.c | 4 +-
> tools/perf/tests/mem.c | 4 +-
> tools/perf/tests/mem2node.c | 4 +-
> tools/perf/tests/mmap-basic.c | 4 +-
> tools/perf/tests/mmap-thread-lookup.c | 4 +-
> tools/perf/tests/openat-syscall-all-cpus.c | 5 +-
> tools/perf/tests/openat-syscall-tp-fields.c | 5 +-
> tools/perf/tests/openat-syscall.c | 5 +-
> tools/perf/tests/parse-events.c | 4 +-
> tools/perf/tests/parse-metric.c | 4 +-
> tools/perf/tests/parse-no-sample-id-all.c | 5 +-
> tools/perf/tests/pe-file-parsing.c | 6 +-
> tools/perf/tests/perf-hooks.c | 4 +-
> tools/perf/tests/perf-record.c | 4 +-
> tools/perf/tests/perf-time-to-tsc.c | 30 +-
> tools/perf/tests/pfm.c | 63 +-
> tools/perf/tests/pmu-events.c | 73 +--
> tools/perf/tests/pmu.c | 4 +-
> tools/perf/tests/python-use.c | 4 +-
> tools/perf/tests/sample-parsing.c | 4 +-
> tools/perf/tests/sdt.c | 6 +-
> tools/perf/tests/stat.c | 11 +-
> tools/perf/tests/sw-clock.c | 4 +-
> tools/perf/tests/switch-tracking.c | 4 +-
> tools/perf/tests/task-exit.c | 4 +-
> tools/perf/tests/tests.h | 238 ++++----
> tools/perf/tests/thread-map.c | 10 +-
> tools/perf/tests/thread-maps-share.c | 4 +-
> tools/perf/tests/time-utils-test.c | 4 +-
> tools/perf/tests/topology.c | 4 +-
> tools/perf/tests/unit_number__scnprintf.c | 4 +-
> tools/perf/tests/vmlinux-kallsyms.c | 5 +-
> tools/perf/tests/wp.c | 122 +---
> tools/perf/util/c++/clang-c.h | 8 +-
> tools/perf/util/c++/clang-test.cpp | 6 +-
> 83 files changed, 811 insertions(+), 966 deletions(-)
>
> --
> 2.33.0.882.g93a45727a2-goog
>

2021-10-20 12:36:08

by Jiri Olsa

[permalink] [raw]
Subject: Re: [PATCH v2 06/22] perf test: Add helper functions for abstraction.

On Wed, Oct 13, 2021 at 10:45:48AM -0700, Ian Rogers wrote:

SNIP

> else
> pr_debug("%s subtest %d:", t->desc, subtest + 1);
> @@ -218,11 +257,10 @@ static int test_and_print(struct test_suite *t, bool force_skip, int subtest)
> pr_info(" Ok\n");
> break;
> case TEST_SKIP: {
> - const char *skip_reason = NULL;
> - if (t->subtest.skip_reason)
> - skip_reason = t->subtest.skip_reason(subtest);
> - if (skip_reason)
> - color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (%s)\n", skip_reason);
> + const char *reason = skip_reason(t, subtest);
> +
> + if (reason)
> + color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (%s)\n", reason);
> else
> color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n");
> }
> @@ -397,7 +435,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
> int width = shell_tests__max_desc_width();
>
> for_each_test(j, k, t) {
> - int len = strlen(t->desc);
> + int len = strlen(test_description(t, -1));
>
> if (width < len)
> width = len;
> @@ -407,17 +445,15 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
> int curr = i++, err;
> int subi;
>
> - if (!perf_test__matches(t->desc, curr, argc, argv)) {
> + if (!perf_test__matches(test_description(t, -1), curr, argc, argv)) {
> bool skip = true;
> int subn;
>
> - if (!t->subtest.get_nr)
> - continue;
> -
> - subn = t->subtest.get_nr();
> + subn = num_subtests(t);

should you call continue on !subn ?

jirka

>
> for (subi = 0; subi < subn; subi++) {
> - if (perf_test__matches(t->subtest.get_desc(subi), curr, argc, argv))
> + if (perf_test__matches(test_description(t, subi),
> + curr, argc, argv))
> skip = false;
> }
>
> @@ -425,22 +461,23 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
> continue;
> }
>

SNIP

2021-10-20 12:47:27

by Jiri Olsa

[permalink] [raw]
Subject: Re: [PATCH v2 11/22] perf test: Convert watch point tests to test cases.

On Wed, Oct 13, 2021 at 10:45:53AM -0700, Ian Rogers wrote:
> Use null terminated array of test cases rather than the previous sub
> test functions.
>
> Signed-off-by: Ian Rogers <[email protected]>
> ---
> tools/perf/tests/wp.c | 128 ++++++++++--------------------------------
> 1 file changed, 30 insertions(+), 98 deletions(-)
>
> diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c
> index 904bdf2dcf81..2c0513257b15 100644
> --- a/tools/perf/tests/wp.c
> +++ b/tools/perf/tests/wp.c
> @@ -62,8 +62,12 @@ static int __event(int wp_type, void *wp_addr, unsigned long wp_len)
> return fd;
> }
>
> -static int wp_ro_test(void)
> +static int test__wp_ro(struct test_suite *test __maybe_unused,
> + int subtest __maybe_unused)
> {
> +#if defined(__s390x__) || defined(__x86_64__) || defined(__i386__)
> + return TEST_SKIP;
> +#else
> int fd;
> unsigned long tmp, tmp1 = rand();
>
> @@ -79,10 +83,15 @@ static int wp_ro_test(void)
>
> close(fd);
> return 0;
> +#endif
> }
>
> -static int wp_wo_test(void)
> +static int test__wp_wo(struct test_suite *test __maybe_unused,
> + int subtest __maybe_unused)
> {
> +#if defined(__s390x__)
> + return TEST_SKIP;
> +#else
> int fd;
> unsigned long tmp, tmp1 = rand();
>
> @@ -98,10 +107,15 @@ static int wp_wo_test(void)
>
> close(fd);
> return 0;
> +#endif
> }
>
> -static int wp_rw_test(void)
> +static int test__wp_rw(struct test_suite *test __maybe_unused,
> + int subtest __maybe_unused)
> {
> +#if defined(__s390x__)
> + return TEST_SKIP;
> +#else
> int fd;
> unsigned long tmp, tmp1 = rand();
>
> @@ -118,10 +132,15 @@ static int wp_rw_test(void)
>
> close(fd);
> return 0;
> +#endif
> }
>
> -static int wp_modify_test(void)
> +static int test__wp_modify(struct test_suite *test __maybe_unused,
> + int subtest __maybe_unused)
> {
> +#if defined(__s390x__)
> + return TEST_SKIP;
> +#else
> int fd, ret;
> unsigned long tmp = rand();
> struct perf_event_attr new_attr;
> @@ -163,105 +182,18 @@ static int wp_modify_test(void)
>
> close(fd);
> return 0;
> -}
> -
> -static bool wp_ro_supported(void)
> -{
> -#if defined (__x86_64__) || defined (__i386__)
> - return false;
> -#else
> - return true;
> -#endif
> -}
> -
> -static const char *wp_ro_skip_msg(void)
> -{
> -#if defined (__x86_64__) || defined (__i386__)
> - return "missing hardware support";
> -#else
> - return NULL;
> #endif
> }
>
> -static struct {
> - const char *desc;
> - int (*target_func)(void);
> - bool (*is_supported)(void);
> - const char *(*skip_msg)(void);
> -} wp_testcase_table[] = {
> - {
> - .desc = "Read Only Watchpoint",
> - .target_func = &wp_ro_test,
> - .is_supported = &wp_ro_supported,
> - .skip_msg = &wp_ro_skip_msg,
> - },
> - {
> - .desc = "Write Only Watchpoint",
> - .target_func = &wp_wo_test,
> - },
> - {
> - .desc = "Read / Write Watchpoint",
> - .target_func = &wp_rw_test,
> - },
> - {
> - .desc = "Modify Watchpoint",
> - .target_func = &wp_modify_test,
> - },
> +static struct test_case wp_tests[] = {
> + TEST_CASE_REASON("Read Only Watchpoint", wp_ro, "missing hardware support"),
> + TEST_CASE_REASON("Write Only Watchpoint", wp_wo, "missing hardware support"),
> + TEST_CASE_REASON("Read / Write Watchpoint", wp_rw, "missing hardware support"),
> + TEST_CASE_REASON("Modify Watchpoint", wp_modify, "missing hardware support"),
> + { .name = NULL, }
> };
>
> -static int test__wp_subtest_get_nr(void)
> -{
> - return (int)ARRAY_SIZE(wp_testcase_table);
> -}
> -
> -static const char *test__wp_subtest_get_desc(int i)
> -{
> - if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
> - return NULL;
> - return wp_testcase_table[i].desc;
> -}
> -
> -static const char *test__wp_subtest_skip_reason(int i)
> -{
> - if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
> - return NULL;
> - if (!wp_testcase_table[i].skip_msg)
> - return NULL;
> - return wp_testcase_table[i].skip_msg();
> -}
> -
> -static int test__wp(struct test_suite *test __maybe_unused, int i)
> -{
> - if (i < 0 || i >= (int)ARRAY_SIZE(wp_testcase_table))
> - return TEST_FAIL;
> -
> - if (wp_testcase_table[i].is_supported &&
> - !wp_testcase_table[i].is_supported())
> - return TEST_SKIP;
> -
> - return !wp_testcase_table[i].target_func() ? TEST_OK : TEST_FAIL;
> -}
> -
> -/* The s390 so far does not have support for
> - * instruction breakpoint using the perf_event_open() system call.
> - */
> -static bool test__wp_is_supported(void)
> -{
> -#if defined(__s390x__)
> - return false;
> -#else
> - return true;
> -#endif
> -}
> -
> struct test_suite suite__wp = {
> .desc = "Watchpoint",
> - .func = test__wp,
> - .is_supported = test__wp_is_supported,

hm, why do we get rid of this callback and instead use #ifdef 3 times above?

jirka

> - .subtest = {
> - .skip_if_fail = false,
> - .get_nr = test__wp_subtest_get_nr,
> - .get_desc = test__wp_subtest_get_desc,
> - .skip_reason = test__wp_subtest_skip_reason,
> - },
> + .test_cases = wp_tests,
> };
> --
> 2.33.0.882.g93a45727a2-goog
>

2021-10-20 13:09:46

by Jiri Olsa

[permalink] [raw]
Subject: Re: [PATCH v2 21/22] perf test: Remove is_supported function

On Wed, Oct 13, 2021 at 10:46:03AM -0700, Ian Rogers wrote:
> All tests now return TEST_SKIP if not supported. Removing this function
> brings perf's test_suite struct more inline with kunit.

ah ok, forget my previous comment then ;-)

jirka

>
> Signed-off-by: Ian Rogers <[email protected]>
> ---
> tools/perf/tests/builtin-test.c | 14 +-------------
> tools/perf/tests/tests.h | 1 -
> 2 files changed, 1 insertion(+), 14 deletions(-)
>
> diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
> index 966948cacba3..086641f60015 100644
> --- a/tools/perf/tests/builtin-test.c
> +++ b/tools/perf/tests/builtin-test.c
> @@ -150,11 +150,6 @@ static const char *test_description(const struct test_suite *t, int subtest)
> return t->desc;
> }
>
> -static bool is_supported(const struct test_suite *t)
> -{
> - return !t->is_supported || t->is_supported();
> -}
> -
> static test_fnptr test_function(const struct test_suite *t, int subtest)
> {
> if (subtest <= 0)
> @@ -480,12 +475,6 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
> continue;
> }
>
> - if (!is_supported(t)) {
> - pr_debug("%2d: %-*s: Disabled\n", i, width,
> - test_description(t, -1));
> - continue;
> - }
> -
> pr_info("%2d: %-*s:", i, width, test_description(t, -1));
>
> if (intlist__find(skiplist, i)) {
> @@ -583,8 +572,7 @@ static int perf_test__list(int argc, const char **argv)
> for_each_test(j, k, t) {
> int curr = i++;
>
> - if (!perf_test__matches(test_description(t, -1), curr, argc, argv) ||
> - !is_supported(t))
> + if (!perf_test__matches(test_description(t, -1), curr, argc, argv))
> continue;
>
> pr_info("%2d: %s\n", i, test_description(t, -1));
> diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
> index 958f94dcc94c..15051801c790 100644
> --- a/tools/perf/tests/tests.h
> +++ b/tools/perf/tests/tests.h
> @@ -44,7 +44,6 @@ struct test_suite {
> bool skip_if_fail;
> } subtest;
> struct test_case *test_cases;
> - bool (*is_supported)(void);
> void *priv;
> };
>
> --
> 2.33.0.882.g93a45727a2-goog
>

2021-10-20 15:53:56

by Ian Rogers

[permalink] [raw]
Subject: Re: [PATCH v2 00/22] Start aligning perf test with kunit style

On Wed, Oct 20, 2021 at 5:14 AM Jiri Olsa <[email protected]> wrote:
>
> On Wed, Oct 13, 2021 at 10:45:42AM -0700, Ian Rogers wrote:
> > Perf test uses its own structs and code layout that differs from kunit
> > that was more recently introduced to the kernel. Besides consistency,
> > it is hoped that moving in the direction of kunit style will enable
> > reuse of infrastructure like test output formatting for continuous
> > testing systems. For example:
> > https://lore.kernel.org/linux-kselftest/CA+GJov6tdjvY9x12JsJT14qn6c7NViJxqaJk+r-K1YJzPggFDQ@mail.gmail.com/
> >
> > The motivation for this restructuring comes from wanting to be able to
> > tag tests with a size:
> > https://lore.kernel.org/linux-perf-users/CAP-5=fWmGyuqFKc-EMP3rbmTkjZ3MS+YSajGZfeRMc38HS82gw@mail.gmail.com/
> > To have more exhaustive and slower running tests. This isn't
> > something kunit currently supports, nor is the execution of python and
> > shell tests, but it seems sensible to work on an approach with kunit
> > rather to invent a new wheel inside of perf.
> >
> > These initial patches are just refactoring the main test suite
> > definitions to be in a more kunit style. Kunit isn't depended upon, it
> > is hoped that this can be done in later patches for the sake of
> > consistency.
> >
> > v2. Gets to a point of the perf test test suite/case structs being
> > close facsimiles of the kunit ones. It also addresses feedback on
> > the v1 RFC, in particular from Jiri Olsa <[email protected]>.
>
> hi,
> when I compile with DEBUG=1 it's ok, but with just make:
>
> [root@krava perf]# ./perf test
> Segmentation fault (core dumped)
> [root@krava perf]# gdb ./perf
> GNU gdb (GDB) Fedora 10.2-4.fc33
> Copyright (C) 2021 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> Type "show copying" and "show warranty" for details.
> This GDB was configured as "x86_64-redhat-linux-gnu".
> Type "show configuration" for configuration details.
> For bug reporting instructions, please see:
> <https://www.gnu.org/software/gdb/bugs/>.
> Find the GDB manual and other documentation resources online at:
> <http://www.gnu.org/software/gdb/documentation/>.
>
> For help, type "help".
> Type "apropos word" to search for commands related to "word"...
> Reading symbols from ./perf...
> (gdb) r test
> Starting program: /home/jolsa/kernel/linux-perf/tools/perf/perf test
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib64/libthread_db.so.1".
>
> Program received signal SIGSEGV, Segmentation fault.
> __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:96
> 96 VPCMPEQ (%rdi), %ymm0, %ymm1
> Missing separate debuginfos, use: dnf debuginfo-install bzip2-libs-1.0.8-4.fc33.x86_64 cyrus-sasl-lib-2.1.27-6.fc33.x86_64 elfutils-debuginfod-client-0.185-2.fc33.x86_64 elfutils-libelf-0.185-2.fc33.x86_64 elfutils-libs-0.185-2.fc33.x86_64 keyutils-libs-1.6.1-1.fc33.x86_64 krb5-libs-1.18.2-31.fc33.x86_64 libbabeltrace-1.5.8-3.fc33.x86_64 libbrotli-1.0.9-3.fc33.x86_64 libcap-2.48-2.fc33.x86_64 libcom_err-1.45.6-4.fc33.x86_64 libgcc-10.3.1-1.fc33.x86_64 libidn2-2.3.2-1.fc33.x86_64 libnghttp2-1.43.0-1.fc33.x86_64 libpsl-0.21.1-2.fc33.x86_64 libselinux-3.1-2.fc33.x86_64 libssh-0.9.6-1.fc33.x86_64 libunistring-0.9.10-9.fc33.x86_64 libunwind-1.4.0-4.fc33.x86_64 libuuid-2.36.1-1.fc33.x86_64 libxcrypt-4.4.26-2.fc33.x86_64 numactl-libs-2.0.14-1.fc33.x86_64 openldap-2.4.50-5.fc33.x86_64 openssl-libs-1.1.1l-2.fc33.x86_64 pcre-8.44-2.fc33.x86_64 perl-libs-5.32.1-471.fc33.x86_64 popt-1.18-2.fc33.x86_64 python2.7-2.7.18-15.fc33.x86_64 slang-2.3.2-8.fc33.x86_64 xz-libs-5.2.5-4.fc33.x86_64 zlib-1.2.11-23.fc33.x86_64
> (gdb) bt
> #0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:96
> #1 0x00000000004a3848 in __cmd_test (skiplist=0x0, argv=0x7fffffffd6c0, argc=0) at tests/builtin-test.c:150
> #2 cmd_test (argc=0, argv=0x7fffffffd6c0) at tests/builtin-test.c:628
> #3 0x00000000004cc47b in run_builtin (p=p@entry=0xa7cda8 <commands+552>, argc=argc@entry=1, argv=argv@entry=0x7fffffffd6c0) at perf.c:313
> #4 0x00000000004397ae in handle_internal_command (argv=0x7fffffffd6c0, argc=1) at perf.c:365
> #5 run_argv (argv=<synthetic pointer>, argcp=<synthetic pointer>) at perf.c:409
> #6 main (argc=1, argv=0x7fffffffd6c0) at perf.c:539
> (gdb)

Thanks, I'll take a look.

> also during the metric test (in make DEBUG=1 build) it runs the
> perf bench synthesize and it takes forever ;-)
>
> 89: perf all metrics test
>
> that might be another patchset I haven't checked,
> but I thought we already agreed not to do that ;-)

The PMU test was merged, and that may be the very slow running one.
The metric tests run with /bin/true, but if they get "not counted" in
the output they try again with perf bench. It generally runs in
O(seconds) for me, but maybe it is slower on a loaded machine. There
may be some middle sized thing between "perf bench" and true that
gives us enough counts for the tests.

Thanks,
Ian

> jirka
>
> >
> > v1. Built/tested on x86.
> >
> > Ian Rogers (22):
> > perf test: Use macro for "suite" declarations
> > perf test: Use macro for "suite" definitions
> > perf test: Make each test/suite its own struct.
> > perf test: Move each test suite struct to its test
> > perf test: Rename struct test to test_suite
> > perf test: Add helper functions for abstraction.
> > perf test: Add test case struct.
> > perf test: Add skip reason to test case.
> > perf test: Convert pfm tests to use test cases.
> > perf test: Convert pmu event tests to test cases.
> > perf test: Convert watch point tests to test cases.
> > perf test: Convert clang tests to test cases.
> > perf test: Convert bpf tests to test cases.
> > perf test: Convert llvm tests to test cases.
> > perf test: Remove now unused subtest helpers
> > perf test: bp tests use test case
> > perf test: Convert time to tsc test to test case.
> > perf test: Remove non test case style support.
> > perf test: BP tests, remove is_supported use
> > perf test: TSC test, remove is_supported use
> > perf test: Remove is_supported function
> > perf test: Remove skip_if_fail
> >
> > tools/perf/arch/arm/include/arch-tests.h | 2 +-
> > tools/perf/arch/arm/tests/arch-tests.c | 18 +-
> > tools/perf/arch/arm/tests/vectors-page.c | 2 +-
> > tools/perf/arch/arm64/include/arch-tests.h | 2 +-
> > tools/perf/arch/arm64/tests/arch-tests.c | 11 +-
> > tools/perf/arch/powerpc/include/arch-tests.h | 2 +-
> > tools/perf/arch/powerpc/tests/arch-tests.c | 12 +-
> > tools/perf/arch/x86/include/arch-tests.h | 14 +-
> > tools/perf/arch/x86/tests/arch-tests.c | 46 +-
> > tools/perf/arch/x86/tests/bp-modify.c | 2 +-
> > tools/perf/arch/x86/tests/insn-x86.c | 2 +-
> > tools/perf/arch/x86/tests/intel-cqm.c | 2 +-
> > .../x86/tests/intel-pt-pkt-decoder-test.c | 2 +-
> > tools/perf/arch/x86/tests/rdpmc.c | 2 +-
> > tools/perf/arch/x86/tests/sample-parsing.c | 2 +-
> > tools/perf/tests/api-io.c | 6 +-
> > tools/perf/tests/attr.c | 4 +-
> > tools/perf/tests/backward-ring-buffer.c | 4 +-
> > tools/perf/tests/bitmap.c | 4 +-
> > tools/perf/tests/bp_account.c | 36 +-
> > tools/perf/tests/bp_signal.c | 34 +-
> > tools/perf/tests/bp_signal_overflow.c | 9 +-
> > tools/perf/tests/bpf.c | 69 ++-
> > tools/perf/tests/builtin-test.c | 578 ++++++------------
> > tools/perf/tests/clang.c | 54 +-
> > tools/perf/tests/code-reading.c | 4 +-
> > tools/perf/tests/cpumap.c | 10 +-
> > tools/perf/tests/demangle-java-test.c | 4 +-
> > tools/perf/tests/demangle-ocaml-test.c | 4 +-
> > tools/perf/tests/dlfilter-test.c | 4 +-
> > tools/perf/tests/dso-data.c | 10 +-
> > tools/perf/tests/dwarf-unwind.c | 5 +-
> > tools/perf/tests/event-times.c | 4 +-
> > tools/perf/tests/event_update.c | 4 +-
> > tools/perf/tests/evsel-roundtrip-name.c | 5 +-
> > tools/perf/tests/evsel-tp-sched.c | 5 +-
> > tools/perf/tests/expand-cgroup.c | 6 +-
> > tools/perf/tests/expr.c | 4 +-
> > tools/perf/tests/fdarray.c | 7 +-
> > tools/perf/tests/genelf.c | 6 +-
> > tools/perf/tests/hists_cumulate.c | 4 +-
> > tools/perf/tests/hists_filter.c | 4 +-
> > tools/perf/tests/hists_link.c | 4 +-
> > tools/perf/tests/hists_output.c | 4 +-
> > tools/perf/tests/is_printable_array.c | 4 +-
> > tools/perf/tests/keep-tracking.c | 4 +-
> > tools/perf/tests/kmod-path.c | 4 +-
> > tools/perf/tests/llvm.c | 74 ++-
> > tools/perf/tests/maps.c | 4 +-
> > tools/perf/tests/mem.c | 4 +-
> > tools/perf/tests/mem2node.c | 4 +-
> > tools/perf/tests/mmap-basic.c | 4 +-
> > tools/perf/tests/mmap-thread-lookup.c | 4 +-
> > tools/perf/tests/openat-syscall-all-cpus.c | 5 +-
> > tools/perf/tests/openat-syscall-tp-fields.c | 5 +-
> > tools/perf/tests/openat-syscall.c | 5 +-
> > tools/perf/tests/parse-events.c | 4 +-
> > tools/perf/tests/parse-metric.c | 4 +-
> > tools/perf/tests/parse-no-sample-id-all.c | 5 +-
> > tools/perf/tests/pe-file-parsing.c | 6 +-
> > tools/perf/tests/perf-hooks.c | 4 +-
> > tools/perf/tests/perf-record.c | 4 +-
> > tools/perf/tests/perf-time-to-tsc.c | 30 +-
> > tools/perf/tests/pfm.c | 63 +-
> > tools/perf/tests/pmu-events.c | 73 +--
> > tools/perf/tests/pmu.c | 4 +-
> > tools/perf/tests/python-use.c | 4 +-
> > tools/perf/tests/sample-parsing.c | 4 +-
> > tools/perf/tests/sdt.c | 6 +-
> > tools/perf/tests/stat.c | 11 +-
> > tools/perf/tests/sw-clock.c | 4 +-
> > tools/perf/tests/switch-tracking.c | 4 +-
> > tools/perf/tests/task-exit.c | 4 +-
> > tools/perf/tests/tests.h | 238 ++++----
> > tools/perf/tests/thread-map.c | 10 +-
> > tools/perf/tests/thread-maps-share.c | 4 +-
> > tools/perf/tests/time-utils-test.c | 4 +-
> > tools/perf/tests/topology.c | 4 +-
> > tools/perf/tests/unit_number__scnprintf.c | 4 +-
> > tools/perf/tests/vmlinux-kallsyms.c | 5 +-
> > tools/perf/tests/wp.c | 122 +---
> > tools/perf/util/c++/clang-c.h | 8 +-
> > tools/perf/util/c++/clang-test.cpp | 6 +-
> > 83 files changed, 811 insertions(+), 966 deletions(-)
> >
> > --
> > 2.33.0.882.g93a45727a2-goog
> >
>

2021-10-26 02:07:15

by Ian Rogers

[permalink] [raw]
Subject: Re: [PATCH v2 06/22] perf test: Add helper functions for abstraction.

On Wed, Oct 20, 2021 at 5:34 AM Jiri Olsa <[email protected]> wrote:
>
> On Wed, Oct 13, 2021 at 10:45:48AM -0700, Ian Rogers wrote:
>
> SNIP
>
> > else
> > pr_debug("%s subtest %d:", t->desc, subtest + 1);
> > @@ -218,11 +257,10 @@ static int test_and_print(struct test_suite *t, bool force_skip, int subtest)
> > pr_info(" Ok\n");
> > break;
> > case TEST_SKIP: {
> > - const char *skip_reason = NULL;
> > - if (t->subtest.skip_reason)
> > - skip_reason = t->subtest.skip_reason(subtest);
> > - if (skip_reason)
> > - color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (%s)\n", skip_reason);
> > + const char *reason = skip_reason(t, subtest);
> > +
> > + if (reason)
> > + color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (%s)\n", reason);
> > else
> > color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n");
> > }
> > @@ -397,7 +435,7 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
> > int width = shell_tests__max_desc_width();
> >
> > for_each_test(j, k, t) {
> > - int len = strlen(t->desc);
> > + int len = strlen(test_description(t, -1));
> >
> > if (width < len)
> > width = len;
> > @@ -407,17 +445,15 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
> > int curr = i++, err;
> > int subi;
> >
> > - if (!perf_test__matches(t->desc, curr, argc, argv)) {
> > + if (!perf_test__matches(test_description(t, -1), curr, argc, argv)) {
> > bool skip = true;
> > int subn;
> >
> > - if (!t->subtest.get_nr)
> > - continue;
> > -
> > - subn = t->subtest.get_nr();
> > + subn = num_subtests(t);
>
> should you call continue on !subn ?

It's not necessary. When subn == 0 then the loop won't be taken and
skip == true, so the immediately after "if (skip) continue;" will
happen.

Thanks,
Ian

> jirka
>
> >
> > for (subi = 0; subi < subn; subi++) {
> > - if (perf_test__matches(t->subtest.get_desc(subi), curr, argc, argv))
> > + if (perf_test__matches(test_description(t, subi),
> > + curr, argc, argv))
> > skip = false;
> > }
> >
> > @@ -425,22 +461,23 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
> > continue;
> > }
> >
>
> SNIP
>

2021-10-28 23:54:08

by Ian Rogers

[permalink] [raw]
Subject: Re: [PATCH v2 00/22] Start aligning perf test with kunit style

On Wed, Oct 20, 2021 at 8:51 AM Ian Rogers <[email protected]> wrote:
>
> On Wed, Oct 20, 2021 at 5:14 AM Jiri Olsa <[email protected]> wrote:
> >
> > On Wed, Oct 13, 2021 at 10:45:42AM -0700, Ian Rogers wrote:
> > > Perf test uses its own structs and code layout that differs from kunit
> > > that was more recently introduced to the kernel. Besides consistency,
> > > it is hoped that moving in the direction of kunit style will enable
> > > reuse of infrastructure like test output formatting for continuous
> > > testing systems. For example:
> > > https://lore.kernel.org/linux-kselftest/CA+GJov6tdjvY9x12JsJT14qn6c7NViJxqaJk+r-K1YJzPggFDQ@mail.gmail.com/
> > >
> > > The motivation for this restructuring comes from wanting to be able to
> > > tag tests with a size:
> > > https://lore.kernel.org/linux-perf-users/CAP-5=fWmGyuqFKc-EMP3rbmTkjZ3MS+YSajGZfeRMc38HS82gw@mail.gmail.com/
> > > To have more exhaustive and slower running tests. This isn't
> > > something kunit currently supports, nor is the execution of python and
> > > shell tests, but it seems sensible to work on an approach with kunit
> > > rather to invent a new wheel inside of perf.
> > >
> > > These initial patches are just refactoring the main test suite
> > > definitions to be in a more kunit style. Kunit isn't depended upon, it
> > > is hoped that this can be done in later patches for the sake of
> > > consistency.
> > >
> > > v2. Gets to a point of the perf test test suite/case structs being
> > > close facsimiles of the kunit ones. It also addresses feedback on
> > > the v1 RFC, in particular from Jiri Olsa <[email protected]>.
> >
> > hi,
> > when I compile with DEBUG=1 it's ok, but with just make:
> >
> > [root@krava perf]# ./perf test
> > Segmentation fault (core dumped)
> > [root@krava perf]# gdb ./perf
> > GNU gdb (GDB) Fedora 10.2-4.fc33
> > Copyright (C) 2021 Free Software Foundation, Inc.
> > License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> > This is free software: you are free to change and redistribute it.
> > There is NO WARRANTY, to the extent permitted by law.
> > Type "show copying" and "show warranty" for details.
> > This GDB was configured as "x86_64-redhat-linux-gnu".
> > Type "show configuration" for configuration details.
> > For bug reporting instructions, please see:
> > <https://www.gnu.org/software/gdb/bugs/>.
> > Find the GDB manual and other documentation resources online at:
> > <http://www.gnu.org/software/gdb/documentation/>.
> >
> > For help, type "help".
> > Type "apropos word" to search for commands related to "word"...
> > Reading symbols from ./perf...
> > (gdb) r test
> > Starting program: /home/jolsa/kernel/linux-perf/tools/perf/perf test
> > [Thread debugging using libthread_db enabled]
> > Using host libthread_db library "/lib64/libthread_db.so.1".
> >
> > Program received signal SIGSEGV, Segmentation fault.
> > __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:96
> > 96 VPCMPEQ (%rdi), %ymm0, %ymm1
> > Missing separate debuginfos, use: dnf debuginfo-install bzip2-libs-1.0.8-4.fc33.x86_64 cyrus-sasl-lib-2.1.27-6.fc33.x86_64 elfutils-debuginfod-client-0.185-2.fc33.x86_64 elfutils-libelf-0.185-2.fc33.x86_64 elfutils-libs-0.185-2.fc33.x86_64 keyutils-libs-1.6.1-1.fc33.x86_64 krb5-libs-1.18.2-31.fc33.x86_64 libbabeltrace-1.5.8-3.fc33.x86_64 libbrotli-1.0.9-3.fc33.x86_64 libcap-2.48-2.fc33.x86_64 libcom_err-1.45.6-4.fc33.x86_64 libgcc-10.3.1-1.fc33.x86_64 libidn2-2.3.2-1.fc33.x86_64 libnghttp2-1.43.0-1.fc33.x86_64 libpsl-0.21.1-2.fc33.x86_64 libselinux-3.1-2.fc33.x86_64 libssh-0.9.6-1.fc33.x86_64 libunistring-0.9.10-9.fc33.x86_64 libunwind-1.4.0-4.fc33.x86_64 libuuid-2.36.1-1.fc33.x86_64 libxcrypt-4.4.26-2.fc33.x86_64 numactl-libs-2.0.14-1.fc33.x86_64 openldap-2.4.50-5.fc33.x86_64 openssl-libs-1.1.1l-2.fc33.x86_64 pcre-8.44-2.fc33.x86_64 perl-libs-5.32.1-471.fc33.x86_64 popt-1.18-2.fc33.x86_64 python2.7-2.7.18-15.fc33.x86_64 slang-2.3.2-8.fc33.x86_64 xz-libs-5.2.5-4.fc33.x86_64 zlib-1.2.11-23.fc33.x86_64
> > (gdb) bt
> > #0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:96
> > #1 0x00000000004a3848 in __cmd_test (skiplist=0x0, argv=0x7fffffffd6c0, argc=0) at tests/builtin-test.c:150
> > #2 cmd_test (argc=0, argv=0x7fffffffd6c0) at tests/builtin-test.c:628
> > #3 0x00000000004cc47b in run_builtin (p=p@entry=0xa7cda8 <commands+552>, argc=argc@entry=1, argv=argv@entry=0x7fffffffd6c0) at perf.c:313
> > #4 0x00000000004397ae in handle_internal_command (argv=0x7fffffffd6c0, argc=1) at perf.c:365
> > #5 run_argv (argv=<synthetic pointer>, argcp=<synthetic pointer>) at perf.c:409
> > #6 main (argc=1, argv=0x7fffffffd6c0) at perf.c:539
> > (gdb)
>
> Thanks, I'll take a look.

I wasn't able to reproduce this, I tried with gcc-10 on each patch
individually, debug disabled and O3. I can send a v3 patch set, but
currently it is just a rebase of v2.

Thanks,
Ian

> > also during the metric test (in make DEBUG=1 build) it runs the
> > perf bench synthesize and it takes forever ;-)
> >
> > 89: perf all metrics test
> >
> > that might be another patchset I haven't checked,
> > but I thought we already agreed not to do that ;-)
>
> The PMU test was merged, and that may be the very slow running one.
> The metric tests run with /bin/true, but if they get "not counted" in
> the output they try again with perf bench. It generally runs in
> O(seconds) for me, but maybe it is slower on a loaded machine. There
> may be some middle sized thing between "perf bench" and true that
> gives us enough counts for the tests.
>
> Thanks,
> Ian
>
> > jirka
> >
> > >
> > > v1. Built/tested on x86.
> > >
> > > Ian Rogers (22):
> > > perf test: Use macro for "suite" declarations
> > > perf test: Use macro for "suite" definitions
> > > perf test: Make each test/suite its own struct.
> > > perf test: Move each test suite struct to its test
> > > perf test: Rename struct test to test_suite
> > > perf test: Add helper functions for abstraction.
> > > perf test: Add test case struct.
> > > perf test: Add skip reason to test case.
> > > perf test: Convert pfm tests to use test cases.
> > > perf test: Convert pmu event tests to test cases.
> > > perf test: Convert watch point tests to test cases.
> > > perf test: Convert clang tests to test cases.
> > > perf test: Convert bpf tests to test cases.
> > > perf test: Convert llvm tests to test cases.
> > > perf test: Remove now unused subtest helpers
> > > perf test: bp tests use test case
> > > perf test: Convert time to tsc test to test case.
> > > perf test: Remove non test case style support.
> > > perf test: BP tests, remove is_supported use
> > > perf test: TSC test, remove is_supported use
> > > perf test: Remove is_supported function
> > > perf test: Remove skip_if_fail
> > >
> > > tools/perf/arch/arm/include/arch-tests.h | 2 +-
> > > tools/perf/arch/arm/tests/arch-tests.c | 18 +-
> > > tools/perf/arch/arm/tests/vectors-page.c | 2 +-
> > > tools/perf/arch/arm64/include/arch-tests.h | 2 +-
> > > tools/perf/arch/arm64/tests/arch-tests.c | 11 +-
> > > tools/perf/arch/powerpc/include/arch-tests.h | 2 +-
> > > tools/perf/arch/powerpc/tests/arch-tests.c | 12 +-
> > > tools/perf/arch/x86/include/arch-tests.h | 14 +-
> > > tools/perf/arch/x86/tests/arch-tests.c | 46 +-
> > > tools/perf/arch/x86/tests/bp-modify.c | 2 +-
> > > tools/perf/arch/x86/tests/insn-x86.c | 2 +-
> > > tools/perf/arch/x86/tests/intel-cqm.c | 2 +-
> > > .../x86/tests/intel-pt-pkt-decoder-test.c | 2 +-
> > > tools/perf/arch/x86/tests/rdpmc.c | 2 +-
> > > tools/perf/arch/x86/tests/sample-parsing.c | 2 +-
> > > tools/perf/tests/api-io.c | 6 +-
> > > tools/perf/tests/attr.c | 4 +-
> > > tools/perf/tests/backward-ring-buffer.c | 4 +-
> > > tools/perf/tests/bitmap.c | 4 +-
> > > tools/perf/tests/bp_account.c | 36 +-
> > > tools/perf/tests/bp_signal.c | 34 +-
> > > tools/perf/tests/bp_signal_overflow.c | 9 +-
> > > tools/perf/tests/bpf.c | 69 ++-
> > > tools/perf/tests/builtin-test.c | 578 ++++++------------
> > > tools/perf/tests/clang.c | 54 +-
> > > tools/perf/tests/code-reading.c | 4 +-
> > > tools/perf/tests/cpumap.c | 10 +-
> > > tools/perf/tests/demangle-java-test.c | 4 +-
> > > tools/perf/tests/demangle-ocaml-test.c | 4 +-
> > > tools/perf/tests/dlfilter-test.c | 4 +-
> > > tools/perf/tests/dso-data.c | 10 +-
> > > tools/perf/tests/dwarf-unwind.c | 5 +-
> > > tools/perf/tests/event-times.c | 4 +-
> > > tools/perf/tests/event_update.c | 4 +-
> > > tools/perf/tests/evsel-roundtrip-name.c | 5 +-
> > > tools/perf/tests/evsel-tp-sched.c | 5 +-
> > > tools/perf/tests/expand-cgroup.c | 6 +-
> > > tools/perf/tests/expr.c | 4 +-
> > > tools/perf/tests/fdarray.c | 7 +-
> > > tools/perf/tests/genelf.c | 6 +-
> > > tools/perf/tests/hists_cumulate.c | 4 +-
> > > tools/perf/tests/hists_filter.c | 4 +-
> > > tools/perf/tests/hists_link.c | 4 +-
> > > tools/perf/tests/hists_output.c | 4 +-
> > > tools/perf/tests/is_printable_array.c | 4 +-
> > > tools/perf/tests/keep-tracking.c | 4 +-
> > > tools/perf/tests/kmod-path.c | 4 +-
> > > tools/perf/tests/llvm.c | 74 ++-
> > > tools/perf/tests/maps.c | 4 +-
> > > tools/perf/tests/mem.c | 4 +-
> > > tools/perf/tests/mem2node.c | 4 +-
> > > tools/perf/tests/mmap-basic.c | 4 +-
> > > tools/perf/tests/mmap-thread-lookup.c | 4 +-
> > > tools/perf/tests/openat-syscall-all-cpus.c | 5 +-
> > > tools/perf/tests/openat-syscall-tp-fields.c | 5 +-
> > > tools/perf/tests/openat-syscall.c | 5 +-
> > > tools/perf/tests/parse-events.c | 4 +-
> > > tools/perf/tests/parse-metric.c | 4 +-
> > > tools/perf/tests/parse-no-sample-id-all.c | 5 +-
> > > tools/perf/tests/pe-file-parsing.c | 6 +-
> > > tools/perf/tests/perf-hooks.c | 4 +-
> > > tools/perf/tests/perf-record.c | 4 +-
> > > tools/perf/tests/perf-time-to-tsc.c | 30 +-
> > > tools/perf/tests/pfm.c | 63 +-
> > > tools/perf/tests/pmu-events.c | 73 +--
> > > tools/perf/tests/pmu.c | 4 +-
> > > tools/perf/tests/python-use.c | 4 +-
> > > tools/perf/tests/sample-parsing.c | 4 +-
> > > tools/perf/tests/sdt.c | 6 +-
> > > tools/perf/tests/stat.c | 11 +-
> > > tools/perf/tests/sw-clock.c | 4 +-
> > > tools/perf/tests/switch-tracking.c | 4 +-
> > > tools/perf/tests/task-exit.c | 4 +-
> > > tools/perf/tests/tests.h | 238 ++++----
> > > tools/perf/tests/thread-map.c | 10 +-
> > > tools/perf/tests/thread-maps-share.c | 4 +-
> > > tools/perf/tests/time-utils-test.c | 4 +-
> > > tools/perf/tests/topology.c | 4 +-
> > > tools/perf/tests/unit_number__scnprintf.c | 4 +-
> > > tools/perf/tests/vmlinux-kallsyms.c | 5 +-
> > > tools/perf/tests/wp.c | 122 +---
> > > tools/perf/util/c++/clang-c.h | 8 +-
> > > tools/perf/util/c++/clang-test.cpp | 6 +-
> > > 83 files changed, 811 insertions(+), 966 deletions(-)
> > >
> > > --
> > > 2.33.0.882.g93a45727a2-goog
> > >
> >

2021-10-29 12:21:19

by Jiri Olsa

[permalink] [raw]
Subject: Re: [PATCH v2 00/22] Start aligning perf test with kunit style

On Thu, Oct 28, 2021 at 04:52:13PM -0700, Ian Rogers wrote:
> On Wed, Oct 20, 2021 at 8:51 AM Ian Rogers <[email protected]> wrote:
> >
> > On Wed, Oct 20, 2021 at 5:14 AM Jiri Olsa <[email protected]> wrote:
> > >
> > > On Wed, Oct 13, 2021 at 10:45:42AM -0700, Ian Rogers wrote:
> > > > Perf test uses its own structs and code layout that differs from kunit
> > > > that was more recently introduced to the kernel. Besides consistency,
> > > > it is hoped that moving in the direction of kunit style will enable
> > > > reuse of infrastructure like test output formatting for continuous
> > > > testing systems. For example:
> > > > https://lore.kernel.org/linux-kselftest/CA+GJov6tdjvY9x12JsJT14qn6c7NViJxqaJk+r-K1YJzPggFDQ@mail.gmail.com/
> > > >
> > > > The motivation for this restructuring comes from wanting to be able to
> > > > tag tests with a size:
> > > > https://lore.kernel.org/linux-perf-users/CAP-5=fWmGyuqFKc-EMP3rbmTkjZ3MS+YSajGZfeRMc38HS82gw@mail.gmail.com/
> > > > To have more exhaustive and slower running tests. This isn't
> > > > something kunit currently supports, nor is the execution of python and
> > > > shell tests, but it seems sensible to work on an approach with kunit
> > > > rather to invent a new wheel inside of perf.
> > > >
> > > > These initial patches are just refactoring the main test suite
> > > > definitions to be in a more kunit style. Kunit isn't depended upon, it
> > > > is hoped that this can be done in later patches for the sake of
> > > > consistency.
> > > >
> > > > v2. Gets to a point of the perf test test suite/case structs being
> > > > close facsimiles of the kunit ones. It also addresses feedback on
> > > > the v1 RFC, in particular from Jiri Olsa <[email protected]>.
> > >
> > > hi,
> > > when I compile with DEBUG=1 it's ok, but with just make:
> > >
> > > [root@krava perf]# ./perf test
> > > Segmentation fault (core dumped)
> > > [root@krava perf]# gdb ./perf
> > > GNU gdb (GDB) Fedora 10.2-4.fc33
> > > Copyright (C) 2021 Free Software Foundation, Inc.
> > > License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> > > This is free software: you are free to change and redistribute it.
> > > There is NO WARRANTY, to the extent permitted by law.
> > > Type "show copying" and "show warranty" for details.
> > > This GDB was configured as "x86_64-redhat-linux-gnu".
> > > Type "show configuration" for configuration details.
> > > For bug reporting instructions, please see:
> > > <https://www.gnu.org/software/gdb/bugs/>.
> > > Find the GDB manual and other documentation resources online at:
> > > <http://www.gnu.org/software/gdb/documentation/>.
> > >
> > > For help, type "help".
> > > Type "apropos word" to search for commands related to "word"...
> > > Reading symbols from ./perf...
> > > (gdb) r test
> > > Starting program: /home/jolsa/kernel/linux-perf/tools/perf/perf test
> > > [Thread debugging using libthread_db enabled]
> > > Using host libthread_db library "/lib64/libthread_db.so.1".
> > >
> > > Program received signal SIGSEGV, Segmentation fault.
> > > __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:96
> > > 96 VPCMPEQ (%rdi), %ymm0, %ymm1
> > > Missing separate debuginfos, use: dnf debuginfo-install bzip2-libs-1.0.8-4.fc33.x86_64 cyrus-sasl-lib-2.1.27-6.fc33.x86_64 elfutils-debuginfod-client-0.185-2.fc33.x86_64 elfutils-libelf-0.185-2.fc33.x86_64 elfutils-libs-0.185-2.fc33.x86_64 keyutils-libs-1.6.1-1.fc33.x86_64 krb5-libs-1.18.2-31.fc33.x86_64 libbabeltrace-1.5.8-3.fc33.x86_64 libbrotli-1.0.9-3.fc33.x86_64 libcap-2.48-2.fc33.x86_64 libcom_err-1.45.6-4.fc33.x86_64 libgcc-10.3.1-1.fc33.x86_64 libidn2-2.3.2-1.fc33.x86_64 libnghttp2-1.43.0-1.fc33.x86_64 libpsl-0.21.1-2.fc33.x86_64 libselinux-3.1-2.fc33.x86_64 libssh-0.9.6-1.fc33.x86_64 libunistring-0.9.10-9.fc33.x86_64 libunwind-1.4.0-4.fc33.x86_64 libuuid-2.36.1-1.fc33.x86_64 libxcrypt-4.4.26-2.fc33.x86_64 numactl-libs-2.0.14-1.fc33.x86_64 openldap-2.4.50-5.fc33.x86_64 openssl-libs-1.1.1l-2.fc33.x86_64 pcre-8.44-2.fc33.x86_64 perl-libs-5.32.1-471.fc33.x86_64 popt-1.18-2.fc33.x86_64 python2.7-2.7.18-15.fc33.x86_64 slang-2.3.2-8.fc33.x86_64 xz-libs-5.2.5-4.fc33.x86_64 zlib-1.2.11-23.fc33.x86_64
> > > (gdb) bt
> > > #0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:96
> > > #1 0x00000000004a3848 in __cmd_test (skiplist=0x0, argv=0x7fffffffd6c0, argc=0) at tests/builtin-test.c:150
> > > #2 cmd_test (argc=0, argv=0x7fffffffd6c0) at tests/builtin-test.c:628
> > > #3 0x00000000004cc47b in run_builtin (p=p@entry=0xa7cda8 <commands+552>, argc=argc@entry=1, argv=argv@entry=0x7fffffffd6c0) at perf.c:313
> > > #4 0x00000000004397ae in handle_internal_command (argv=0x7fffffffd6c0, argc=1) at perf.c:365
> > > #5 run_argv (argv=<synthetic pointer>, argcp=<synthetic pointer>) at perf.c:409
> > > #6 main (argc=1, argv=0x7fffffffd6c0) at perf.c:539
> > > (gdb)
> >
> > Thanks, I'll take a look.
>
> I wasn't able to reproduce this, I tried with gcc-10 on each patch
> individually, debug disabled and O3. I can send a v3 patch set, but
> currently it is just a rebase of v2.

ok, I'll try to debug that if I can still reproduce

jirka

2021-11-03 19:18:07

by Ian Rogers

[permalink] [raw]
Subject: Re: [PATCH v2 00/22] Start aligning perf test with kunit style

On Fri, Oct 29, 2021 at 5:19 AM Jiri Olsa <[email protected]> wrote:
>
> On Thu, Oct 28, 2021 at 04:52:13PM -0700, Ian Rogers wrote:
> > On Wed, Oct 20, 2021 at 8:51 AM Ian Rogers <[email protected]> wrote:
> > >
> > > On Wed, Oct 20, 2021 at 5:14 AM Jiri Olsa <[email protected]> wrote:
> > > >
> > > > On Wed, Oct 13, 2021 at 10:45:42AM -0700, Ian Rogers wrote:
> > > > > Perf test uses its own structs and code layout that differs from kunit
> > > > > that was more recently introduced to the kernel. Besides consistency,
> > > > > it is hoped that moving in the direction of kunit style will enable
> > > > > reuse of infrastructure like test output formatting for continuous
> > > > > testing systems. For example:
> > > > > https://lore.kernel.org/linux-kselftest/CA+GJov6tdjvY9x12JsJT14qn6c7NViJxqaJk+r-K1YJzPggFDQ@mail.gmail.com/
> > > > >
> > > > > The motivation for this restructuring comes from wanting to be able to
> > > > > tag tests with a size:
> > > > > https://lore.kernel.org/linux-perf-users/CAP-5=fWmGyuqFKc-EMP3rbmTkjZ3MS+YSajGZfeRMc38HS82gw@mail.gmail.com/
> > > > > To have more exhaustive and slower running tests. This isn't
> > > > > something kunit currently supports, nor is the execution of python and
> > > > > shell tests, but it seems sensible to work on an approach with kunit
> > > > > rather to invent a new wheel inside of perf.
> > > > >
> > > > > These initial patches are just refactoring the main test suite
> > > > > definitions to be in a more kunit style. Kunit isn't depended upon, it
> > > > > is hoped that this can be done in later patches for the sake of
> > > > > consistency.
> > > > >
> > > > > v2. Gets to a point of the perf test test suite/case structs being
> > > > > close facsimiles of the kunit ones. It also addresses feedback on
> > > > > the v1 RFC, in particular from Jiri Olsa <[email protected]>.
> > > >
> > > > hi,
> > > > when I compile with DEBUG=1 it's ok, but with just make:
> > > >
> > > > [root@krava perf]# ./perf test
> > > > Segmentation fault (core dumped)
> > > > [root@krava perf]# gdb ./perf
> > > > GNU gdb (GDB) Fedora 10.2-4.fc33
> > > > Copyright (C) 2021 Free Software Foundation, Inc.
> > > > License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> > > > This is free software: you are free to change and redistribute it.
> > > > There is NO WARRANTY, to the extent permitted by law.
> > > > Type "show copying" and "show warranty" for details.
> > > > This GDB was configured as "x86_64-redhat-linux-gnu".
> > > > Type "show configuration" for configuration details.
> > > > For bug reporting instructions, please see:
> > > > <https://www.gnu.org/software/gdb/bugs/>.
> > > > Find the GDB manual and other documentation resources online at:
> > > > <http://www.gnu.org/software/gdb/documentation/>.
> > > >
> > > > For help, type "help".
> > > > Type "apropos word" to search for commands related to "word"...
> > > > Reading symbols from ./perf...
> > > > (gdb) r test
> > > > Starting program: /home/jolsa/kernel/linux-perf/tools/perf/perf test
> > > > [Thread debugging using libthread_db enabled]
> > > > Using host libthread_db library "/lib64/libthread_db.so.1".
> > > >
> > > > Program received signal SIGSEGV, Segmentation fault.
> > > > __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:96
> > > > 96 VPCMPEQ (%rdi), %ymm0, %ymm1
> > > > Missing separate debuginfos, use: dnf debuginfo-install bzip2-libs-1.0.8-4.fc33.x86_64 cyrus-sasl-lib-2.1.27-6.fc33.x86_64 elfutils-debuginfod-client-0.185-2.fc33.x86_64 elfutils-libelf-0.185-2.fc33.x86_64 elfutils-libs-0.185-2.fc33.x86_64 keyutils-libs-1.6.1-1.fc33.x86_64 krb5-libs-1.18.2-31.fc33.x86_64 libbabeltrace-1.5.8-3.fc33.x86_64 libbrotli-1.0.9-3.fc33.x86_64 libcap-2.48-2.fc33.x86_64 libcom_err-1.45.6-4.fc33.x86_64 libgcc-10.3.1-1.fc33.x86_64 libidn2-2.3.2-1.fc33.x86_64 libnghttp2-1.43.0-1.fc33.x86_64 libpsl-0.21.1-2.fc33.x86_64 libselinux-3.1-2.fc33.x86_64 libssh-0.9.6-1.fc33.x86_64 libunistring-0.9.10-9.fc33.x86_64 libunwind-1.4.0-4.fc33.x86_64 libuuid-2.36.1-1.fc33.x86_64 libxcrypt-4.4.26-2.fc33.x86_64 numactl-libs-2.0.14-1.fc33.x86_64 openldap-2.4.50-5.fc33.x86_64 openssl-libs-1.1.1l-2.fc33.x86_64 pcre-8.44-2.fc33.x86_64 perl-libs-5.32.1-471.fc33.x86_64 popt-1.18-2.fc33.x86_64 python2.7-2.7.18-15.fc33.x86_64 slang-2.3.2-8.fc33.x86_64 xz-libs-5.2.5-4.fc33.x86_64 zlib-1.2.11-23.fc33.x86_64
> > > > (gdb) bt
> > > > #0 __strlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:96
> > > > #1 0x00000000004a3848 in __cmd_test (skiplist=0x0, argv=0x7fffffffd6c0, argc=0) at tests/builtin-test.c:150
> > > > #2 cmd_test (argc=0, argv=0x7fffffffd6c0) at tests/builtin-test.c:628
> > > > #3 0x00000000004cc47b in run_builtin (p=p@entry=0xa7cda8 <commands+552>, argc=argc@entry=1, argv=argv@entry=0x7fffffffd6c0) at perf.c:313
> > > > #4 0x00000000004397ae in handle_internal_command (argv=0x7fffffffd6c0, argc=1) at perf.c:365
> > > > #5 run_argv (argv=<synthetic pointer>, argcp=<synthetic pointer>) at perf.c:409
> > > > #6 main (argc=1, argv=0x7fffffffd6c0) at perf.c:539
> > > > (gdb)
> > >
> > > Thanks, I'll take a look.
> >
> > I wasn't able to reproduce this, I tried with gcc-10 on each patch
> > individually, debug disabled and O3. I can send a v3 patch set, but
> > currently it is just a rebase of v2.
>
> ok, I'll try to debug that if I can still reproduce
>
> jirka

Thanks to Sohaib I have a reproduction now, and it looks like there
are a bunch of issues to fix in v3.

Thanks,
Ian

2021-11-13 21:11:09

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH v2 11/22] perf test: Convert watch point tests to test cases.

Em Wed, Oct 13, 2021 at 10:45:53AM -0700, Ian Rogers escreveu:
> Use null terminated array of test cases rather than the previous sub
> test functions.
>
> Signed-off-by: Ian Rogers <[email protected]>
> ---
> tools/perf/tests/wp.c | 128 ++++++++++--------------------------------
> 1 file changed, 30 insertions(+), 98 deletions(-)
>
> diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c
> index 904bdf2dcf81..2c0513257b15 100644
> --- a/tools/perf/tests/wp.c
> +++ b/tools/perf/tests/wp.c
> @@ -62,8 +62,12 @@ static int __event(int wp_type, void *wp_addr, unsigned long wp_len)
> return fd;
> }
>

65 6.29 ubuntu:16.04-x-s390 : FAIL gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)
tests/wp.c:24:12: error: 'wp_read' defined but not used [-Werror=unused-function]
static int wp_read(int fd, long long *count, int size)
^
tests/wp.c:51:12: error: '__event' defined but not used [-Werror=unused-function]
static int __event(int wp_type, void *wp_addr, unsigned long wp_len)
^
cc1: all warnings being treated as errors
/git/perf-5.15.0/tools/build/Makefile.build:139: recipe for target 'tests' failed
make[3]: *** [tests] Error 2


Trying with:


diff --git a/tools/perf/tests/wp.c b/tools/perf/tests/wp.c
index 2c0513257b15c041..820d942b30c390e9 100644
--- a/tools/perf/tests/wp.c
+++ b/tools/perf/tests/wp.c
@@ -48,6 +48,7 @@ static void get__perf_event_attr(struct perf_event_attr *attr, int wp_type,
attr->exclude_hv = 1;
}

+#ifndef __s390x__
static int __event(int wp_type, void *wp_addr, unsigned long wp_len)
{
int fd;
@@ -61,6 +62,7 @@ static int __event(int wp_type, void *wp_addr, unsigned long wp_len)

return fd;
}
+#endif

static int test__wp_ro(struct test_suite *test __maybe_unused,
int subtest __maybe_unused)