Merge ~bladernr/checkbox-support:1815132-fwts_test_validation into checkbox-support:master

Proposed by Jeff Lane 
Status: Merged
Approved by: Jeff Lane 
Approved revision: b3dd1e46168c87265e2b9dd63f5a33d1363d1fb9
Merged at revision: 8d6c0dd9bcfb9233eb87c0e2468df901dd691692
Proposed branch: ~bladernr/checkbox-support:1815132-fwts_test_validation
Merge into: checkbox-support:master
Diff against target: 273 lines (+105/-67)
1 file modified
checkbox_support/scripts/fwts_test.py (+105/-67)
Reviewer Review Type Date Requested Status
Rod Smith Approve
Review via email: mp+362886@code.launchpad.net

Description of the change

Added test validation to avoid attempting to run tests in our pre-defined lists that are not applicable on various architectures. Also made some minor tweaks to output for readability as well as some pep8 fixes.

To post a comment you must log in.
Revision history for this message
Rod Smith (rodsmith) wrote :

LGTM. I ran a quick test on coconut. There were some failures and warnings, but that's par for the course with fwts; it didn't look like the script went off the rails or anything.

https://certification.canonical.com/hardware/200902-1663/submission/138529/test/152/result/10377740/

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

Oh good. Thanks. I ran it on a Power system and on an x86 box here locally, so it's good to see some additional output that verifies what I saw. Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/checkbox_support/scripts/fwts_test.py b/checkbox_support/scripts/fwts_test.py
2index e86a8b9..a33eb79 100644
3--- a/checkbox_support/scripts/fwts_test.py
4+++ b/checkbox_support/scripts/fwts_test.py
5@@ -74,14 +74,17 @@ ACPI_TESTS = ['acpiinfo', 'xenv', 'xsdt', 'wsmt', 'wpbt', 'wmi', 'wdat',
6 'pptt', 'pmtt', 'pdtt', 'pcct', 'pcc', 'nfit', 'method', 'msdm',
7 'msct', 'mpst', 'mchi', 'mcfg', 'madt', 'lpit', 'iort', 'hmat',
8 'hpet', 'hest', 'gtdt', 'fpdt', 'fadt', 'facs', 'erst', 'einj',
9- 'ecdt', 'drtm', 'dppt', 'dmar', 'acpi_wpc', 'acpi_time', 'acpi_als',
10- 'acpi_lid', 'acpi_slpb', 'acpi_pwrb', 'acpi_ec', 'smart_battery',
11- 'acpi_battery', 'acpi_ac', 'dbg2', 'dbgp', 'cstates', 'csrt',
12- 'cpep', 'checksum', 'boot', 'bgrt', 'bert', 'aspt', 'asf',
13- 'apicinstance', 'acpitables']
14+ 'ecdt', 'drtm', 'dppt', 'dmar', 'acpi_wpc', 'acpi_time',
15+ 'acpi_als', 'acpi_lid', 'acpi_slpb', 'acpi_pwrb', 'acpi_ec',
16+ 'smart_battery', 'acpi_battery', 'acpi_ac', 'dbg2', 'dbgp',
17+ 'cstates', 'csrt', 'cpep', 'checksum', 'boot', 'bgrt', 'bert',
18+ 'aspt', 'asf', 'apicinstance', 'acpitables']
19 # There are some overlaps there, this creates one master list removing
20-# duplicates
21+# duplicates and then we add some that seem to only apply to Power hardware
22 SERVER_TESTS = list(dict.fromkeys(ACPI_TESTS + SBBR_TESTS + UEFI_TESTS))
23+SERVER_TESTS.extend(['cpu_info', 'dt_base', 'dt_sysinfo', 'maxreadreq',
24+ 'mem_info', 'mtd_info', 'power_mgmt', 'prd_info',
25+ 'reserv_mem version'])
26 # By default, we launch all the tests
27 TESTS = sorted(list(set(QA_TESTS + HWE_TESTS)))
28 SLEEP_TIME_RE = re.compile('(Suspend|Resume):\s+([\d\.]+)\s+seconds.')
29@@ -150,6 +153,7 @@ def detect_progress_indicator():
30 # Return empty list if no progress indicator is to be used
31 return []
32
33+
34 def main():
35 description_text = 'Tests the system BIOS using the Firmware Test Suite'
36 epilog_text = ('To perform sleep testing, you will need at least some of '
37@@ -234,10 +238,12 @@ def main():
38 help='List all QA concerned tests in fwts')
39 group.add_argument('--list-server',
40 action='store_true',
41- help='List all Server Certification concerned tests in fwts')
42+ help=('List all Server Certification concerned tests '
43+ 'in fwts'))
44 args = parser.parse_args()
45
46 tests = []
47+ requested_tests = []
48 results = {}
49 critical_fails = []
50 high_fails = []
51@@ -246,6 +252,7 @@ def main():
52 passed = []
53 aborted = []
54 skipped = []
55+ unavailable = []
56 warnings = []
57
58 # Set correct fail level
59@@ -277,13 +284,13 @@ def main():
60 print('Server Certification Tests:')
61 print(' * ', '\n * '.join(SERVER_TESTS))
62 elif args.test:
63- tests.extend(args.test)
64+ requested_tests.extend(args.test)
65 elif args.hwe:
66- tests.extend(HWE_TESTS)
67+ requested_tests.extend(HWE_TESTS)
68 elif args.qa:
69- tests.extend(QA_TESTS)
70+ requested_tests.extend(QA_TESTS)
71 elif args.server:
72- tests.extend(SERVER_TESTS)
73+ requested_tests.extend(SERVER_TESTS)
74 elif args.sleep:
75 args.sleep = fix_sleep_args(args.sleep)
76 iterations = 1
77@@ -298,12 +305,13 @@ def main():
78 if s4 in args.sleep:
79 iterations = int(args.sleep.pop(args.sleep.index(s4) + 1))
80 args.sleep.remove(s4)
81- tests.extend(args.sleep)
82+ requested_tests.extend(args.sleep)
83 else:
84- tests.extend(TESTS)
85+ requested_tests.extend(TESTS)
86
87- # run the tests we want
88+ # run the tests we want
89 if args.sleep:
90+ tests = requested_tests
91 iteration_results = {}
92 print('=' * 20 + ' Test Results ' + '=' * 20)
93 progress_indicator = None
94@@ -359,69 +367,91 @@ def main():
95 if 's4' not in args.sleep:
96 average_times(iteration_results)
97 else:
98- for test in tests:
99- # ACPI tests can now be run with --acpitests (fwts >= 15.07.00)
100- log = args.log
101- # Split the log file for HWE (only if -t is not used)
102- if test == 'acpitests':
103- test = '--acpitests'
104- command = ('fwts -q --stdout-summary -r %s %s'
105- % (log, test))
106- results[test] = (Popen(command, stdout=PIPE, shell=True)
107- .communicate()[0].strip()).decode()
108+ # Because the list of available tests varies from arch to arch, we
109+ # need to validate our test selections and remove any unsupported
110+ # tests.
111+ cmd = ('fwts --show-tests')
112+ fwts_test_list = (Popen(cmd, stdout=PIPE, shell=True)
113+ .communicate()[0].strip().decode().split('\n'))
114+ AVAILABLE_TESTS = list(dict.fromkeys(
115+ [item.lstrip().split()[0] for item in
116+ fwts_test_list if not item.endswith(':')
117+ and item != '']))
118+ # Compare requested tests to AVAILABLE_TESTS, and if we've requested a
119+ # test that isn't available, go ahead and mark it as skipped, otherwise
120+ # add it to tests for execution
121+ for test in requested_tests:
122+ if test not in AVAILABLE_TESTS:
123+ unavailable.append(test)
124+ else:
125+ tests.append(test)
126
127+ if tests:
128+ for test in tests:
129+ # ACPI tests can now be run with --acpitests (fwts >= 15.07.00)
130+ log = args.log
131+ # Split the log file for HWE (only if -t is not used)
132+ if test == 'acpitests':
133+ test = '--acpitests'
134+ command = ('fwts -q --stdout-summary -r %s %s'
135+ % (log, test))
136+ results[test] = (Popen(command, stdout=PIPE, shell=True)
137+ .communicate()[0].strip()).decode()
138 # parse the summaries
139- for test in results.keys():
140- if 'FAILED_CRITICAL' in results[test]:
141- critical_fails.append(test)
142- elif 'FAILED_HIGH' in results[test]:
143- high_fails.append(test)
144- elif 'FAILED_MEDIUM' in results[test]:
145- medium_fails.append(test)
146- elif 'FAILED_LOW' in results[test]:
147- low_fails.append(test)
148- elif 'PASSED' in results[test]:
149- passed.append(test)
150- elif 'ABORTED' in results[test]:
151- aborted.append(test)
152- elif 'WARNING' in results[test]:
153- warnings.append(test)
154- elif 'SKIPPED' in results[test]:
155- skipped.append(test)
156- else:
157- return 1
158+ if results:
159+ for test in results.keys():
160+ if 'FAILED_CRITICAL' in results[test]:
161+ critical_fails.append(test)
162+ elif 'FAILED_HIGH' in results[test]:
163+ high_fails.append(test)
164+ elif 'FAILED_MEDIUM' in results[test]:
165+ medium_fails.append(test)
166+ elif 'FAILED_LOW' in results[test]:
167+ low_fails.append(test)
168+ elif 'PASSED' in results[test]:
169+ passed.append(test)
170+ elif 'ABORTED' in results[test]:
171+ aborted.append(test)
172+ elif 'WARNING' in results[test]:
173+ warnings.append(test)
174+ elif 'SKIPPED' in results[test]:
175+ skipped.append(test)
176+ else:
177+ return 1
178 if critical_fails:
179 print("Critical Failures: %d" % len(critical_fails))
180 if not args.quiet:
181- print("WARNING: The following test cases were reported as critical\n"
182- "level failures by fwts. Please review the log at\n"
183- "%s for more information." % args.log)
184+ print(" WARNING: The following test cases were reported as"
185+ " critical\n"
186+ " level failures by fwts. Please review the log at\n"
187+ " %s for more information." % args.log)
188 for test in critical_fails:
189- print(" - " + test)
190+ print(" - " + test)
191 if high_fails:
192 print("High Failures: %d" % len(high_fails))
193 if not args.quiet:
194- print("WARNING: The following test cases were reported as high\n"
195- "level failures by fwts. Please review the log at\n"
196- "%s for more information." % args.log)
197+ print(" WARNING: The following test cases were reported as high\n"
198+ " level failures by fwts. Please review the log at\n"
199+ " %s for more information." % args.log)
200 for test in high_fails:
201- print(" - " + test)
202+ print(" - " + test)
203 if medium_fails:
204 print("Medium Failures: %d" % len(medium_fails))
205 if not args.quiet:
206- print("WARNING: The following test cases were reported as medium\n"
207- "level failures by fwts. Please review the log at\n"
208- "%s for more information." % args.log)
209+ print(" WARNING: The following test cases were reported as"
210+ " medium\n"
211+ " level failures by fwts. Please review the log at\n"
212+ " %s for more information." % args.log)
213 for test in medium_fails:
214- print(" - " + test)
215+ print(" - " + test)
216 if low_fails:
217 print("Low Failures: %d" % len(low_fails))
218 if not args.quiet:
219- print("WARNING: The following test cases were reported as low\n"
220- "level failures by fwts. Please review the log at\n"
221- "%s for more information." % args.log)
222+ print(" WARNING: The following test cases were reported as low\n"
223+ " level failures by fwts. Please review the log at\n"
224+ " %s for more information." % args.log)
225 for test in low_fails:
226- print(" - " + test)
227+ print(" - " + test)
228 if passed:
229 print("Passed: %d" % len(passed))
230 if not args.quiet:
231@@ -430,26 +460,34 @@ def main():
232 if skipped:
233 print("Skipped Tests: %d" % len(skipped))
234 if not args.quiet:
235- print("WARNING: The following test cases were skipped by fwts\n"
236- "Please review the log at %s for more information."
237+ print(" WARNING: The following test cases were skipped by fwts\n"
238+ " Please review the log at %s for more information."
239 % args.log)
240 for test in skipped:
241- print(" - " + test)
242+ print(" - " + test)
243+ if unavailable:
244+ print("Unavailable Tests: %d" % len(unavailable))
245+ if not args.quiet:
246+ print(" WARNING: The following test cases are not available\n"
247+ " on this architecture. Running fwts --show-tests on\n"
248+ " this system will list available tests.")
249+ for test in unavailable:
250+ print(" - " + test)
251 if warnings:
252 print("WARNINGS: %d" % len(warnings))
253 if not args.quiet:
254- print("Please review the log at %s for more information."
255+ print(" Please review the log at %s for more information."
256 % args.log)
257 for test in warnings:
258- print(" - " + test)
259+ print(" - " + test)
260 if aborted:
261 print("Aborted Tests: %d" % len(aborted))
262 if not args.quiet:
263- print("WARNING: The following test cases were aborted by fwts\n"
264- "Please review the log at %s for more information."
265+ print(" WARNING: The following test cases were aborted by fwts\n"
266+ " Please review the log at %s for more information."
267 % args.log)
268 for test in aborted:
269- print(" - " + test)
270+ print(" - " + test)
271
272 if args.fail_level is not 'none':
273 if fail_priority == fail_levels['FAILED_CRITICAL']:

Subscribers

People subscribed via source and target branches