Re: [PATCH v5 15/15] perf jevents: Run metric_test.py at compile-time

Arnaldo Carvalho de Melo
2023-02-03T20:15:39Z

Em Thu, Jan 26, 2023 at 03:36:45PM -0800, Ian Rogers escreveu:
> Add a target that generates a log file for running metric_test.py and
> make this a dependency on generating pmu-events.c. The log output is
> displayed if the test fails like (the test was modified to make it
> fail):
>
> ```
> TEST /tmp/perf/pmu-events/metric_test.log
> F......
> ======================================================================
> FAIL: test_Brackets (__main__.TestMetricExpressions)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "tools/perf/pmu-events/metric_test.py", line 33, in test_Brackets
> self.assertEqual((a * b + c).ToPerfJson(), 'a * b + d')
> AssertionError: 'a * b + c' != 'a * b + d'
> - a * b + c
> ? ^
> + a * b + d

Added this:

diff --git a/tools/perf/.gitignore b/tools/perf/.gitignore
index 05806ecfc33c12a1..f533e76fb48002b7 100644
--- a/tools/perf/.gitignore
+++ b/tools/perf/.gitignore
@@ -38,6 +38,7 @@ arch/*/include/generated/
trace/beauty/generated/
pmu-events/pmu-events.c
pmu-events/jevents
+pmu-events/metric_test.log
feature/
libapi/
libbpf/
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index b7d9c42062300d04..bac9272682b759e9 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -1103,6 +1103,7 @@ clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-clean $(
$(OUTPUT)util/intel-pt-decoder/inat-tables.c \
$(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
$(OUTPUT)pmu-events/pmu-events.c \
+ $(OUTPUT)pmu-events/metric_test.log \
$(OUTPUT)$(fadvise_advice_array) \
$(OUTPUT)$(fsconfig_arrays) \
$(OUTPUT)$(fsmount_arrays) \