perf test: Check test suite description properly
authorNamhyung Kim <namhyung@kernel.org>
Tue, 1 Jul 2025 20:10:25 +0000 (13:10 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Tue, 1 Jul 2025 22:51:53 +0000 (15:51 -0700)
Currently perf test checks the given string with descriptions for both
test suites and cases (subtests).  But sometimes it's confusing since
the subtests don't contain the important keyword.

I think it's better to check the suite level and run the whole suite
together if it matches description in the suite.

Before:
  $ perf test hwmon
  (no output)

After:
  $ perf test hwmon
   10: Hwmon PMU                                                       :
   10.1: Basic parsing test                                            : Ok
   10.2: Parsing without PMU name                                      : Ok
   10.3: Parsing with PMU name                                         : Ok

And keep the existing behavior when it only matches test description only.

  $ perf test "Equal cpu map"
   39.5: Equal cpu map                                                 : Ok

Reviewed-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250701201027.1171561-1-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/tests/builtin-test.c

index 80375ca39a37a25607227a8896a9462dad96ef80..846c9b3a732c9b3a4dbe2ace6b6636e5af5d9cda 100644 (file)
@@ -539,6 +539,7 @@ static int __cmd_test(struct test_suite **suites, int argc, const char *argv[],
 
                for (struct test_suite **t = suites; *t; t++, curr_suite++) {
                        int curr_test_case;
+                       bool suite_matched = false;
 
                        if (!perf_test__matches(test_description(*t, -1), curr_suite, argc, argv)) {
                                /*
@@ -556,6 +557,8 @@ static int __cmd_test(struct test_suite **suites, int argc, const char *argv[],
                                }
                                if (skip)
                                        continue;
+                       } else {
+                               suite_matched = true;
                        }
 
                        if (intlist__find(skiplist, curr_suite + 1)) {
@@ -567,10 +570,10 @@ static int __cmd_test(struct test_suite **suites, int argc, const char *argv[],
 
                        for (unsigned int run = 0; run < runs_per_test; run++) {
                                test_suite__for_each_test_case(*t, curr_test_case) {
-                                       if (!perf_test__matches(test_description(*t, curr_test_case),
+                                       if (!suite_matched &&
+                                           !perf_test__matches(test_description(*t, curr_test_case),
                                                                curr_suite, argc, argv))
                                                continue;
-
                                        err = start_test(*t, curr_suite, curr_test_case,
                                                         &child_tests[child_test_num++],
                                                         width, pass);