From 789e150b0aa8d15a28170ec37019e1073c632621 Mon Sep 17 00:00:00 2001 From: Javi Merino Date: Tue, 27 Apr 2021 16:36:15 +0100 Subject: [PATCH] perf: report a config error if stat is combined with report options When running perf/simpleperf stat, the report_option_string, report_sample_options and run_report_sample configuration parameters don't make sense. Instead of quietly ignoring them, raise a ConfigError so that the user can fix the agenda. --- wa/instruments/perf.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wa/instruments/perf.py b/wa/instruments/perf.py index fd49e190..351b131c 100644 --- a/wa/instruments/perf.py +++ b/wa/instruments/perf.py @@ -21,7 +21,7 @@ import re from devlib.collector.perf import PerfCollector -from wa import Instrument, Parameter +from wa import Instrument, Parameter, ConfigError from wa.utils.types import list_or_string, list_of_strs, numeric PERF_COUNT_REGEX = re.compile(r'^(CPU\d+)?\s*(\d+)\s*(.*?)\s*(\[\s*\d+\.\d+%\s*\])?\s*$') @@ -116,6 +116,14 @@ class PerfInstrument(Instrument): self.collector = None self.outdir = None + def validate(self): + if self.report_option_string and (self.command != "record"): + raise ConfigError("report_option_string only works with perf/simpleperf record. Set command to record or remove report_option_string") + if self.report_sample_options and (self.command != "record"): + raise ConfigError("report_sample_options only works with perf/simpleperf record. Set command to record or remove report_sample_options") + if self.run_report_sample and (self.command != "record"): + raise ConfigError("run_report_sample only works with perf/simpleperf record. Set command to record or remove run_report_sample") + def initialize(self, context): if self.report_sample_options: self.run_report_sample = True