Commit d685e6c1 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf tests: Consider subtests when searching for user specified tests

It's now possible to put subtest name as a test filter:

  $ perf test 'PMU event table sanity'
  10: PMU events                                            :
  10.1: PMU event table sanity                              : Ok

Committer testing:

Before:

  $ perf test 'PMU event table sanity'
  $

After:

  $ perf test 'PMU event table sanity'
  10: PMU events                                            :
  10.1: PMU event table sanity                              : Ok
  $
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20200524224219.234847-2-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent a90a1c54
...@@ -334,7 +334,7 @@ static struct test *tests[] = { ...@@ -334,7 +334,7 @@ static struct test *tests[] = {
arch_tests, arch_tests,
}; };
static bool perf_test__matches(struct test *test, int curr, int argc, const char *argv[]) static bool perf_test__matches(const char *desc, int curr, int argc, const char *argv[])
{ {
int i; int i;
...@@ -351,7 +351,7 @@ static bool perf_test__matches(struct test *test, int curr, int argc, const char ...@@ -351,7 +351,7 @@ static bool perf_test__matches(struct test *test, int curr, int argc, const char
continue; continue;
} }
if (strcasestr(test->desc, argv[i])) if (strcasestr(desc, argv[i]))
return true; return true;
} }
...@@ -580,7 +580,7 @@ static int run_shell_tests(int argc, const char *argv[], int i, int width) ...@@ -580,7 +580,7 @@ static int run_shell_tests(int argc, const char *argv[], int i, int width)
.priv = &st, .priv = &st,
}; };
if (!perf_test__matches(&test, curr, argc, argv)) if (!perf_test__matches(test.desc, curr, argc, argv))
continue; continue;
st.file = ent->d_name; st.file = ent->d_name;
...@@ -608,9 +608,25 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) ...@@ -608,9 +608,25 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
for_each_test(j, t) { for_each_test(j, t) {
int curr = i++, err; int curr = i++, err;
int subi;
if (!perf_test__matches(t, curr, argc, argv)) if (!perf_test__matches(t->desc, curr, argc, argv)) {
continue; bool skip = true;
int subn;
if (!t->subtest.get_nr)
continue;
subn = t->subtest.get_nr();
for (subi = 0; subi < subn; subi++) {
if (perf_test__matches(t->subtest.get_desc(subi), curr, argc, argv))
skip = false;
}
if (skip)
continue;
}
if (t->is_supported && !t->is_supported()) { if (t->is_supported && !t->is_supported()) {
pr_debug("%2d: %-*s: Disabled\n", i, width, t->desc); pr_debug("%2d: %-*s: Disabled\n", i, width, t->desc);
...@@ -638,7 +654,6 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) ...@@ -638,7 +654,6 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
*/ */
int subw = width > 2 ? width - 2 : width; int subw = width > 2 ? width - 2 : width;
bool skip = false; bool skip = false;
int subi;
if (subn <= 0) { if (subn <= 0) {
color_fprintf(stderr, PERF_COLOR_YELLOW, color_fprintf(stderr, PERF_COLOR_YELLOW,
...@@ -655,6 +670,9 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist) ...@@ -655,6 +670,9 @@ static int __cmd_test(int argc, const char *argv[], struct intlist *skiplist)
} }
for (subi = 0; subi < subn; subi++) { for (subi = 0; subi < subn; subi++) {
if (!perf_test__matches(t->subtest.get_desc(subi), curr, argc, argv))
continue;
pr_info("%2d.%1d: %-*s:", i, subi + 1, subw, pr_info("%2d.%1d: %-*s:", i, subi + 1, subw,
t->subtest.get_desc(subi)); t->subtest.get_desc(subi));
err = test_and_print(t, skip, subi); err = test_and_print(t, skip, subi);
...@@ -688,7 +706,7 @@ static int perf_test__list_shell(int argc, const char **argv, int i) ...@@ -688,7 +706,7 @@ static int perf_test__list_shell(int argc, const char **argv, int i)
.desc = shell_test__description(bf, sizeof(bf), path, ent->d_name), .desc = shell_test__description(bf, sizeof(bf), path, ent->d_name),
}; };
if (!perf_test__matches(&t, curr, argc, argv)) if (!perf_test__matches(t.desc, curr, argc, argv))
continue; continue;
pr_info("%2d: %s\n", i, t.desc); pr_info("%2d: %s\n", i, t.desc);
...@@ -707,7 +725,7 @@ static int perf_test__list(int argc, const char **argv) ...@@ -707,7 +725,7 @@ static int perf_test__list(int argc, const char **argv)
for_each_test(j, t) { for_each_test(j, t) {
int curr = i++; int curr = i++;
if (!perf_test__matches(t, curr, argc, argv) || if (!perf_test__matches(t->desc, curr, argc, argv) ||
(t->is_supported && !t->is_supported())) (t->is_supported && !t->is_supported()))
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment