Now subtests can inform why a test was skipped. The upcoming patch
improvint PMU event metric testing will use it.

Signed-off-by: Ian Rogers <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Jin Yao <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: John Garry <[email protected]>
Cc: Kajol Jain <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Leo Yan <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Clarke <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
 tools/perf/tests/builtin-test.c | 11 +++++++++--
 tools/perf/tests/tests.h        |  1 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 3471ec52ea11..baee735e6aa5 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -429,8 +429,15 @@ static int test_and_print(struct test *t, bool force_skip, 
int subtest)
        case TEST_OK:
                pr_info(" Ok\n");
                break;
-       case TEST_SKIP:
-               color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n");
+       case TEST_SKIP: {
+               const char *skip_reason = NULL;
+               if (t->subtest.skip_reason)
+                       skip_reason = t->subtest.skip_reason(subtest);
+               if (skip_reason)
+                       color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip 
(%s)\n", skip_reason);
+               else
+                       color_fprintf(stderr, PERF_COLOR_YELLOW, " Skip\n");
+       }
                break;
        case TEST_FAIL:
        default:
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index d6d4ac34eeb7..88e45aeab94f 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -34,6 +34,7 @@ struct test {
                bool skip_if_fail;
                int (*get_nr)(void);
                const char *(*get_desc)(int subtest);
+               const char *(*skip_reason)(int subtest);
        } subtest;
        bool (*is_supported)(void);
        void *priv;
-- 
2.26.2.761.g0e0b3e54be-goog

Reply via email to