Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | """Analyze the test outcomes from a full CI run. |
| 4 | |
| 5 | This script can also run on outcomes from a partial run, but the results are |
| 6 | less likely to be useful. |
| 7 | """ |
| 8 | |
| 9 | import argparse |
| 10 | import sys |
| 11 | import traceback |
Przemek Stekiel | 85c54ea | 2022-11-17 11:50:23 +0100 | [diff] [blame] | 12 | import re |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 13 | import subprocess |
| 14 | import os |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 15 | import typing |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 16 | |
Gilles Peskine | 8d3c70a | 2020-06-25 18:37:43 +0200 | [diff] [blame] | 17 | import check_test_cases |
| 18 | |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 19 | |
Pengyu Lv | 550cd6f | 2023-11-29 09:17:59 +0800 | [diff] [blame] | 20 | # `ComponentOutcomes` is a named tuple which is defined as: |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 21 | # ComponentOutcomes( |
| 22 | # successes = { |
| 23 | # "<suite_case>", |
| 24 | # ... |
| 25 | # }, |
| 26 | # failures = { |
| 27 | # "<suite_case>", |
| 28 | # ... |
| 29 | # } |
| 30 | # ) |
| 31 | # suite_case = "<suite>;<case>" |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 32 | ComponentOutcomes = typing.NamedTuple('ComponentOutcomes', |
| 33 | [('successes', typing.Set[str]), |
| 34 | ('failures', typing.Set[str])]) |
| 35 | |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 36 | # `Outcomes` is a representation of the outcomes file, |
| 37 | # which defined as: |
| 38 | # Outcomes = { |
| 39 | # "<component>": ComponentOutcomes, |
| 40 | # ... |
| 41 | # } |
| 42 | Outcomes = typing.Dict[str, ComponentOutcomes] |
| 43 | |
| 44 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 45 | class Results: |
| 46 | """Process analysis results.""" |
| 47 | |
| 48 | def __init__(self): |
| 49 | self.error_count = 0 |
| 50 | self.warning_count = 0 |
| 51 | |
Valerio Setti | 2cff820 | 2023-10-18 14:36:47 +0200 | [diff] [blame] | 52 | def new_section(self, fmt, *args, **kwargs): |
| 53 | self._print_line('\n*** ' + fmt + ' ***\n', *args, **kwargs) |
| 54 | |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 55 | def info(self, fmt, *args, **kwargs): |
Valerio Setti | 8070dbe | 2023-10-17 12:29:30 +0200 | [diff] [blame] | 56 | self._print_line('Info: ' + fmt, *args, **kwargs) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 57 | |
| 58 | def error(self, fmt, *args, **kwargs): |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 59 | self.error_count += 1 |
Valerio Setti | 8070dbe | 2023-10-17 12:29:30 +0200 | [diff] [blame] | 60 | self._print_line('Error: ' + fmt, *args, **kwargs) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 61 | |
| 62 | def warning(self, fmt, *args, **kwargs): |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 63 | self.warning_count += 1 |
Valerio Setti | 8070dbe | 2023-10-17 12:29:30 +0200 | [diff] [blame] | 64 | self._print_line('Warning: ' + fmt, *args, **kwargs) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 65 | |
Valerio Setti | 3f33989 | 2023-10-17 10:42:11 +0200 | [diff] [blame] | 66 | @staticmethod |
Valerio Setti | 8070dbe | 2023-10-17 12:29:30 +0200 | [diff] [blame] | 67 | def _print_line(fmt, *args, **kwargs): |
Valerio Setti | 735794c | 2023-10-18 08:05:15 +0200 | [diff] [blame] | 68 | sys.stderr.write((fmt + '\n').format(*args, **kwargs)) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 69 | |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 70 | def execute_reference_driver_tests(results: Results, ref_component: str, driver_component: str, \ |
| 71 | outcome_file: str) -> None: |
Valerio Setti | 22992a0 | 2023-03-29 11:15:28 +0200 | [diff] [blame] | 72 | """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 Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 74 | coverage analysis""" |
Pengyu Lv | 20e3ca3 | 2023-11-28 15:30:03 +0800 | [diff] [blame] | 75 | results.new_section("Test {} and {}", ref_component, driver_component) |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 76 | |
| 77 | shell_command = "tests/scripts/all.sh --outcome-file " + outcome_file + \ |
| 78 | " " + ref_component + " " + driver_component |
Valerio Setti | 39d4b9d | 2023-10-18 14:30:03 +0200 | [diff] [blame] | 79 | results.info("Running: {}", shell_command) |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 80 | ret_val = subprocess.run(shell_command.split(), check=False).returncode |
| 81 | |
| 82 | if ret_val != 0: |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame] | 83 | results.error("failed to run reference/driver components") |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 84 | |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 85 | def analyze_coverage(results: Results, outcomes: Outcomes, |
| 86 | allow_list: typing.List[str], full_coverage: bool) -> None: |
Gilles Peskine | 8d3c70a | 2020-06-25 18:37:43 +0200 | [diff] [blame] | 87 | """Check that all available test cases are executed at least once.""" |
Gilles Peskine | 78ae4f6 | 2024-05-21 20:26:18 +0200 | [diff] [blame] | 88 | # Make sure that the generated data files are present (and up-to-date). |
| 89 | # This allows analyze_outcomes.py to run correctly on a fresh Git |
| 90 | # checkout. |
| 91 | cp = subprocess.run(['make', 'generated_files'], |
| 92 | cwd='tests', |
Gilles Peskine | 2ad2f32 | 2024-05-22 09:35:11 +0200 | [diff] [blame] | 93 | stdout=subprocess.PIPE, stderr=subprocess.STDOUT, |
| 94 | check=False) |
Gilles Peskine | 78ae4f6 | 2024-05-21 20:26:18 +0200 | [diff] [blame] | 95 | if cp.returncode != 0: |
| 96 | sys.stderr.write(cp.stdout.decode('utf-8')) |
Gilles Peskine | 2ad2f32 | 2024-05-22 09:35:11 +0200 | [diff] [blame] | 97 | results.error("Failed \"make generated_files\" in tests. " |
| 98 | "Coverage analysis may be incorrect.") |
Gilles Peskine | 686c292 | 2022-01-07 15:58:38 +0100 | [diff] [blame] | 99 | available = check_test_cases.collect_available_test_cases() |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 100 | for suite_case in available: |
Pengyu Lv | 5dcfd0c | 2023-11-29 18:03:28 +0800 | [diff] [blame] | 101 | hit = any(suite_case in comp_outcomes.successes or |
| 102 | suite_case in comp_outcomes.failures |
| 103 | for comp_outcomes in outcomes.values()) |
Pengyu Lv | a442858 | 2023-11-22 19:02:15 +0800 | [diff] [blame] | 104 | |
Pengyu Lv | 5dcfd0c | 2023-11-29 18:03:28 +0800 | [diff] [blame] | 105 | if not hit and suite_case not in allow_list: |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 106 | if full_coverage: |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 107 | results.error('Test case not executed: {}', suite_case) |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 108 | else: |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 109 | results.warning('Test case not executed: {}', suite_case) |
Pengyu Lv | 5dcfd0c | 2023-11-29 18:03:28 +0800 | [diff] [blame] | 110 | elif hit and suite_case in allow_list: |
Tomás González | 07bdcc2 | 2023-08-11 14:59:03 +0100 | [diff] [blame] | 111 | # Test Case should be removed from the allow list. |
Tomás González | 7ebb18f | 2023-08-22 09:40:23 +0100 | [diff] [blame] | 112 | if full_coverage: |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 113 | results.error('Allow listed test case was executed: {}', suite_case) |
Tomás González | 7ebb18f | 2023-08-22 09:40:23 +0100 | [diff] [blame] | 114 | else: |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 115 | results.warning('Allow listed test case was executed: {}', suite_case) |
Gilles Peskine | 8d3c70a | 2020-06-25 18:37:43 +0200 | [diff] [blame] | 116 | |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 117 | def name_matches_pattern(name: str, str_or_re) -> bool: |
Manuel Pégourié-Gonnard | 881ce01 | 2023-10-18 10:22:07 +0200 | [diff] [blame] | 118 | """Check if name matches a pattern, that may be a string or regex. |
| 119 | - If the pattern is a string, name must be equal to match. |
| 120 | - If the pattern is a regex, name must fully match. |
| 121 | """ |
Manuel Pégourié-Gonnard | b269543 | 2023-10-23 09:30:40 +0200 | [diff] [blame] | 122 | # The CI's python is too old for re.Pattern |
| 123 | #if isinstance(str_or_re, re.Pattern): |
| 124 | if not isinstance(str_or_re, str): |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 125 | return str_or_re.fullmatch(name) is not None |
Manuel Pégourié-Gonnard | 881ce01 | 2023-10-18 10:22:07 +0200 | [diff] [blame] | 126 | else: |
Manuel Pégourié-Gonnard | 9d9c234 | 2023-10-26 09:37:40 +0200 | [diff] [blame] | 127 | return str_or_re == name |
Manuel Pégourié-Gonnard | 881ce01 | 2023-10-18 10:22:07 +0200 | [diff] [blame] | 128 | |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 129 | def analyze_driver_vs_reference(results: Results, outcomes: Outcomes, |
| 130 | component_ref: str, component_driver: str, |
| 131 | ignored_suites: typing.List[str], ignored_tests=None) -> None: |
Sam Berry | e262c23 | 2024-06-21 10:03:37 +0100 | [diff] [blame] | 132 | """Check that all tests passing in the driver component are also |
| 133 | passing in the corresponding reference component. |
Valerio Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 134 | Skip: |
| 135 | - full test suites provided in ignored_suites list |
| 136 | - only some specific test inside a test suite, for which the corresponding |
| 137 | output string is provided |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 138 | """ |
Pengyu Lv | a442858 | 2023-11-22 19:02:15 +0800 | [diff] [blame] | 139 | ref_outcomes = outcomes.get("component_" + component_ref) |
| 140 | driver_outcomes = outcomes.get("component_" + component_driver) |
| 141 | |
Pengyu Lv | 59b9efc | 2023-11-28 11:15:00 +0800 | [diff] [blame] | 142 | if ref_outcomes is None or driver_outcomes is None: |
| 143 | results.error("required components are missing: bad outcome file?") |
| 144 | return |
| 145 | |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 146 | if not ref_outcomes.successes: |
Pengyu Lv | a442858 | 2023-11-22 19:02:15 +0800 | [diff] [blame] | 147 | results.error("no passing test in reference component: bad outcome file?") |
| 148 | return |
| 149 | |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 150 | for suite_case in ref_outcomes.successes: |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 151 | # suite_case is like "test_suite_foo.bar;Description of test case" |
| 152 | (full_test_suite, test_string) = suite_case.split(';') |
Valerio Setti | 00c1ccb | 2023-02-02 11:33:31 +0100 | [diff] [blame] | 153 | test_suite = full_test_suite.split('.')[0] # retrieve main part of test suite name |
Manuel Pégourié-Gonnard | 371165a | 2023-10-18 12:44:54 +0200 | [diff] [blame] | 154 | |
| 155 | # Immediately skip fully-ignored test suites |
Manuel Pégourié-Gonnard | 7d381f5 | 2023-03-17 15:13:08 +0100 | [diff] [blame] | 156 | if test_suite in ignored_suites or full_test_suite in ignored_suites: |
Valerio Setti | 00c1ccb | 2023-02-02 11:33:31 +0100 | [diff] [blame] | 157 | continue |
Manuel Pégourié-Gonnard | 371165a | 2023-10-18 12:44:54 +0200 | [diff] [blame] | 158 | |
| 159 | # For ignored test cases inside test suites, just remember and: |
| 160 | # don't issue an error if they're skipped with drivers, |
| 161 | # but issue an error if they're not (means we have a bad entry). |
| 162 | ignored = False |
Gilles Peskine | a7469d3 | 2024-05-24 09:18:25 +0200 | [diff] [blame] | 163 | for str_or_re in (ignored_tests.get(full_test_suite, []) + |
| 164 | ignored_tests.get(test_suite, [])): |
| 165 | if name_matches_pattern(test_string, str_or_re): |
| 166 | ignored = True |
Manuel Pégourié-Gonnard | 4da369f | 2023-10-18 09:40:32 +0200 | [diff] [blame] | 167 | |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 168 | if not ignored and not suite_case in driver_outcomes.successes: |
Elena Uziunaite | c21675e | 2024-09-02 15:32:07 +0100 | [diff] [blame] | 169 | results.error("SKIP/FAIL -> PASS: {}", suite_case) |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 170 | if ignored and suite_case in driver_outcomes.successes: |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 171 | results.error("uselessly ignored: {}", suite_case) |
Manuel Pégourié-Gonnard | 371165a | 2023-10-18 12:44:54 +0200 | [diff] [blame] | 172 | |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 173 | def read_outcome_file(outcome_file: str) -> Outcomes: |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 174 | """Parse an outcome file and return an outcome collection. |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 175 | """ |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 176 | outcomes = {} |
| 177 | with open(outcome_file, 'r', encoding='utf-8') as input_file: |
| 178 | for line in input_file: |
Pengyu Lv | dd1d6a7 | 2023-11-27 17:57:31 +0800 | [diff] [blame] | 179 | (_platform, component, suite, case, result, _cause) = line.split(';') |
Pengyu Lv | 451ec8a | 2023-11-28 17:59:05 +0800 | [diff] [blame] | 180 | # Note that `component` is not unique. If a test case passes on Linux |
| 181 | # and fails on FreeBSD, it'll end up in both the successes set and |
| 182 | # the failures set. |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 183 | suite_case = ';'.join([suite, case]) |
Pengyu Lv | dd1d6a7 | 2023-11-27 17:57:31 +0800 | [diff] [blame] | 184 | if component not in outcomes: |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 185 | outcomes[component] = ComponentOutcomes(set(), set()) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 186 | if result == 'PASS': |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 187 | outcomes[component].successes.add(suite_case) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 188 | elif result == 'FAIL': |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 189 | outcomes[component].failures.add(suite_case) |
Pengyu Lv | a442858 | 2023-11-22 19:02:15 +0800 | [diff] [blame] | 190 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 191 | return outcomes |
| 192 | |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 193 | def do_analyze_driver_vs_reference(results: Results, outcomes: Outcomes, args) -> None: |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 194 | """Perform driver vs reference analyze.""" |
Valerio Setti | 2cff820 | 2023-10-18 14:36:47 +0200 | [diff] [blame] | 195 | results.new_section("Analyze driver {} vs reference {}", |
| 196 | args['component_driver'], args['component_ref']) |
Valerio Setti | b0c618e | 2023-10-16 14:19:49 +0200 | [diff] [blame] | 197 | |
Valerio Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 198 | ignored_suites = ['test_suite_' + x for x in args['ignored_suites']] |
Przemek Stekiel | 51f30ff | 2022-11-09 12:07:29 +0100 | [diff] [blame] | 199 | |
Valerio Setti | 781c234 | 2023-10-17 12:47:35 +0200 | [diff] [blame] | 200 | analyze_driver_vs_reference(results, outcomes, |
| 201 | args['component_ref'], args['component_driver'], |
| 202 | ignored_suites, args['ignored_tests']) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 203 | |
Gilles Peskine | 19ef1ae | 2024-09-16 19:12:09 +0200 | [diff] [blame] | 204 | |
| 205 | class Task: |
| 206 | """Base class for outcome analysis tasks.""" |
| 207 | |
| 208 | def __init__(self, options) -> None: |
| 209 | """Pass command line options to the tasks. |
| 210 | |
| 211 | Each task decides which command line options it cares about. |
| 212 | """ |
| 213 | pass |
| 214 | |
Gilles Peskine | f646dbf | 2024-09-16 19:15:29 +0200 | [diff] [blame^] | 215 | def section_name(self) -> str: |
| 216 | """The section name to use in results.""" |
| 217 | |
Gilles Peskine | 19ef1ae | 2024-09-16 19:12:09 +0200 | [diff] [blame] | 218 | def run(self, results: Results, outcomes: Outcomes): |
| 219 | """Run the analysis on the specified outcomes. |
| 220 | |
| 221 | Signal errors via the results objects |
| 222 | """ |
| 223 | raise NotImplementedError |
| 224 | |
| 225 | |
Gilles Peskine | f646dbf | 2024-09-16 19:15:29 +0200 | [diff] [blame^] | 226 | class CoverageTask(Task): |
| 227 | """Analyze test coverage.""" |
| 228 | |
| 229 | ALLOW_LIST = [ |
| 230 | # Algorithm not supported yet |
| 231 | 'test_suite_psa_crypto_metadata;Asymmetric signature: pure EdDSA', |
| 232 | # Algorithm not supported yet |
| 233 | 'test_suite_psa_crypto_metadata;Cipher: XTS', |
| 234 | ] |
| 235 | |
| 236 | def __init__(self, options) -> None: |
| 237 | super().__init__(options) |
| 238 | self.full_coverage = options.full_coverage #type: bool |
| 239 | |
| 240 | @staticmethod |
| 241 | def section_name() -> str: |
| 242 | return "Analyze coverage" |
| 243 | |
| 244 | def run(self, results: Results, outcomes: Outcomes): |
| 245 | """Check that all test cases are executed at least once.""" |
| 246 | analyze_coverage(results, outcomes, |
| 247 | self.ALLOW_LIST, self.full_coverage) |
| 248 | |
| 249 | |
Przemek Stekiel | 6856f4c | 2022-11-09 10:50:29 +0100 | [diff] [blame] | 250 | # List of tasks with a function that can handle this task and additional arguments if required |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 251 | KNOWN_TASKS = { |
Gilles Peskine | f646dbf | 2024-09-16 19:15:29 +0200 | [diff] [blame^] | 252 | 'analyze_coverage': CoverageTask, |
| 253 | |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 254 | # There are 2 options to use analyze_driver_vs_reference_xxx locally: |
| 255 | # 1. Run tests and then analysis: |
| 256 | # - tests/scripts/all.sh --outcome-file "$PWD/out.csv" <component_ref> <component_driver> |
| 257 | # - tests/scripts/analyze_outcomes.py out.csv analyze_driver_vs_reference_xxx |
| 258 | # 2. Let this script run both automatically: |
| 259 | # - tests/scripts/analyze_outcomes.py out.csv analyze_driver_vs_reference_xxx |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 260 | 'analyze_driver_vs_reference_hash': { |
| 261 | 'test_function': do_analyze_driver_vs_reference, |
| 262 | 'args': { |
Przemek Stekiel | 51f30ff | 2022-11-09 12:07:29 +0100 | [diff] [blame] | 263 | 'component_ref': 'test_psa_crypto_config_reference_hash_use_psa', |
| 264 | 'component_driver': 'test_psa_crypto_config_accel_hash_use_psa', |
Manuel Pégourié-Gonnard | 10e3963 | 2022-12-29 12:29:09 +0100 | [diff] [blame] | 265 | 'ignored_suites': [ |
| 266 | 'shax', 'mdx', # the software implementations that are being excluded |
Manuel Pégourié-Gonnard | 7d381f5 | 2023-03-17 15:13:08 +0100 | [diff] [blame] | 267 | 'md.psa', # purposefully depends on whether drivers are present |
Gilles Peskine | 35b49c4 | 2023-10-04 12:28:41 +0200 | [diff] [blame] | 268 | 'psa_crypto_low_hash.generated', # testing the builtins |
Valerio Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 269 | ], |
| 270 | 'ignored_tests': { |
Gilles Peskine | a7469d3 | 2024-05-24 09:18:25 +0200 | [diff] [blame] | 271 | 'test_suite_config': [ |
| 272 | re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'), |
| 273 | ], |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 274 | 'test_suite_platform': [ |
| 275 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 276 | # component uses a sanitizer but the reference component |
| 277 | # doesn't, we have a PASS vs SKIP mismatch. |
| 278 | 'Check mbedtls_calloc overallocation', |
| 279 | ], |
Valerio Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 280 | } |
| 281 | } |
| 282 | }, |
Valerio Setti | 20cea94 | 2024-01-22 16:23:25 +0100 | [diff] [blame] | 283 | 'analyze_driver_vs_reference_hmac': { |
| 284 | 'test_function': do_analyze_driver_vs_reference, |
| 285 | 'args': { |
| 286 | 'component_ref': 'test_psa_crypto_config_reference_hmac', |
| 287 | 'component_driver': 'test_psa_crypto_config_accel_hmac', |
| 288 | 'ignored_suites': [ |
Valerio Setti | cd89b0b | 2024-01-24 14:24:55 +0100 | [diff] [blame] | 289 | # These suites require legacy hash support, which is disabled |
Valerio Setti | 89d8a12 | 2024-01-26 15:04:05 +0100 | [diff] [blame] | 290 | # in the accelerated component. |
Valerio Setti | cd89b0b | 2024-01-24 14:24:55 +0100 | [diff] [blame] | 291 | 'shax', 'mdx', |
Valerio Setti | 20cea94 | 2024-01-22 16:23:25 +0100 | [diff] [blame] | 292 | # This suite tests builtins directly, but these are missing |
| 293 | # in the accelerated case. |
| 294 | 'psa_crypto_low_hash.generated', |
| 295 | ], |
| 296 | 'ignored_tests': { |
Gilles Peskine | a7469d3 | 2024-05-24 09:18:25 +0200 | [diff] [blame] | 297 | 'test_suite_config': [ |
| 298 | re.compile(r'.*\bMBEDTLS_(MD5|RIPEMD160|SHA[0-9]+)_.*'), |
| 299 | re.compile(r'.*\bMBEDTLS_MD_C\b') |
| 300 | ], |
Valerio Setti | 20cea94 | 2024-01-22 16:23:25 +0100 | [diff] [blame] | 301 | 'test_suite_md': [ |
| 302 | # Builtin HMAC is not supported in the accelerate component. |
| 303 | re.compile('.*HMAC.*'), |
| 304 | # Following tests make use of functions which are not available |
| 305 | # when MD_C is disabled, as it happens in the accelerated |
| 306 | # test component. |
| 307 | re.compile('generic .* Hash file .*'), |
| 308 | 'MD list', |
| 309 | ], |
| 310 | 'test_suite_md.psa': [ |
| 311 | # "legacy only" tests require hash algorithms to be NOT |
| 312 | # accelerated, but this of course false for the accelerated |
| 313 | # test component. |
| 314 | re.compile('PSA dispatch .* legacy only'), |
| 315 | ], |
| 316 | 'test_suite_platform': [ |
| 317 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 318 | # component uses a sanitizer but the reference component |
| 319 | # doesn't, we have a PASS vs SKIP mismatch. |
| 320 | 'Check mbedtls_calloc overallocation', |
| 321 | ], |
| 322 | } |
| 323 | } |
| 324 | }, |
Manuel Pégourié-Gonnard | 7f48d5e | 2024-01-08 10:55:09 +0100 | [diff] [blame] | 325 | 'analyze_driver_vs_reference_cipher_aead_cmac': { |
Valerio Setti | b6b301f | 2023-10-04 12:05:05 +0200 | [diff] [blame] | 326 | 'test_function': do_analyze_driver_vs_reference, |
| 327 | 'args': { |
Manuel Pégourié-Gonnard | 7f48d5e | 2024-01-08 10:55:09 +0100 | [diff] [blame] | 328 | 'component_ref': 'test_psa_crypto_config_reference_cipher_aead_cmac', |
| 329 | 'component_driver': 'test_psa_crypto_config_accel_cipher_aead_cmac', |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 330 | # Modules replaced by drivers. |
Valerio Setti | b6b301f | 2023-10-04 12:05:05 +0200 | [diff] [blame] | 331 | 'ignored_suites': [ |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 332 | # low-level (block/stream) cipher modules |
| 333 | 'aes', 'aria', 'camellia', 'des', 'chacha20', |
Manuel Pégourié-Gonnard | 7f48d5e | 2024-01-08 10:55:09 +0100 | [diff] [blame] | 334 | # AEAD modes and CMAC |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 335 | 'ccm', 'chachapoly', 'cmac', 'gcm', |
| 336 | # The Cipher abstraction layer |
| 337 | 'cipher', |
Valerio Setti | b6b301f | 2023-10-04 12:05:05 +0200 | [diff] [blame] | 338 | ], |
| 339 | 'ignored_tests': { |
Gilles Peskine | a7469d3 | 2024-05-24 09:18:25 +0200 | [diff] [blame] | 340 | 'test_suite_config': [ |
| 341 | re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA|CHACHA20|DES)_.*'), |
| 342 | re.compile(r'.*\bMBEDTLS_(CCM|CHACHAPOLY|CMAC|GCM)_.*'), |
| 343 | re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'), |
| 344 | re.compile(r'.*\bMBEDTLS_CIPHER_.*'), |
| 345 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 346 | # PEM decryption is not supported so far. |
| 347 | # The rest of PEM (write, unencrypted read) works though. |
Valerio Setti | 7448cee | 2023-10-04 15:46:42 +0200 | [diff] [blame] | 348 | 'test_suite_pem': [ |
Manuel Pégourié-Gonnard | cd84a29 | 2023-10-27 09:24:44 +0200 | [diff] [blame] | 349 | re.compile(r'PEM read .*(AES|DES|\bencrypt).*'), |
Valerio Setti | 7448cee | 2023-10-04 15:46:42 +0200 | [diff] [blame] | 350 | ], |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 351 | 'test_suite_platform': [ |
| 352 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 353 | # component uses a sanitizer but the reference component |
| 354 | # doesn't, we have a PASS vs SKIP mismatch. |
| 355 | 'Check mbedtls_calloc overallocation', |
| 356 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 357 | # Following tests depend on AES_C/DES_C but are not about |
| 358 | # them really, just need to know some error code is there. |
Valerio Setti | 7448cee | 2023-10-04 15:46:42 +0200 | [diff] [blame] | 359 | 'test_suite_error': [ |
| 360 | 'Low and high error', |
| 361 | 'Single low error' |
| 362 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 363 | # Similar to test_suite_error above. |
Valerio Setti | 7448cee | 2023-10-04 15:46:42 +0200 | [diff] [blame] | 364 | 'test_suite_version': [ |
| 365 | 'Check for MBEDTLS_AES_C when already present', |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 366 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 367 | # The en/decryption part of PKCS#12 is not supported so far. |
| 368 | # The rest of PKCS#12 (key derivation) works though. |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 369 | 'test_suite_pkcs12': [ |
Manuel Pégourié-Gonnard | cd84a29 | 2023-10-27 09:24:44 +0200 | [diff] [blame] | 370 | re.compile(r'PBE Encrypt, .*'), |
| 371 | re.compile(r'PBE Decrypt, .*'), |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 372 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 373 | # The en/decryption part of PKCS#5 is not supported so far. |
| 374 | # The rest of PKCS#5 (PBKDF2) works though. |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 375 | 'test_suite_pkcs5': [ |
Manuel Pégourié-Gonnard | cd84a29 | 2023-10-27 09:24:44 +0200 | [diff] [blame] | 376 | re.compile(r'PBES2 Encrypt, .*'), |
| 377 | re.compile(r'PBES2 Decrypt .*'), |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 378 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 379 | # Encrypted keys are not supported so far. |
Valerio Setti | 5cd18f9 | 2023-10-13 15:14:07 +0200 | [diff] [blame] | 380 | # pylint: disable=line-too-long |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 381 | 'test_suite_pkparse': [ |
| 382 | 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)', |
| 383 | 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)', |
Pengyu Lv | a1ddcfa | 2023-11-28 09:46:01 +0800 | [diff] [blame] | 384 | re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'), |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 385 | ], |
Sam Berry | 4beeb0c | 2024-06-27 14:18:22 +0100 | [diff] [blame] | 386 | # Encrypted keys are not supported so far. |
| 387 | 'ssl-opt': [ |
| 388 | 'TLS: password protected server key', |
| 389 | 'TLS: password protected client key', |
| 390 | 'TLS: password protected server key, two certificates', |
| 391 | ], |
Valerio Setti | b6b301f | 2023-10-04 12:05:05 +0200 | [diff] [blame] | 392 | } |
| 393 | } |
| 394 | }, |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 395 | 'analyze_driver_vs_reference_ecp_light_only': { |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 396 | 'test_function': do_analyze_driver_vs_reference, |
| 397 | 'args': { |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 398 | 'component_ref': 'test_psa_crypto_config_reference_ecc_ecp_light_only', |
| 399 | 'component_driver': 'test_psa_crypto_config_accel_ecc_ecp_light_only', |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 400 | 'ignored_suites': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 401 | # Modules replaced by drivers |
| 402 | 'ecdsa', 'ecdh', 'ecjpake', |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 403 | ], |
| 404 | 'ignored_tests': { |
Gilles Peskine | a7469d3 | 2024-05-24 09:18:25 +0200 | [diff] [blame] | 405 | 'test_suite_config': [ |
| 406 | re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'), |
| 407 | ], |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 408 | 'test_suite_platform': [ |
| 409 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 410 | # component uses a sanitizer but the reference component |
| 411 | # doesn't, we have a PASS vs SKIP mismatch. |
| 412 | 'Check mbedtls_calloc overallocation', |
| 413 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 414 | # This test wants a legacy function that takes f_rng, p_rng |
| 415 | # arguments, and uses legacy ECDSA for that. The test is |
| 416 | # really about the wrapper around the PSA RNG, not ECDSA. |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 417 | 'test_suite_random': [ |
| 418 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 419 | ], |
Valerio Setti | 0c477d3 | 2023-04-07 15:54:20 +0200 | [diff] [blame] | 420 | # In the accelerated test ECP_C is not set (only ECP_LIGHT is) |
| 421 | # so we must ignore disparities in the tests for which ECP_C |
| 422 | # is required. |
| 423 | 'test_suite_ecp': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 424 | re.compile(r'ECP check public-private .*'), |
Gilles Peskine | 3b17ae7 | 2023-06-23 11:08:39 +0200 | [diff] [blame] | 425 | re.compile(r'ECP calculate public: .*'), |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 426 | re.compile(r'ECP gen keypair .*'), |
| 427 | re.compile(r'ECP point muladd .*'), |
| 428 | re.compile(r'ECP point multiplication .*'), |
| 429 | re.compile(r'ECP test vectors .*'), |
Valerio Setti | 482a0b9 | 2023-08-18 15:55:10 +0200 | [diff] [blame] | 430 | ], |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 431 | 'test_suite_ssl': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 432 | # This deprecated function is only present when ECP_C is On. |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 433 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 434 | ], |
Valerio Setti | 5f54020 | 2023-06-30 17:20:49 +0200 | [diff] [blame] | 435 | } |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 436 | } |
| 437 | }, |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 438 | 'analyze_driver_vs_reference_no_ecp_at_all': { |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 439 | 'test_function': do_analyze_driver_vs_reference, |
| 440 | 'args': { |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 441 | 'component_ref': 'test_psa_crypto_config_reference_ecc_no_ecp_at_all', |
| 442 | 'component_driver': 'test_psa_crypto_config_accel_ecc_no_ecp_at_all', |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 443 | 'ignored_suites': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 444 | # Modules replaced by drivers |
| 445 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 446 | ], |
| 447 | 'ignored_tests': { |
Gilles Peskine | a7469d3 | 2024-05-24 09:18:25 +0200 | [diff] [blame] | 448 | 'test_suite_config': [ |
| 449 | re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'), |
| 450 | re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'), |
| 451 | ], |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 452 | 'test_suite_platform': [ |
| 453 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 454 | # component uses a sanitizer but the reference component |
| 455 | # doesn't, we have a PASS vs SKIP mismatch. |
| 456 | 'Check mbedtls_calloc overallocation', |
| 457 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 458 | # See ecp_light_only |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 459 | 'test_suite_random': [ |
| 460 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 461 | ], |
Valerio Setti | addeee4 | 2023-06-14 10:46:55 +0200 | [diff] [blame] | 462 | 'test_suite_pkparse': [ |
Valerio Setti | 5bd2523 | 2023-06-19 19:32:14 +0200 | [diff] [blame] | 463 | # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED |
| 464 | # is automatically enabled in build_info.h (backward compatibility) |
| 465 | # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a |
| 466 | # consequence compressed points are supported in the reference |
| 467 | # component but not in the accelerated one, so they should be skipped |
| 468 | # while checking driver's coverage. |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 469 | re.compile(r'Parse EC Key .*compressed\)'), |
| 470 | re.compile(r'Parse Public EC Key .*compressed\)'), |
Valerio Setti | addeee4 | 2023-06-14 10:46:55 +0200 | [diff] [blame] | 471 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 472 | # See ecp_light_only |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 473 | 'test_suite_ssl': [ |
| 474 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 475 | ], |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 476 | } |
| 477 | } |
| 478 | }, |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 479 | 'analyze_driver_vs_reference_ecc_no_bignum': { |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 480 | 'test_function': do_analyze_driver_vs_reference, |
| 481 | 'args': { |
| 482 | 'component_ref': 'test_psa_crypto_config_reference_ecc_no_bignum', |
| 483 | 'component_driver': 'test_psa_crypto_config_accel_ecc_no_bignum', |
| 484 | 'ignored_suites': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 485 | # Modules replaced by drivers |
| 486 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', |
| 487 | 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw', |
| 488 | 'bignum.generated', 'bignum.misc', |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 489 | ], |
| 490 | 'ignored_tests': { |
Gilles Peskine | a7469d3 | 2024-05-24 09:18:25 +0200 | [diff] [blame] | 491 | 'test_suite_config': [ |
| 492 | re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'), |
| 493 | re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'), |
| 494 | re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'), |
| 495 | ], |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 496 | 'test_suite_platform': [ |
| 497 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 498 | # component uses a sanitizer but the reference component |
| 499 | # doesn't, we have a PASS vs SKIP mismatch. |
| 500 | 'Check mbedtls_calloc overallocation', |
| 501 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 502 | # See ecp_light_only |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 503 | 'test_suite_random': [ |
| 504 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 505 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 506 | # See no_ecp_at_all |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 507 | 'test_suite_pkparse': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 508 | re.compile(r'Parse EC Key .*compressed\)'), |
| 509 | re.compile(r'Parse Public EC Key .*compressed\)'), |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 510 | ], |
Valerio Setti | 9b3dbcc | 2023-07-26 18:00:31 +0200 | [diff] [blame] | 511 | 'test_suite_asn1parse': [ |
Valerio Setti | 9b3dbcc | 2023-07-26 18:00:31 +0200 | [diff] [blame] | 512 | 'INTEGER too large for mpi', |
| 513 | ], |
| 514 | 'test_suite_asn1write': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 515 | re.compile(r'ASN.1 Write mpi.*'), |
Valerio Setti | 9b3dbcc | 2023-07-26 18:00:31 +0200 | [diff] [blame] | 516 | ], |
Valerio Setti | e0be95e | 2023-08-01 09:07:43 +0200 | [diff] [blame] | 517 | 'test_suite_debug': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 518 | re.compile(r'Debug print mbedtls_mpi.*'), |
Valerio Setti | e0be95e | 2023-08-01 09:07:43 +0200 | [diff] [blame] | 519 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 520 | # See ecp_light_only |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 521 | 'test_suite_ssl': [ |
| 522 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 523 | ], |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 524 | } |
| 525 | } |
| 526 | }, |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 527 | 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': { |
| 528 | 'test_function': do_analyze_driver_vs_reference, |
| 529 | 'args': { |
| 530 | 'component_ref': 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum', |
| 531 | 'component_driver': 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum', |
| 532 | 'ignored_suites': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 533 | # Modules replaced by drivers |
| 534 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm', |
| 535 | 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw', |
| 536 | 'bignum.generated', 'bignum.misc', |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 537 | ], |
| 538 | 'ignored_tests': { |
Gilles Peskine | ff3b821 | 2024-04-30 14:25:30 +0200 | [diff] [blame] | 539 | 'ssl-opt': [ |
| 540 | # DHE support in TLS 1.2 requires built-in MBEDTLS_DHM_C |
| 541 | # (because it needs custom groups, which PSA does not |
| 542 | # provide), even with MBEDTLS_USE_PSA_CRYPTO. |
| 543 | re.compile(r'PSK callback:.*\bdhe-psk\b.*'), |
| 544 | ], |
Gilles Peskine | a7469d3 | 2024-05-24 09:18:25 +0200 | [diff] [blame] | 545 | 'test_suite_config': [ |
| 546 | re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'), |
| 547 | re.compile(r'.*\bMBEDTLS_DHM_C\b.*'), |
| 548 | re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECJPAKE|ECP)_.*'), |
| 549 | re.compile(r'.*\bMBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED\b.*'), |
| 550 | re.compile(r'.*\bMBEDTLS_PK_PARSE_EC_COMPRESSED\b.*'), |
| 551 | ], |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 552 | 'test_suite_platform': [ |
| 553 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 554 | # component uses a sanitizer but the reference component |
| 555 | # doesn't, we have a PASS vs SKIP mismatch. |
| 556 | 'Check mbedtls_calloc overallocation', |
| 557 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 558 | # See ecp_light_only |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 559 | 'test_suite_random': [ |
| 560 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 561 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 562 | # See no_ecp_at_all |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 563 | 'test_suite_pkparse': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 564 | re.compile(r'Parse EC Key .*compressed\)'), |
| 565 | re.compile(r'Parse Public EC Key .*compressed\)'), |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 566 | ], |
| 567 | 'test_suite_asn1parse': [ |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 568 | 'INTEGER too large for mpi', |
| 569 | ], |
| 570 | 'test_suite_asn1write': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 571 | re.compile(r'ASN.1 Write mpi.*'), |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 572 | ], |
| 573 | 'test_suite_debug': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 574 | re.compile(r'Debug print mbedtls_mpi.*'), |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 575 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 576 | # See ecp_light_only |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 577 | 'test_suite_ssl': [ |
| 578 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 579 | ], |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 580 | } |
| 581 | } |
| 582 | }, |
Przemek Stekiel | 85b6442 | 2023-05-26 09:55:23 +0200 | [diff] [blame] | 583 | 'analyze_driver_vs_reference_ffdh_alg': { |
| 584 | 'test_function': do_analyze_driver_vs_reference, |
| 585 | 'args': { |
| 586 | 'component_ref': 'test_psa_crypto_config_reference_ffdh', |
| 587 | 'component_driver': 'test_psa_crypto_config_accel_ffdh', |
Przemek Stekiel | 84f4ff1 | 2023-07-04 12:35:31 +0200 | [diff] [blame] | 588 | 'ignored_suites': ['dhm'], |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 589 | 'ignored_tests': { |
Gilles Peskine | a7469d3 | 2024-05-24 09:18:25 +0200 | [diff] [blame] | 590 | 'test_suite_config': [ |
| 591 | re.compile(r'.*\bMBEDTLS_DHM_C\b.*'), |
| 592 | ], |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 593 | 'test_suite_platform': [ |
| 594 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 595 | # component uses a sanitizer but the reference component |
| 596 | # doesn't, we have a PASS vs SKIP mismatch. |
| 597 | 'Check mbedtls_calloc overallocation', |
| 598 | ], |
| 599 | } |
Przemek Stekiel | 85b6442 | 2023-05-26 09:55:23 +0200 | [diff] [blame] | 600 | } |
| 601 | }, |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 602 | 'analyze_driver_vs_reference_tfm_config': { |
| 603 | 'test_function': do_analyze_driver_vs_reference, |
| 604 | 'args': { |
Gilles Peskine | effa6a0 | 2024-09-14 11:35:36 +0200 | [diff] [blame] | 605 | 'component_ref': 'test_tfm_config_no_p256m', |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 606 | 'component_driver': 'test_tfm_config_p256m_driver_accel_ec', |
Manuel Pégourié-Gonnard | e9d9797 | 2023-08-08 18:34:47 +0200 | [diff] [blame] | 607 | 'ignored_suites': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 608 | # Modules replaced by drivers |
Yanray Wang | 5779096 | 2023-10-31 13:39:07 +0800 | [diff] [blame] | 609 | 'asn1parse', 'asn1write', |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 610 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', |
| 611 | 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw', |
| 612 | 'bignum.generated', 'bignum.misc', |
Manuel Pégourié-Gonnard | e9d9797 | 2023-08-08 18:34:47 +0200 | [diff] [blame] | 613 | ], |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 614 | 'ignored_tests': { |
Gilles Peskine | a7469d3 | 2024-05-24 09:18:25 +0200 | [diff] [blame] | 615 | 'test_suite_config': [ |
| 616 | re.compile(r'.*\bMBEDTLS_BIGNUM_C\b.*'), |
| 617 | re.compile(r'.*\bMBEDTLS_(ASN1\w+)_C\b.*'), |
| 618 | re.compile(r'.*\bMBEDTLS_(ECDH|ECDSA|ECP)_.*'), |
| 619 | re.compile(r'.*\bMBEDTLS_PSA_P256M_DRIVER_ENABLED\b.*') |
| 620 | ], |
| 621 | 'test_suite_config.crypto_combinations': [ |
| 622 | 'Config: ECC: Weierstrass curves only', |
| 623 | ], |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 624 | 'test_suite_platform': [ |
| 625 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 626 | # component uses a sanitizer but the reference component |
| 627 | # doesn't, we have a PASS vs SKIP mismatch. |
| 628 | 'Check mbedtls_calloc overallocation', |
| 629 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 630 | # See ecp_light_only |
Manuel Pégourié-Gonnard | e9d9797 | 2023-08-08 18:34:47 +0200 | [diff] [blame] | 631 | 'test_suite_random': [ |
| 632 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 633 | ], |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 634 | } |
| 635 | } |
Pengyu Lv | 3cd16c4 | 2023-12-06 18:17:39 +0800 | [diff] [blame] | 636 | }, |
| 637 | 'analyze_driver_vs_reference_rsa': { |
| 638 | 'test_function': do_analyze_driver_vs_reference, |
| 639 | 'args': { |
| 640 | 'component_ref': 'test_psa_crypto_config_reference_rsa_crypto', |
| 641 | 'component_driver': 'test_psa_crypto_config_accel_rsa_crypto', |
| 642 | 'ignored_suites': [ |
| 643 | # Modules replaced by drivers. |
| 644 | 'rsa', 'pkcs1_v15', 'pkcs1_v21', |
Pengyu Lv | 98a90c6 | 2023-12-07 17:23:25 +0800 | [diff] [blame] | 645 | # We temporarily don't care about PK stuff. |
Pengyu Lv | 3cd16c4 | 2023-12-06 18:17:39 +0800 | [diff] [blame] | 646 | 'pk', 'pkwrite', 'pkparse' |
| 647 | ], |
| 648 | 'ignored_tests': { |
Gilles Peskine | a7469d3 | 2024-05-24 09:18:25 +0200 | [diff] [blame] | 649 | 'test_suite_config': [ |
| 650 | re.compile(r'.*\bMBEDTLS_(PKCS1|RSA)_.*'), |
| 651 | re.compile(r'.*\bMBEDTLS_GENPRIME\b.*') |
| 652 | ], |
Pengyu Lv | 3cd16c4 | 2023-12-06 18:17:39 +0800 | [diff] [blame] | 653 | 'test_suite_platform': [ |
| 654 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 655 | # component uses a sanitizer but the reference component |
| 656 | # doesn't, we have a PASS vs SKIP mismatch. |
| 657 | 'Check mbedtls_calloc overallocation', |
| 658 | ], |
| 659 | # Following tests depend on RSA_C but are not about |
| 660 | # them really, just need to know some error code is there. |
| 661 | 'test_suite_error': [ |
| 662 | 'Low and high error', |
| 663 | 'Single high error' |
| 664 | ], |
| 665 | # Constant time operations only used for PKCS1_V15 |
| 666 | 'test_suite_constant_time': [ |
| 667 | re.compile(r'mbedtls_ct_zeroize_if .*'), |
| 668 | re.compile(r'mbedtls_ct_memmove_left .*') |
| 669 | ], |
Gilles Peskine | 63072b1 | 2024-02-15 11:48:58 +0100 | [diff] [blame] | 670 | 'test_suite_psa_crypto': [ |
Gilles Peskine | 1084e8e | 2024-06-07 11:26:53 +0200 | [diff] [blame] | 671 | # We don't support generate_key_custom entry points |
Gilles Peskine | 63072b1 | 2024-02-15 11:48:58 +0100 | [diff] [blame] | 672 | # in drivers yet. |
Gilles Peskine | 1084e8e | 2024-06-07 11:26:53 +0200 | [diff] [blame] | 673 | re.compile(r'PSA generate key custom: RSA, e=.*'), |
Gilles Peskine | 63072b1 | 2024-02-15 11:48:58 +0100 | [diff] [blame] | 674 | re.compile(r'PSA generate key ext: RSA, e=.*'), |
| 675 | ], |
Pengyu Lv | 3cd16c4 | 2023-12-06 18:17:39 +0800 | [diff] [blame] | 676 | } |
| 677 | } |
Valerio Setti | 52ab8fa | 2023-12-14 18:04:04 +0100 | [diff] [blame] | 678 | }, |
| 679 | 'analyze_block_cipher_dispatch': { |
| 680 | 'test_function': do_analyze_driver_vs_reference, |
| 681 | 'args': { |
Valerio Setti | 4a8ef7c | 2023-12-19 11:16:27 +0100 | [diff] [blame] | 682 | 'component_ref': 'test_full_block_cipher_legacy_dispatch', |
Valerio Setti | 52ab8fa | 2023-12-14 18:04:04 +0100 | [diff] [blame] | 683 | 'component_driver': 'test_full_block_cipher_psa_dispatch', |
| 684 | 'ignored_suites': [ |
Valerio Setti | 4a8ef7c | 2023-12-19 11:16:27 +0100 | [diff] [blame] | 685 | # Skipped in the accelerated component |
| 686 | 'aes', 'aria', 'camellia', |
Valerio Setti | 0635cca | 2023-12-28 16:16:02 +0100 | [diff] [blame] | 687 | # These require AES_C, ARIA_C or CAMELLIA_C to be enabled in |
| 688 | # order for the cipher module (actually cipher_wrapper) to work |
| 689 | # properly. However these symbols are disabled in the accelerated |
| 690 | # component so we ignore them. |
Valerio Setti | a0c9c66 | 2023-12-29 14:14:11 +0100 | [diff] [blame] | 691 | 'cipher.ccm', 'cipher.gcm', 'cipher.aes', 'cipher.aria', |
Valerio Setti | 0635cca | 2023-12-28 16:16:02 +0100 | [diff] [blame] | 692 | 'cipher.camellia', |
Valerio Setti | 52ab8fa | 2023-12-14 18:04:04 +0100 | [diff] [blame] | 693 | ], |
| 694 | 'ignored_tests': { |
Gilles Peskine | a7469d3 | 2024-05-24 09:18:25 +0200 | [diff] [blame] | 695 | 'test_suite_config': [ |
| 696 | re.compile(r'.*\bMBEDTLS_(AES|ARIA|CAMELLIA)_.*'), |
| 697 | re.compile(r'.*\bMBEDTLS_AES(\w+)_C\b.*'), |
| 698 | ], |
Valerio Setti | a0c9c66 | 2023-12-29 14:14:11 +0100 | [diff] [blame] | 699 | 'test_suite_cmac': [ |
| 700 | # Following tests require AES_C/ARIA_C/CAMELLIA_C to be enabled, |
| 701 | # but these are not available in the accelerated component. |
| 702 | 'CMAC null arguments', |
| 703 | re.compile('CMAC.* (AES|ARIA|Camellia).*'), |
| 704 | ], |
Valerio Setti | 0635cca | 2023-12-28 16:16:02 +0100 | [diff] [blame] | 705 | 'test_suite_cipher.padding': [ |
| 706 | # Following tests require AES_C/CAMELLIA_C to be enabled, |
| 707 | # but these are not available in the accelerated component. |
| 708 | re.compile('Set( non-existent)? padding with (AES|CAMELLIA).*'), |
Valerio Setti | 5f665c3 | 2023-12-20 09:56:05 +0100 | [diff] [blame] | 709 | ], |
Ryan Everett | afb2eee | 2024-02-08 14:31:54 +0000 | [diff] [blame] | 710 | 'test_suite_pkcs5': [ |
Ryan Everett | 67f3568 | 2024-02-09 13:02:23 +0000 | [diff] [blame] | 711 | # The AES part of PKCS#5 PBES2 is not yet supported. |
Ryan Everett | afb2eee | 2024-02-08 14:31:54 +0000 | [diff] [blame] | 712 | # The rest of PKCS#5 (PBKDF2) works, though. |
Ryan Everett | 67f3568 | 2024-02-09 13:02:23 +0000 | [diff] [blame] | 713 | re.compile(r'PBES2 .* AES-.*') |
Ryan Everett | afb2eee | 2024-02-08 14:31:54 +0000 | [diff] [blame] | 714 | ], |
Valerio Setti | 0635cca | 2023-12-28 16:16:02 +0100 | [diff] [blame] | 715 | 'test_suite_pkparse': [ |
| 716 | # PEM (called by pkparse) requires AES_C in order to decrypt |
| 717 | # the key, but this is not available in the accelerated |
| 718 | # component. |
| 719 | re.compile('Parse RSA Key.*(password|AES-).*'), |
Valerio Setti | 5f665c3 | 2023-12-20 09:56:05 +0100 | [diff] [blame] | 720 | ], |
Valerio Setti | 0635cca | 2023-12-28 16:16:02 +0100 | [diff] [blame] | 721 | 'test_suite_pem': [ |
| 722 | # Following tests require AES_C, but this is diabled in the |
| 723 | # accelerated component. |
Valerio Setti | eba4ca1 | 2024-02-19 07:42:18 +0100 | [diff] [blame] | 724 | re.compile('PEM read .*AES.*'), |
Valerio Setti | 0635cca | 2023-12-28 16:16:02 +0100 | [diff] [blame] | 725 | 'PEM read (unknown encryption algorithm)', |
Valerio Setti | 5f665c3 | 2023-12-20 09:56:05 +0100 | [diff] [blame] | 726 | ], |
| 727 | 'test_suite_error': [ |
Valerio Setti | ab0494f | 2023-12-28 13:56:13 +0100 | [diff] [blame] | 728 | # Following tests depend on AES_C but are not about them |
| 729 | # really, just need to know some error code is there. |
Valerio Setti | 5f665c3 | 2023-12-20 09:56:05 +0100 | [diff] [blame] | 730 | 'Single low error', |
| 731 | 'Low and high error', |
| 732 | ], |
| 733 | 'test_suite_version': [ |
Valerio Setti | ab0494f | 2023-12-28 13:56:13 +0100 | [diff] [blame] | 734 | # Similar to test_suite_error above. |
Valerio Setti | 5f665c3 | 2023-12-20 09:56:05 +0100 | [diff] [blame] | 735 | 'Check for MBEDTLS_AES_C when already present', |
| 736 | ], |
Valerio Setti | 52ab8fa | 2023-12-14 18:04:04 +0100 | [diff] [blame] | 737 | 'test_suite_platform': [ |
| 738 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 739 | # component uses a sanitizer but the reference component |
| 740 | # doesn't, we have a PASS vs SKIP mismatch. |
| 741 | 'Check mbedtls_calloc overallocation', |
| 742 | ], |
| 743 | } |
| 744 | } |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 745 | } |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 746 | } |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 747 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 748 | def main(): |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame] | 749 | main_results = Results() |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 750 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 751 | try: |
| 752 | parser = argparse.ArgumentParser(description=__doc__) |
Przemek Stekiel | 58bbc23 | 2022-10-24 08:10:10 +0200 | [diff] [blame] | 753 | parser.add_argument('outcomes', metavar='OUTCOMES.CSV', |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 754 | help='Outcome file to analyze') |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 755 | parser.add_argument('specified_tasks', default='all', nargs='?', |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 756 | help='Analysis to be done. By default, run all tasks. ' |
| 757 | 'With one or more TASK, run only those. ' |
| 758 | 'TASK can be the name of a single task or ' |
Przemek Stekiel | 85c54ea | 2022-11-17 11:50:23 +0100 | [diff] [blame] | 759 | 'comma/space-separated list of tasks. ') |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 760 | parser.add_argument('--list', action='store_true', |
| 761 | help='List all available tasks and exit.') |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 762 | parser.add_argument('--require-full-coverage', action='store_true', |
| 763 | dest='full_coverage', help="Require all available " |
| 764 | "test cases to be executed and issue an error " |
| 765 | "otherwise. This flag is ignored if 'task' is " |
| 766 | "neither 'all' nor 'analyze_coverage'") |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 767 | options = parser.parse_args() |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 768 | |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 769 | if options.list: |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 770 | for task in KNOWN_TASKS: |
Valerio Setti | 5329ff0 | 2023-10-17 09:44:36 +0200 | [diff] [blame] | 771 | print(task) |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 772 | sys.exit(0) |
| 773 | |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 774 | if options.specified_tasks == 'all': |
| 775 | tasks_list = KNOWN_TASKS.keys() |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 776 | else: |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 777 | tasks_list = re.split(r'[, ]+', options.specified_tasks) |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 778 | for task in tasks_list: |
| 779 | if task not in KNOWN_TASKS: |
Manuel Pégourié-Gonnard | 62d6131 | 2023-10-20 10:51:57 +0200 | [diff] [blame] | 780 | sys.stderr.write('invalid task: {}\n'.format(task)) |
Valerio Setti | fb2750e | 2023-10-17 10:11:45 +0200 | [diff] [blame] | 781 | sys.exit(2) |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 782 | |
Pengyu Lv | dd1d6a7 | 2023-11-27 17:57:31 +0800 | [diff] [blame] | 783 | # If the outcome file exists, parse it once and share the result |
| 784 | # among tasks to improve performance. |
Pengyu Lv | 20e3ca3 | 2023-11-28 15:30:03 +0800 | [diff] [blame] | 785 | # Otherwise, it will be generated by execute_reference_driver_tests. |
| 786 | if not os.path.exists(options.outcomes): |
| 787 | if len(tasks_list) > 1: |
| 788 | sys.stderr.write("mutiple tasks found, please provide a valid outcomes file.\n") |
| 789 | sys.exit(2) |
| 790 | |
| 791 | task_name = tasks_list[0] |
| 792 | task = KNOWN_TASKS[task_name] |
Gilles Peskine | 19ef1ae | 2024-09-16 19:12:09 +0200 | [diff] [blame] | 793 | if isinstance(task, dict) and \ |
| 794 | task['test_function'] != do_analyze_driver_vs_reference: # pylint: disable=comparison-with-callable |
Pengyu Lv | 20e3ca3 | 2023-11-28 15:30:03 +0800 | [diff] [blame] | 795 | sys.stderr.write("please provide valid outcomes file for {}.\n".format(task_name)) |
| 796 | sys.exit(2) |
| 797 | |
| 798 | execute_reference_driver_tests(main_results, |
| 799 | task['args']['component_ref'], |
| 800 | task['args']['component_driver'], |
| 801 | options.outcomes) |
| 802 | |
| 803 | outcomes = read_outcome_file(options.outcomes) |
Pengyu Lv | a6cf5d6 | 2023-11-22 11:35:21 +0800 | [diff] [blame] | 804 | |
Gilles Peskine | 19ef1ae | 2024-09-16 19:12:09 +0200 | [diff] [blame] | 805 | for task_name in tasks_list: |
| 806 | task_constructor = KNOWN_TASKS[task_name] |
| 807 | if isinstance(task_constructor, dict): |
| 808 | test_function = task_constructor['test_function'] |
| 809 | test_args = task_constructor['args'] |
| 810 | test_function(main_results, outcomes, test_args) |
| 811 | else: |
| 812 | task = task_constructor(options) |
Gilles Peskine | f646dbf | 2024-09-16 19:15:29 +0200 | [diff] [blame^] | 813 | main_results.new_section(task.section_name()) |
Gilles Peskine | 19ef1ae | 2024-09-16 19:12:09 +0200 | [diff] [blame] | 814 | task.run(main_results, outcomes) |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 815 | |
Valerio Setti | f6f64cf | 2023-10-17 12:28:26 +0200 | [diff] [blame] | 816 | main_results.info("Overall results: {} warnings and {} errors", |
| 817 | main_results.warning_count, main_results.error_count) |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 818 | |
Valerio Setti | 8d178be | 2023-10-17 12:23:55 +0200 | [diff] [blame] | 819 | sys.exit(0 if (main_results.error_count == 0) else 1) |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 820 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 821 | except Exception: # pylint: disable=broad-except |
| 822 | # Print the backtrace and exit explicitly with our chosen status. |
| 823 | traceback.print_exc() |
| 824 | sys.exit(120) |
| 825 | |
| 826 | if __name__ == '__main__': |
| 827 | main() |