diff options
author | Adrian Lane <adrian.lane@canonical.com> | 2021-01-05 15:01:54 -0800 |
---|---|---|
committer | Adrian Lane <adrian.lane@canonical.com> | 2021-01-05 15:01:54 -0800 |
commit | 56579f1e583dd09d4cd8da9c6b8ec5e13dc61aa8 (patch) | |
tree | 033dbf77ceca76462e16014a3a4a81f1f2e3e03e /bin | |
parent | 7748fd527657de4b90aedb738191e9500ec0be48 (diff) |
Fix exception handling class in bin/cpufreq_test.py, ensuring unsupported systems warn and exit cleanly. lp: 1910278
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/cpufreq_test.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/bin/cpufreq_test.py b/bin/cpufreq_test.py index 81ee276..ec3cf6c 100755 --- a/bin/cpufreq_test.py +++ b/bin/cpufreq_test.py @@ -40,9 +40,11 @@ class CpuFreqTestError(Exception): """Exception handling.""" def __init__(self, message): super().__init__() + # warn and exit if cpufreq scaling non-supported if 'scaling_driver' in message: - logging.error( - '%s\n## Fatal: scaling via cpufeq unsupported ##') + logging.warning( + '## Warning: scaling via CpuFreq non-supported ##') + sys.exit() # exempt systems unable to change intel_pstate driver mode elif 'intel_pstate/status' in message: pass @@ -675,6 +677,8 @@ class CpuFreqCoreTest(CpuFreqTest): for idx, freq in enumerate(self.scaling_freqs): # re-init some attributes after 1st pass if idx: + # time buffer ensure all prior freq intervals processed + time.sleep(1) # reset freq list self.__observed_freqs = [] # reset signal.signal() event loop bit @@ -685,7 +689,7 @@ class CpuFreqCoreTest(CpuFreqTest): load_observe_map(freq) -def parse_args_logging(): +def parse_arg_logging(): """ Ingest arguments and init logging.""" def init_logging(_user_arg): """ Pass user arg and configure logging module.""" @@ -732,7 +736,7 @@ def parse_args_logging(): '-q', '-Q', '--quiet', dest='log_level', action='store_const', - # repurpose built-in logging level + # allow visible warnings in quiet mode const=logging.WARNING, help='suppress output') parser_mutex_grp.add_argument( @@ -747,7 +751,7 @@ def parse_args_logging(): def main(): # configure and start logging - user_arg = parse_args_logging() + user_arg = parse_arg_logging() # instantiate CpuFreqTest as cpu_freq_test cpu_freq_test = CpuFreqTest() # provide access to reset() method |