4 * Builtin regression testing command: ever growing number of sanity tests
8 #include "util/cache.h"
9 #include "util/color.h"
10 #include "util/debug.h"
11 #include "util/debugfs.h"
12 #include "util/evlist.h"
13 #include "util/machine.h"
14 #include "util/parse-options.h"
15 #include "util/parse-events.h"
16 #include "util/symbol.h"
17 #include "util/thread_map.h"
19 #include "event-parse.h"
20 #include "../../include/linux/hw_breakpoint.h"
24 #include "util/cpumap.h"
25 #include "util/evsel.h"
26 #include <sys/types.h>
33 static int test__perf_pmu(void)
35 return perf_pmu__test();
43 .desc
= "vmlinux symtab matches kallsyms",
44 .func
= test__vmlinux_matches_kallsyms
,
47 .desc
= "detect open syscall event",
48 .func
= test__open_syscall_event
,
51 .desc
= "detect open syscall event on all cpus",
52 .func
= test__open_syscall_event_on_all_cpus
,
55 .desc
= "read samples using the mmap interface",
56 .func
= test__basic_mmap
,
59 .desc
= "parse events tests",
60 .func
= parse_events__test
,
62 #if defined(__x86_64__) || defined(__i386__)
64 .desc
= "x86 rdpmc test",
69 .desc
= "Validate PERF_RECORD_* events & perf_sample fields",
70 .func
= test__PERF_RECORD
,
73 .desc
= "Test perf pmu format parsing",
74 .func
= test__perf_pmu
,
77 .desc
= "Test dso data interface",
78 .func
= dso__test_data
,
81 .desc
= "roundtrip evsel->name check",
82 .func
= test__perf_evsel__roundtrip_name_test
,
85 .desc
= "Check parsing of sched tracepoints fields",
86 .func
= test__perf_evsel__tp_sched_test
,
89 .desc
= "Generate and check syscalls:sys_enter_open event fields",
90 .func
= test__syscall_open_tp_fields
,
93 .desc
= "struct perf_event_attr setup",
94 .func
= test_attr__run
,
101 static bool perf_test__matches(int curr
, int argc
, const char *argv
[])
108 for (i
= 0; i
< argc
; ++i
) {
110 long nr
= strtoul(argv
[i
], &end
, 10);
118 if (strstr(tests
[curr
].desc
, argv
[i
]))
125 static int __cmd_test(int argc
, const char *argv
[])
130 while (tests
[i
].func
) {
131 int len
= strlen(tests
[i
].desc
);
139 while (tests
[i
].func
) {
142 if (!perf_test__matches(curr
, argc
, argv
))
145 pr_info("%2d: %-*s:", i
, width
, tests
[curr
].desc
);
146 pr_debug("\n--- start ---\n");
147 err
= tests
[curr
].func();
148 pr_debug("---- end ----\n%s:", tests
[curr
].desc
);
150 color_fprintf(stderr
, PERF_COLOR_RED
, " FAILED!\n");
158 static int perf_test__list(int argc
, const char **argv
)
162 while (tests
[i
].func
) {
165 if (argc
> 1 && !strstr(tests
[curr
].desc
, argv
[1]))
168 pr_info("%2d: %s\n", i
, tests
[curr
].desc
);
174 int cmd_test(int argc
, const char **argv
, const char *prefix __maybe_unused
)
176 const char * const test_usage
[] = {
177 "perf test [<options>] [{list <test-name-fragment>|[<test-name-fragments>|<test-numbers>]}]",
180 const struct option test_options
[] = {
181 OPT_INCR('v', "verbose", &verbose
,
182 "be more verbose (show symbol address, etc)"),
186 argc
= parse_options(argc
, argv
, test_options
, test_usage
, 0);
187 if (argc
>= 1 && !strcmp(argv
[0], "list"))
188 return perf_test__list(argc
, argv
);
190 symbol_conf
.priv_size
= sizeof(int);
191 symbol_conf
.sort_by_name
= true;
192 symbol_conf
.try_vmlinux_path
= true;
194 if (symbol__init() < 0)
197 return __cmd_test(argc
, argv
);