Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Arnaldo Carvalho de Melo | 1c6a800 | 2010-04-29 18:58:32 -0300 | [diff] [blame] | 2 | /* |
| 3 | * builtin-test.c |
| 4 | * |
| 5 | * Builtin regression testing command: ever growing number of sanity tests |
| 6 | */ |
Arnaldo Carvalho de Melo | c23c2a0 | 2017-09-11 10:50:26 -0300 | [diff] [blame] | 7 | #include <fcntl.h> |
Arnaldo Carvalho de Melo | a43783a | 2017-04-18 10:46:11 -0300 | [diff] [blame] | 8 | #include <errno.h> |
Jiri Olsa | 0d8a5fa | 2014-05-10 17:22:30 +0200 | [diff] [blame] | 9 | #include <unistd.h> |
| 10 | #include <string.h> |
Arnaldo Carvalho de Melo | f2a39fe | 2019-08-30 14:45:20 -0300 | [diff] [blame] | 11 | #include <stdlib.h> |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 12 | #include <sys/types.h> |
| 13 | #include <dirent.h> |
Arnaldo Carvalho de Melo | 4208735 | 2017-04-19 19:06:30 -0300 | [diff] [blame] | 14 | #include <sys/wait.h> |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 15 | #include <sys/stat.h> |
Arnaldo Carvalho de Melo | 1c6a800 | 2010-04-29 18:58:32 -0300 | [diff] [blame] | 16 | #include "builtin.h" |
Arnaldo Carvalho de Melo | a635fc5 | 2014-10-09 16:16:00 -0300 | [diff] [blame] | 17 | #include "hist.h" |
Arnaldo Carvalho de Melo | 2ae8287 | 2013-01-24 16:22:55 -0300 | [diff] [blame] | 18 | #include "intlist.h" |
Jiri Olsa | 0a4e1ae | 2012-11-10 01:46:41 +0100 | [diff] [blame] | 19 | #include "tests.h" |
Jiri Olsa | c81251e | 2012-11-10 01:46:51 +0100 | [diff] [blame] | 20 | #include "debug.h" |
| 21 | #include "color.h" |
Josh Poimboeuf | 4b6ab94 | 2015-12-15 09:39:39 -0600 | [diff] [blame] | 22 | #include <subcmd/parse-options.h> |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 23 | #include "string2.h" |
Jiri Olsa | c81251e | 2012-11-10 01:46:51 +0100 | [diff] [blame] | 24 | #include "symbol.h" |
Arnaldo Carvalho de Melo | d3280ce | 2019-07-09 16:27:01 -0300 | [diff] [blame] | 25 | #include "util/rlimit.h" |
Arnaldo Carvalho de Melo | 877a7a1 | 2017-04-17 11:39:06 -0300 | [diff] [blame] | 26 | #include <linux/kernel.h> |
Arnaldo Carvalho de Melo | 3ca43b6 | 2019-06-26 12:06:20 -0300 | [diff] [blame] | 27 | #include <linux/string.h> |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 28 | #include <subcmd/exec-cmd.h> |
Riccardo Mancini | eb7261f | 2021-07-09 18:34:53 +0200 | [diff] [blame] | 29 | #include <linux/zalloc.h> |
Arnaldo Carvalho de Melo | 0252208 | 2011-01-04 11:55:27 -0200 | [diff] [blame] | 30 | |
Jiri Olsa | 7fa9b8f | 2016-06-28 13:29:01 +0200 | [diff] [blame] | 31 | static bool dont_fork; |
| 32 | |
Ian Rogers | 33f44bf | 2021-11-03 23:41:51 -0700 | [diff] [blame] | 33 | struct test_suite *__weak arch_tests[] = { |
Ian Rogers | df22520 | 2021-11-03 23:41:49 -0700 | [diff] [blame] | 34 | NULL, |
Matt Fleming | 31b6753 | 2015-10-05 15:40:19 +0100 | [diff] [blame] | 35 | }; |
| 36 | |
Ian Rogers | 33f44bf | 2021-11-03 23:41:51 -0700 | [diff] [blame] | 37 | static struct test_suite *generic_tests[] = { |
Ian Rogers | d68f036 | 2021-11-03 23:41:50 -0700 | [diff] [blame] | 38 | &suite__vmlinux_matches_kallsyms, |
| 39 | &suite__openat_syscall_event, |
| 40 | &suite__openat_syscall_event_on_all_cpus, |
| 41 | &suite__basic_mmap, |
| 42 | &suite__mem, |
| 43 | &suite__parse_events, |
| 44 | &suite__expr, |
| 45 | &suite__PERF_RECORD, |
| 46 | &suite__pmu, |
| 47 | &suite__pmu_events, |
| 48 | &suite__dso_data, |
| 49 | &suite__dso_data_cache, |
| 50 | &suite__dso_data_reopen, |
| 51 | &suite__perf_evsel__roundtrip_name_test, |
| 52 | &suite__perf_evsel__tp_sched_test, |
| 53 | &suite__syscall_openat_tp_fields, |
| 54 | &suite__attr, |
| 55 | &suite__hists_link, |
| 56 | &suite__python_use, |
| 57 | &suite__bp_signal, |
| 58 | &suite__bp_signal_overflow, |
| 59 | &suite__bp_accounting, |
| 60 | &suite__wp, |
| 61 | &suite__task_exit, |
| 62 | &suite__sw_clock_freq, |
| 63 | &suite__code_reading, |
| 64 | &suite__sample_parsing, |
| 65 | &suite__keep_tracking, |
| 66 | &suite__parse_no_sample_id_all, |
| 67 | &suite__hists_filter, |
| 68 | &suite__mmap_thread_lookup, |
| 69 | &suite__thread_maps_share, |
| 70 | &suite__hists_output, |
| 71 | &suite__hists_cumulate, |
| 72 | &suite__switch_tracking, |
| 73 | &suite__fdarray__filter, |
| 74 | &suite__fdarray__add, |
| 75 | &suite__kmod_path__parse, |
| 76 | &suite__thread_map, |
| 77 | &suite__llvm, |
| 78 | &suite__session_topology, |
| 79 | &suite__bpf, |
| 80 | &suite__thread_map_synthesize, |
| 81 | &suite__thread_map_remove, |
| 82 | &suite__cpu_map_synthesize, |
| 83 | &suite__synthesize_stat_config, |
| 84 | &suite__synthesize_stat, |
| 85 | &suite__synthesize_stat_round, |
| 86 | &suite__event_update, |
| 87 | &suite__event_times, |
| 88 | &suite__backward_ring_buffer, |
| 89 | &suite__cpu_map_print, |
| 90 | &suite__cpu_map_merge, |
| 91 | &suite__sdt_event, |
| 92 | &suite__is_printable_array, |
| 93 | &suite__bitmap_print, |
| 94 | &suite__perf_hooks, |
| 95 | &suite__clang, |
| 96 | &suite__unit_number__scnprint, |
| 97 | &suite__mem2node, |
| 98 | &suite__time_utils, |
| 99 | &suite__jit_write_elf, |
| 100 | &suite__pfm, |
| 101 | &suite__api_io, |
| 102 | &suite__maps__merge_in, |
| 103 | &suite__demangle_java, |
| 104 | &suite__demangle_ocaml, |
| 105 | &suite__parse_metric, |
| 106 | &suite__pe_file_parsing, |
| 107 | &suite__expand_cgroup_events, |
| 108 | &suite__perf_time_to_tsc, |
| 109 | &suite__dlfilter, |
Ian Rogers | df22520 | 2021-11-03 23:41:49 -0700 | [diff] [blame] | 110 | NULL, |
Arnaldo Carvalho de Melo | 1c6a800 | 2010-04-29 18:58:32 -0300 | [diff] [blame] | 111 | }; |
| 112 | |
Ian Rogers | 33f44bf | 2021-11-03 23:41:51 -0700 | [diff] [blame] | 113 | static struct test_suite **tests[] = { |
Matt Fleming | 31b6753 | 2015-10-05 15:40:19 +0100 | [diff] [blame] | 114 | generic_tests, |
| 115 | arch_tests, |
| 116 | }; |
| 117 | |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 118 | static int num_subtests(const struct test_suite *t) |
| 119 | { |
Ian Rogers | 78244d2 | 2021-11-03 23:41:53 -0700 | [diff] [blame] | 120 | int num; |
| 121 | |
Ian Rogers | 78244d2 | 2021-11-03 23:41:53 -0700 | [diff] [blame] | 122 | if (!t->test_cases) |
| 123 | return 0; |
| 124 | |
| 125 | num = 0; |
| 126 | while (t->test_cases[num].name) |
| 127 | num++; |
| 128 | |
| 129 | return num; |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | static bool has_subtests(const struct test_suite *t) |
| 133 | { |
Ian Rogers | 94e11fc | 2021-11-03 23:42:01 -0700 | [diff] [blame] | 134 | return num_subtests(t) > 1; |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | static const char *skip_reason(const struct test_suite *t, int subtest) |
| 138 | { |
Ian Rogers | 9be56d3 | 2021-11-03 23:41:54 -0700 | [diff] [blame] | 139 | if (t->test_cases && subtest >= 0) |
| 140 | return t->test_cases[subtest].skip_reason; |
| 141 | |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 142 | return NULL; |
| 143 | } |
| 144 | |
| 145 | static const char *test_description(const struct test_suite *t, int subtest) |
| 146 | { |
Ian Rogers | 78244d2 | 2021-11-03 23:41:53 -0700 | [diff] [blame] | 147 | if (t->test_cases && subtest >= 0) |
| 148 | return t->test_cases[subtest].desc; |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 149 | |
Ian Rogers | 78244d2 | 2021-11-03 23:41:53 -0700 | [diff] [blame] | 150 | return t->desc; |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Ian Rogers | 78244d2 | 2021-11-03 23:41:53 -0700 | [diff] [blame] | 153 | static test_fnptr test_function(const struct test_suite *t, int subtest) |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 154 | { |
Ian Rogers | 78244d2 | 2021-11-03 23:41:53 -0700 | [diff] [blame] | 155 | if (subtest <= 0) |
| 156 | return t->test_cases[0].run_case; |
| 157 | |
| 158 | return t->test_cases[subtest].run_case; |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 159 | } |
| 160 | |
Jiri Olsa | d685e6c | 2020-05-25 00:42:06 +0200 | [diff] [blame] | 161 | static bool perf_test__matches(const char *desc, int curr, int argc, const char *argv[]) |
Arnaldo Carvalho de Melo | e60770a | 2011-11-29 12:52:07 -0200 | [diff] [blame] | 162 | { |
| 163 | int i; |
| 164 | |
| 165 | if (argc == 0) |
| 166 | return true; |
| 167 | |
| 168 | for (i = 0; i < argc; ++i) { |
| 169 | char *end; |
| 170 | long nr = strtoul(argv[i], &end, 10); |
| 171 | |
| 172 | if (*end == '\0') { |
| 173 | if (nr == curr + 1) |
| 174 | return true; |
| 175 | continue; |
| 176 | } |
| 177 | |
Jiri Olsa | d685e6c | 2020-05-25 00:42:06 +0200 | [diff] [blame] | 178 | if (strcasestr(desc, argv[i])) |
Arnaldo Carvalho de Melo | e60770a | 2011-11-29 12:52:07 -0200 | [diff] [blame] | 179 | return true; |
| 180 | } |
| 181 | |
| 182 | return false; |
| 183 | } |
| 184 | |
Ian Rogers | 33f44bf | 2021-11-03 23:41:51 -0700 | [diff] [blame] | 185 | static int run_test(struct test_suite *test, int subtest) |
Jiri Olsa | 0d8a5fa | 2014-05-10 17:22:30 +0200 | [diff] [blame] | 186 | { |
Jiri Olsa | 7fa9b8f | 2016-06-28 13:29:01 +0200 | [diff] [blame] | 187 | int status, err = -1, child = dont_fork ? 0 : fork(); |
Masami Hiramatsu | ba3dfff | 2014-08-14 02:22:45 +0000 | [diff] [blame] | 188 | char sbuf[STRERR_BUFSIZE]; |
Jiri Olsa | 0d8a5fa | 2014-05-10 17:22:30 +0200 | [diff] [blame] | 189 | |
| 190 | if (child < 0) { |
Masami Hiramatsu | ba3dfff | 2014-08-14 02:22:45 +0000 | [diff] [blame] | 191 | pr_err("failed to fork test: %s\n", |
Arnaldo Carvalho de Melo | c8b5f2c | 2016-07-06 11:56:20 -0300 | [diff] [blame] | 192 | str_error_r(errno, sbuf, sizeof(sbuf))); |
Jiri Olsa | 0d8a5fa | 2014-05-10 17:22:30 +0200 | [diff] [blame] | 193 | return -1; |
| 194 | } |
| 195 | |
| 196 | if (!child) { |
Jiri Olsa | 7fa9b8f | 2016-06-28 13:29:01 +0200 | [diff] [blame] | 197 | if (!dont_fork) { |
| 198 | pr_debug("test child forked, pid %d\n", getpid()); |
Wang Nan | 5bcf2fe | 2015-11-17 08:32:50 +0000 | [diff] [blame] | 199 | |
Namhyung Kim | bb963e1 | 2017-02-17 17:17:38 +0900 | [diff] [blame] | 200 | if (verbose <= 0) { |
Jiri Olsa | 7fa9b8f | 2016-06-28 13:29:01 +0200 | [diff] [blame] | 201 | int nullfd = open("/dev/null", O_WRONLY); |
| 202 | |
| 203 | if (nullfd >= 0) { |
| 204 | close(STDERR_FILENO); |
| 205 | close(STDOUT_FILENO); |
| 206 | |
| 207 | dup2(nullfd, STDOUT_FILENO); |
| 208 | dup2(STDOUT_FILENO, STDERR_FILENO); |
| 209 | close(nullfd); |
| 210 | } |
| 211 | } else { |
| 212 | signal(SIGSEGV, sighandler_dump_stack); |
| 213 | signal(SIGFPE, sighandler_dump_stack); |
Wang Nan | 5bcf2fe | 2015-11-17 08:32:50 +0000 | [diff] [blame] | 214 | } |
| 215 | } |
| 216 | |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 217 | err = test_function(test, subtest)(test, subtest); |
Jiri Olsa | 7fa9b8f | 2016-06-28 13:29:01 +0200 | [diff] [blame] | 218 | if (!dont_fork) |
| 219 | exit(err); |
Jiri Olsa | 0d8a5fa | 2014-05-10 17:22:30 +0200 | [diff] [blame] | 220 | } |
| 221 | |
Jiri Olsa | 7fa9b8f | 2016-06-28 13:29:01 +0200 | [diff] [blame] | 222 | if (!dont_fork) { |
| 223 | wait(&status); |
Jiri Olsa | 0d8a5fa | 2014-05-10 17:22:30 +0200 | [diff] [blame] | 224 | |
Jiri Olsa | 7fa9b8f | 2016-06-28 13:29:01 +0200 | [diff] [blame] | 225 | if (WIFEXITED(status)) { |
| 226 | err = (signed char)WEXITSTATUS(status); |
| 227 | pr_debug("test child finished with %d\n", err); |
| 228 | } else if (WIFSIGNALED(status)) { |
| 229 | err = -1; |
| 230 | pr_debug("test child interrupted\n"); |
| 231 | } |
Jiri Olsa | 0d8a5fa | 2014-05-10 17:22:30 +0200 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | return err; |
| 235 | } |
| 236 | |
Ian Rogers | df22520 | 2021-11-03 23:41:49 -0700 | [diff] [blame] | 237 | #define for_each_test(j, k, t) \ |
Matt Fleming | 31b6753 | 2015-10-05 15:40:19 +0100 | [diff] [blame] | 238 | for (j = 0; j < ARRAY_SIZE(tests); j++) \ |
Ian Rogers | df22520 | 2021-11-03 23:41:49 -0700 | [diff] [blame] | 239 | for (k = 0, t = tests[j][k]; tests[j][k]; k++, t = tests[j][k]) |
Matt Fleming | e8210ce | 2015-09-05 20:02:20 +0100 | [diff] [blame] | 240 | |
Ian Rogers | b47d2fb | 2021-11-03 23:42:08 -0700 | [diff] [blame] | 241 | static int test_and_print(struct test_suite *t, int subtest) |
Wang Nan | e8c6d50 | 2015-11-17 08:32:48 +0000 | [diff] [blame] | 242 | { |
| 243 | int err; |
| 244 | |
Ian Rogers | b47d2fb | 2021-11-03 23:42:08 -0700 | [diff] [blame] | 245 | pr_debug("\n--- start ---\n"); |
| 246 | err = run_test(t, subtest); |
| 247 | pr_debug("---- end ----\n"); |
Wang Nan | e8c6d50 | 2015-11-17 08:32:48 +0000 | [diff] [blame] | 248 | |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 249 | if (!has_subtests(t)) |
Wang Nan | e8c6d50 | 2015-11-17 08:32:48 +0000 | [diff] [blame] | 250 | pr_debug("%s:", t->desc); |
| 251 | else |
Sandipan Das | aa90f9f | 2018-07-26 22:47:33 +0530 | [diff] [blame] | 252 | pr_debug("%s subtest %d:", t->desc, subtest + 1); |
Wang Nan | e8c6d50 | 2015-11-17 08:32:48 +0000 | [diff] [blame] | 253 | |
| 254 | switch (err) { |
| 255 | case TEST_OK: |
| 256 | pr_info(" Ok\n"); |
| 257 | break; |
Ian Rogers | 3b53665 | 2020-05-13 14:29:33 -0700 | [diff] [blame] | 258 | case TEST_SKIP: { |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 259 | const char *reason = skip_reason(t, subtest); |
| 260 | |
| 261 | if (reason) |
| 262 | color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (%s)\n", reason); |
Ian Rogers | 3b53665 | 2020-05-13 14:29:33 -0700 | [diff] [blame] | 263 | else |
| 264 | color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n"); |
| 265 | } |
Wang Nan | e8c6d50 | 2015-11-17 08:32:48 +0000 | [diff] [blame] | 266 | break; |
| 267 | case TEST_FAIL: |
| 268 | default: |
| 269 | color_fprintf(stderr, PERF_COLOR_RED, " FAILED!\n"); |
| 270 | break; |
| 271 | } |
| 272 | |
| 273 | return err; |
| 274 | } |
| 275 | |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 276 | static const char *shell_test__description(char *description, size_t size, |
| 277 | const char *path, const char *name) |
| 278 | { |
| 279 | FILE *fp; |
| 280 | char filename[PATH_MAX]; |
| 281 | |
| 282 | path__join(filename, sizeof(filename), path, name); |
| 283 | fp = fopen(filename, "r"); |
| 284 | if (!fp) |
| 285 | return NULL; |
| 286 | |
Michael Petlan | 4eaf97e | 2018-11-21 16:39:18 -0500 | [diff] [blame] | 287 | /* Skip shebang */ |
| 288 | while (fgetc(fp) != '\n'); |
| 289 | |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 290 | description = fgets(description, size, fp); |
| 291 | fclose(fp); |
| 292 | |
Arnaldo Carvalho de Melo | 3ca43b6 | 2019-06-26 12:06:20 -0300 | [diff] [blame] | 293 | return description ? strim(description + 1) : NULL; |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 294 | } |
| 295 | |
Riccardo Mancini | da96383 | 2021-05-26 01:05:17 +0200 | [diff] [blame] | 296 | #define for_each_shell_test(entlist, nr, base, ent) \ |
| 297 | for (int __i = 0; __i < nr && (ent = entlist[__i]); __i++) \ |
Kim Phillips | db8fec5 | 2018-06-29 12:46:58 -0500 | [diff] [blame] | 298 | if (!is_directory(base, ent) && ent->d_name[0] != '.') |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 299 | |
| 300 | static const char *shell_tests__dir(char *path, size_t size) |
| 301 | { |
| 302 | const char *devel_dirs[] = { "./tools/perf/tests", "./tests", }; |
| 303 | char *exec_path; |
| 304 | unsigned int i; |
| 305 | |
| 306 | for (i = 0; i < ARRAY_SIZE(devel_dirs); ++i) { |
| 307 | struct stat st; |
| 308 | if (!lstat(devel_dirs[i], &st)) { |
| 309 | scnprintf(path, size, "%s/shell", devel_dirs[i]); |
| 310 | if (!lstat(devel_dirs[i], &st)) |
| 311 | return path; |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | /* Then installed path. */ |
| 316 | exec_path = get_argv_exec_path(); |
| 317 | scnprintf(path, size, "%s/tests/shell", exec_path); |
| 318 | free(exec_path); |
| 319 | return path; |
| 320 | } |
| 321 | |
| 322 | static int shell_tests__max_desc_width(void) |
| 323 | { |
Riccardo Mancini | da96383 | 2021-05-26 01:05:17 +0200 | [diff] [blame] | 324 | struct dirent **entlist; |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 325 | struct dirent *ent; |
Riccardo Mancini | eb7261f | 2021-07-09 18:34:53 +0200 | [diff] [blame] | 326 | int n_dirs, e; |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 327 | char path_dir[PATH_MAX]; |
| 328 | const char *path = shell_tests__dir(path_dir, sizeof(path_dir)); |
| 329 | int width = 0; |
| 330 | |
| 331 | if (path == NULL) |
| 332 | return -1; |
| 333 | |
Riccardo Mancini | da96383 | 2021-05-26 01:05:17 +0200 | [diff] [blame] | 334 | n_dirs = scandir(path, &entlist, NULL, alphasort); |
| 335 | if (n_dirs == -1) |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 336 | return -1; |
| 337 | |
Riccardo Mancini | da96383 | 2021-05-26 01:05:17 +0200 | [diff] [blame] | 338 | for_each_shell_test(entlist, n_dirs, path, ent) { |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 339 | char bf[256]; |
| 340 | const char *desc = shell_test__description(bf, sizeof(bf), path, ent->d_name); |
| 341 | |
| 342 | if (desc) { |
| 343 | int len = strlen(desc); |
| 344 | |
| 345 | if (width < len) |
| 346 | width = len; |
| 347 | } |
| 348 | } |
| 349 | |
Riccardo Mancini | eb7261f | 2021-07-09 18:34:53 +0200 | [diff] [blame] | 350 | for (e = 0; e < n_dirs; e++) |
| 351 | zfree(&entlist[e]); |
Riccardo Mancini | da96383 | 2021-05-26 01:05:17 +0200 | [diff] [blame] | 352 | free(entlist); |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 353 | return width; |
| 354 | } |
| 355 | |
| 356 | struct shell_test { |
| 357 | const char *dir; |
| 358 | const char *file; |
| 359 | }; |
| 360 | |
Ian Rogers | 33f44bf | 2021-11-03 23:41:51 -0700 | [diff] [blame] | 361 | static int shell_test__run(struct test_suite *test, int subdir __maybe_unused) |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 362 | { |
| 363 | int err; |
| 364 | char script[PATH_MAX]; |
| 365 | struct shell_test *st = test->priv; |
| 366 | |
Ian Rogers | e3c9cfd | 2021-06-21 14:56:46 -0700 | [diff] [blame] | 367 | path__join(script, sizeof(script) - 3, st->dir, st->file); |
| 368 | |
| 369 | if (verbose) |
| 370 | strncat(script, " -v", sizeof(script) - strlen(script) - 1); |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 371 | |
| 372 | err = system(script); |
| 373 | if (!err) |
| 374 | return TEST_OK; |
| 375 | |
| 376 | return WEXITSTATUS(err) == 2 ? TEST_SKIP : TEST_FAIL; |
| 377 | } |
| 378 | |
Riccardo Mancini | ebdf90a4 | 2021-08-11 20:06:26 +0200 | [diff] [blame] | 379 | static int run_shell_tests(int argc, const char *argv[], int i, int width, |
| 380 | struct intlist *skiplist) |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 381 | { |
Riccardo Mancini | da96383 | 2021-05-26 01:05:17 +0200 | [diff] [blame] | 382 | struct dirent **entlist; |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 383 | struct dirent *ent; |
Riccardo Mancini | eb7261f | 2021-07-09 18:34:53 +0200 | [diff] [blame] | 384 | int n_dirs, e; |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 385 | char path_dir[PATH_MAX]; |
| 386 | struct shell_test st = { |
| 387 | .dir = shell_tests__dir(path_dir, sizeof(path_dir)), |
| 388 | }; |
| 389 | |
| 390 | if (st.dir == NULL) |
| 391 | return -1; |
| 392 | |
Riccardo Mancini | da96383 | 2021-05-26 01:05:17 +0200 | [diff] [blame] | 393 | n_dirs = scandir(st.dir, &entlist, NULL, alphasort); |
| 394 | if (n_dirs == -1) { |
Ian Rogers | b2bf666 | 2020-03-12 17:56:02 -0700 | [diff] [blame] | 395 | pr_err("failed to open shell test directory: %s\n", |
| 396 | st.dir); |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 397 | return -1; |
Ian Rogers | b2bf666 | 2020-03-12 17:56:02 -0700 | [diff] [blame] | 398 | } |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 399 | |
Riccardo Mancini | da96383 | 2021-05-26 01:05:17 +0200 | [diff] [blame] | 400 | for_each_shell_test(entlist, n_dirs, st.dir, ent) { |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 401 | int curr = i++; |
| 402 | char desc[256]; |
Ian Rogers | c76ec1c | 2021-11-03 23:42:04 -0700 | [diff] [blame] | 403 | struct test_case test_cases[] = { |
| 404 | { |
| 405 | .desc = shell_test__description(desc, |
| 406 | sizeof(desc), |
| 407 | st.dir, |
| 408 | ent->d_name), |
| 409 | .run_case = shell_test__run, |
| 410 | }, |
| 411 | { .name = NULL, } |
| 412 | }; |
| 413 | struct test_suite test_suite = { |
| 414 | .desc = test_cases[0].desc, |
| 415 | .test_cases = test_cases, |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 416 | .priv = &st, |
| 417 | }; |
| 418 | |
Ian Rogers | c76ec1c | 2021-11-03 23:42:04 -0700 | [diff] [blame] | 419 | if (!perf_test__matches(test_suite.desc, curr, argc, argv)) |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 420 | continue; |
| 421 | |
| 422 | st.file = ent->d_name; |
Ian Rogers | c76ec1c | 2021-11-03 23:42:04 -0700 | [diff] [blame] | 423 | pr_info("%2d: %-*s:", i, width, test_suite.desc); |
Riccardo Mancini | ebdf90a4 | 2021-08-11 20:06:26 +0200 | [diff] [blame] | 424 | |
| 425 | if (intlist__find(skiplist, i)) { |
| 426 | color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n"); |
| 427 | continue; |
| 428 | } |
| 429 | |
Ian Rogers | b47d2fb | 2021-11-03 23:42:08 -0700 | [diff] [blame] | 430 | test_and_print(&test_suite, 0); |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 431 | } |
| 432 | |
Riccardo Mancini | eb7261f | 2021-07-09 18:34:53 +0200 | [diff] [blame] | 433 | for (e = 0; e < n_dirs; e++) |
| 434 | zfree(&entlist[e]); |
Riccardo Mancini | da96383 | 2021-05-26 01:05:17 +0200 | [diff] [blame] | 435 | free(entlist); |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 436 | return 0; |
| 437 | } |
| 438 | |
Arnaldo Carvalho de Melo | 2ae8287 | 2013-01-24 16:22:55 -0300 | [diff] [blame] | 439 | static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) |
Arnaldo Carvalho de Melo | 1c6a800 | 2010-04-29 18:58:32 -0300 | [diff] [blame] | 440 | { |
Ian Rogers | 33f44bf | 2021-11-03 23:41:51 -0700 | [diff] [blame] | 441 | struct test_suite *t; |
Ian Rogers | df22520 | 2021-11-03 23:41:49 -0700 | [diff] [blame] | 442 | unsigned int j, k; |
Arnaldo Carvalho de Melo | 1c6a800 | 2010-04-29 18:58:32 -0300 | [diff] [blame] | 443 | int i = 0; |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 444 | int width = shell_tests__max_desc_width(); |
Arnaldo Carvalho de Melo | 1c6a800 | 2010-04-29 18:58:32 -0300 | [diff] [blame] | 445 | |
Ian Rogers | df22520 | 2021-11-03 23:41:49 -0700 | [diff] [blame] | 446 | for_each_test(j, k, t) { |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 447 | int len = strlen(test_description(t, -1)); |
Arnaldo Carvalho de Melo | 9a8e85a | 2012-10-24 15:44:41 -0200 | [diff] [blame] | 448 | |
| 449 | if (width < len) |
| 450 | width = len; |
Arnaldo Carvalho de Melo | 9a8e85a | 2012-10-24 15:44:41 -0200 | [diff] [blame] | 451 | } |
Jiri Olsa | 945aea2 | 2012-10-30 23:01:43 +0100 | [diff] [blame] | 452 | |
Ian Rogers | df22520 | 2021-11-03 23:41:49 -0700 | [diff] [blame] | 453 | for_each_test(j, k, t) { |
Ian Rogers | b47d2fb | 2021-11-03 23:42:08 -0700 | [diff] [blame] | 454 | int curr = i++; |
Jiri Olsa | d685e6c | 2020-05-25 00:42:06 +0200 | [diff] [blame] | 455 | int subi; |
Arnaldo Carvalho de Melo | e60770a | 2011-11-29 12:52:07 -0200 | [diff] [blame] | 456 | |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 457 | if (!perf_test__matches(test_description(t, -1), curr, argc, argv)) { |
Jiri Olsa | d685e6c | 2020-05-25 00:42:06 +0200 | [diff] [blame] | 458 | bool skip = true; |
| 459 | int subn; |
| 460 | |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 461 | subn = num_subtests(t); |
Jiri Olsa | d685e6c | 2020-05-25 00:42:06 +0200 | [diff] [blame] | 462 | |
| 463 | for (subi = 0; subi < subn; subi++) { |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 464 | if (perf_test__matches(test_description(t, subi), |
| 465 | curr, argc, argv)) |
Jiri Olsa | d685e6c | 2020-05-25 00:42:06 +0200 | [diff] [blame] | 466 | skip = false; |
| 467 | } |
| 468 | |
| 469 | if (skip) |
| 470 | continue; |
| 471 | } |
Arnaldo Carvalho de Melo | e60770a | 2011-11-29 12:52:07 -0200 | [diff] [blame] | 472 | |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 473 | pr_info("%2d: %-*s:", i, width, test_description(t, -1)); |
Arnaldo Carvalho de Melo | 2ae8287 | 2013-01-24 16:22:55 -0300 | [diff] [blame] | 474 | |
| 475 | if (intlist__find(skiplist, i)) { |
| 476 | color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (user override)\n"); |
| 477 | continue; |
| 478 | } |
| 479 | |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 480 | if (!has_subtests(t)) { |
Ian Rogers | b47d2fb | 2021-11-03 23:42:08 -0700 | [diff] [blame] | 481 | test_and_print(t, -1); |
Wang Nan | e8c6d50 | 2015-11-17 08:32:48 +0000 | [diff] [blame] | 482 | } else { |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 483 | int subn = num_subtests(t); |
Wang Nan | e8c6d50 | 2015-11-17 08:32:48 +0000 | [diff] [blame] | 484 | /* |
| 485 | * minus 2 to align with normal testcases. |
| 486 | * For subtest we print additional '.x' in number. |
| 487 | * for example: |
| 488 | * |
| 489 | * 35: Test LLVM searching and compiling : |
| 490 | * 35.1: Basic BPF llvm compiling test : Ok |
| 491 | */ |
| 492 | int subw = width > 2 ? width - 2 : width; |
Jiri Olsa | f4c1ea5 | 2012-12-19 11:33:39 -0300 | [diff] [blame] | 493 | |
Wang Nan | e8c6d50 | 2015-11-17 08:32:48 +0000 | [diff] [blame] | 494 | if (subn <= 0) { |
| 495 | color_fprintf(stderr, PERF_COLOR_YELLOW, |
| 496 | " Skip (not compiled in)\n"); |
| 497 | continue; |
| 498 | } |
| 499 | pr_info("\n"); |
| 500 | |
| 501 | for (subi = 0; subi < subn; subi++) { |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 502 | int len = strlen(test_description(t, subi)); |
Wang Nan | e8c6d50 | 2015-11-17 08:32:48 +0000 | [diff] [blame] | 503 | |
| 504 | if (subw < len) |
| 505 | subw = len; |
| 506 | } |
| 507 | |
| 508 | for (subi = 0; subi < subn; subi++) { |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 509 | if (!perf_test__matches(test_description(t, subi), |
| 510 | curr, argc, argv)) |
Jiri Olsa | d685e6c | 2020-05-25 00:42:06 +0200 | [diff] [blame] | 511 | continue; |
| 512 | |
Wang Nan | e8c6d50 | 2015-11-17 08:32:48 +0000 | [diff] [blame] | 513 | pr_info("%2d.%1d: %-*s:", i, subi + 1, subw, |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 514 | test_description(t, subi)); |
Ian Rogers | b47d2fb | 2021-11-03 23:42:08 -0700 | [diff] [blame] | 515 | test_and_print(t, subi); |
Wang Nan | e8c6d50 | 2015-11-17 08:32:48 +0000 | [diff] [blame] | 516 | } |
Jiri Olsa | f4c1ea5 | 2012-12-19 11:33:39 -0300 | [diff] [blame] | 517 | } |
Arnaldo Carvalho de Melo | 1c6a800 | 2010-04-29 18:58:32 -0300 | [diff] [blame] | 518 | } |
| 519 | |
Riccardo Mancini | ebdf90a4 | 2021-08-11 20:06:26 +0200 | [diff] [blame] | 520 | return run_shell_tests(argc, argv, i, width, skiplist); |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | static int perf_test__list_shell(int argc, const char **argv, int i) |
| 524 | { |
Riccardo Mancini | da96383 | 2021-05-26 01:05:17 +0200 | [diff] [blame] | 525 | struct dirent **entlist; |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 526 | struct dirent *ent; |
Riccardo Mancini | eb7261f | 2021-07-09 18:34:53 +0200 | [diff] [blame] | 527 | int n_dirs, e; |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 528 | char path_dir[PATH_MAX]; |
| 529 | const char *path = shell_tests__dir(path_dir, sizeof(path_dir)); |
| 530 | |
| 531 | if (path == NULL) |
| 532 | return -1; |
| 533 | |
Riccardo Mancini | da96383 | 2021-05-26 01:05:17 +0200 | [diff] [blame] | 534 | n_dirs = scandir(path, &entlist, NULL, alphasort); |
| 535 | if (n_dirs == -1) |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 536 | return -1; |
| 537 | |
Riccardo Mancini | da96383 | 2021-05-26 01:05:17 +0200 | [diff] [blame] | 538 | for_each_shell_test(entlist, n_dirs, path, ent) { |
Arnaldo Carvalho de Melo | 6d02acc | 2017-08-04 11:16:40 -0300 | [diff] [blame] | 539 | int curr = i++; |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 540 | char bf[256]; |
Ian Rogers | 33f44bf | 2021-11-03 23:41:51 -0700 | [diff] [blame] | 541 | struct test_suite t = { |
Arnaldo Carvalho de Melo | 6d02acc | 2017-08-04 11:16:40 -0300 | [diff] [blame] | 542 | .desc = shell_test__description(bf, sizeof(bf), path, ent->d_name), |
| 543 | }; |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 544 | |
Jiri Olsa | d685e6c | 2020-05-25 00:42:06 +0200 | [diff] [blame] | 545 | if (!perf_test__matches(t.desc, curr, argc, argv)) |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 546 | continue; |
| 547 | |
Arnaldo Carvalho de Melo | 6d02acc | 2017-08-04 11:16:40 -0300 | [diff] [blame] | 548 | pr_info("%2d: %s\n", i, t.desc); |
Riccardo Mancini | eb7261f | 2021-07-09 18:34:53 +0200 | [diff] [blame] | 549 | |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 550 | } |
| 551 | |
Riccardo Mancini | eb7261f | 2021-07-09 18:34:53 +0200 | [diff] [blame] | 552 | for (e = 0; e < n_dirs; e++) |
| 553 | zfree(&entlist[e]); |
Riccardo Mancini | da96383 | 2021-05-26 01:05:17 +0200 | [diff] [blame] | 554 | free(entlist); |
Arnaldo Carvalho de Melo | 1c6a800 | 2010-04-29 18:58:32 -0300 | [diff] [blame] | 555 | return 0; |
| 556 | } |
| 557 | |
Arnaldo Carvalho de Melo | e60770a | 2011-11-29 12:52:07 -0200 | [diff] [blame] | 558 | static int perf_test__list(int argc, const char **argv) |
| 559 | { |
Ian Rogers | df22520 | 2021-11-03 23:41:49 -0700 | [diff] [blame] | 560 | unsigned int j, k; |
Ian Rogers | 33f44bf | 2021-11-03 23:41:51 -0700 | [diff] [blame] | 561 | struct test_suite *t; |
Arnaldo Carvalho de Melo | e60770a | 2011-11-29 12:52:07 -0200 | [diff] [blame] | 562 | int i = 0; |
Arnaldo Carvalho de Melo | 1c6a800 | 2010-04-29 18:58:32 -0300 | [diff] [blame] | 563 | |
Ian Rogers | df22520 | 2021-11-03 23:41:49 -0700 | [diff] [blame] | 564 | for_each_test(j, k, t) { |
Arnaldo Carvalho de Melo | 6d02acc | 2017-08-04 11:16:40 -0300 | [diff] [blame] | 565 | int curr = i++; |
Arnaldo Carvalho de Melo | 28765bf | 2017-08-04 11:16:40 -0300 | [diff] [blame] | 566 | |
Ian Rogers | 848ddf5 | 2021-11-03 23:42:07 -0700 | [diff] [blame] | 567 | if (!perf_test__matches(test_description(t, -1), curr, argc, argv)) |
Arnaldo Carvalho de Melo | e60770a | 2011-11-29 12:52:07 -0200 | [diff] [blame] | 568 | continue; |
| 569 | |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 570 | pr_info("%2d: %s\n", i, test_description(t, -1)); |
Hendrik Brueckner | ea40b6d | 2018-04-13 09:42:23 +0200 | [diff] [blame] | 571 | |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 572 | if (has_subtests(t)) { |
| 573 | int subn = num_subtests(t); |
Hendrik Brueckner | ea40b6d | 2018-04-13 09:42:23 +0200 | [diff] [blame] | 574 | int subi; |
| 575 | |
| 576 | for (subi = 0; subi < subn; subi++) |
| 577 | pr_info("%2d:%1d: %s\n", i, subi + 1, |
Ian Rogers | f832044 | 2021-11-03 23:41:52 -0700 | [diff] [blame] | 578 | test_description(t, subi)); |
Hendrik Brueckner | ea40b6d | 2018-04-13 09:42:23 +0200 | [diff] [blame] | 579 | } |
Arnaldo Carvalho de Melo | e60770a | 2011-11-29 12:52:07 -0200 | [diff] [blame] | 580 | } |
| 581 | |
Arnaldo Carvalho de Melo | 1209b27 | 2017-08-03 16:49:15 -0300 | [diff] [blame] | 582 | perf_test__list_shell(argc, argv, i); |
| 583 | |
Arnaldo Carvalho de Melo | e60770a | 2011-11-29 12:52:07 -0200 | [diff] [blame] | 584 | return 0; |
| 585 | } |
Arnaldo Carvalho de Melo | 1c6a800 | 2010-04-29 18:58:32 -0300 | [diff] [blame] | 586 | |
Arnaldo Carvalho de Melo | b0ad8ea | 2017-03-27 11:47:20 -0300 | [diff] [blame] | 587 | int cmd_test(int argc, const char **argv) |
Arnaldo Carvalho de Melo | 1c6a800 | 2010-04-29 18:58:32 -0300 | [diff] [blame] | 588 | { |
Yunlong Song | 1f9975f | 2015-03-18 21:35:55 +0800 | [diff] [blame] | 589 | const char *test_usage[] = { |
Arnaldo Carvalho de Melo | e60770a | 2011-11-29 12:52:07 -0200 | [diff] [blame] | 590 | "perf test [<options>] [{list <test-name-fragment>|[<test-name-fragments>|<test-numbers>]}]", |
| 591 | NULL, |
| 592 | }; |
Arnaldo Carvalho de Melo | 2ae8287 | 2013-01-24 16:22:55 -0300 | [diff] [blame] | 593 | const char *skip = NULL; |
Arnaldo Carvalho de Melo | e60770a | 2011-11-29 12:52:07 -0200 | [diff] [blame] | 594 | const struct option test_options[] = { |
Arnaldo Carvalho de Melo | 2ae8287 | 2013-01-24 16:22:55 -0300 | [diff] [blame] | 595 | OPT_STRING('s', "skip", &skip, "tests", "tests to skip"), |
Namhyung Kim | c30ab8a | 2012-01-08 02:25:26 +0900 | [diff] [blame] | 596 | OPT_INCR('v', "verbose", &verbose, |
Arnaldo Carvalho de Melo | e60770a | 2011-11-29 12:52:07 -0200 | [diff] [blame] | 597 | "be more verbose (show symbol address, etc)"), |
Jiri Olsa | 7fa9b8f | 2016-06-28 13:29:01 +0200 | [diff] [blame] | 598 | OPT_BOOLEAN('F', "dont-fork", &dont_fork, |
| 599 | "Do not fork for testcase"), |
Arnaldo Carvalho de Melo | e60770a | 2011-11-29 12:52:07 -0200 | [diff] [blame] | 600 | OPT_END() |
| 601 | }; |
Yunlong Song | 1f9975f | 2015-03-18 21:35:55 +0800 | [diff] [blame] | 602 | const char * const test_subcommands[] = { "list", NULL }; |
Arnaldo Carvalho de Melo | 2ae8287 | 2013-01-24 16:22:55 -0300 | [diff] [blame] | 603 | struct intlist *skiplist = NULL; |
Arnaldo Carvalho de Melo | a635fc5 | 2014-10-09 16:16:00 -0300 | [diff] [blame] | 604 | int ret = hists__init(); |
| 605 | |
| 606 | if (ret < 0) |
| 607 | return ret; |
Arnaldo Carvalho de Melo | e60770a | 2011-11-29 12:52:07 -0200 | [diff] [blame] | 608 | |
Yunlong Song | 1f9975f | 2015-03-18 21:35:55 +0800 | [diff] [blame] | 609 | argc = parse_options_subcommand(argc, argv, test_options, test_subcommands, test_usage, 0); |
Arnaldo Carvalho de Melo | e60770a | 2011-11-29 12:52:07 -0200 | [diff] [blame] | 610 | if (argc >= 1 && !strcmp(argv[0], "list")) |
Arnaldo Carvalho de Melo | 6d02acc | 2017-08-04 11:16:40 -0300 | [diff] [blame] | 611 | return perf_test__list(argc - 1, argv + 1); |
Arnaldo Carvalho de Melo | 1c6a800 | 2010-04-29 18:58:32 -0300 | [diff] [blame] | 612 | |
| 613 | symbol_conf.priv_size = sizeof(int); |
| 614 | symbol_conf.sort_by_name = true; |
| 615 | symbol_conf.try_vmlinux_path = true; |
| 616 | |
Namhyung Kim | 0a7e6d1 | 2014-08-12 15:40:45 +0900 | [diff] [blame] | 617 | if (symbol__init(NULL) < 0) |
Arnaldo Carvalho de Melo | 1c6a800 | 2010-04-29 18:58:32 -0300 | [diff] [blame] | 618 | return -1; |
| 619 | |
Arnaldo Carvalho de Melo | 2ae8287 | 2013-01-24 16:22:55 -0300 | [diff] [blame] | 620 | if (skip != NULL) |
| 621 | skiplist = intlist__new(skip); |
Arnaldo Carvalho de Melo | d3280ce | 2019-07-09 16:27:01 -0300 | [diff] [blame] | 622 | /* |
| 623 | * Tests that create BPF maps, for instance, need more than the 64K |
| 624 | * default: |
| 625 | */ |
| 626 | rlimit__bump_memlock(); |
Arnaldo Carvalho de Melo | 2ae8287 | 2013-01-24 16:22:55 -0300 | [diff] [blame] | 627 | |
| 628 | return __cmd_test(argc, argv, skiplist); |
Arnaldo Carvalho de Melo | 1c6a800 | 2010-04-29 18:58:32 -0300 | [diff] [blame] | 629 | } |