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 |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 15 | |
Gilles Peskine | 8d3c70a | 2020-06-25 18:37:43 +0200 | [diff] [blame] | 16 | import check_test_cases |
| 17 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 18 | class Results: |
| 19 | """Process analysis results.""" |
| 20 | |
| 21 | def __init__(self): |
| 22 | self.error_count = 0 |
| 23 | self.warning_count = 0 |
| 24 | |
Valerio Setti | 2cff820 | 2023-10-18 14:36:47 +0200 | [diff] [blame] | 25 | def new_section(self, fmt, *args, **kwargs): |
| 26 | self._print_line('\n*** ' + fmt + ' ***\n', *args, **kwargs) |
| 27 | |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 28 | def info(self, fmt, *args, **kwargs): |
Valerio Setti | 8070dbe | 2023-10-17 12:29:30 +0200 | [diff] [blame] | 29 | self._print_line('Info: ' + fmt, *args, **kwargs) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 30 | |
| 31 | def error(self, fmt, *args, **kwargs): |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 32 | self.error_count += 1 |
Valerio Setti | 8070dbe | 2023-10-17 12:29:30 +0200 | [diff] [blame] | 33 | self._print_line('Error: ' + fmt, *args, **kwargs) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 34 | |
| 35 | def warning(self, fmt, *args, **kwargs): |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 36 | self.warning_count += 1 |
Valerio Setti | 8070dbe | 2023-10-17 12:29:30 +0200 | [diff] [blame] | 37 | self._print_line('Warning: ' + fmt, *args, **kwargs) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 38 | |
Valerio Setti | 3f33989 | 2023-10-17 10:42:11 +0200 | [diff] [blame] | 39 | @staticmethod |
Valerio Setti | 8070dbe | 2023-10-17 12:29:30 +0200 | [diff] [blame] | 40 | def _print_line(fmt, *args, **kwargs): |
Valerio Setti | 735794c | 2023-10-18 08:05:15 +0200 | [diff] [blame] | 41 | sys.stderr.write((fmt + '\n').format(*args, **kwargs)) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 42 | |
| 43 | class TestCaseOutcomes: |
| 44 | """The outcomes of one test case across many configurations.""" |
| 45 | # pylint: disable=too-few-public-methods |
| 46 | |
| 47 | def __init__(self): |
Gilles Peskine | 3d863f2 | 2020-06-26 13:02:30 +0200 | [diff] [blame] | 48 | # Collect a list of witnesses of the test case succeeding or failing. |
| 49 | # Currently we don't do anything with witnesses except count them. |
| 50 | # The format of a witness is determined by the read_outcome_file |
| 51 | # function; it's the platform and configuration joined by ';'. |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 52 | self.successes = [] |
| 53 | self.failures = [] |
| 54 | |
| 55 | def hits(self): |
| 56 | """Return the number of times a test case has been run. |
| 57 | |
| 58 | This includes passes and failures, but not skips. |
| 59 | """ |
| 60 | return len(self.successes) + len(self.failures) |
| 61 | |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame] | 62 | def execute_reference_driver_tests(results: Results, ref_component, driver_component, \ |
Valerio Setti | 781c234 | 2023-10-17 12:47:35 +0200 | [diff] [blame] | 63 | outcome_file): |
Valerio Setti | 22992a0 | 2023-03-29 11:15:28 +0200 | [diff] [blame] | 64 | """Run the tests specified in ref_component and driver_component. Results |
| 65 | 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] | 66 | coverage analysis""" |
| 67 | # If the outcome file already exists, we assume that the user wants to |
| 68 | # perform the comparison analysis again without repeating the tests. |
| 69 | if os.path.exists(outcome_file): |
Valerio Setti | 39d4b9d | 2023-10-18 14:30:03 +0200 | [diff] [blame] | 70 | results.info("Outcome file ({}) already exists. Tests will be skipped.", outcome_file) |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 71 | return |
| 72 | |
| 73 | shell_command = "tests/scripts/all.sh --outcome-file " + outcome_file + \ |
| 74 | " " + ref_component + " " + driver_component |
Valerio Setti | 39d4b9d | 2023-10-18 14:30:03 +0200 | [diff] [blame] | 75 | results.info("Running: {}", shell_command) |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 76 | ret_val = subprocess.run(shell_command.split(), check=False).returncode |
| 77 | |
| 78 | if ret_val != 0: |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame] | 79 | results.error("failed to run reference/driver components") |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 80 | |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 81 | def analyze_coverage(results, outcomes, allow_list, full_coverage): |
Gilles Peskine | 8d3c70a | 2020-06-25 18:37:43 +0200 | [diff] [blame] | 82 | """Check that all available test cases are executed at least once.""" |
Gilles Peskine | 686c292 | 2022-01-07 15:58:38 +0100 | [diff] [blame] | 83 | available = check_test_cases.collect_available_test_cases() |
Gilles Peskine | 8d3c70a | 2020-06-25 18:37:43 +0200 | [diff] [blame] | 84 | for key in available: |
| 85 | hits = outcomes[key].hits() if key in outcomes else 0 |
Tomás González | 07bdcc2 | 2023-08-11 14:59:03 +0100 | [diff] [blame] | 86 | if hits == 0 and key not in allow_list: |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 87 | if full_coverage: |
| 88 | results.error('Test case not executed: {}', key) |
| 89 | else: |
| 90 | results.warning('Test case not executed: {}', key) |
Tomás González | 07bdcc2 | 2023-08-11 14:59:03 +0100 | [diff] [blame] | 91 | elif hits != 0 and key in allow_list: |
| 92 | # Test Case should be removed from the allow list. |
Tomás González | 7ebb18f | 2023-08-22 09:40:23 +0100 | [diff] [blame] | 93 | if full_coverage: |
Tomás González | a063144 | 2023-08-22 12:17:57 +0100 | [diff] [blame] | 94 | results.error('Allow listed test case was executed: {}', key) |
Tomás González | 7ebb18f | 2023-08-22 09:40:23 +0100 | [diff] [blame] | 95 | else: |
| 96 | results.warning('Allow listed test case was executed: {}', key) |
Gilles Peskine | 8d3c70a | 2020-06-25 18:37:43 +0200 | [diff] [blame] | 97 | |
Manuel Pégourié-Gonnard | 881ce01 | 2023-10-18 10:22:07 +0200 | [diff] [blame] | 98 | def name_matches_pattern(name, str_or_re): |
| 99 | """Check if name matches a pattern, that may be a string or regex. |
| 100 | - If the pattern is a string, name must be equal to match. |
| 101 | - If the pattern is a regex, name must fully match. |
| 102 | """ |
Manuel Pégourié-Gonnard | b269543 | 2023-10-23 09:30:40 +0200 | [diff] [blame] | 103 | # The CI's python is too old for re.Pattern |
| 104 | #if isinstance(str_or_re, re.Pattern): |
| 105 | if not isinstance(str_or_re, str): |
Manuel Pégourié-Gonnard | 9d9c234 | 2023-10-26 09:37:40 +0200 | [diff] [blame] | 106 | return str_or_re.fullmatch(name) |
Manuel Pégourié-Gonnard | 881ce01 | 2023-10-18 10:22:07 +0200 | [diff] [blame] | 107 | else: |
Manuel Pégourié-Gonnard | 9d9c234 | 2023-10-26 09:37:40 +0200 | [diff] [blame] | 108 | return str_or_re == name |
Manuel Pégourié-Gonnard | 881ce01 | 2023-10-18 10:22:07 +0200 | [diff] [blame] | 109 | |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame] | 110 | def analyze_driver_vs_reference(results: Results, outcomes, |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 111 | component_ref, component_driver, |
Manuel Pégourié-Gonnard | 881ce01 | 2023-10-18 10:22:07 +0200 | [diff] [blame] | 112 | ignored_suites, ignored_tests=None): |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 113 | """Check that all tests executed in the reference component are also |
| 114 | executed in the corresponding driver component. |
Valerio Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 115 | Skip: |
| 116 | - full test suites provided in ignored_suites list |
| 117 | - only some specific test inside a test suite, for which the corresponding |
| 118 | output string is provided |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 119 | """ |
Manuel Pégourié-Gonnard | 371165a | 2023-10-18 12:44:54 +0200 | [diff] [blame] | 120 | seen_reference_passing = False |
| 121 | for key in outcomes: |
Manuel Pégourié-Gonnard | 4da369f | 2023-10-18 09:40:32 +0200 | [diff] [blame] | 122 | # key is like "test_suite_foo.bar;Description of test case" |
| 123 | (full_test_suite, test_string) = key.split(';') |
Valerio Setti | 00c1ccb | 2023-02-02 11:33:31 +0100 | [diff] [blame] | 124 | 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] | 125 | |
| 126 | # Immediately skip fully-ignored test suites |
Manuel Pégourié-Gonnard | 7d381f5 | 2023-03-17 15:13:08 +0100 | [diff] [blame] | 127 | 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] | 128 | continue |
Manuel Pégourié-Gonnard | 371165a | 2023-10-18 12:44:54 +0200 | [diff] [blame] | 129 | |
| 130 | # For ignored test cases inside test suites, just remember and: |
| 131 | # don't issue an error if they're skipped with drivers, |
| 132 | # but issue an error if they're not (means we have a bad entry). |
| 133 | ignored = False |
Manuel Pégourié-Gonnard | 881ce01 | 2023-10-18 10:22:07 +0200 | [diff] [blame] | 134 | if full_test_suite in ignored_tests: |
Manuel Pégourié-Gonnard | d36a37f | 2023-10-26 09:41:59 +0200 | [diff] [blame] | 135 | for str_or_re in ignored_tests[test_suite]: |
Manuel Pégourié-Gonnard | 881ce01 | 2023-10-18 10:22:07 +0200 | [diff] [blame] | 136 | if name_matches_pattern(test_string, str_or_re): |
Manuel Pégourié-Gonnard | 371165a | 2023-10-18 12:44:54 +0200 | [diff] [blame] | 137 | ignored = True |
Manuel Pégourié-Gonnard | 4da369f | 2023-10-18 09:40:32 +0200 | [diff] [blame] | 138 | |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 139 | # Search for tests that run in reference component and not in driver component |
| 140 | driver_test_passed = False |
| 141 | reference_test_passed = False |
| 142 | for entry in outcomes[key].successes: |
Przemek Stekiel | 51f30ff | 2022-11-09 12:07:29 +0100 | [diff] [blame] | 143 | if component_driver in entry: |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 144 | driver_test_passed = True |
Przemek Stekiel | 51f30ff | 2022-11-09 12:07:29 +0100 | [diff] [blame] | 145 | if component_ref in entry: |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 146 | reference_test_passed = True |
Manuel Pégourié-Gonnard | 371165a | 2023-10-18 12:44:54 +0200 | [diff] [blame] | 147 | seen_reference_passing = True |
Manuel Pégourié-Gonnard | c51c411 | 2023-10-30 10:21:22 +0100 | [diff] [blame] | 148 | if reference_test_passed and not driver_test_passed and not ignored: |
| 149 | results.error("PASS -> SKIP/FAIL: {}", key) |
| 150 | if ignored and driver_test_passed: |
| 151 | results.error("uselessly ignored: {}", key) |
Manuel Pégourié-Gonnard | 371165a | 2023-10-18 12:44:54 +0200 | [diff] [blame] | 152 | |
| 153 | if not seen_reference_passing: |
| 154 | results.error("no passing test in reference component: bad outcome file?") |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 155 | |
Valerio Setti | 781c234 | 2023-10-17 12:47:35 +0200 | [diff] [blame] | 156 | def analyze_outcomes(results: Results, outcomes, args): |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 157 | """Run all analyses on the given outcome collection.""" |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 158 | analyze_coverage(results, outcomes, args['allow_list'], |
| 159 | args['full_coverage']) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 160 | |
| 161 | def read_outcome_file(outcome_file): |
| 162 | """Parse an outcome file and return an outcome collection. |
| 163 | |
| 164 | An outcome collection is a dictionary mapping keys to TestCaseOutcomes objects. |
| 165 | The keys are the test suite name and the test case description, separated |
| 166 | by a semicolon. |
| 167 | """ |
| 168 | outcomes = {} |
| 169 | with open(outcome_file, 'r', encoding='utf-8') as input_file: |
| 170 | for line in input_file: |
| 171 | (platform, config, suite, case, result, _cause) = line.split(';') |
| 172 | key = ';'.join([suite, case]) |
| 173 | setup = ';'.join([platform, config]) |
| 174 | if key not in outcomes: |
| 175 | outcomes[key] = TestCaseOutcomes() |
| 176 | if result == 'PASS': |
| 177 | outcomes[key].successes.append(setup) |
| 178 | elif result == 'FAIL': |
| 179 | outcomes[key].failures.append(setup) |
| 180 | return outcomes |
| 181 | |
Valerio Setti | 781c234 | 2023-10-17 12:47:35 +0200 | [diff] [blame] | 182 | def do_analyze_coverage(results: Results, outcome_file, args): |
Przemek Stekiel | 6856f4c | 2022-11-09 10:50:29 +0100 | [diff] [blame] | 183 | """Perform coverage analysis.""" |
Valerio Setti | 2cff820 | 2023-10-18 14:36:47 +0200 | [diff] [blame] | 184 | results.new_section("Analyze coverage") |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 185 | outcomes = read_outcome_file(outcome_file) |
Valerio Setti | 781c234 | 2023-10-17 12:47:35 +0200 | [diff] [blame] | 186 | analyze_outcomes(results, outcomes, args) |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 187 | |
Valerio Setti | 781c234 | 2023-10-17 12:47:35 +0200 | [diff] [blame] | 188 | def do_analyze_driver_vs_reference(results: Results, outcome_file, args): |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 189 | """Perform driver vs reference analyze.""" |
Valerio Setti | 2cff820 | 2023-10-18 14:36:47 +0200 | [diff] [blame] | 190 | results.new_section("Analyze driver {} vs reference {}", |
| 191 | args['component_driver'], args['component_ref']) |
Valerio Setti | b0c618e | 2023-10-16 14:19:49 +0200 | [diff] [blame] | 192 | |
Valerio Setti | 781c234 | 2023-10-17 12:47:35 +0200 | [diff] [blame] | 193 | execute_reference_driver_tests(results, args['component_ref'], \ |
| 194 | args['component_driver'], outcome_file) |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 195 | |
Valerio Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 196 | ignored_suites = ['test_suite_' + x for x in args['ignored_suites']] |
Przemek Stekiel | 51f30ff | 2022-11-09 12:07:29 +0100 | [diff] [blame] | 197 | |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 198 | outcomes = read_outcome_file(outcome_file) |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [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 | |
Przemek Stekiel | 6856f4c | 2022-11-09 10:50:29 +0100 | [diff] [blame] | 204 | # 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] | 205 | KNOWN_TASKS = { |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 206 | 'analyze_coverage': { |
| 207 | 'test_function': do_analyze_coverage, |
Tomás González | 07bdcc2 | 2023-08-11 14:59:03 +0100 | [diff] [blame] | 208 | 'args': { |
Tomás González | 358c6c6 | 2023-08-14 15:43:46 +0100 | [diff] [blame] | 209 | 'allow_list': [ |
Tomás González | 5022311 | 2023-08-22 09:52:06 +0100 | [diff] [blame] | 210 | # Algorithm not supported yet |
| 211 | 'test_suite_psa_crypto_metadata;Asymmetric signature: pure EdDSA', |
| 212 | # Algorithm not supported yet |
| 213 | 'test_suite_psa_crypto_metadata;Cipher: XTS', |
Tomás González | d43cab3 | 2023-08-24 09:12:40 +0100 | [diff] [blame] | 214 | ], |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 215 | 'full_coverage': False, |
Tomás González | 07bdcc2 | 2023-08-11 14:59:03 +0100 | [diff] [blame] | 216 | } |
Tomás González | d43cab3 | 2023-08-24 09:12:40 +0100 | [diff] [blame] | 217 | }, |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 218 | # There are 2 options to use analyze_driver_vs_reference_xxx locally: |
| 219 | # 1. Run tests and then analysis: |
| 220 | # - tests/scripts/all.sh --outcome-file "$PWD/out.csv" <component_ref> <component_driver> |
| 221 | # - tests/scripts/analyze_outcomes.py out.csv analyze_driver_vs_reference_xxx |
| 222 | # 2. Let this script run both automatically: |
| 223 | # - tests/scripts/analyze_outcomes.py out.csv analyze_driver_vs_reference_xxx |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 224 | 'analyze_driver_vs_reference_hash': { |
| 225 | 'test_function': do_analyze_driver_vs_reference, |
| 226 | 'args': { |
Przemek Stekiel | 51f30ff | 2022-11-09 12:07:29 +0100 | [diff] [blame] | 227 | 'component_ref': 'test_psa_crypto_config_reference_hash_use_psa', |
| 228 | 'component_driver': 'test_psa_crypto_config_accel_hash_use_psa', |
Manuel Pégourié-Gonnard | 10e3963 | 2022-12-29 12:29:09 +0100 | [diff] [blame] | 229 | 'ignored_suites': [ |
| 230 | 'shax', 'mdx', # the software implementations that are being excluded |
Manuel Pégourié-Gonnard | 7d381f5 | 2023-03-17 15:13:08 +0100 | [diff] [blame] | 231 | 'md.psa', # purposefully depends on whether drivers are present |
Gilles Peskine | 35b49c4 | 2023-10-04 12:28:41 +0200 | [diff] [blame] | 232 | 'psa_crypto_low_hash.generated', # testing the builtins |
Valerio Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 233 | ], |
| 234 | 'ignored_tests': { |
| 235 | } |
| 236 | } |
| 237 | }, |
Valerio Setti | b6b301f | 2023-10-04 12:05:05 +0200 | [diff] [blame] | 238 | 'analyze_driver_vs_reference_cipher_aead': { |
| 239 | 'test_function': do_analyze_driver_vs_reference, |
| 240 | 'args': { |
| 241 | 'component_ref': 'test_psa_crypto_config_reference_cipher_aead', |
| 242 | 'component_driver': 'test_psa_crypto_config_accel_cipher_aead', |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 243 | # Modules replaced by drivers. |
Valerio Setti | b6b301f | 2023-10-04 12:05:05 +0200 | [diff] [blame] | 244 | 'ignored_suites': [ |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 245 | # low-level (block/stream) cipher modules |
| 246 | 'aes', 'aria', 'camellia', 'des', 'chacha20', |
| 247 | # AEAD modes |
| 248 | 'ccm', 'chachapoly', 'cmac', 'gcm', |
| 249 | # The Cipher abstraction layer |
| 250 | 'cipher', |
Valerio Setti | b6b301f | 2023-10-04 12:05:05 +0200 | [diff] [blame] | 251 | ], |
| 252 | 'ignored_tests': { |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 253 | # PEM decryption is not supported so far. |
| 254 | # The rest of PEM (write, unencrypted read) works though. |
Valerio Setti | 7448cee | 2023-10-04 15:46:42 +0200 | [diff] [blame] | 255 | 'test_suite_pem': [ |
Manuel Pégourié-Gonnard | cd84a29 | 2023-10-27 09:24:44 +0200 | [diff] [blame] | 256 | re.compile(r'PEM read .*(AES|DES|\bencrypt).*'), |
Valerio Setti | 7448cee | 2023-10-04 15:46:42 +0200 | [diff] [blame] | 257 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 258 | # Following tests depend on AES_C/DES_C but are not about |
| 259 | # them really, just need to know some error code is there. |
Valerio Setti | 7448cee | 2023-10-04 15:46:42 +0200 | [diff] [blame] | 260 | 'test_suite_error': [ |
| 261 | 'Low and high error', |
| 262 | 'Single low error' |
| 263 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 264 | # Similar to test_suite_error above. |
Valerio Setti | 7448cee | 2023-10-04 15:46:42 +0200 | [diff] [blame] | 265 | 'test_suite_version': [ |
| 266 | 'Check for MBEDTLS_AES_C when already present', |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 267 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 268 | # The en/decryption part of PKCS#12 is not supported so far. |
| 269 | # The rest of PKCS#12 (key derivation) works though. |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 270 | 'test_suite_pkcs12': [ |
Manuel Pégourié-Gonnard | cd84a29 | 2023-10-27 09:24:44 +0200 | [diff] [blame] | 271 | re.compile(r'PBE Encrypt, .*'), |
| 272 | re.compile(r'PBE Decrypt, .*'), |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 273 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 274 | # The en/decryption part of PKCS#5 is not supported so far. |
| 275 | # The rest of PKCS#5 (PBKDF2) works though. |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 276 | 'test_suite_pkcs5': [ |
Manuel Pégourié-Gonnard | cd84a29 | 2023-10-27 09:24:44 +0200 | [diff] [blame] | 277 | re.compile(r'PBES2 Encrypt, .*'), |
| 278 | re.compile(r'PBES2 Decrypt .*'), |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 279 | ], |
Valerio Setti | 507e08f | 2023-10-26 09:44:06 +0200 | [diff] [blame] | 280 | # Encrypted keys are not supported so far. |
Valerio Setti | 5cd18f9 | 2023-10-13 15:14:07 +0200 | [diff] [blame] | 281 | # pylint: disable=line-too-long |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 282 | 'test_suite_pkparse': [ |
| 283 | 'Key ASN1 (Encrypted key PKCS12, trailing garbage data)', |
| 284 | 'Key ASN1 (Encrypted key PKCS5, trailing garbage data)', |
Manuel Pégourié-Gonnard | cd84a29 | 2023-10-27 09:24:44 +0200 | [diff] [blame] | 285 | re.compile(r'Parse RSA Key .*\(PKCS#8 encrypted .*\)'), |
Valerio Setti | 9394144 | 2023-10-13 09:19:52 +0200 | [diff] [blame] | 286 | ], |
Valerio Setti | b6b301f | 2023-10-04 12:05:05 +0200 | [diff] [blame] | 287 | } |
| 288 | } |
| 289 | }, |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 290 | 'analyze_driver_vs_reference_ecp_light_only': { |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 291 | 'test_function': do_analyze_driver_vs_reference, |
| 292 | 'args': { |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 293 | 'component_ref': 'test_psa_crypto_config_reference_ecc_ecp_light_only', |
| 294 | 'component_driver': 'test_psa_crypto_config_accel_ecc_ecp_light_only', |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 295 | 'ignored_suites': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 296 | # Modules replaced by drivers |
| 297 | 'ecdsa', 'ecdh', 'ecjpake', |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 298 | ], |
| 299 | 'ignored_tests': { |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 300 | # This test wants a legacy function that takes f_rng, p_rng |
| 301 | # arguments, and uses legacy ECDSA for that. The test is |
| 302 | # really about the wrapper around the PSA RNG, not ECDSA. |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 303 | 'test_suite_random': [ |
| 304 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 305 | ], |
Valerio Setti | 0c477d3 | 2023-04-07 15:54:20 +0200 | [diff] [blame] | 306 | # In the accelerated test ECP_C is not set (only ECP_LIGHT is) |
| 307 | # so we must ignore disparities in the tests for which ECP_C |
| 308 | # is required. |
| 309 | 'test_suite_ecp': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 310 | re.compile(r'ECP check public-private .*'), |
| 311 | re.compile(r'ECP gen keypair .*'), |
| 312 | re.compile(r'ECP point muladd .*'), |
| 313 | re.compile(r'ECP point multiplication .*'), |
| 314 | re.compile(r'ECP test vectors .*'), |
Valerio Setti | 482a0b9 | 2023-08-18 15:55:10 +0200 | [diff] [blame] | 315 | ], |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 316 | 'test_suite_ssl': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 317 | # 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] | 318 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 319 | ], |
Valerio Setti | 5f54020 | 2023-06-30 17:20:49 +0200 | [diff] [blame] | 320 | } |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 321 | } |
| 322 | }, |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 323 | 'analyze_driver_vs_reference_no_ecp_at_all': { |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 324 | 'test_function': do_analyze_driver_vs_reference, |
| 325 | 'args': { |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 326 | 'component_ref': 'test_psa_crypto_config_reference_ecc_no_ecp_at_all', |
| 327 | 'component_driver': 'test_psa_crypto_config_accel_ecc_no_ecp_at_all', |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 328 | 'ignored_suites': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 329 | # Modules replaced by drivers |
| 330 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 331 | ], |
| 332 | 'ignored_tests': { |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 333 | # See ecp_light_only |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 334 | 'test_suite_random': [ |
| 335 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 336 | ], |
Valerio Setti | addeee4 | 2023-06-14 10:46:55 +0200 | [diff] [blame] | 337 | 'test_suite_pkparse': [ |
Valerio Setti | 5bd2523 | 2023-06-19 19:32:14 +0200 | [diff] [blame] | 338 | # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED |
| 339 | # is automatically enabled in build_info.h (backward compatibility) |
| 340 | # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a |
| 341 | # consequence compressed points are supported in the reference |
| 342 | # component but not in the accelerated one, so they should be skipped |
| 343 | # while checking driver's coverage. |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 344 | re.compile(r'Parse EC Key .*compressed\)'), |
| 345 | re.compile(r'Parse Public EC Key .*compressed\)'), |
Valerio Setti | addeee4 | 2023-06-14 10:46:55 +0200 | [diff] [blame] | 346 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 347 | # See ecp_light_only |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 348 | 'test_suite_ssl': [ |
| 349 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 350 | ], |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 351 | } |
| 352 | } |
| 353 | }, |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 354 | 'analyze_driver_vs_reference_ecc_no_bignum': { |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 355 | 'test_function': do_analyze_driver_vs_reference, |
| 356 | 'args': { |
| 357 | 'component_ref': 'test_psa_crypto_config_reference_ecc_no_bignum', |
| 358 | 'component_driver': 'test_psa_crypto_config_accel_ecc_no_bignum', |
| 359 | 'ignored_suites': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 360 | # Modules replaced by drivers |
| 361 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', |
| 362 | 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw', |
| 363 | 'bignum.generated', 'bignum.misc', |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 364 | ], |
| 365 | 'ignored_tests': { |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 366 | # See ecp_light_only |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 367 | 'test_suite_random': [ |
| 368 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 369 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 370 | # See no_ecp_at_all |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 371 | 'test_suite_pkparse': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 372 | re.compile(r'Parse EC Key .*compressed\)'), |
| 373 | re.compile(r'Parse Public EC Key .*compressed\)'), |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 374 | ], |
Valerio Setti | 9b3dbcc | 2023-07-26 18:00:31 +0200 | [diff] [blame] | 375 | 'test_suite_asn1parse': [ |
Valerio Setti | 9b3dbcc | 2023-07-26 18:00:31 +0200 | [diff] [blame] | 376 | 'INTEGER too large for mpi', |
| 377 | ], |
| 378 | 'test_suite_asn1write': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 379 | re.compile(r'ASN.1 Write mpi.*'), |
Valerio Setti | 9b3dbcc | 2023-07-26 18:00:31 +0200 | [diff] [blame] | 380 | ], |
Valerio Setti | e0be95e | 2023-08-01 09:07:43 +0200 | [diff] [blame] | 381 | 'test_suite_debug': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 382 | re.compile(r'Debug print mbedtls_mpi.*'), |
Valerio Setti | e0be95e | 2023-08-01 09:07:43 +0200 | [diff] [blame] | 383 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 384 | # See ecp_light_only |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 385 | 'test_suite_ssl': [ |
| 386 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 387 | ], |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 388 | } |
| 389 | } |
| 390 | }, |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 391 | 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': { |
| 392 | 'test_function': do_analyze_driver_vs_reference, |
| 393 | 'args': { |
| 394 | 'component_ref': 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum', |
| 395 | 'component_driver': 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum', |
| 396 | 'ignored_suites': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 397 | # Modules replaced by drivers |
| 398 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', 'dhm', |
| 399 | 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw', |
| 400 | 'bignum.generated', 'bignum.misc', |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 401 | ], |
| 402 | 'ignored_tests': { |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 403 | # See ecp_light_only |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 404 | 'test_suite_random': [ |
| 405 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 406 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 407 | # See no_ecp_at_all |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 408 | 'test_suite_pkparse': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 409 | re.compile(r'Parse EC Key .*compressed\)'), |
| 410 | re.compile(r'Parse Public EC Key .*compressed\)'), |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 411 | ], |
| 412 | 'test_suite_asn1parse': [ |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 413 | 'INTEGER too large for mpi', |
| 414 | ], |
| 415 | 'test_suite_asn1write': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 416 | re.compile(r'ASN.1 Write mpi.*'), |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 417 | ], |
| 418 | 'test_suite_debug': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 419 | re.compile(r'Debug print mbedtls_mpi.*'), |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 420 | ], |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 421 | # See ecp_light_only |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 422 | 'test_suite_ssl': [ |
| 423 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 424 | ], |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 425 | } |
| 426 | } |
| 427 | }, |
Przemek Stekiel | 85b6442 | 2023-05-26 09:55:23 +0200 | [diff] [blame] | 428 | 'analyze_driver_vs_reference_ffdh_alg': { |
| 429 | 'test_function': do_analyze_driver_vs_reference, |
| 430 | 'args': { |
| 431 | 'component_ref': 'test_psa_crypto_config_reference_ffdh', |
| 432 | 'component_driver': 'test_psa_crypto_config_accel_ffdh', |
Przemek Stekiel | 84f4ff1 | 2023-07-04 12:35:31 +0200 | [diff] [blame] | 433 | 'ignored_suites': ['dhm'], |
Przemek Stekiel | 565353e | 2023-07-05 11:07:07 +0200 | [diff] [blame] | 434 | 'ignored_tests': {} |
Przemek Stekiel | 85b6442 | 2023-05-26 09:55:23 +0200 | [diff] [blame] | 435 | } |
| 436 | }, |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 437 | 'analyze_driver_vs_reference_tfm_config': { |
| 438 | 'test_function': do_analyze_driver_vs_reference, |
| 439 | 'args': { |
| 440 | 'component_ref': 'test_tfm_config', |
| 441 | 'component_driver': 'test_tfm_config_p256m_driver_accel_ec', |
Manuel Pégourié-Gonnard | e9d9797 | 2023-08-08 18:34:47 +0200 | [diff] [blame] | 442 | 'ignored_suites': [ |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 443 | # Modules replaced by drivers |
Yanray Wang | 5779096 | 2023-10-31 13:39:07 +0800 | [diff] [blame^] | 444 | 'asn1parse', 'asn1write', |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 445 | 'ecp', 'ecdsa', 'ecdh', 'ecjpake', |
| 446 | 'bignum_core', 'bignum_random', 'bignum_mod', 'bignum_mod_raw', |
| 447 | 'bignum.generated', 'bignum.misc', |
Manuel Pégourié-Gonnard | e9d9797 | 2023-08-08 18:34:47 +0200 | [diff] [blame] | 448 | ], |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 449 | 'ignored_tests': { |
Manuel Pégourié-Gonnard | 4fd5a6a | 2023-10-20 10:21:09 +0200 | [diff] [blame] | 450 | # See ecp_light_only |
Manuel Pégourié-Gonnard | e9d9797 | 2023-08-08 18:34:47 +0200 | [diff] [blame] | 451 | 'test_suite_random': [ |
| 452 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 453 | ], |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 454 | } |
| 455 | } |
| 456 | } |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 457 | } |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 458 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 459 | def main(): |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame] | 460 | main_results = Results() |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 461 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 462 | try: |
| 463 | parser = argparse.ArgumentParser(description=__doc__) |
Przemek Stekiel | 58bbc23 | 2022-10-24 08:10:10 +0200 | [diff] [blame] | 464 | parser.add_argument('outcomes', metavar='OUTCOMES.CSV', |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 465 | help='Outcome file to analyze') |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 466 | parser.add_argument('specified_tasks', default='all', nargs='?', |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 467 | help='Analysis to be done. By default, run all tasks. ' |
| 468 | 'With one or more TASK, run only those. ' |
| 469 | 'TASK can be the name of a single task or ' |
Przemek Stekiel | 85c54ea | 2022-11-17 11:50:23 +0100 | [diff] [blame] | 470 | 'comma/space-separated list of tasks. ') |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 471 | parser.add_argument('--list', action='store_true', |
| 472 | help='List all available tasks and exit.') |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 473 | parser.add_argument('--require-full-coverage', action='store_true', |
| 474 | dest='full_coverage', help="Require all available " |
| 475 | "test cases to be executed and issue an error " |
| 476 | "otherwise. This flag is ignored if 'task' is " |
| 477 | "neither 'all' nor 'analyze_coverage'") |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 478 | options = parser.parse_args() |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 479 | |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 480 | if options.list: |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 481 | for task in KNOWN_TASKS: |
Valerio Setti | 5329ff0 | 2023-10-17 09:44:36 +0200 | [diff] [blame] | 482 | print(task) |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 483 | sys.exit(0) |
| 484 | |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 485 | if options.specified_tasks == 'all': |
| 486 | tasks_list = KNOWN_TASKS.keys() |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 487 | else: |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 488 | tasks_list = re.split(r'[, ]+', options.specified_tasks) |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 489 | for task in tasks_list: |
| 490 | if task not in KNOWN_TASKS: |
Manuel Pégourié-Gonnard | 62d6131 | 2023-10-20 10:51:57 +0200 | [diff] [blame] | 491 | sys.stderr.write('invalid task: {}\n'.format(task)) |
Valerio Setti | fb2750e | 2023-10-17 10:11:45 +0200 | [diff] [blame] | 492 | sys.exit(2) |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 493 | |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 494 | KNOWN_TASKS['analyze_coverage']['args']['full_coverage'] = options.full_coverage |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 495 | |
Valerio Setti | fb2750e | 2023-10-17 10:11:45 +0200 | [diff] [blame] | 496 | for task in tasks_list: |
| 497 | test_function = KNOWN_TASKS[task]['test_function'] |
| 498 | test_args = KNOWN_TASKS[task]['args'] |
Valerio Setti | 781c234 | 2023-10-17 12:47:35 +0200 | [diff] [blame] | 499 | test_function(main_results, options.outcomes, test_args) |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 500 | |
Valerio Setti | f6f64cf | 2023-10-17 12:28:26 +0200 | [diff] [blame] | 501 | main_results.info("Overall results: {} warnings and {} errors", |
| 502 | main_results.warning_count, main_results.error_count) |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 503 | |
Valerio Setti | 8d178be | 2023-10-17 12:23:55 +0200 | [diff] [blame] | 504 | sys.exit(0 if (main_results.error_count == 0) else 1) |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 505 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 506 | except Exception: # pylint: disable=broad-except |
| 507 | # Print the backtrace and exit explicitly with our chosen status. |
| 508 | traceback.print_exc() |
| 509 | sys.exit(120) |
| 510 | |
| 511 | if __name__ == '__main__': |
| 512 | main() |