blob: 9d441c7d3f3f502095f5b726f22ebc7de13784fa [file] [log] [blame]
Gilles Peskine15c2cbf2020-06-25 18:36:28 +02001#!/usr/bin/env python3
2
3"""Analyze the test outcomes from a full CI run.
4
5This script can also run on outcomes from a partial run, but the results are
6less likely to be useful.
7"""
8
9import argparse
10import sys
11import traceback
Przemek Stekiel85c54ea2022-11-17 11:50:23 +010012import re
Valerio Settia2663322023-03-24 08:20:18 +010013import subprocess
14import os
Pengyu Lv18908ec2023-11-28 12:11:52 +080015import typing
Gilles Peskine15c2cbf2020-06-25 18:36:28 +020016
Gilles Peskine8d3c70a2020-06-25 18:37:43 +020017import check_test_cases
18
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +080019
Pengyu Lv550cd6f2023-11-29 09:17:59 +080020# `ComponentOutcomes` is a named tuple which is defined as:
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +080021# ComponentOutcomes(
22# successes = {
23# "<suite_case>",
24# ...
25# },
26# failures = {
27# "<suite_case>",
28# ...
29# }
30# )
31# suite_case = "<suite>;<case>"
Pengyu Lv18908ec2023-11-28 12:11:52 +080032ComponentOutcomes = typing.NamedTuple('ComponentOutcomes',
33 [('successes', typing.Set[str]),
34 ('failures', typing.Set[str])])
35
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +080036# `Outcomes` is a representation of the outcomes file,
37# which defined as:
38# Outcomes = {
39# "<component>": ComponentOutcomes,
40# ...
41# }
42Outcomes = typing.Dict[str, ComponentOutcomes]
43
44
Gilles Peskine15c2cbf2020-06-25 18:36:28 +020045class Results:
46 """Process analysis results."""
47
48 def __init__(self):
49 self.error_count = 0
50 self.warning_count = 0
51
Valerio Setti2cff8202023-10-18 14:36:47 +020052 def new_section(self, fmt, *args, **kwargs):
53 self._print_line('\n*** ' + fmt + ' ***\n', *args, **kwargs)
54
Valerio Settiaaef0bc2023-10-10 09:42:13 +020055 def info(self, fmt, *args, **kwargs):
Valerio Setti8070dbe2023-10-17 12:29:30 +020056 self._print_line('Info: ' + fmt, *args, **kwargs)
Gilles Peskine15c2cbf2020-06-25 18:36:28 +020057
58 def error(self, fmt, *args, **kwargs):
Gilles Peskine15c2cbf2020-06-25 18:36:28 +020059 self.error_count += 1
Valerio Setti8070dbe2023-10-17 12:29:30 +020060 self._print_line('Error: ' + fmt, *args, **kwargs)
Gilles Peskine15c2cbf2020-06-25 18:36:28 +020061
62 def warning(self, fmt, *args, **kwargs):
Gilles Peskine15c2cbf2020-06-25 18:36:28 +020063 self.warning_count += 1
Valerio Setti8070dbe2023-10-17 12:29:30 +020064 self._print_line('Warning: ' + fmt, *args, **kwargs)
Gilles Peskine15c2cbf2020-06-25 18:36:28 +020065
Valerio Setti3f339892023-10-17 10:42:11 +020066 @staticmethod
Valerio Setti8070dbe2023-10-17 12:29:30 +020067 def _print_line(fmt, *args, **kwargs):
Valerio Setti735794c2023-10-18 08:05:15 +020068 sys.stderr.write((fmt + '\n').format(*args, **kwargs))
Gilles Peskine15c2cbf2020-06-25 18:36:28 +020069
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +080070def execute_reference_driver_tests(results: Results, ref_component: str, driver_component: str, \
71 outcome_file: str) -> None:
Valerio Setti22992a02023-03-29 11:15:28 +020072 """Run the tests specified in ref_component and driver_component. Results
73 are stored in the output_file and they will be used for the following
Valerio Settia2663322023-03-24 08:20:18 +010074 coverage analysis"""
Pengyu Lv20e3ca32023-11-28 15:30:03 +080075 results.new_section("Test {} and {}", ref_component, driver_component)
Valerio Settia2663322023-03-24 08:20:18 +010076
77 shell_command = "tests/scripts/all.sh --outcome-file " + outcome_file + \
78 " " + ref_component + " " + driver_component
Valerio Setti39d4b9d2023-10-18 14:30:03 +020079 results.info("Running: {}", shell_command)
Valerio Settia2663322023-03-24 08:20:18 +010080 ret_val = subprocess.run(shell_command.split(), check=False).returncode
81
82 if ret_val != 0:
Valerio Settif075e472023-10-17 11:03:16 +020083 results.error("failed to run reference/driver components")
Valerio Settia2663322023-03-24 08:20:18 +010084
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +080085def analyze_coverage(results: Results, outcomes: Outcomes,
86 allow_list: typing.List[str], full_coverage: bool) -> None:
Gilles Peskine8d3c70a2020-06-25 18:37:43 +020087 """Check that all available test cases are executed at least once."""
Gilles Peskine686c2922022-01-07 15:58:38 +010088 available = check_test_cases.collect_available_test_cases()
Pengyu Lv31a9b782023-11-23 14:15:37 +080089 for suite_case in available:
Pengyu Lv5dcfd0c2023-11-29 18:03:28 +080090 hit = any(suite_case in comp_outcomes.successes or
91 suite_case in comp_outcomes.failures
92 for comp_outcomes in outcomes.values())
Pengyu Lva4428582023-11-22 19:02:15 +080093
Pengyu Lv5dcfd0c2023-11-29 18:03:28 +080094 if not hit and suite_case not in allow_list:
Tomás Gonzálezb401e112023-08-11 15:22:04 +010095 if full_coverage:
Pengyu Lv31a9b782023-11-23 14:15:37 +080096 results.error('Test case not executed: {}', suite_case)
Tomás Gonzálezb401e112023-08-11 15:22:04 +010097 else:
Pengyu Lv31a9b782023-11-23 14:15:37 +080098 results.warning('Test case not executed: {}', suite_case)
Pengyu Lv5dcfd0c2023-11-29 18:03:28 +080099 elif hit and suite_case in allow_list:
Tomás González07bdcc22023-08-11 14:59:03 +0100100 # Test Case should be removed from the allow list.
Tomás González7ebb18f2023-08-22 09:40:23 +0100101 if full_coverage:
Pengyu Lv31a9b782023-11-23 14:15:37 +0800102 results.error('Allow listed test case was executed: {}', suite_case)
Tomás González7ebb18f2023-08-22 09:40:23 +0100103 else:
Pengyu Lv31a9b782023-11-23 14:15:37 +0800104 results.warning('Allow listed test case was executed: {}', suite_case)
Gilles Peskine8d3c70a2020-06-25 18:37:43 +0200105
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +0800106def name_matches_pattern(name: str, str_or_re) -> bool:
Manuel Pégourié-Gonnard881ce012023-10-18 10:22:07 +0200107 """Check if name matches a pattern, that may be a string or regex.
108 - If the pattern is a string, name must be equal to match.
109 - If the pattern is a regex, name must fully match.
110 """
Manuel Pégourié-Gonnardb2695432023-10-23 09:30:40 +0200111 # The CI's python is too old for re.Pattern
112 #if isinstance(str_or_re, re.Pattern):
113 if not isinstance(str_or_re, str):
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +0800114 return str_or_re.fullmatch(name) is not None
Manuel Pégourié-Gonnard881ce012023-10-18 10:22:07 +0200115 else:
Manuel Pégourié-Gonnard9d9c2342023-10-26 09:37:40 +0200116 return str_or_re == name
Manuel Pégourié-Gonnard881ce012023-10-18 10:22:07 +0200117
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +0800118def analyze_driver_vs_reference(results: Results, outcomes: Outcomes,
119 component_ref: str, component_driver: str,
120 ignored_suites: typing.List[str], ignored_tests=None) -> None:
Pengyu Lvdd1d6a72023-11-27 17:57:31 +0800121 """Check that all tests passing in the reference component are also
122 passing in the corresponding driver component.
Valerio Setti3002c992023-01-18 17:28:36 +0100123 Skip:
124 - full test suites provided in ignored_suites list
125 - only some specific test inside a test suite, for which the corresponding
126 output string is provided
Przemek Stekiel4e955902022-10-21 13:42:08 +0200127 """
Pengyu Lva4428582023-11-22 19:02:15 +0800128 ref_outcomes = outcomes.get("component_" + component_ref)
129 driver_outcomes = outcomes.get("component_" + component_driver)
130
Pengyu Lv59b9efc2023-11-28 11:15:00 +0800131 if ref_outcomes is None or driver_outcomes is None:
132 results.error("required components are missing: bad outcome file?")
133 return
134
Pengyu Lv18908ec2023-11-28 12:11:52 +0800135 if not ref_outcomes.successes:
Pengyu Lva4428582023-11-22 19:02:15 +0800136 results.error("no passing test in reference component: bad outcome file?")
137 return
138
Pengyu Lv18908ec2023-11-28 12:11:52 +0800139 for suite_case in ref_outcomes.successes:
Pengyu Lv31a9b782023-11-23 14:15:37 +0800140 # suite_case is like "test_suite_foo.bar;Description of test case"
141 (full_test_suite, test_string) = suite_case.split(';')
Valerio Setti00c1ccb2023-02-02 11:33:31 +0100142 test_suite = full_test_suite.split('.')[0] # retrieve main part of test suite name
Manuel Pégourié-Gonnard371165a2023-10-18 12:44:54 +0200143
144 # Immediately skip fully-ignored test suites
Manuel Pégourié-Gonnard7d381f52023-03-17 15:13:08 +0100145 if test_suite in ignored_suites or full_test_suite in ignored_suites:
Valerio Setti00c1ccb2023-02-02 11:33:31 +0100146 continue
Manuel Pégourié-Gonnard371165a2023-10-18 12:44:54 +0200147
148 # For ignored test cases inside test suites, just remember and:
149 # don't issue an error if they're skipped with drivers,
150 # but issue an error if they're not (means we have a bad entry).
151 ignored = False
Manuel Pégourié-Gonnard881ce012023-10-18 10:22:07 +0200152 if full_test_suite in ignored_tests:
Valerio Setti9afa3292023-12-20 09:55:28 +0100153 for str_or_re in ignored_tests[full_test_suite]:
Manuel Pégourié-Gonnard881ce012023-10-18 10:22:07 +0200154 if name_matches_pattern(test_string, str_or_re):
Manuel Pégourié-Gonnard371165a2023-10-18 12:44:54 +0200155 ignored = True
Manuel Pégourié-Gonnard4da369f2023-10-18 09:40:32 +0200156
Pengyu Lv18908ec2023-11-28 12:11:52 +0800157 if not ignored and not suite_case in driver_outcomes.successes:
Pengyu Lv31a9b782023-11-23 14:15:37 +0800158 results.error("PASS -> SKIP/FAIL: {}", suite_case)
Pengyu Lv18908ec2023-11-28 12:11:52 +0800159 if ignored and suite_case in driver_outcomes.successes:
Pengyu Lv31a9b782023-11-23 14:15:37 +0800160 results.error("uselessly ignored: {}", suite_case)
Manuel Pégourié-Gonnard371165a2023-10-18 12:44:54 +0200161
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +0800162def analyze_outcomes(results: Results, outcomes: Outcomes, args) -> None:
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200163 """Run all analyses on the given outcome collection."""
Tomás Gonzálezb401e112023-08-11 15:22:04 +0100164 analyze_coverage(results, outcomes, args['allow_list'],
165 args['full_coverage'])
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200166
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +0800167def read_outcome_file(outcome_file: str) -> Outcomes:
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200168 """Parse an outcome file and return an outcome collection.
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +0800169 """
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200170 outcomes = {}
171 with open(outcome_file, 'r', encoding='utf-8') as input_file:
172 for line in input_file:
Pengyu Lvdd1d6a72023-11-27 17:57:31 +0800173 (_platform, component, suite, case, result, _cause) = line.split(';')
Pengyu Lv451ec8a2023-11-28 17:59:05 +0800174 # Note that `component` is not unique. If a test case passes on Linux
175 # and fails on FreeBSD, it'll end up in both the successes set and
176 # the failures set.
Pengyu Lv31a9b782023-11-23 14:15:37 +0800177 suite_case = ';'.join([suite, case])
Pengyu Lvdd1d6a72023-11-27 17:57:31 +0800178 if component not in outcomes:
Pengyu Lv18908ec2023-11-28 12:11:52 +0800179 outcomes[component] = ComponentOutcomes(set(), set())
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200180 if result == 'PASS':
Pengyu Lv18908ec2023-11-28 12:11:52 +0800181 outcomes[component].successes.add(suite_case)
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200182 elif result == 'FAIL':
Pengyu Lv18908ec2023-11-28 12:11:52 +0800183 outcomes[component].failures.add(suite_case)
Pengyu Lva4428582023-11-22 19:02:15 +0800184
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200185 return outcomes
186
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +0800187def do_analyze_coverage(results: Results, outcomes: Outcomes, args) -> None:
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100188 """Perform coverage analysis."""
Valerio Setti2cff8202023-10-18 14:36:47 +0200189 results.new_section("Analyze coverage")
Valerio Setti781c2342023-10-17 12:47:35 +0200190 analyze_outcomes(results, outcomes, args)
Przemek Stekiel4e955902022-10-21 13:42:08 +0200191
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +0800192def do_analyze_driver_vs_reference(results: Results, outcomes: Outcomes, args) -> None:
Przemek Stekiel4e955902022-10-21 13:42:08 +0200193 """Perform driver vs reference analyze."""
Valerio Setti2cff8202023-10-18 14:36:47 +0200194 results.new_section("Analyze driver {} vs reference {}",
195 args['component_driver'], args['component_ref'])
Valerio Settib0c618e2023-10-16 14:19:49 +0200196
Valerio Setti3002c992023-01-18 17:28:36 +0100197 ignored_suites = ['test_suite_' + x for x in args['ignored_suites']]
Przemek Stekiel51f30ff2022-11-09 12:07:29 +0100198
Valerio Setti781c2342023-10-17 12:47:35 +0200199 analyze_driver_vs_reference(results, outcomes,
200 args['component_ref'], args['component_driver'],
201 ignored_suites, args['ignored_tests'])
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200202
Przemek Stekiel6856f4c2022-11-09 10:50:29 +0100203# List of tasks with a function that can handle this task and additional arguments if required
Valerio Settidfd7ca62023-10-09 16:30:11 +0200204KNOWN_TASKS = {
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200205 'analyze_coverage': {
206 'test_function': do_analyze_coverage,
Tomás González07bdcc22023-08-11 14:59:03 +0100207 'args': {
Tomás González358c6c62023-08-14 15:43:46 +0100208 'allow_list': [
Tomás González50223112023-08-22 09:52:06 +0100209 # Algorithm not supported yet
210 'test_suite_psa_crypto_metadata;Asymmetric signature: pure EdDSA',
211 # Algorithm not supported yet
212 'test_suite_psa_crypto_metadata;Cipher: XTS',
Tomás Gonzálezd43cab32023-08-24 09:12:40 +0100213 ],
Tomás Gonzálezb401e112023-08-11 15:22:04 +0100214 'full_coverage': False,
Tomás González07bdcc22023-08-11 14:59:03 +0100215 }
Tomás Gonzálezd43cab32023-08-24 09:12:40 +0100216 },
Valerio Settia2663322023-03-24 08:20:18 +0100217 # There are 2 options to use analyze_driver_vs_reference_xxx locally:
218 # 1. Run tests and then analysis:
219 # - tests/scripts/all.sh --outcome-file "$PWD/out.csv" <component_ref> <component_driver>
220 # - tests/scripts/analyze_outcomes.py out.csv analyze_driver_vs_reference_xxx
221 # 2. Let this script run both automatically:
222 # - tests/scripts/analyze_outcomes.py out.csv analyze_driver_vs_reference_xxx
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200223 'analyze_driver_vs_reference_hash': {
224 'test_function': do_analyze_driver_vs_reference,
225 'args': {
Przemek Stekiel51f30ff2022-11-09 12:07:29 +0100226 'component_ref': 'test_psa_crypto_config_reference_hash_use_psa',
227 'component_driver': 'test_psa_crypto_config_accel_hash_use_psa',
Manuel Pégourié-Gonnard10e39632022-12-29 12:29:09 +0100228 'ignored_suites': [
229 'shax', 'mdx', # the software implementations that are being excluded
Manuel Pégourié-Gonnard7d381f52023-03-17 15:13:08 +0100230 'md.psa', # purposefully depends on whether drivers are present
Gilles Peskine35b49c42023-10-04 12:28:41 +0200231 'psa_crypto_low_hash.generated', # testing the builtins
Valerio Setti3002c992023-01-18 17:28:36 +0100232 ],
233 'ignored_tests': {
Gilles Peskine150002c2023-11-27 18:24:45 +0100234 'test_suite_platform': [
235 # Incompatible with sanitizers (e.g. ASan). If the driver
236 # component uses a sanitizer but the reference component
237 # doesn't, we have a PASS vs SKIP mismatch.
238 'Check mbedtls_calloc overallocation',
239 ],
Valerio Setti3002c992023-01-18 17:28:36 +0100240 }
241 }
242 },
Valerio Setti20cea942024-01-22 16:23:25 +0100243 'analyze_driver_vs_reference_hmac': {
244 'test_function': do_analyze_driver_vs_reference,
245 'args': {
246 'component_ref': 'test_psa_crypto_config_reference_hmac',
247 'component_driver': 'test_psa_crypto_config_accel_hmac',
248 'ignored_suites': [
249 # This suite tests builtins directly, but these are missing
250 # in the accelerated case.
251 'psa_crypto_low_hash.generated',
252 ],
253 'ignored_tests': {
254 'test_suite_md': [
255 # Builtin HMAC is not supported in the accelerate component.
256 re.compile('.*HMAC.*'),
257 # Following tests make use of functions which are not available
258 # when MD_C is disabled, as it happens in the accelerated
259 # test component.
260 re.compile('generic .* Hash file .*'),
261 'MD list',
262 ],
263 'test_suite_md.psa': [
264 # "legacy only" tests require hash algorithms to be NOT
265 # accelerated, but this of course false for the accelerated
266 # test component.
267 re.compile('PSA dispatch .* legacy only'),
268 ],
269 'test_suite_platform': [
270 # Incompatible with sanitizers (e.g. ASan). If the driver
271 # component uses a sanitizer but the reference component
272 # doesn't, we have a PASS vs SKIP mismatch.
273 'Check mbedtls_calloc overallocation',
274 ],
275 }
276 }
277 },
Manuel Pégourié-Gonnard7f48d5e2024-01-08 10:55:09 +0100278 'analyze_driver_vs_reference_cipher_aead_cmac': {
Valerio Settib6b301f2023-10-04 12:05:05 +0200279 'test_function': do_analyze_driver_vs_reference,
280 'args': {
Manuel Pégourié-Gonnard7f48d5e2024-01-08 10:55:09 +0100281 'component_ref': 'test_psa_crypto_config_reference_cipher_aead_cmac',
282 'component_driver': 'test_psa_crypto_config_accel_cipher_aead_cmac',
Valerio Setti507e08f2023-10-26 09:44:06 +0200283 # Modules replaced by drivers.
Valerio Settib6b301f2023-10-04 12:05:05 +0200284 'ignored_suites': [
Valerio Setti507e08f2023-10-26 09:44:06 +0200285 # low-level (block/stream) cipher modules
286 'aes', 'aria', 'camellia', 'des', 'chacha20',
Manuel Pégourié-Gonnard7f48d5e2024-01-08 10:55:09 +0100287 # AEAD modes and CMAC
Valerio Setti507e08f2023-10-26 09:44:06 +0200288 'ccm', 'chachapoly', 'cmac', 'gcm',
289 # The Cipher abstraction layer
290 'cipher',
Valerio Settib6b301f2023-10-04 12:05:05 +0200291 ],
292 'ignored_tests': {
Valerio Setti507e08f2023-10-26 09:44:06 +0200293 # PEM decryption is not supported so far.
294 # The rest of PEM (write, unencrypted read) works though.
Valerio Setti7448cee2023-10-04 15:46:42 +0200295 'test_suite_pem': [
Manuel Pégourié-Gonnardcd84a292023-10-27 09:24:44 +0200296 re.compile(r'PEM read .*(AES|DES|\bencrypt).*'),
Valerio Setti7448cee2023-10-04 15:46:42 +0200297 ],
Gilles Peskine150002c2023-11-27 18:24:45 +0100298 'test_suite_platform': [
299 # Incompatible with sanitizers (e.g. ASan). If the driver
300 # component uses a sanitizer but the reference component
301 # doesn't, we have a PASS vs SKIP mismatch.
302 'Check mbedtls_calloc overallocation',
303 ],
Valerio Setti507e08f2023-10-26 09:44:06 +0200304 # Following tests depend on AES_C/DES_C but are not about
305 # them really, just need to know some error code is there.
Valerio Setti7448cee2023-10-04 15:46:42 +0200306 'test_suite_error': [
307 'Low and high error',
308 'Single low error'
309 ],
Valerio Setti507e08f2023-10-26 09:44:06 +0200310 # Similar to test_suite_error above.
Valerio Setti7448cee2023-10-04 15:46:42 +0200311 'test_suite_version': [
312 'Check for MBEDTLS_AES_C when already present',
Valerio Setti93941442023-10-13 09:19:52 +0200313 ],
Valerio Setti507e08f2023-10-26 09:44:06 +0200314 # The en/decryption part of PKCS#12 is not supported so far.
315 # The rest of PKCS#12 (key derivation) works though.
Valerio Setti93941442023-10-13 09:19:52 +0200316 'test_suite_pkcs12': [
Manuel Pégourié-Gonnardcd84a292023-10-27 09:24:44 +0200317 re.compile(r'PBE Encrypt, .*'),
318 re.compile(r'PBE Decrypt, .*'),
Valerio Setti93941442023-10-13 09:19:52 +0200319 ],
Valerio Setti507e08f2023-10-26 09:44:06 +0200320 # The en/decryption part of PKCS#5 is not supported so far.
321 # The rest of PKCS#5 (PBKDF2) works though.
Valerio Setti93941442023-10-13 09:19:52 +0200322 'test_suite_pkcs5': [
Manuel Pégourié-Gonnardcd84a292023-10-27 09:24:44 +0200323 re.compile(r'PBES2 Encrypt, .*'),
324 re.compile(r'PBES2 Decrypt .*'),
Valerio Setti93941442023-10-13 09:19:52 +0200325 ],
Valerio Setti507e08f2023-10-26 09:44:06 +0200326 # Encrypted keys are not supported so far.
Valerio Setti5cd18f92023-10-13 15:14:07 +0200327 # pylint: disable=line-too-long
Valerio Setti93941442023-10-13 09:19:52 +0200328 'test_suite_pkparse': [
329 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)',
330 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)',
Pengyu Lva1ddcfa2023-11-28 09:46:01 +0800331 re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'),
Valerio Setti93941442023-10-13 09:19:52 +0200332 ],
Valerio Settib6b301f2023-10-04 12:05:05 +0200333 }
334 }
335 },
Valerio Setti4d25a8d2023-06-14 10:33:10 +0200336 'analyze_driver_vs_reference_ecp_light_only': {
Valerio Setti42d5f192023-03-20 13:54:41 +0100337 'test_function': do_analyze_driver_vs_reference,
338 'args': {
Valerio Setti4d25a8d2023-06-14 10:33:10 +0200339 'component_ref': 'test_psa_crypto_config_reference_ecc_ecp_light_only',
340 'component_driver': 'test_psa_crypto_config_accel_ecc_ecp_light_only',
Valerio Setti42d5f192023-03-20 13:54:41 +0100341 'ignored_suites': [
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200342 # Modules replaced by drivers
343 'ecdsa', 'ecdh', 'ecjpake',
Valerio Setti42d5f192023-03-20 13:54:41 +0100344 ],
345 'ignored_tests': {
Gilles Peskine150002c2023-11-27 18:24:45 +0100346 'test_suite_platform': [
347 # Incompatible with sanitizers (e.g. ASan). If the driver
348 # component uses a sanitizer but the reference component
349 # doesn't, we have a PASS vs SKIP mismatch.
350 'Check mbedtls_calloc overallocation',
351 ],
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200352 # This test wants a legacy function that takes f_rng, p_rng
353 # arguments, and uses legacy ECDSA for that. The test is
354 # really about the wrapper around the PSA RNG, not ECDSA.
Valerio Setti42d5f192023-03-20 13:54:41 +0100355 'test_suite_random': [
356 'PSA classic wrapper: ECDSA signature (SECP256R1)',
357 ],
Valerio Setti0c477d32023-04-07 15:54:20 +0200358 # In the accelerated test ECP_C is not set (only ECP_LIGHT is)
359 # so we must ignore disparities in the tests for which ECP_C
360 # is required.
361 'test_suite_ecp': [
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200362 re.compile(r'ECP check public-private .*'),
Gilles Peskine3b17ae72023-06-23 11:08:39 +0200363 re.compile(r'ECP calculate public: .*'),
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200364 re.compile(r'ECP gen keypair .*'),
365 re.compile(r'ECP point muladd .*'),
366 re.compile(r'ECP point multiplication .*'),
367 re.compile(r'ECP test vectors .*'),
Valerio Setti482a0b92023-08-18 15:55:10 +0200368 ],
Manuel Pégourié-Gonnardf07ce3b2023-09-22 11:53:41 +0200369 'test_suite_ssl': [
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200370 # This deprecated function is only present when ECP_C is On.
Manuel Pégourié-Gonnardf07ce3b2023-09-22 11:53:41 +0200371 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
372 ],
Valerio Setti5f540202023-06-30 17:20:49 +0200373 }
Valerio Setti42d5f192023-03-20 13:54:41 +0100374 }
375 },
Valerio Setti4d25a8d2023-06-14 10:33:10 +0200376 'analyze_driver_vs_reference_no_ecp_at_all': {
Valerio Settie618cb02023-04-12 14:59:16 +0200377 'test_function': do_analyze_driver_vs_reference,
378 'args': {
Valerio Setti4d25a8d2023-06-14 10:33:10 +0200379 'component_ref': 'test_psa_crypto_config_reference_ecc_no_ecp_at_all',
380 'component_driver': 'test_psa_crypto_config_accel_ecc_no_ecp_at_all',
Valerio Settie618cb02023-04-12 14:59:16 +0200381 'ignored_suites': [
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200382 # Modules replaced by drivers
383 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
Valerio Settie618cb02023-04-12 14:59:16 +0200384 ],
385 'ignored_tests': {
Gilles Peskine150002c2023-11-27 18:24:45 +0100386 'test_suite_platform': [
387 # Incompatible with sanitizers (e.g. ASan). If the driver
388 # component uses a sanitizer but the reference component
389 # doesn't, we have a PASS vs SKIP mismatch.
390 'Check mbedtls_calloc overallocation',
391 ],
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200392 # See ecp_light_only
Valerio Settie618cb02023-04-12 14:59:16 +0200393 'test_suite_random': [
394 'PSA classic wrapper: ECDSA signature (SECP256R1)',
395 ],
Valerio Settiaddeee42023-06-14 10:46:55 +0200396 'test_suite_pkparse': [
Valerio Setti5bd25232023-06-19 19:32:14 +0200397 # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED
398 # is automatically enabled in build_info.h (backward compatibility)
399 # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a
400 # consequence compressed points are supported in the reference
401 # component but not in the accelerated one, so they should be skipped
402 # while checking driver's coverage.
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200403 re.compile(r'Parse EC Key .*compressed\)'),
404 re.compile(r'Parse Public EC Key .*compressed\)'),
Valerio Settiaddeee42023-06-14 10:46:55 +0200405 ],
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200406 # See ecp_light_only
Manuel Pégourié-Gonnardf07ce3b2023-09-22 11:53:41 +0200407 'test_suite_ssl': [
408 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
409 ],
Valerio Settie618cb02023-04-12 14:59:16 +0200410 }
411 }
412 },
Valerio Setti307810b2023-08-15 10:12:25 +0200413 'analyze_driver_vs_reference_ecc_no_bignum': {
Manuel Pégourié-Gonnardabd00d02023-06-12 17:51:33 +0200414 'test_function': do_analyze_driver_vs_reference,
415 'args': {
416 'component_ref': 'test_psa_crypto_config_reference_ecc_no_bignum',
417 'component_driver': 'test_psa_crypto_config_accel_ecc_no_bignum',
418 'ignored_suites': [
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200419 # Modules replaced by drivers
420 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
421 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
422 'bignum.generated', 'bignum.misc',
Manuel Pégourié-Gonnardabd00d02023-06-12 17:51:33 +0200423 ],
424 'ignored_tests': {
Gilles Peskine150002c2023-11-27 18:24:45 +0100425 'test_suite_platform': [
426 # Incompatible with sanitizers (e.g. ASan). If the driver
427 # component uses a sanitizer but the reference component
428 # doesn't, we have a PASS vs SKIP mismatch.
429 'Check mbedtls_calloc overallocation',
430 ],
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200431 # See ecp_light_only
Manuel Pégourié-Gonnardabd00d02023-06-12 17:51:33 +0200432 'test_suite_random': [
433 'PSA classic wrapper: ECDSA signature (SECP256R1)',
434 ],
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200435 # See no_ecp_at_all
Manuel Pégourié-Gonnardabd00d02023-06-12 17:51:33 +0200436 'test_suite_pkparse': [
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200437 re.compile(r'Parse EC Key .*compressed\)'),
438 re.compile(r'Parse Public EC Key .*compressed\)'),
Manuel Pégourié-Gonnardabd00d02023-06-12 17:51:33 +0200439 ],
Valerio Setti9b3dbcc2023-07-26 18:00:31 +0200440 'test_suite_asn1parse': [
Valerio Setti9b3dbcc2023-07-26 18:00:31 +0200441 'INTEGER too large for mpi',
442 ],
443 'test_suite_asn1write': [
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200444 re.compile(r'ASN.1 Write mpi.*'),
Valerio Setti9b3dbcc2023-07-26 18:00:31 +0200445 ],
Valerio Settie0be95e2023-08-01 09:07:43 +0200446 'test_suite_debug': [
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200447 re.compile(r'Debug print mbedtls_mpi.*'),
Valerio Settie0be95e2023-08-01 09:07:43 +0200448 ],
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200449 # See ecp_light_only
Manuel Pégourié-Gonnardf07ce3b2023-09-22 11:53:41 +0200450 'test_suite_ssl': [
451 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
452 ],
Manuel Pégourié-Gonnardabd00d02023-06-12 17:51:33 +0200453 }
454 }
455 },
Valerio Setti307810b2023-08-15 10:12:25 +0200456 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': {
457 'test_function': do_analyze_driver_vs_reference,
458 'args': {
459 'component_ref': 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum',
460 'component_driver': 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum',
461 'ignored_suites': [
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200462 # Modules replaced by drivers
463 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm',
464 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
465 'bignum.generated', 'bignum.misc',
Valerio Setti307810b2023-08-15 10:12:25 +0200466 ],
467 'ignored_tests': {
Gilles Peskine150002c2023-11-27 18:24:45 +0100468 'test_suite_platform': [
469 # Incompatible with sanitizers (e.g. ASan). If the driver
470 # component uses a sanitizer but the reference component
471 # doesn't, we have a PASS vs SKIP mismatch.
472 'Check mbedtls_calloc overallocation',
473 ],
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200474 # See ecp_light_only
Valerio Setti307810b2023-08-15 10:12:25 +0200475 'test_suite_random': [
476 'PSA classic wrapper: ECDSA signature (SECP256R1)',
477 ],
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200478 # See no_ecp_at_all
Valerio Setti307810b2023-08-15 10:12:25 +0200479 'test_suite_pkparse': [
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200480 re.compile(r'Parse EC Key .*compressed\)'),
481 re.compile(r'Parse Public EC Key .*compressed\)'),
Valerio Setti307810b2023-08-15 10:12:25 +0200482 ],
483 'test_suite_asn1parse': [
Valerio Setti307810b2023-08-15 10:12:25 +0200484 'INTEGER too large for mpi',
485 ],
486 'test_suite_asn1write': [
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200487 re.compile(r'ASN.1 Write mpi.*'),
Valerio Setti307810b2023-08-15 10:12:25 +0200488 ],
489 'test_suite_debug': [
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200490 re.compile(r'Debug print mbedtls_mpi.*'),
Valerio Setti307810b2023-08-15 10:12:25 +0200491 ],
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200492 # See ecp_light_only
Manuel Pégourié-Gonnardf07ce3b2023-09-22 11:53:41 +0200493 'test_suite_ssl': [
494 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()',
495 ],
Valerio Setti307810b2023-08-15 10:12:25 +0200496 }
497 }
498 },
Przemek Stekiel85b64422023-05-26 09:55:23 +0200499 'analyze_driver_vs_reference_ffdh_alg': {
500 'test_function': do_analyze_driver_vs_reference,
501 'args': {
502 'component_ref': 'test_psa_crypto_config_reference_ffdh',
503 'component_driver': 'test_psa_crypto_config_accel_ffdh',
Przemek Stekiel84f4ff12023-07-04 12:35:31 +0200504 'ignored_suites': ['dhm'],
Gilles Peskine150002c2023-11-27 18:24:45 +0100505 'ignored_tests': {
506 'test_suite_platform': [
507 # Incompatible with sanitizers (e.g. ASan). If the driver
508 # component uses a sanitizer but the reference component
509 # doesn't, we have a PASS vs SKIP mismatch.
510 'Check mbedtls_calloc overallocation',
511 ],
512 }
Przemek Stekiel85b64422023-05-26 09:55:23 +0200513 }
514 },
Valerio Settif01d6482023-08-04 13:51:18 +0200515 'analyze_driver_vs_reference_tfm_config': {
516 'test_function': do_analyze_driver_vs_reference,
517 'args': {
518 'component_ref': 'test_tfm_config',
519 'component_driver': 'test_tfm_config_p256m_driver_accel_ec',
Manuel Pégourié-Gonnarde9d97972023-08-08 18:34:47 +0200520 'ignored_suites': [
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200521 # Modules replaced by drivers
Yanray Wang57790962023-10-31 13:39:07 +0800522 'asn1parse', 'asn1write',
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200523 'ecp', 'ecdsa', 'ecdh', 'ecjpake',
524 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw',
525 'bignum.generated', 'bignum.misc',
Manuel Pégourié-Gonnarde9d97972023-08-08 18:34:47 +0200526 ],
Valerio Settif01d6482023-08-04 13:51:18 +0200527 'ignored_tests': {
Gilles Peskine150002c2023-11-27 18:24:45 +0100528 'test_suite_platform': [
529 # Incompatible with sanitizers (e.g. ASan). If the driver
530 # component uses a sanitizer but the reference component
531 # doesn't, we have a PASS vs SKIP mismatch.
532 'Check mbedtls_calloc overallocation',
533 ],
Manuel Pégourié-Gonnard4fd5a6a2023-10-20 10:21:09 +0200534 # See ecp_light_only
Manuel Pégourié-Gonnarde9d97972023-08-08 18:34:47 +0200535 'test_suite_random': [
536 'PSA classic wrapper: ECDSA signature (SECP256R1)',
537 ],
Valerio Settif01d6482023-08-04 13:51:18 +0200538 }
539 }
Pengyu Lv3cd16c42023-12-06 18:17:39 +0800540 },
541 'analyze_driver_vs_reference_rsa': {
542 'test_function': do_analyze_driver_vs_reference,
543 'args': {
544 'component_ref': 'test_psa_crypto_config_reference_rsa_crypto',
545 'component_driver': 'test_psa_crypto_config_accel_rsa_crypto',
546 'ignored_suites': [
547 # Modules replaced by drivers.
548 'rsa', 'pkcs1_v15', 'pkcs1_v21',
Pengyu Lv98a90c62023-12-07 17:23:25 +0800549 # We temporarily don't care about PK stuff.
Pengyu Lv3cd16c42023-12-06 18:17:39 +0800550 'pk', 'pkwrite', 'pkparse'
551 ],
552 'ignored_tests': {
553 'test_suite_platform': [
554 # Incompatible with sanitizers (e.g. ASan). If the driver
555 # component uses a sanitizer but the reference component
556 # doesn't, we have a PASS vs SKIP mismatch.
557 'Check mbedtls_calloc overallocation',
558 ],
559 # Following tests depend on RSA_C but are not about
560 # them really, just need to know some error code is there.
561 'test_suite_error': [
562 'Low and high error',
563 'Single high error'
564 ],
565 # Constant time operations only used for PKCS1_V15
566 'test_suite_constant_time': [
567 re.compile(r'mbedtls_ct_zeroize_if .*'),
568 re.compile(r'mbedtls_ct_memmove_left .*')
569 ],
570 }
571 }
Valerio Setti52ab8fa2023-12-14 18:04:04 +0100572 },
573 'analyze_block_cipher_dispatch': {
574 'test_function': do_analyze_driver_vs_reference,
575 'args': {
Valerio Setti4a8ef7c2023-12-19 11:16:27 +0100576 'component_ref': 'test_full_block_cipher_legacy_dispatch',
Valerio Setti52ab8fa2023-12-14 18:04:04 +0100577 'component_driver': 'test_full_block_cipher_psa_dispatch',
578 'ignored_suites': [
Valerio Setti4a8ef7c2023-12-19 11:16:27 +0100579 # Skipped in the accelerated component
580 'aes', 'aria', 'camellia',
Valerio Setti0635cca2023-12-28 16:16:02 +0100581 # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in
582 # order for the cipher module (actually cipher_wrapper) to work
583 # properly. However these symbols are disabled in the accelerated
584 # component so we ignore them.
Valerio Settia0c9c662023-12-29 14:14:11 +0100585 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria',
Valerio Setti0635cca2023-12-28 16:16:02 +0100586 'cipher.camellia',
Valerio Setti52ab8fa2023-12-14 18:04:04 +0100587 ],
588 'ignored_tests': {
Valerio Settia0c9c662023-12-29 14:14:11 +0100589 'test_suite_cmac': [
590 # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled,
591 # but these are not available in the accelerated component.
592 'CMAC null arguments',
593 re.compile('CMAC.* (AES|ARIA|Camellia).*'),
594 ],
Valerio Setti0635cca2023-12-28 16:16:02 +0100595 'test_suite_cipher.padding': [
596 # Following tests require AES_C/CAMELLIA_C to be enabled,
597 # but these are not available in the accelerated component.
598 re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'),
Valerio Setti5f665c32023-12-20 09:56:05 +0100599 ],
Valerio Setti0635cca2023-12-28 16:16:02 +0100600 'test_suite_pkparse': [
601 # PEM (called by pkparse) requires AES_C in order to decrypt
602 # the key, but this is not available in the accelerated
603 # component.
604 re.compile('Parse RSA Key.*(password|AES-).*'),
Valerio Setti5f665c32023-12-20 09:56:05 +0100605 ],
Valerio Setti0635cca2023-12-28 16:16:02 +0100606 'test_suite_pem': [
607 # Following tests require AES_C, but this is diabled in the
608 # accelerated component.
609 'PEM read (AES-128-CBC + invalid iv)',
610 'PEM read (malformed PEM AES-128-CBC)',
611 'PEM read (unknown encryption algorithm)',
Valerio Setti5f665c32023-12-20 09:56:05 +0100612 ],
613 'test_suite_error': [
Valerio Settiab0494f2023-12-28 13:56:13 +0100614 # Following tests depend on AES_C but are not about them
615 # really, just need to know some error code is there.
Valerio Setti5f665c32023-12-20 09:56:05 +0100616 'Single low error',
617 'Low and high error',
618 ],
619 'test_suite_version': [
Valerio Settiab0494f2023-12-28 13:56:13 +0100620 # Similar to test_suite_error above.
Valerio Setti5f665c32023-12-20 09:56:05 +0100621 'Check for MBEDTLS_AES_C when already present',
622 ],
Valerio Setti52ab8fa2023-12-14 18:04:04 +0100623 'test_suite_platform': [
624 # Incompatible with sanitizers (e.g. ASan). If the driver
625 # component uses a sanitizer but the reference component
626 # doesn't, we have a PASS vs SKIP mismatch.
627 'Check mbedtls_calloc overallocation',
628 ],
629 }
630 }
Valerio Settif01d6482023-08-04 13:51:18 +0200631 }
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200632}
Przemek Stekiel4d13c832022-10-26 16:11:26 +0200633
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200634def main():
Valerio Settif075e472023-10-17 11:03:16 +0200635 main_results = Results()
Valerio Settiaaef0bc2023-10-10 09:42:13 +0200636
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200637 try:
638 parser = argparse.ArgumentParser(description=__doc__)
Przemek Stekiel58bbc232022-10-24 08:10:10 +0200639 parser.add_argument('outcomes', metavar='OUTCOMES.CSV',
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200640 help='Outcome file to analyze')
Valerio Settidfd7ca62023-10-09 16:30:11 +0200641 parser.add_argument('specified_tasks', default='all', nargs='?',
Przemek Stekiel992de3c2022-11-09 13:54:49 +0100642 help='Analysis to be done. By default, run all tasks. '
643 'With one or more TASK, run only those. '
644 'TASK can be the name of a single task or '
Przemek Stekiel85c54ea2022-11-17 11:50:23 +0100645 'comma/space-separated list of tasks. ')
Przemek Stekiel992de3c2022-11-09 13:54:49 +0100646 parser.add_argument('--list', action='store_true',
647 help='List all available tasks and exit.')
Tomás Gonzálezb401e112023-08-11 15:22:04 +0100648 parser.add_argument('--require-full-coverage', action='store_true',
649 dest='full_coverage', help="Require all available "
650 "test cases to be executed and issue an error "
651 "otherwise. This flag is ignored if 'task' is "
652 "neither 'all' nor 'analyze_coverage'")
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200653 options = parser.parse_args()
Przemek Stekiel4e955902022-10-21 13:42:08 +0200654
Przemek Stekiel992de3c2022-11-09 13:54:49 +0100655 if options.list:
Valerio Settidfd7ca62023-10-09 16:30:11 +0200656 for task in KNOWN_TASKS:
Valerio Setti5329ff02023-10-17 09:44:36 +0200657 print(task)
Przemek Stekiel992de3c2022-11-09 13:54:49 +0100658 sys.exit(0)
659
Valerio Settidfd7ca62023-10-09 16:30:11 +0200660 if options.specified_tasks == 'all':
661 tasks_list = KNOWN_TASKS.keys()
Przemek Stekiel992de3c2022-11-09 13:54:49 +0100662 else:
Valerio Settidfd7ca62023-10-09 16:30:11 +0200663 tasks_list = re.split(r'[, ]+', options.specified_tasks)
Valerio Settidfd7ca62023-10-09 16:30:11 +0200664 for task in tasks_list:
665 if task not in KNOWN_TASKS:
Manuel Pégourié-Gonnard62d61312023-10-20 10:51:57 +0200666 sys.stderr.write('invalid task: {}\n'.format(task))
Valerio Settifb2750e2023-10-17 10:11:45 +0200667 sys.exit(2)
Przemek Stekiel992de3c2022-11-09 13:54:49 +0100668
Valerio Settidfd7ca62023-10-09 16:30:11 +0200669 KNOWN_TASKS['analyze_coverage']['args']['full_coverage'] = options.full_coverage
Przemek Stekiel992de3c2022-11-09 13:54:49 +0100670
Pengyu Lvdd1d6a72023-11-27 17:57:31 +0800671 # If the outcome file exists, parse it once and share the result
672 # among tasks to improve performance.
Pengyu Lv20e3ca32023-11-28 15:30:03 +0800673 # Otherwise, it will be generated by execute_reference_driver_tests.
674 if not os.path.exists(options.outcomes):
675 if len(tasks_list) > 1:
676 sys.stderr.write("mutiple tasks found, please provide a valid outcomes file.\n")
677 sys.exit(2)
678
679 task_name = tasks_list[0]
680 task = KNOWN_TASKS[task_name]
Pengyu Lvc2e8f3a2023-11-28 17:22:04 +0800681 if task['test_function'] != do_analyze_driver_vs_reference: # pylint: disable=comparison-with-callable
Pengyu Lv20e3ca32023-11-28 15:30:03 +0800682 sys.stderr.write("please provide valid outcomes file for {}.\n".format(task_name))
683 sys.exit(2)
684
685 execute_reference_driver_tests(main_results,
686 task['args']['component_ref'],
687 task['args']['component_driver'],
688 options.outcomes)
689
690 outcomes = read_outcome_file(options.outcomes)
Pengyu Lva6cf5d62023-11-22 11:35:21 +0800691
Valerio Settifb2750e2023-10-17 10:11:45 +0200692 for task in tasks_list:
693 test_function = KNOWN_TASKS[task]['test_function']
694 test_args = KNOWN_TASKS[task]['args']
Pengyu Lv20e3ca32023-11-28 15:30:03 +0800695 test_function(main_results, outcomes, test_args)
Tomás Gonzálezb401e112023-08-11 15:22:04 +0100696
Valerio Settif6f64cf2023-10-17 12:28:26 +0200697 main_results.info("Overall results: {} warnings and {} errors",
698 main_results.warning_count, main_results.error_count)
Przemek Stekiel4e955902022-10-21 13:42:08 +0200699
Valerio Setti8d178be2023-10-17 12:23:55 +0200700 sys.exit(0 if (main_results.error_count == 0) else 1)
Valerio Settiaaef0bc2023-10-10 09:42:13 +0200701
Gilles Peskine15c2cbf2020-06-25 18:36:28 +0200702 except Exception: # pylint: disable=broad-except
703 # Print the backtrace and exit explicitly with our chosen status.
704 traceback.print_exc()
705 sys.exit(120)
706
707if __name__ == '__main__':
708 main()