From fd0130576c0151027c299181813dc15e1e4b1d30 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 16 Dec 2024 20:02:45 +0100 Subject: [PATCH] Do run not-supported test cases on not-implemented mechanisms In automatically generated PSA test cases with automatically inferred dependencies, we were systematically skipping test cases when a dependency mentions a mechanism that is not supported, even when that dependency is negated. Fix this. This causes more not-supported test cases to run. Signed-off-by: Gilles Peskine --- scripts/mbedtls_framework/psa_test_case.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/mbedtls_framework/psa_test_case.py b/scripts/mbedtls_framework/psa_test_case.py index 39b0ab37e..7084bada8 100644 --- a/scripts/mbedtls_framework/psa_test_case.py +++ b/scripts/mbedtls_framework/psa_test_case.py @@ -13,11 +13,14 @@ from . import psa_information from . import test_case -# A temporary hack: at the time of writing, not all dependency symbols -# are implemented yet. Skip test cases for which the dependency symbols are -# not available. Once all dependency symbols are available, this hack must -# be removed so that a bug in the dependency symbols properly leads to a test -# failure. +# Skip test cases for which the dependency symbols are not defined. +# We assume that this means that a required mechanism is not implemented. +# Note that if we erroneously skip generating test cases for +# mechanisms that are not implemented, this should be caught +# by the NOT_SUPPORTED test cases generated by generate_psa_tests.py +# in test_suite_psa_crypto_not_supported and test_suite_psa_crypto_op_fail: +# those emit tests with negative dependencies, which will not be skipped here. + def read_implemented_dependencies(acc: Set[str], filename: str) -> None: with open(filename) as input_stream: for line in input_stream: @@ -46,8 +49,8 @@ def find_dependencies_not_implemented(dependencies: List[str]) -> List[str]: _implemented_dependencies = frozenset(acc) return [dep for dep in dependencies - if (dep.lstrip('!') not in _implemented_dependencies and - dep.lstrip('!').startswith('PSA_WANT'))] + if (dep not in _implemented_dependencies and + dep.startswith('PSA_WANT'))] class TestCase(test_case.TestCase):