4 * Builtin regression testing command: ever growing number of sanity tests
11 #include "parse-options.h"
19 .desc = "vmlinux symtab matches kallsyms",
20 .func = test__vmlinux_matches_kallsyms,
23 .desc = "detect open syscall event",
24 .func = test__open_syscall_event,
27 .desc = "detect open syscall event on all cpus",
28 .func = test__open_syscall_event_on_all_cpus,
31 .desc = "read samples using the mmap interface",
32 .func = test__basic_mmap,
35 .desc = "parse events tests",
36 .func = test__parse_events,
38 #if defined(__x86_64__) || defined(__i386__)
40 .desc = "x86 rdpmc test",
45 .desc = "Validate PERF_RECORD_* events & perf_sample fields",
46 .func = test__PERF_RECORD,
49 .desc = "Test perf pmu format parsing",
53 .desc = "Test dso data interface",
54 .func = test__dso_data,
57 .desc = "roundtrip evsel->name check",
58 .func = test__perf_evsel__roundtrip_name_test,
61 .desc = "Check parsing of sched tracepoints fields",
62 .func = test__perf_evsel__tp_sched_test,
65 .desc = "Generate and check syscalls:sys_enter_open event fields",
66 .func = test__syscall_open_tp_fields,
69 .desc = "struct perf_event_attr setup",
73 .desc = "Test matching and linking multiple hists",
74 .func = test__hists_link,
77 .desc = "Try 'use perf' in python, checking link problems",
78 .func = test__python_use,
81 .desc = "Test breakpoint overflow signal handler",
82 .func = test__bp_signal,
85 .desc = "Test breakpoint overflow sampling",
86 .func = test__bp_signal_overflow,
89 .desc = "Test number of exit event of a simple workload",
90 .func = test__task_exit,
93 .desc = "Test software clock events have valid period values",
94 .func = test__sw_clock_freq,
96 #if defined(__x86_64__) || defined(__i386__)
98 .desc = "Test converting perf time to TSC",
99 .func = test__perf_time_to_tsc,
103 .desc = "Test object code reading",
104 .func = test__code_reading,
107 .desc = "Test sample parsing",
108 .func = test__sample_parsing,
111 .desc = "Test using a dummy software event to keep tracking",
112 .func = test__keep_tracking,
115 .desc = "Test parsing with no sample_id_all bit set",
116 .func = test__parse_no_sample_id_all,
118 #if defined(__x86_64__) || defined(__i386__) || defined(__arm__)
119 #ifdef HAVE_DWARF_UNWIND_SUPPORT
121 .desc = "Test dwarf unwind",
122 .func = test__dwarf_unwind,
127 .desc = "Test filtering hist entries",
128 .func = test__hists_filter,
131 .desc = "Test mmap thread lookup",
132 .func = test__mmap_thread_lookup,
135 .desc = "Test thread mg sharing",
136 .func = test__thread_mg_share,
139 .desc = "Test output sorting of hist entries",
140 .func = test__hists_output,
143 .desc = "Test cumulation of child hist entries",
144 .func = test__hists_cumulate,
151 static bool perf_test__matches(int curr, int argc, const char *argv[])
158 for (i = 0; i < argc; ++i) {
160 long nr = strtoul(argv[i], &end, 10);
168 if (strstr(tests[curr].desc, argv[i]))
175 static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
180 while (tests[i].func) {
181 int len = strlen(tests[i].desc);
189 while (tests[i].func) {
192 if (!perf_test__matches(curr, argc, argv))
195 pr_info("%2d: %-*s:", i, width, tests[curr].desc);
197 if (intlist__find(skiplist, i)) {
198 color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n");
202 pr_debug("\n--- start ---\n");
203 err = tests[curr].func();
204 pr_debug("---- end ----\n%s:", tests[curr].desc);
211 color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n");
215 color_fprintf(stderr, PERF_COLOR_RED, " FAILED!\n");
223 static int perf_test__list(int argc, const char **argv)
227 while (tests[i].func) {
230 if (argc > 1 && !strstr(tests[curr].desc, argv[1]))
233 pr_info("%2d: %s\n", i, tests[curr].desc);
239 int cmd_test(int argc, const char **argv, const char *prefix __maybe_unused)
241 const char * const test_usage[] = {
242 "perf test [<options>] [{list <test-name-fragment>|[<test-name-fragments>|<test-numbers>]}]",
245 const char *skip = NULL;
246 const struct option test_options[] = {
247 OPT_STRING('s', "skip", &skip, "tests", "tests to skip"),
248 OPT_INCR('v', "verbose", &verbose,
249 "be more verbose (show symbol address, etc)"),
252 struct intlist *skiplist = NULL;
254 argc = parse_options(argc, argv, test_options, test_usage, 0);
255 if (argc >= 1 && !strcmp(argv[0], "list"))
256 return perf_test__list(argc, argv);
258 symbol_conf.priv_size = sizeof(int);
259 symbol_conf.sort_by_name = true;
260 symbol_conf.try_vmlinux_path = true;
262 if (symbol__init() < 0)
266 skiplist = intlist__new(skip);
268 return __cmd_test(argc, argv, skiplist);