mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-09-08 11:19:56 +00:00
INTERNAL_TEST_CASES moved to a separate data-only module
This way, when Mbed TLS's `analyze_outcomes.py` loads the python module from TF-PSA-Crypto (because it needs to know the value of `INTERNAL_TEST_CASES`), there's no risk that the subproject and the superproject will have different requirements on auxiliary modules such as `mbedtls_framework.outcome_analysis`. Signed-off-by: Gilles Peskine <[email protected]>
This commit is contained in:
@@ -22,7 +22,7 @@ from mbedtls_framework import typing_util
|
|||||||
|
|
||||||
|
|
||||||
class CryptoAnalyzeOutcomesType(typing_util.Protocol):
|
class CryptoAnalyzeOutcomesType(typing_util.Protocol):
|
||||||
"""Our expectations on tf-psa-crypto/tests/scripts/analyze_outcomes.py.
|
"""Our expectations on tf-psa-crypto/tests/scripts/tf_psa_crypto_test_case_info.py.
|
||||||
|
|
||||||
See CoverageTask_load_crypto_module().
|
See CoverageTask_load_crypto_module().
|
||||||
"""
|
"""
|
||||||
@@ -225,17 +225,19 @@ class CoverageTask(outcome_analysis.CoverageTask):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def _load_crypto_module(self) -> None:
|
def _load_crypto_module(self) -> None:
|
||||||
"""Try to load the tf-psa-crypto submodule's outcome analysis Python module."""
|
"""Try to load the information about test cases from the tf-psa-crypto submodule.."""
|
||||||
|
# All this complexity is because we don't want to add the directory
|
||||||
|
# to the import path.
|
||||||
if self.crypto_module is not None:
|
if self.crypto_module is not None:
|
||||||
return
|
return
|
||||||
crypto_script_path = 'tf-psa-crypto/tests/scripts/analyze_outcomes.py'
|
crypto_script_path = 'tf-psa-crypto/tests/scripts/tf_psa_crypto_test_case_info.py'
|
||||||
if not os.path.exists(crypto_script_path):
|
if not os.path.exists(crypto_script_path):
|
||||||
# During a transition period, while the crypto script is not
|
# During a transition period, while the crypto script is not
|
||||||
# yet present in all branches we care about, allow it not to
|
# yet present in all branches we care about, allow it not to
|
||||||
# exist.
|
# exist.
|
||||||
return
|
return
|
||||||
crypto_spec = importlib.util.spec_from_file_location(
|
crypto_spec = importlib.util.spec_from_file_location(
|
||||||
'tf_psa_crypto.analyze_outcomes',
|
'tf_psa_crypto_test_case_info',
|
||||||
crypto_script_path)
|
crypto_script_path)
|
||||||
# Assertions to help mypy.
|
# Assertions to help mypy.
|
||||||
assert crypto_spec is not None
|
assert crypto_spec is not None
|
||||||
|
|||||||
Reference in New Issue
Block a user