11 #include <sys/types.h> 21 #include <subcmd/parse-options.h> 24 #include <linux/kernel.h> 25 #include <subcmd/exec-cmd.h> 37 .
desc =
"vmlinux symtab matches kallsyms",
41 .desc =
"Detect openat syscall event",
45 .desc =
"Detect openat syscall event on all cpus",
49 .desc =
"Read samples using the mmap interface",
53 .desc =
"Test data source output",
57 .desc =
"Parse event definition strings",
61 .desc =
"Simple expression parser",
65 .desc =
"PERF_RECORD_* events & perf_sample fields",
69 .desc =
"Parse perf pmu format",
73 .desc =
"DSO data read",
77 .desc =
"DSO data cache",
81 .desc =
"DSO data reopen",
85 .desc =
"Roundtrip evsel->name",
89 .desc =
"Parse sched tracepoints fields",
93 .desc =
"syscalls:sys_enter_openat event fields",
97 .desc =
"Setup struct perf_event_attr",
101 .desc =
"Match and link multiple hists",
105 .desc =
"'import perf' in python",
109 .desc =
"Breakpoint overflow signal handler",
114 .desc =
"Breakpoint overflow sampling",
119 .desc =
"Breakpoint accounting",
124 .desc =
"Number of exit events of a simple workload",
128 .desc =
"Software clock events period values",
132 .desc =
"Object code reading",
136 .desc =
"Sample parsing",
140 .desc =
"Use a dummy software event to keep tracking",
144 .desc =
"Parse with no sample_id_all bit set",
148 .desc =
"Filter hist entries",
152 .desc =
"Lookup mmap thread",
156 .desc =
"Share thread mg",
160 .desc =
"Sort output of hist entries",
164 .desc =
"Cumulate child hist entries",
168 .desc =
"Track with sched_switch",
172 .desc =
"Filter fds with revents mask in a fdarray",
176 .desc =
"Add fd to a fdarray, making it autogrow",
180 .desc =
"kmod_path__parse",
184 .desc =
"Thread map",
188 .desc =
"LLVM search and compile",
191 .skip_if_fail =
true,
197 .desc =
"Session topology",
201 .desc =
"BPF filter",
204 .skip_if_fail =
true,
210 .desc =
"Synthesize thread map",
214 .desc =
"Remove thread map",
218 .desc =
"Synthesize cpu map",
222 .desc =
"Synthesize stat config",
226 .desc =
"Synthesize stat",
230 .desc =
"Synthesize stat round",
234 .desc =
"Synthesize attr update",
238 .desc =
"Event times",
242 .desc =
"Read backward ring buffer",
246 .desc =
"Print cpu map",
250 .desc =
"Probe SDT events",
254 .desc =
"is_printable_array",
258 .desc =
"Print bitmap",
262 .desc =
"perf hooks",
266 .desc =
"builtin clang support",
269 .skip_if_fail =
true,
275 .desc =
"unit_number__scnprintf",
299 for (i = 0; i <
argc; ++i) {
301 long nr = strtoul(argv[i], &end, 10);
309 if (strcasestr(test->
desc, argv[i]))
322 pr_err(
"failed to fork test: %s\n",
323 str_error_r(errno, sbuf,
sizeof(sbuf)));
329 pr_debug(
"test child forked, pid %d\n", getpid());
332 int nullfd = open(
"/dev/null", O_WRONLY);
335 close(STDERR_FILENO);
336 close(STDOUT_FILENO);
338 dup2(nullfd, STDOUT_FILENO);
339 dup2(STDOUT_FILENO, STDERR_FILENO);
348 err = test->
func(test, subtest);
356 if (WIFEXITED(status)) {
357 err = (
signed char)WEXITSTATUS(status);
358 pr_debug(
"test child finished with %d\n", err);
359 }
else if (WIFSIGNALED(status)) {
361 pr_debug(
"test child interrupted\n");
368 #define for_each_test(j, t) \ 369 for (j = 0; j < ARRAY_SIZE(tests); j++) \ 370 for (t = &tests[j][0]; t->func; t++) 381 pr_debug(
"\n--- force skipped ---\n");
407 const char *path,
const char *
name)
412 path__join(filename,
sizeof(filename), path, name);
413 fp = fopen(filename,
"r");
417 description = fgets(description, size, fp);
420 return description ?
trim(description + 1) : NULL;
423 #define for_each_shell_test(dir, base, ent) \ 424 while ((ent = readdir(dir)) != NULL) \ 425 if (!is_directory(base, ent)) 429 const char *devel_dirs[] = {
"./tools/perf/tests",
"./tests", };
433 for (i = 0; i < ARRAY_SIZE(devel_dirs); ++i) {
435 if (!lstat(devel_dirs[i], &st)) {
436 scnprintf(path, size,
"%s/shell", devel_dirs[i]);
437 if (!lstat(devel_dirs[i], &st))
443 exec_path = get_argv_exec_path();
444 scnprintf(path, size,
"%s/tests/shell", exec_path);
469 int len = strlen(desc);
493 err = system(script);
512 dir = opendir(st.
dir);
528 st.
file = ent->d_name;
545 int len = strlen(t->
desc);
581 int subw = width > 2 ? width - 2 : width;
587 " Skip (not compiled in)\n");
592 for (subi = 0; subi < subn; subi++) {
599 for (subi = 0; subi < subn; subi++) {
600 pr_info(
"%2d.%1d: %-*s:", i, subi + 1, subw,
662 for (subi = 0; subi < subn; subi++)
663 pr_info(
"%2d:%1d: %s\n", i, subi + 1,
675 const char *test_usage[] = {
676 "perf test [<options>] [{list <test-name-fragment>|[<test-name-fragments>|<test-numbers>]}]",
679 const char *
skip = NULL;
680 const struct option test_options[] = {
681 OPT_STRING(
's',
"skip", &skip,
"tests",
"tests to skip"),
682 OPT_INCR(
'v',
"verbose", &
verbose,
683 "be more verbose (show symbol address, etc)"),
684 OPT_BOOLEAN(
'F',
"dont-fork", &
dont_fork,
685 "Do not fork for testcase"),
688 const char *
const test_subcommands[] = {
"list", NULL };
689 struct intlist *skiplist = NULL;
695 argc = parse_options_subcommand(argc, argv, test_options, test_subcommands, test_usage, 0);
696 if (argc >= 1 && !strcmp(argv[0],
"list"))
int test__thread_map_remove(struct test *test, int subtest)
int test__backward_ring_buffer(struct test *test __maybe_unused, int subtest __maybe_unused)
int color_fprintf(FILE *fp, const char *color, const char *fmt,...)
int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unused)
static int shell_test__run(struct test *test, int subdir __maybe_unused)
int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__PERF_RECORD(struct test *test __maybe_unused, int subtest __maybe_unused)
static struct test generic_tests[]
int test__hists_link(struct test *test __maybe_unused, int subtest __maybe_unused)
bool test__bp_signal_is_supported(void)
int test__pmu(struct test *test __maybe_unused, int subtest __maybe_unused)
static void skip(int size)
int test__bp_signal_overflow(struct test *test __maybe_unused, int subtest __maybe_unused)
#define for_each_test(j, t)
int test__parse_no_sample_id_all(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__bpf(struct test *test __maybe_unused, int i __maybe_unused)
int test__bp_signal(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__thread_map_synthesize(struct test *test, int subtest)
int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)
int test__thread_mg_share(struct test *test, int subtest)
int test__synthesize_stat(struct test *test __maybe_unused, int subtest __maybe_unused)
bool(* is_supported)(void)
int test__sw_clock_freq(struct test *test __maybe_unused, int subtest __maybe_unused)
static char * trim(char *s)
int test__fdarray__filter(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__synthesize_stat_config(struct test *test __maybe_unused, int subtest __maybe_unused)
static int perf_test__list_shell(int argc, const char **argv, int i)
int(* func)(struct test *test, int subtest)
int test__fdarray__add(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__unit_number__scnprint(struct test *test, int subtest)
static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
int test__hists_output(struct test *test __maybe_unused, int subtest __maybe_unused)
static const char * shell_test__description(char *description, size_t size, const char *path, const char *name)
int path__join(char *bf, size_t size, const char *path1, const char *path2)
int test__parse_events(struct test *test __maybe_unused, int subtest __maybe_unused)
struct int_node * intlist__find(struct intlist *ilist, int i)
int test__attr(struct test *test __maybe_unused, int subtest __maybe_unused)
static int run_test(struct test *test, int subtest)
static int run_shell_tests(int argc, const char *argv[], int i, int width)
#define pr_debug(fmt,...)
int test__bitmap_print(struct test *test __maybe_unused, int subtest __maybe_unused)
const char * test__llvm_subtest_get_desc(int subtest)
static struct test * tests[]
int test__bp_accounting(struct test *test __maybe_unused, int subtest __maybe_unused)
struct test __weak arch_tests[]
int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__hists_cumulate(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__llvm_subtest_get_nr(void)
static const char * shell_tests__dir(char *path, size_t size)
int test__clang(struct test *test __maybe_unused, int i __maybe_unused)
const char * test__bpf_subtest_get_desc(int i __maybe_unused)
int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused)
const char * test__clang_subtest_get_desc(int i)
int test__dso_data(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__llvm(struct test *test __maybe_unused, int subtest)
int test__cpu_map_print(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__hists_filter(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__sample_parsing(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__python_use(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__mem(struct test *text __maybe_unused, int subtest __maybe_unused)
struct intlist * intlist__new(const char *slist)
static int perf_test__list(int argc, const char **argv)
int test__openat_syscall_event(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__code_reading(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__clang_subtest_get_nr(void)
int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__kmod_path__parse(struct test *t __maybe_unused, int subtest __maybe_unused)
int test__synthesize_stat_round(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__bpf_subtest_get_nr(void)
int test__mem2node(struct test *t __maybe_unused, int subtest __maybe_unused)
int test__thread_map(struct test *test, int subtest)
int test__dso_data_cache(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__perf_hooks(struct test *test __maybe_unused, int subtest __maybe_unused)
static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[])
int test__dso_data_reopen(struct test *test __maybe_unused, int subtest __maybe_unused)
int symbol__init(struct perf_env *env)
int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__vmlinux_matches_kallsyms(struct test *test, int subtest)
int test__sdt_event(struct test *test __maybe_unused, int subtests __maybe_unused)
const char *(* get_desc)(int subtest)
#define PERF_COLOR_YELLOW
int test__event_times(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__session_topology(struct test *test, int subtest)
int test__is_printable_array(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__mmap_thread_lookup(struct test *test __maybe_unused, int subtest __maybe_unused)
void sighandler_dump_stack(int sig)
int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtest __maybe_unused)
#define for_each_shell_test(dir, base, ent)
int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_unused)
int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, int subtest __maybe_unused)
int cmd_test(int argc, const char **argv)
static int test_and_print(struct test *t, bool force_skip, int subtest)
static int shell_tests__max_desc_width(void)
int test__perf_evsel__roundtrip_name_test(struct test *test __maybe_unused, int subtest __maybe_unused)