.. | .. |
---|
8 | 8 | #include <errno.h> |
---|
9 | 9 | #include <unistd.h> |
---|
10 | 10 | #include <string.h> |
---|
| 11 | +#include <stdlib.h> |
---|
11 | 12 | #include <sys/types.h> |
---|
12 | 13 | #include <dirent.h> |
---|
13 | 14 | #include <sys/wait.h> |
---|
.. | .. |
---|
21 | 22 | #include <subcmd/parse-options.h> |
---|
22 | 23 | #include "string2.h" |
---|
23 | 24 | #include "symbol.h" |
---|
| 25 | +#include "util/rlimit.h" |
---|
24 | 26 | #include <linux/kernel.h> |
---|
| 27 | +#include <linux/string.h> |
---|
25 | 28 | #include <subcmd/exec-cmd.h> |
---|
26 | 29 | |
---|
27 | 30 | static bool dont_fork; |
---|
.. | .. |
---|
68 | 71 | { |
---|
69 | 72 | .desc = "Parse perf pmu format", |
---|
70 | 73 | .func = test__pmu, |
---|
| 74 | + }, |
---|
| 75 | + { |
---|
| 76 | + .desc = "PMU events", |
---|
| 77 | + .func = test__pmu_events, |
---|
| 78 | + .subtest = { |
---|
| 79 | + .skip_if_fail = false, |
---|
| 80 | + .get_nr = test__pmu_events_subtest_get_nr, |
---|
| 81 | + .get_desc = test__pmu_events_subtest_get_desc, |
---|
| 82 | + .skip_reason = test__pmu_events_subtest_skip_reason, |
---|
| 83 | + }, |
---|
| 84 | + |
---|
71 | 85 | }, |
---|
72 | 86 | { |
---|
73 | 87 | .desc = "DSO data read", |
---|
.. | .. |
---|
118 | 132 | { |
---|
119 | 133 | .desc = "Breakpoint accounting", |
---|
120 | 134 | .func = test__bp_accounting, |
---|
121 | | - .is_supported = test__bp_signal_is_supported, |
---|
| 135 | + .is_supported = test__bp_account_is_supported, |
---|
| 136 | + }, |
---|
| 137 | + { |
---|
| 138 | + .desc = "Watchpoint", |
---|
| 139 | + .func = test__wp, |
---|
| 140 | + .is_supported = test__wp_is_supported, |
---|
| 141 | + .subtest = { |
---|
| 142 | + .skip_if_fail = false, |
---|
| 143 | + .get_nr = test__wp_subtest_get_nr, |
---|
| 144 | + .get_desc = test__wp_subtest_get_desc, |
---|
| 145 | + }, |
---|
122 | 146 | }, |
---|
123 | 147 | { |
---|
124 | 148 | .desc = "Number of exit events of a simple workload", |
---|
.. | .. |
---|
153 | 177 | .func = test__mmap_thread_lookup, |
---|
154 | 178 | }, |
---|
155 | 179 | { |
---|
156 | | - .desc = "Share thread mg", |
---|
157 | | - .func = test__thread_mg_share, |
---|
| 180 | + .desc = "Share thread maps", |
---|
| 181 | + .func = test__thread_maps_share, |
---|
158 | 182 | }, |
---|
159 | 183 | { |
---|
160 | 184 | .desc = "Sort output of hist entries", |
---|
.. | .. |
---|
247 | 271 | .func = test__cpu_map_print, |
---|
248 | 272 | }, |
---|
249 | 273 | { |
---|
| 274 | + .desc = "Merge cpu map", |
---|
| 275 | + .func = test__cpu_map_merge, |
---|
| 276 | + }, |
---|
| 277 | + |
---|
| 278 | + { |
---|
250 | 279 | .desc = "Probe SDT events", |
---|
251 | 280 | .func = test__sdt_event, |
---|
252 | 281 | }, |
---|
.. | .. |
---|
280 | 309 | .func = test__mem2node, |
---|
281 | 310 | }, |
---|
282 | 311 | { |
---|
| 312 | + .desc = "time utils", |
---|
| 313 | + .func = test__time_utils, |
---|
| 314 | + }, |
---|
| 315 | + { |
---|
| 316 | + .desc = "Test jit_write_elf", |
---|
| 317 | + .func = test__jit_write_elf, |
---|
| 318 | + }, |
---|
| 319 | + { |
---|
| 320 | + .desc = "Test libpfm4 support", |
---|
| 321 | + .func = test__pfm, |
---|
| 322 | + .subtest = { |
---|
| 323 | + .skip_if_fail = true, |
---|
| 324 | + .get_nr = test__pfm_subtest_get_nr, |
---|
| 325 | + .get_desc = test__pfm_subtest_get_desc, |
---|
| 326 | + } |
---|
| 327 | + }, |
---|
| 328 | + { |
---|
| 329 | + .desc = "Test api io", |
---|
| 330 | + .func = test__api_io, |
---|
| 331 | + }, |
---|
| 332 | + { |
---|
| 333 | + .desc = "maps__merge_in", |
---|
| 334 | + .func = test__maps__merge_in, |
---|
| 335 | + }, |
---|
| 336 | + { |
---|
| 337 | + .desc = "Demangle Java", |
---|
| 338 | + .func = test__demangle_java, |
---|
| 339 | + }, |
---|
| 340 | + { |
---|
| 341 | + .desc = "Parse and process metrics", |
---|
| 342 | + .func = test__parse_metric, |
---|
| 343 | + }, |
---|
| 344 | + { |
---|
| 345 | + .desc = "PE file support", |
---|
| 346 | + .func = test__pe_file_parsing, |
---|
| 347 | + }, |
---|
| 348 | + { |
---|
| 349 | + .desc = "Event expansion for cgroups", |
---|
| 350 | + .func = test__expand_cgroup_events, |
---|
| 351 | + }, |
---|
| 352 | + { |
---|
283 | 353 | .func = NULL, |
---|
284 | 354 | }, |
---|
285 | 355 | }; |
---|
.. | .. |
---|
289 | 359 | arch_tests, |
---|
290 | 360 | }; |
---|
291 | 361 | |
---|
292 | | -static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[]) |
---|
| 362 | +static bool perf_test__matches(const char *desc, int curr, int argc, const char *argv[]) |
---|
293 | 363 | { |
---|
294 | 364 | int i; |
---|
295 | 365 | |
---|
.. | .. |
---|
306 | 376 | continue; |
---|
307 | 377 | } |
---|
308 | 378 | |
---|
309 | | - if (strcasestr(test->desc, argv[i])) |
---|
| 379 | + if (strcasestr(desc, argv[i])) |
---|
310 | 380 | return true; |
---|
311 | 381 | } |
---|
312 | 382 | |
---|
.. | .. |
---|
391 | 461 | case TEST_OK: |
---|
392 | 462 | pr_info(" Ok\n"); |
---|
393 | 463 | break; |
---|
394 | | - case TEST_SKIP: |
---|
395 | | - color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n"); |
---|
| 464 | + case TEST_SKIP: { |
---|
| 465 | + const char *skip_reason = NULL; |
---|
| 466 | + if (t->subtest.skip_reason) |
---|
| 467 | + skip_reason = t->subtest.skip_reason(subtest); |
---|
| 468 | + if (skip_reason) |
---|
| 469 | + color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip (%s)\n", skip_reason); |
---|
| 470 | + else |
---|
| 471 | + color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n"); |
---|
| 472 | + } |
---|
396 | 473 | break; |
---|
397 | 474 | case TEST_FAIL: |
---|
398 | 475 | default: |
---|
.. | .. |
---|
414 | 491 | if (!fp) |
---|
415 | 492 | return NULL; |
---|
416 | 493 | |
---|
| 494 | + /* Skip shebang */ |
---|
| 495 | + while (fgetc(fp) != '\n'); |
---|
| 496 | + |
---|
417 | 497 | description = fgets(description, size, fp); |
---|
418 | 498 | fclose(fp); |
---|
419 | 499 | |
---|
420 | | - return description ? trim(description + 1) : NULL; |
---|
| 500 | + return description ? strim(description + 1) : NULL; |
---|
421 | 501 | } |
---|
422 | 502 | |
---|
423 | 503 | #define for_each_shell_test(dir, base, ent) \ |
---|
.. | .. |
---|
510 | 590 | return -1; |
---|
511 | 591 | |
---|
512 | 592 | dir = opendir(st.dir); |
---|
513 | | - if (!dir) |
---|
| 593 | + if (!dir) { |
---|
| 594 | + pr_err("failed to open shell test directory: %s\n", |
---|
| 595 | + st.dir); |
---|
514 | 596 | return -1; |
---|
| 597 | + } |
---|
515 | 598 | |
---|
516 | 599 | for_each_shell_test(dir, st.dir, ent) { |
---|
517 | 600 | int curr = i++; |
---|
.. | .. |
---|
522 | 605 | .priv = &st, |
---|
523 | 606 | }; |
---|
524 | 607 | |
---|
525 | | - if (!perf_test__matches(&test, curr, argc, argv)) |
---|
| 608 | + if (!perf_test__matches(test.desc, curr, argc, argv)) |
---|
526 | 609 | continue; |
---|
527 | 610 | |
---|
528 | 611 | st.file = ent->d_name; |
---|
.. | .. |
---|
550 | 633 | |
---|
551 | 634 | for_each_test(j, t) { |
---|
552 | 635 | int curr = i++, err; |
---|
| 636 | + int subi; |
---|
553 | 637 | |
---|
554 | | - if (!perf_test__matches(t, curr, argc, argv)) |
---|
555 | | - continue; |
---|
| 638 | + if (!perf_test__matches(t->desc, curr, argc, argv)) { |
---|
| 639 | + bool skip = true; |
---|
| 640 | + int subn; |
---|
| 641 | + |
---|
| 642 | + if (!t->subtest.get_nr) |
---|
| 643 | + continue; |
---|
| 644 | + |
---|
| 645 | + subn = t->subtest.get_nr(); |
---|
| 646 | + |
---|
| 647 | + for (subi = 0; subi < subn; subi++) { |
---|
| 648 | + if (perf_test__matches(t->subtest.get_desc(subi), curr, argc, argv)) |
---|
| 649 | + skip = false; |
---|
| 650 | + } |
---|
| 651 | + |
---|
| 652 | + if (skip) |
---|
| 653 | + continue; |
---|
| 654 | + } |
---|
556 | 655 | |
---|
557 | 656 | if (t->is_supported && !t->is_supported()) { |
---|
558 | 657 | pr_debug("%2d: %-*s: Disabled\n", i, width, t->desc); |
---|
.. | .. |
---|
580 | 679 | */ |
---|
581 | 680 | int subw = width > 2 ? width - 2 : width; |
---|
582 | 681 | bool skip = false; |
---|
583 | | - int subi; |
---|
584 | 682 | |
---|
585 | 683 | if (subn <= 0) { |
---|
586 | 684 | color_fprintf(stderr, PERF_COLOR_YELLOW, |
---|
.. | .. |
---|
597 | 695 | } |
---|
598 | 696 | |
---|
599 | 697 | for (subi = 0; subi < subn; subi++) { |
---|
| 698 | + if (!perf_test__matches(t->subtest.get_desc(subi), curr, argc, argv)) |
---|
| 699 | + continue; |
---|
| 700 | + |
---|
600 | 701 | pr_info("%2d.%1d: %-*s:", i, subi + 1, subw, |
---|
601 | 702 | t->subtest.get_desc(subi)); |
---|
602 | 703 | err = test_and_print(t, skip, subi); |
---|
.. | .. |
---|
630 | 731 | .desc = shell_test__description(bf, sizeof(bf), path, ent->d_name), |
---|
631 | 732 | }; |
---|
632 | 733 | |
---|
633 | | - if (!perf_test__matches(&t, curr, argc, argv)) |
---|
| 734 | + if (!perf_test__matches(t.desc, curr, argc, argv)) |
---|
634 | 735 | continue; |
---|
635 | 736 | |
---|
636 | 737 | pr_info("%2d: %s\n", i, t.desc); |
---|
.. | .. |
---|
649 | 750 | for_each_test(j, t) { |
---|
650 | 751 | int curr = i++; |
---|
651 | 752 | |
---|
652 | | - if (!perf_test__matches(t, curr, argc, argv) || |
---|
| 753 | + if (!perf_test__matches(t->desc, curr, argc, argv) || |
---|
653 | 754 | (t->is_supported && !t->is_supported())) |
---|
654 | 755 | continue; |
---|
655 | 756 | |
---|
.. | .. |
---|
705 | 806 | |
---|
706 | 807 | if (skip != NULL) |
---|
707 | 808 | skiplist = intlist__new(skip); |
---|
| 809 | + /* |
---|
| 810 | + * Tests that create BPF maps, for instance, need more than the 64K |
---|
| 811 | + * default: |
---|
| 812 | + */ |
---|
| 813 | + rlimit__bump_memlock(); |
---|
708 | 814 | |
---|
709 | 815 | return __cmd_test(argc, argv, skiplist); |
---|
710 | 816 | } |
---|