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 | 686c292 | 2022-01-07 15:58:38 +0100 | [diff] [blame] | 88 | available = check_test_cases.collect_available_test_cases() |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 89 | for suite_case in available: |
Pengyu Lv | 5dcfd0c | 2023-11-29 18:03:28 +0800 | [diff] [blame] | 90 | hit = any(suite_case in comp_outcomes.successes or |
| 91 | suite_case in comp_outcomes.failures |
| 92 | for comp_outcomes in outcomes.values()) |
Pengyu Lv | a442858 | 2023-11-22 19:02:15 +0800 | [diff] [blame] | 93 | |
Pengyu Lv | 5dcfd0c | 2023-11-29 18:03:28 +0800 | [diff] [blame] | 94 | if not hit and suite_case not in allow_list: |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 95 | if full_coverage: |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 96 | results.error('Test case not executed: {}', suite_case) |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 97 | else: |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 98 | results.warning('Test case not executed: {}', suite_case) |
Pengyu Lv | 5dcfd0c | 2023-11-29 18:03:28 +0800 | [diff] [blame] | 99 | elif hit and suite_case in allow_list: |
Tomás González | 07bdcc2 | 2023-08-11 14:59:03 +0100 | [diff] [blame] | 100 | # Test Case should be removed from the allow list. |
Tomás González | 7ebb18f | 2023-08-22 09:40:23 +0100 | [diff] [blame] | 101 | if full_coverage: |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 102 | results.error('Allow listed test case was executed: {}', suite_case) |
Tomás González | 7ebb18f | 2023-08-22 09:40:23 +0100 | [diff] [blame] | 103 | else: |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 104 | results.warning('Allow listed test case was executed: {}', suite_case) |
Gilles Peskine | 8d3c70a | 2020-06-25 18:37:43 +0200 | [diff] [blame] | 105 | |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 106 | def name_matches_pattern(name: str, str_or_re) -> bool: |
Manuel Pégourié-Gonnard | 881ce01 | 2023-10-18 10:22:07 +0200 | [diff] [blame] | 107 | """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é-Gonnard | b269543 | 2023-10-23 09:30:40 +0200 | [diff] [blame] | 111 | # 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 Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 114 | return str_or_re.fullmatch(name) is not None |
Manuel Pégourié-Gonnard | 881ce01 | 2023-10-18 10:22:07 +0200 | [diff] [blame] | 115 | else: |
Manuel Pégourié-Gonnard | 9d9c234 | 2023-10-26 09:37:40 +0200 | [diff] [blame] | 116 | return str_or_re == name |
Manuel Pégourié-Gonnard | 881ce01 | 2023-10-18 10:22:07 +0200 | [diff] [blame] | 117 | |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 118 | def 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 Lv | dd1d6a7 | 2023-11-27 17:57:31 +0800 | [diff] [blame] | 121 | """Check that all tests passing in the reference component are also |
| 122 | passing in the corresponding driver component. |
Valerio Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 123 | 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 Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 127 | """ |
Pengyu Lv | a442858 | 2023-11-22 19:02:15 +0800 | [diff] [blame] | 128 | ref_outcomes = outcomes.get("component_" + component_ref) |
| 129 | driver_outcomes = outcomes.get("component_" + component_driver) |
| 130 | |
Pengyu Lv | 59b9efc | 2023-11-28 11:15:00 +0800 | [diff] [blame] | 131 | if ref_outcomes is None or driver_outcomes is None: |
| 132 | results.error("required components are missing: bad outcome file?") |
| 133 | return |
| 134 | |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 135 | if not ref_outcomes.successes: |
Pengyu Lv | a442858 | 2023-11-22 19:02:15 +0800 | [diff] [blame] | 136 | results.error("no passing test in reference component: bad outcome file?") |
| 137 | return |
| 138 | |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 139 | for suite_case in ref_outcomes.successes: |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 140 | # suite_case is like "test_suite_foo.bar;Description of test case" |
| 141 | (full_test_suite, test_string) = suite_case.split(';') |
Valerio Setti | 00c1ccb | 2023-02-02 11:33:31 +0100 | [diff] [blame] | 142 | 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] | 143 | |
| 144 | # Immediately skip fully-ignored test suites |
Manuel Pégourié-Gonnard | 7d381f5 | 2023-03-17 15:13:08 +0100 | [diff] [blame] | 145 | 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] | 146 | continue |
Manuel Pégourié-Gonnard | 371165a | 2023-10-18 12:44:54 +0200 | [diff] [blame] | 147 | |
| 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é-Gonnard | 881ce01 | 2023-10-18 10:22:07 +0200 | [diff] [blame] | 152 | if full_test_suite in ignored_tests: |
Manuel Pégourié-Gonnard | d36a37f | 2023-10-26 09:41:59 +0200 | [diff] [blame] | 153 | for str_or_re in ignored_tests[test_suite]: |
Manuel Pégourié-Gonnard | 881ce01 | 2023-10-18 10:22:07 +0200 | [diff] [blame] | 154 | if name_matches_pattern(test_string, str_or_re): |
Manuel Pégourié-Gonnard | 371165a | 2023-10-18 12:44:54 +0200 | [diff] [blame] | 155 | ignored = True |
Manuel Pégourié-Gonnard | 4da369f | 2023-10-18 09:40:32 +0200 | [diff] [blame] | 156 | |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 157 | if not ignored and not suite_case in driver_outcomes.successes: |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 158 | results.error("PASS -> SKIP/FAIL: {}", suite_case) |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 159 | if ignored and suite_case in driver_outcomes.successes: |
Pengyu Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 160 | results.error("uselessly ignored: {}", suite_case) |
Manuel Pégourié-Gonnard | 371165a | 2023-10-18 12:44:54 +0200 | [diff] [blame] | 161 | |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 162 | def analyze_outcomes(results: Results, outcomes: Outcomes, args) -> None: |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 163 | """Run all analyses on the given outcome collection.""" |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 164 | analyze_coverage(results, outcomes, args['allow_list'], |
| 165 | args['full_coverage']) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 166 | |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 167 | def read_outcome_file(outcome_file: str) -> Outcomes: |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 168 | """Parse an outcome file and return an outcome collection. |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 169 | """ |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 170 | outcomes = {} |
| 171 | with open(outcome_file, 'r', encoding='utf-8') as input_file: |
| 172 | for line in input_file: |
Pengyu Lv | dd1d6a7 | 2023-11-27 17:57:31 +0800 | [diff] [blame] | 173 | (_platform, component, suite, case, result, _cause) = line.split(';') |
Pengyu Lv | 451ec8a | 2023-11-28 17:59:05 +0800 | [diff] [blame] | 174 | # 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 Lv | 31a9b78 | 2023-11-23 14:15:37 +0800 | [diff] [blame] | 177 | suite_case = ';'.join([suite, case]) |
Pengyu Lv | dd1d6a7 | 2023-11-27 17:57:31 +0800 | [diff] [blame] | 178 | if component not in outcomes: |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 179 | outcomes[component] = ComponentOutcomes(set(), set()) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 180 | if result == 'PASS': |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 181 | outcomes[component].successes.add(suite_case) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 182 | elif result == 'FAIL': |
Pengyu Lv | 18908ec | 2023-11-28 12:11:52 +0800 | [diff] [blame] | 183 | outcomes[component].failures.add(suite_case) |
Pengyu Lv | a442858 | 2023-11-22 19:02:15 +0800 | [diff] [blame] | 184 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 185 | return outcomes |
| 186 | |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 187 | def do_analyze_coverage(results: Results, outcomes: Outcomes, args) -> None: |
Przemek Stekiel | 6856f4c | 2022-11-09 10:50:29 +0100 | [diff] [blame] | 188 | """Perform coverage analysis.""" |
Valerio Setti | 2cff820 | 2023-10-18 14:36:47 +0200 | [diff] [blame] | 189 | results.new_section("Analyze coverage") |
Valerio Setti | 781c234 | 2023-10-17 12:47:35 +0200 | [diff] [blame] | 190 | analyze_outcomes(results, outcomes, args) |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 191 | |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 192 | def do_analyze_driver_vs_reference(results: Results, outcomes: Outcomes, args) -> None: |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 193 | """Perform driver vs reference analyze.""" |
Valerio Setti | 2cff820 | 2023-10-18 14:36:47 +0200 | [diff] [blame] | 194 | results.new_section("Analyze driver {} vs reference {}", |
| 195 | args['component_driver'], args['component_ref']) |
Valerio Setti | b0c618e | 2023-10-16 14:19:49 +0200 | [diff] [blame] | 196 | |
Valerio Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 197 | ignored_suites = ['test_suite_' + x for x in args['ignored_suites']] |
Przemek Stekiel | 51f30ff | 2022-11-09 12:07:29 +0100 | [diff] [blame] | 198 | |
Valerio Setti | 781c234 | 2023-10-17 12:47:35 +0200 | [diff] [blame] | 199 | analyze_driver_vs_reference(results, outcomes, |
| 200 | args['component_ref'], args['component_driver'], |
| 201 | ignored_suites, args['ignored_tests']) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 202 | |
Przemek Stekiel | 6856f4c | 2022-11-09 10:50:29 +0100 | [diff] [blame] | 203 | # 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] | 204 | KNOWN_TASKS = { |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 205 | 'analyze_coverage': { |
| 206 | 'test_function': do_analyze_coverage, |
Tomás González | 07bdcc2 | 2023-08-11 14:59:03 +0100 | [diff] [blame] | 207 | 'args': { |
Tomás González | 358c6c6 | 2023-08-14 15:43:46 +0100 | [diff] [blame] | 208 | 'allow_list': [ |
Tomás González | 5022311 | 2023-08-22 09:52:06 +0100 | [diff] [blame] | 209 | # 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ález | d43cab3 | 2023-08-24 09:12:40 +0100 | [diff] [blame] | 213 | ], |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 214 | 'full_coverage': False, |
Tomás González | 07bdcc2 | 2023-08-11 14:59:03 +0100 | [diff] [blame] | 215 | } |
Tomás González | d43cab3 | 2023-08-24 09:12:40 +0100 | [diff] [blame] | 216 | }, |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 217 | # 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 Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 223 | 'analyze_driver_vs_reference_hash': { |
| 224 | 'test_function': do_analyze_driver_vs_reference, |
| 225 | 'args': { |
Przemek Stekiel | 51f30ff | 2022-11-09 12:07:29 +0100 | [diff] [blame] | 226 | 'component_ref': 'test_psa_crypto_config_reference_hash_use_psa', |
| 227 | 'component_driver': 'test_psa_crypto_config_accel_hash_use_psa', |
Manuel Pégourié-Gonnard | 10e3963 | 2022-12-29 12:29:09 +0100 | [diff] [blame] | 228 | 'ignored_suites': [ |
| 229 | 'shax', 'mdx', # the software implementations that are being excluded |
Manuel Pégourié-Gonnard | 7d381f5 | 2023-03-17 15:13:08 +0100 | [diff] [blame] | 230 | 'md.psa', # purposefully depends on whether drivers are present |
Gilles Peskine | 35b49c4 | 2023-10-04 12:28:41 +0200 | [diff] [blame] | 231 | 'psa_crypto_low_hash.generated', # testing the builtins |
Valerio Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 232 | ], |
| 233 | 'ignored_tests': { |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 234 | '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 Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 240 | } |
| 241 | } |
| 242 | }, |
Valerio Setti | b6b301f | 2023-10-04 12:05:05 +0200 | [diff] [blame] | 243 | 'analyze_driver_vs_reference_cipher_aead': { |
| 244 | 'test_function': do_analyze_driver_vs_reference, |
| 245 | 'args': { |
| 246 | 'component_ref': 'test_psa_crypto_config_reference_cipher_aead', |
| 247 | 'component_driver': 'test_psa_crypto_config_accel_cipher_aead', |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 248 | # Modules replaced by drivers. |
Valerio Setti | b6b301f | 2023-10-04 12:05:05 +0200 | [diff] [blame] | 249 | 'ignored_suites': [ |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 250 | # low-level (block/stream) cipher modules |
| 251 | 'aes', 'aria', 'camellia', 'des', 'chacha20', |
| 252 | # AEAD modes |
| 253 | 'ccm', 'chachapoly', 'cmac', 'gcm', |
| 254 | # The Cipher abstraction layer |
| 255 | 'cipher', |
Valerio Setti | b6b301f | 2023-10-04 12:05:05 +0200 | [diff] [blame] | 256 | ], |
| 257 | 'ignored_tests': { |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 258 | # PEM decryption is not supported so far. |
| 259 | # The rest of PEM (write, unencrypted read) works though. |
Valerio Setti | 7448cee | 2023-10-04 15:46:42 +0200 | [diff] [blame] | 260 | 'test_suite_pem': [ |
Manuel Pégourié-Gonnard | cd84a29 | 2023-10-27 09:24:44 +0200 | [diff] [blame] | 261 | re.compile(r'PEM read .*(AES|DES|\bencrypt).*'), |
Valerio Setti | 7448cee | 2023-10-04 15:46:42 +0200 | [diff] [blame] | 262 | ], |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 263 | 'test_suite_platform': [ |
| 264 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 265 | # component uses a sanitizer but the reference component |
| 266 | # doesn't, we have a PASS vs SKIP mismatch. |
| 267 | 'Check mbedtls_calloc overallocation', |
| 268 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 269 | # Following tests depend on AES_C/DES_C but are not about |
| 270 | # them really, just need to know some error code is there. |
Valerio Setti | 7448cee | 2023-10-04 15:46:42 +0200 | [diff] [blame] | 271 | 'test_suite_error': [ |
| 272 | 'Low and high error', |
| 273 | 'Single low error' |
| 274 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 275 | # Similar to test_suite_error above. |
Valerio Setti | 7448cee | 2023-10-04 15:46:42 +0200 | [diff] [blame] | 276 | 'test_suite_version': [ |
| 277 | 'Check for MBEDTLS_AES_C when already present', |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 278 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 279 | # The en/decryption part of PKCS#12 is not supported so far. |
| 280 | # The rest of PKCS#12 (key derivation) works though. |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 281 | 'test_suite_pkcs12': [ |
Manuel Pégourié-Gonnard | cd84a29 | 2023-10-27 09:24:44 +0200 | [diff] [blame] | 282 | re.compile(r'PBE Encrypt, .*'), |
| 283 | re.compile(r'PBE Decrypt, .*'), |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 284 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 285 | # The en/decryption part of PKCS#5 is not supported so far. |
| 286 | # The rest of PKCS#5 (PBKDF2) works though. |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 287 | 'test_suite_pkcs5': [ |
Manuel Pégourié-Gonnard | cd84a29 | 2023-10-27 09:24:44 +0200 | [diff] [blame] | 288 | re.compile(r'PBES2 Encrypt, .*'), |
| 289 | re.compile(r'PBES2 Decrypt .*'), |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 290 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 291 | # Encrypted keys are not supported so far. |
Valerio Setti | 5cd18f9 | 2023-10-13 15:14:07 +0200 | [diff] [blame] | 292 | # pylint: disable=line-too-long |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 293 | 'test_suite_pkparse': [ |
| 294 | 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)', |
| 295 | 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)', |
Pengyu Lv | a1ddcfa | 2023-11-28 09:46:01 +0800 | [diff] [blame] | 296 | re.compile(r'Parse (RSA|EC) Key .*\(.* ([Ee]ncrypted|password).*\)'), |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 297 | ], |
Valerio Setti | b6b301f | 2023-10-04 12:05:05 +0200 | [diff] [blame] | 298 | } |
| 299 | } |
| 300 | }, |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 301 | 'analyze_driver_vs_reference_ecp_light_only': { |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 302 | 'test_function': do_analyze_driver_vs_reference, |
| 303 | 'args': { |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 304 | 'component_ref': 'test_psa_crypto_config_reference_ecc_ecp_light_only', |
| 305 | 'component_driver': 'test_psa_crypto_config_accel_ecc_ecp_light_only', |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 306 | 'ignored_suites': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 307 | # Modules replaced by drivers |
| 308 | 'ecdsa', 'ecdh', 'ecjpake', |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 309 | ], |
| 310 | 'ignored_tests': { |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 311 | 'test_suite_platform': [ |
| 312 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 313 | # component uses a sanitizer but the reference component |
| 314 | # doesn't, we have a PASS vs SKIP mismatch. |
| 315 | 'Check mbedtls_calloc overallocation', |
| 316 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 317 | # This test wants a legacy function that takes f_rng, p_rng |
| 318 | # arguments, and uses legacy ECDSA for that. The test is |
| 319 | # really about the wrapper around the PSA RNG, not ECDSA. |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 320 | 'test_suite_random': [ |
| 321 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 322 | ], |
Valerio Setti | 0c477d3 | 2023-04-07 15:54:20 +0200 | [diff] [blame] | 323 | # In the accelerated test ECP_C is not set (only ECP_LIGHT is) |
| 324 | # so we must ignore disparities in the tests for which ECP_C |
| 325 | # is required. |
| 326 | 'test_suite_ecp': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 327 | re.compile(r'ECP check public-private .*'), |
| 328 | re.compile(r'ECP gen keypair .*'), |
| 329 | re.compile(r'ECP point muladd .*'), |
| 330 | re.compile(r'ECP point multiplication .*'), |
| 331 | re.compile(r'ECP test vectors .*'), |
Valerio Setti | 482a0b9 | 2023-08-18 15:55:10 +0200 | [diff] [blame] | 332 | ], |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 333 | 'test_suite_ssl': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 334 | # 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] | 335 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 336 | ], |
Valerio Setti | 5f54020 | 2023-06-30 17:20:49 +0200 | [diff] [blame] | 337 | } |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 338 | } |
| 339 | }, |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 340 | 'analyze_driver_vs_reference_no_ecp_at_all': { |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 341 | 'test_function': do_analyze_driver_vs_reference, |
| 342 | 'args': { |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 343 | 'component_ref': 'test_psa_crypto_config_reference_ecc_no_ecp_at_all', |
| 344 | 'component_driver': 'test_psa_crypto_config_accel_ecc_no_ecp_at_all', |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 345 | 'ignored_suites': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 346 | # Modules replaced by drivers |
| 347 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 348 | ], |
| 349 | 'ignored_tests': { |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 350 | 'test_suite_platform': [ |
| 351 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 352 | # component uses a sanitizer but the reference component |
| 353 | # doesn't, we have a PASS vs SKIP mismatch. |
| 354 | 'Check mbedtls_calloc overallocation', |
| 355 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 356 | # See ecp_light_only |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 357 | 'test_suite_random': [ |
| 358 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 359 | ], |
Valerio Setti | addeee4 | 2023-06-14 10:46:55 +0200 | [diff] [blame] | 360 | 'test_suite_pkparse': [ |
Valerio Setti | 5bd2523 | 2023-06-19 19:32:14 +0200 | [diff] [blame] | 361 | # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED |
| 362 | # is automatically enabled in build_info.h (backward compatibility) |
| 363 | # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a |
| 364 | # consequence compressed points are supported in the reference |
| 365 | # component but not in the accelerated one, so they should be skipped |
| 366 | # while checking driver's coverage. |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 367 | re.compile(r'Parse EC Key .*compressed\)'), |
| 368 | re.compile(r'Parse Public EC Key .*compressed\)'), |
Valerio Setti | addeee4 | 2023-06-14 10:46:55 +0200 | [diff] [blame] | 369 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 370 | # See ecp_light_only |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 371 | 'test_suite_ssl': [ |
| 372 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 373 | ], |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 374 | } |
| 375 | } |
| 376 | }, |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 377 | 'analyze_driver_vs_reference_ecc_no_bignum': { |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 378 | 'test_function': do_analyze_driver_vs_reference, |
| 379 | 'args': { |
| 380 | 'component_ref': 'test_psa_crypto_config_reference_ecc_no_bignum', |
| 381 | 'component_driver': 'test_psa_crypto_config_accel_ecc_no_bignum', |
| 382 | 'ignored_suites': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 383 | # Modules replaced by drivers |
| 384 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', |
| 385 | 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw', |
| 386 | 'bignum.generated', 'bignum.misc', |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 387 | ], |
| 388 | 'ignored_tests': { |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 389 | 'test_suite_platform': [ |
| 390 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 391 | # component uses a sanitizer but the reference component |
| 392 | # doesn't, we have a PASS vs SKIP mismatch. |
| 393 | 'Check mbedtls_calloc overallocation', |
| 394 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 395 | # See ecp_light_only |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 396 | 'test_suite_random': [ |
| 397 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 398 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 399 | # See no_ecp_at_all |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 400 | 'test_suite_pkparse': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 401 | re.compile(r'Parse EC Key .*compressed\)'), |
| 402 | re.compile(r'Parse Public EC Key .*compressed\)'), |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 403 | ], |
Valerio Setti | 9b3dbcc | 2023-07-26 18:00:31 +0200 | [diff] [blame] | 404 | 'test_suite_asn1parse': [ |
Valerio Setti | 9b3dbcc | 2023-07-26 18:00:31 +0200 | [diff] [blame] | 405 | 'INTEGER too large for mpi', |
| 406 | ], |
| 407 | 'test_suite_asn1write': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 408 | re.compile(r'ASN.1 Write mpi.*'), |
Valerio Setti | 9b3dbcc | 2023-07-26 18:00:31 +0200 | [diff] [blame] | 409 | ], |
Valerio Setti | e0be95e | 2023-08-01 09:07:43 +0200 | [diff] [blame] | 410 | 'test_suite_debug': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 411 | re.compile(r'Debug print mbedtls_mpi.*'), |
Valerio Setti | e0be95e | 2023-08-01 09:07:43 +0200 | [diff] [blame] | 412 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 413 | # See ecp_light_only |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 414 | 'test_suite_ssl': [ |
| 415 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 416 | ], |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 417 | } |
| 418 | } |
| 419 | }, |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 420 | 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': { |
| 421 | 'test_function': do_analyze_driver_vs_reference, |
| 422 | 'args': { |
| 423 | 'component_ref': 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum', |
| 424 | 'component_driver': 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum', |
| 425 | 'ignored_suites': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 426 | # Modules replaced by drivers |
| 427 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm', |
| 428 | 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw', |
| 429 | 'bignum.generated', 'bignum.misc', |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 430 | ], |
| 431 | 'ignored_tests': { |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 432 | 'test_suite_platform': [ |
| 433 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 434 | # component uses a sanitizer but the reference component |
| 435 | # doesn't, we have a PASS vs SKIP mismatch. |
| 436 | 'Check mbedtls_calloc overallocation', |
| 437 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 438 | # See ecp_light_only |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 439 | 'test_suite_random': [ |
| 440 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 441 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 442 | # See no_ecp_at_all |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 443 | 'test_suite_pkparse': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 444 | re.compile(r'Parse EC Key .*compressed\)'), |
| 445 | re.compile(r'Parse Public EC Key .*compressed\)'), |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 446 | ], |
| 447 | 'test_suite_asn1parse': [ |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 448 | 'INTEGER too large for mpi', |
| 449 | ], |
| 450 | 'test_suite_asn1write': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 451 | re.compile(r'ASN.1 Write mpi.*'), |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 452 | ], |
| 453 | 'test_suite_debug': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 454 | re.compile(r'Debug print mbedtls_mpi.*'), |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 455 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 456 | # See ecp_light_only |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 457 | 'test_suite_ssl': [ |
| 458 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 459 | ], |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 460 | } |
| 461 | } |
| 462 | }, |
Przemek Stekiel | 85b6442 | 2023-05-26 09:55:23 +0200 | [diff] [blame] | 463 | 'analyze_driver_vs_reference_ffdh_alg': { |
| 464 | 'test_function': do_analyze_driver_vs_reference, |
| 465 | 'args': { |
| 466 | 'component_ref': 'test_psa_crypto_config_reference_ffdh', |
| 467 | 'component_driver': 'test_psa_crypto_config_accel_ffdh', |
Przemek Stekiel | 84f4ff1 | 2023-07-04 12:35:31 +0200 | [diff] [blame] | 468 | 'ignored_suites': ['dhm'], |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 469 | 'ignored_tests': { |
| 470 | 'test_suite_platform': [ |
| 471 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 472 | # component uses a sanitizer but the reference component |
| 473 | # doesn't, we have a PASS vs SKIP mismatch. |
| 474 | 'Check mbedtls_calloc overallocation', |
| 475 | ], |
| 476 | } |
Przemek Stekiel | 85b6442 | 2023-05-26 09:55:23 +0200 | [diff] [blame] | 477 | } |
| 478 | }, |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 479 | 'analyze_driver_vs_reference_tfm_config': { |
| 480 | 'test_function': do_analyze_driver_vs_reference, |
| 481 | 'args': { |
| 482 | 'component_ref': 'test_tfm_config', |
| 483 | 'component_driver': 'test_tfm_config_p256m_driver_accel_ec', |
Manuel Pégourié-Gonnard | e9d9797 | 2023-08-08 18:34:47 +0200 | [diff] [blame] | 484 | 'ignored_suites': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 485 | # Modules replaced by drivers |
Yanray Wang | 5779096 | 2023-10-31 13:39:07 +0800 | [diff] [blame] | 486 | 'asn1parse', 'asn1write', |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 487 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', |
| 488 | 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw', |
| 489 | 'bignum.generated', 'bignum.misc', |
Manuel Pégourié-Gonnard | e9d9797 | 2023-08-08 18:34:47 +0200 | [diff] [blame] | 490 | ], |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 491 | 'ignored_tests': { |
Gilles Peskine | 150002c | 2023-11-27 18:24:45 +0100 | [diff] [blame] | 492 | 'test_suite_platform': [ |
| 493 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 494 | # component uses a sanitizer but the reference component |
| 495 | # doesn't, we have a PASS vs SKIP mismatch. |
| 496 | 'Check mbedtls_calloc overallocation', |
| 497 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 498 | # See ecp_light_only |
Manuel Pégourié-Gonnard | e9d9797 | 2023-08-08 18:34:47 +0200 | [diff] [blame] | 499 | 'test_suite_random': [ |
| 500 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 501 | ], |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 502 | } |
| 503 | } |
Pengyu Lv | 3cd16c4 | 2023-12-06 18:17:39 +0800 | [diff] [blame] | 504 | }, |
| 505 | 'analyze_driver_vs_reference_rsa': { |
| 506 | 'test_function': do_analyze_driver_vs_reference, |
| 507 | 'args': { |
| 508 | 'component_ref': 'test_psa_crypto_config_reference_rsa_crypto', |
| 509 | 'component_driver': 'test_psa_crypto_config_accel_rsa_crypto', |
| 510 | 'ignored_suites': [ |
| 511 | # Modules replaced by drivers. |
| 512 | 'rsa', 'pkcs1_v15', 'pkcs1_v21', |
Pengyu Lv | 98a90c6 | 2023-12-07 17:23:25 +0800 | [diff] [blame] | 513 | # We temporarily don't care about PK stuff. |
Pengyu Lv | 3cd16c4 | 2023-12-06 18:17:39 +0800 | [diff] [blame] | 514 | 'pk', 'pkwrite', 'pkparse' |
| 515 | ], |
| 516 | 'ignored_tests': { |
| 517 | 'test_suite_platform': [ |
| 518 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 519 | # component uses a sanitizer but the reference component |
| 520 | # doesn't, we have a PASS vs SKIP mismatch. |
| 521 | 'Check mbedtls_calloc overallocation', |
| 522 | ], |
| 523 | # Following tests depend on RSA_C but are not about |
| 524 | # them really, just need to know some error code is there. |
| 525 | 'test_suite_error': [ |
| 526 | 'Low and high error', |
| 527 | 'Single high error' |
| 528 | ], |
| 529 | # Constant time operations only used for PKCS1_V15 |
| 530 | 'test_suite_constant_time': [ |
| 531 | re.compile(r'mbedtls_ct_zeroize_if .*'), |
| 532 | re.compile(r'mbedtls_ct_memmove_left .*') |
| 533 | ], |
| 534 | } |
| 535 | } |
Valerio Setti | 52ab8fa | 2023-12-14 18:04:04 +0100 | [diff] [blame^] | 536 | }, |
| 537 | 'analyze_block_cipher_dispatch': { |
| 538 | 'test_function': do_analyze_driver_vs_reference, |
| 539 | 'args': { |
| 540 | 'component_ref': 'test_full_common_reference', |
| 541 | 'component_driver': 'test_full_block_cipher_psa_dispatch', |
| 542 | 'ignored_suites': [ |
| 543 | ], |
| 544 | 'ignored_tests': { |
| 545 | 'test_suite_platform': [ |
| 546 | # Incompatible with sanitizers (e.g. ASan). If the driver |
| 547 | # component uses a sanitizer but the reference component |
| 548 | # doesn't, we have a PASS vs SKIP mismatch. |
| 549 | 'Check mbedtls_calloc overallocation', |
| 550 | ], |
| 551 | } |
| 552 | } |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 553 | } |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 554 | } |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 555 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 556 | def main(): |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame] | 557 | main_results = Results() |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 558 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 559 | try: |
| 560 | parser = argparse.ArgumentParser(description=__doc__) |
Przemek Stekiel | 58bbc23 | 2022-10-24 08:10:10 +0200 | [diff] [blame] | 561 | parser.add_argument('outcomes', metavar='OUTCOMES.CSV', |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 562 | help='Outcome file to analyze') |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 563 | parser.add_argument('specified_tasks', default='all', nargs='?', |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 564 | help='Analysis to be done. By default, run all tasks. ' |
| 565 | 'With one or more TASK, run only those. ' |
| 566 | 'TASK can be the name of a single task or ' |
Przemek Stekiel | 85c54ea | 2022-11-17 11:50:23 +0100 | [diff] [blame] | 567 | 'comma/space-separated list of tasks. ') |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 568 | parser.add_argument('--list', action='store_true', |
| 569 | help='List all available tasks and exit.') |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 570 | parser.add_argument('--require-full-coverage', action='store_true', |
| 571 | dest='full_coverage', help="Require all available " |
| 572 | "test cases to be executed and issue an error " |
| 573 | "otherwise. This flag is ignored if 'task' is " |
| 574 | "neither 'all' nor 'analyze_coverage'") |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 575 | options = parser.parse_args() |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 576 | |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 577 | if options.list: |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 578 | for task in KNOWN_TASKS: |
Valerio Setti | 5329ff0 | 2023-10-17 09:44:36 +0200 | [diff] [blame] | 579 | print(task) |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 580 | sys.exit(0) |
| 581 | |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 582 | if options.specified_tasks == 'all': |
| 583 | tasks_list = KNOWN_TASKS.keys() |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 584 | else: |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 585 | tasks_list = re.split(r'[, ]+', options.specified_tasks) |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 586 | for task in tasks_list: |
| 587 | if task not in KNOWN_TASKS: |
Manuel Pégourié-Gonnard | 62d6131 | 2023-10-20 10:51:57 +0200 | [diff] [blame] | 588 | sys.stderr.write('invalid task: {}\n'.format(task)) |
Valerio Setti | fb2750e | 2023-10-17 10:11:45 +0200 | [diff] [blame] | 589 | sys.exit(2) |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 590 | |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 591 | KNOWN_TASKS['analyze_coverage']['args']['full_coverage'] = options.full_coverage |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 592 | |
Pengyu Lv | dd1d6a7 | 2023-11-27 17:57:31 +0800 | [diff] [blame] | 593 | # If the outcome file exists, parse it once and share the result |
| 594 | # among tasks to improve performance. |
Pengyu Lv | 20e3ca3 | 2023-11-28 15:30:03 +0800 | [diff] [blame] | 595 | # Otherwise, it will be generated by execute_reference_driver_tests. |
| 596 | if not os.path.exists(options.outcomes): |
| 597 | if len(tasks_list) > 1: |
| 598 | sys.stderr.write("mutiple tasks found, please provide a valid outcomes file.\n") |
| 599 | sys.exit(2) |
| 600 | |
| 601 | task_name = tasks_list[0] |
| 602 | task = KNOWN_TASKS[task_name] |
Pengyu Lv | c2e8f3a | 2023-11-28 17:22:04 +0800 | [diff] [blame] | 603 | if 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] | 604 | sys.stderr.write("please provide valid outcomes file for {}.\n".format(task_name)) |
| 605 | sys.exit(2) |
| 606 | |
| 607 | execute_reference_driver_tests(main_results, |
| 608 | task['args']['component_ref'], |
| 609 | task['args']['component_driver'], |
| 610 | options.outcomes) |
| 611 | |
| 612 | outcomes = read_outcome_file(options.outcomes) |
Pengyu Lv | a6cf5d6 | 2023-11-22 11:35:21 +0800 | [diff] [blame] | 613 | |
Valerio Setti | fb2750e | 2023-10-17 10:11:45 +0200 | [diff] [blame] | 614 | for task in tasks_list: |
| 615 | test_function = KNOWN_TASKS[task]['test_function'] |
| 616 | test_args = KNOWN_TASKS[task]['args'] |
Pengyu Lv | 20e3ca3 | 2023-11-28 15:30:03 +0800 | [diff] [blame] | 617 | test_function(main_results, outcomes, test_args) |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 618 | |
Valerio Setti | f6f64cf | 2023-10-17 12:28:26 +0200 | [diff] [blame] | 619 | main_results.info("Overall results: {} warnings and {} errors", |
| 620 | main_results.warning_count, main_results.error_count) |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 621 | |
Valerio Setti | 8d178be | 2023-10-17 12:23:55 +0200 | [diff] [blame] | 622 | sys.exit(0 if (main_results.error_count == 0) else 1) |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 623 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 624 | except Exception: # pylint: disable=broad-except |
| 625 | # Print the backtrace and exit explicitly with our chosen status. |
| 626 | traceback.print_exc() |
| 627 | sys.exit(120) |
| 628 | |
| 629 | if __name__ == '__main__': |
| 630 | main() |