summaryrefslogtreecommitdiff
path: root/bin
diff options
authorSylvain Pineau <sylvain.pineau@canonical.com>2018-08-23 21:10:38 +0200
committerSylvain Pineau <sylvain.pineau@canonical.com>2018-08-23 21:10:38 +0200
commit38bb7702ff70c0341eb827e6394814d7060c283a (patch)
tree6e811a9c063f4ba48021bd8b994aed2669f8b391 /bin
parent20da71ec18b8f9d6699b5f54ad2addebaab9ed12 (diff)
pm_test: Only check fwts logs if suspends_before_reboot option is used
reboot or poweroff + suspends_before_reboot = fwts log check reboot or poweroff only = no fwts log check Otherwise __result special file contains a failed outcome because pm_test was unable to open the nonexistent fwts log file. Fixes lp:1783742
Diffstat (limited to 'bin')
-rwxr-xr-xbin/pm_test46
1 files changed, 24 insertions, 22 deletions
diff --git a/bin/pm_test b/bin/pm_test
index 70cd1213..86bf2d96 100755
--- a/bin/pm_test
+++ b/bin/pm_test
@@ -223,28 +223,30 @@ class PowerManagementOperation():
message = ('{0} test complete'
.format(self.args.pm_operation.capitalize()))
- total_suspends_expected = (
- self.args.suspends_before_reboot * self.args.total)
- problems = ''
- fwts_log_path = os.path.join(self.args.log_dir, 'fwts.log')
- try:
- with open(fwts_log_path, 'rt') as f:
- magic_line = 'Completed S3 cycle(s) \n'
- count = f.readlines().count(magic_line)
- if count != total_suspends_expected:
- problems = (
- "Found {} occurrences of '{}'. Expected {}".format(
- count, magic_line.strip(),
- total_suspends_expected))
- except FileNotFoundError:
- problems = "Error opening {}".format(fwts_log_path)
- if problems:
- result = {
- 'outcome': 'fail' if problems else 'pass',
- 'comment': problems,
- }
- with open(os.path.join(self.args.log_dir, '__result'), 'wt') as f:
- json.dump(result, f)
+ if self.args.suspends_before_reboot:
+ total_suspends_expected = (
+ self.args.suspends_before_reboot * self.args.total)
+ problems = ''
+ fwts_log_path = os.path.join(self.args.log_dir, 'fwts.log')
+ try:
+ with open(fwts_log_path, 'rt') as f:
+ magic_line = 'Completed S3 cycle(s) \n'
+ count = f.readlines().count(magic_line)
+ if count != total_suspends_expected:
+ problems = (
+ "Found {} occurrences of '{}'. Expected {}".format(
+ count, magic_line.strip(),
+ total_suspends_expected))
+ except FileNotFoundError:
+ problems = "Error opening {}".format(fwts_log_path)
+ if problems:
+ result = {
+ 'outcome': 'fail' if problems else 'pass',
+ 'comment': problems,
+ }
+ result_filename = os.path.join(self.args.log_dir, '__result')
+ with open(result_filename, 'wt') as f:
+ json.dump(result, f)
if self.args.silent:
logging.info(message)