Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf test: make metric validation test return early when there is no metric supported on the test system

Add a check to return the metric validation test early when perf list metric
does not output any metric. This would happen when NO_JEVENTS=1 is set or in a
system that there is no metric supported.

Signed-off-by: Weilin Wang <weilin.wang@intel.com>
Tested-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Samantha Alt <samantha.alt@intel.com>
Link: https://lore.kernel.org/lkml/20240522204254.1841420-1-weilin.wang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Weilin Wang and committed by
Arnaldo Carvalho de Melo
4ed0f392 74ae366c

+8 -2
+8 -2
tools/perf/tests/shell/lib/perf_metric_validation.py
··· 95 95 indent=4) 96 96 97 97 def get_results(self, idx: int = 0): 98 - return self.results[idx] 98 + return self.results.get(idx) 99 99 100 100 def get_bounds(self, lb, ub, error, alias={}, ridx: int = 0) -> list: 101 101 """ ··· 173 173 pcnt = 0 174 174 tcnt = 0 175 175 rerun = list() 176 - for name, val in self.get_results().items(): 176 + results = self.get_results() 177 + if not results: 178 + return 179 + for name, val in results.items(): 177 180 if val < 0: 178 181 negmetric[name] = val 179 182 rerun.append(name) ··· 535 532 ''' 536 533 if not self.collectlist: 537 534 self.parse_perf_metrics() 535 + if not self.metrics: 536 + print("No metric found for testing") 537 + return 0 538 538 self.create_rules() 539 539 for i in range(0, len(self.workloads)): 540 540 self.wlidx = i