Merge ~alanec/plainbox-provider-checkbox:cpufreq_test-excp-fix into plainbox-provider-checkbox:master

Proposed by Adrian Lane
Status: Merged
Approved by: Adrian Lane
Approved revision: 56579f1e583dd09d4cd8da9c6b8ec5e13dc61aa8
Merged at revision: 8fdcabedc6fd3ca073b385d80f8085ed3cc6c849
Proposed branch: ~alanec/plainbox-provider-checkbox:cpufreq_test-excp-fix
Merge into: plainbox-provider-checkbox:master
Diff against target: 54 lines (+9/-5)
1 file modified
bin/cpufreq_test.py (+9/-5)
Reviewer Review Type Date Requested Status
Jeff Lane  Approve
Jonathan Cave (community) Abstain
Review via email: mp+395815@code.launchpad.net

Description of the change

Minor fixup of exception handling class in bin/cpufreq_test.py. This fix will allow this class to now behave as fully intended, exiting cleanly without traceback if cpufreq scaling is non-supported.
Additionally warnings (logging.warning) are now visible in all modes, included quiet, as quiet is the default operating mode in Checkbox.

Sample output to demo if scaling via cpufreq is unsupported:

z3r0@maas ~ ❯❯❯ python3 test.py
## Warning: scaling via CpuFreq non-supported ##
z3r0@maas ~ ❯❯❯ python3 test.py -q
## Warning: scaling via CpuFreq non-supported ##
z3r0@maas ~ ❯❯❯ python3 test.py -d
## Warning: scaling via CpuFreq non-supported ##
z3r0@maas ~ ❯❯❯ python3 test.py -r
## Warning: scaling via CpuFreq non-supported ##

To post a comment you must log in.
Revision history for this message
Adrian Lane (alanec) wrote :

Above demo performed on a VM.

Revision history for this message
Jonathan Cave (jocave) wrote :

I would personally prefer the test to be skipped if scaling is not supported rather than the test run and result in a pass.

review: Abstain
Revision history for this message
Jeff Lane  (bladernr) wrote :

Lets file a new bug to address Jonathan's concern. I don't disagree, but that would be out of scope for fixing this particular bug.

SO, Approve for this with the following conditions:

1: File a new bug to add a new resource job to create something like cpufreq.supported
2: Add an arg to the cpufreq script so that we can simply check that it is supported and if so, set cpufreq.supported to True.
3: modify the test job in P-P-C to require that resource == True.

review: Approve
Revision history for this message
Jonathan Cave (jocave) wrote :

Happy with that course of action, thanks

Revision history for this message
Adrian Lane (alanec) wrote :

This sounds good to me as well. I'll start working on adding this functionality next week.
Thanks-

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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):
40 """Exception handling."""40 """Exception handling."""
41 def __init__(self, message):41 def __init__(self, message):
42 super().__init__()42 super().__init__()
43 # warn and exit if cpufreq scaling non-supported
43 if 'scaling_driver' in message:44 if 'scaling_driver' in message:
44 logging.error(45 logging.warning(
45 '%s\n## Fatal: scaling via cpufeq unsupported ##')46 '## Warning: scaling via CpuFreq non-supported ##')
47 sys.exit()
46 # exempt systems unable to change intel_pstate driver mode48 # exempt systems unable to change intel_pstate driver mode
47 elif 'intel_pstate/status' in message:49 elif 'intel_pstate/status' in message:
48 pass50 pass
@@ -675,6 +677,8 @@ class CpuFreqCoreTest(CpuFreqTest):
675 for idx, freq in enumerate(self.scaling_freqs):677 for idx, freq in enumerate(self.scaling_freqs):
676 # re-init some attributes after 1st pass678 # re-init some attributes after 1st pass
677 if idx:679 if idx:
680 # time buffer ensure all prior freq intervals processed
681 time.sleep(1)
678 # reset freq list682 # reset freq list
679 self.__observed_freqs = []683 self.__observed_freqs = []
680 # reset signal.signal() event loop bit684 # reset signal.signal() event loop bit
@@ -685,7 +689,7 @@ class CpuFreqCoreTest(CpuFreqTest):
685 load_observe_map(freq)689 load_observe_map(freq)
686690
687691
688def parse_args_logging():692def parse_arg_logging():
689 """ Ingest arguments and init logging."""693 """ Ingest arguments and init logging."""
690 def init_logging(_user_arg):694 def init_logging(_user_arg):
691 """ Pass user arg and configure logging module."""695 """ Pass user arg and configure logging module."""
@@ -732,7 +736,7 @@ def parse_args_logging():
732 '-q', '-Q', '--quiet',736 '-q', '-Q', '--quiet',
733 dest='log_level',737 dest='log_level',
734 action='store_const',738 action='store_const',
735 # repurpose built-in logging level739 # allow visible warnings in quiet mode
736 const=logging.WARNING,740 const=logging.WARNING,
737 help='suppress output')741 help='suppress output')
738 parser_mutex_grp.add_argument(742 parser_mutex_grp.add_argument(
@@ -747,7 +751,7 @@ def parse_args_logging():
747751
748def main():752def main():
749 # configure and start logging753 # configure and start logging
750 user_arg = parse_args_logging()754 user_arg = parse_arg_logging()
751 # instantiate CpuFreqTest as cpu_freq_test755 # instantiate CpuFreqTest as cpu_freq_test
752 cpu_freq_test = CpuFreqTest()756 cpu_freq_test = CpuFreqTest()
753 # provide access to reset() method757 # provide access to reset() method

Subscribers

People subscribed via source and target branches