55# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
66#
77
8+ import os
89import re
910from collections import OrderedDict
1011from typing import FrozenSet , List , Optional
@@ -30,8 +31,16 @@ def remove_unwanted_macros(
3031 def read_psa_interface (self ) -> macro_collector .PSAMacroEnumerator :
3132 """Return the list of known key types, algorithms, etc."""
3233 constructors = macro_collector .InputsForTest ()
33- header_file_names = ['include/psa/crypto_values.h' ,
34- 'include/psa/crypto_extra.h' ]
34+ # Temporary, while Mbed TLS does not just rely on the TF-PSA-Crypto
35+ # build system to build its crypto library. When it does, the first
36+ # case can just be removed.
37+ if os .path .isdir ('tf-psa-crypto' ):
38+ header_file_names = ['tf-psa-crypto/include/psa/crypto_values.h' ,
39+ 'tf-psa-crypto/include/psa/crypto_extra.h' ]
40+ else :
41+ header_file_names = ['include/psa/crypto_values.h' ,
42+ 'include/psa/crypto_extra.h' ]
43+
3544 test_suites = ['tests/suites/test_suite_psa_crypto_metadata.data' ]
3645 for header_file_name in header_file_names :
3746 constructors .parse_header (header_file_name )
@@ -124,10 +133,22 @@ def read_implemented_dependencies(filename: str) -> FrozenSet[str]:
124133 for symbol in re .findall (r'\bPSA_WANT_\w+\b' , line ))
125134_implemented_dependencies = None #type: Optional[FrozenSet[str]] #pylint: disable=invalid-name
126135def hack_dependencies_not_implemented (dependencies : List [str ]) -> None :
136+ """
137+ Hack dependencies to skip test cases for which at least one dependency
138+ symbol is not available yet.
139+ """
127140 global _implemented_dependencies #pylint: disable=global-statement,invalid-name
128141 if _implemented_dependencies is None :
129- _implemented_dependencies = \
130- read_implemented_dependencies ('include/psa/crypto_config.h' )
142+ # Temporary, while Mbed TLS does not just rely on the TF-PSA-Crypto
143+ # build system to build its crypto library. When it does, the first
144+ # case can just be removed.
145+ if os .path .isdir ('tf-psa-crypto' ):
146+ _implemented_dependencies = \
147+ read_implemented_dependencies ('tf-psa-crypto/include/psa/crypto_config.h' )
148+ else :
149+ _implemented_dependencies = \
150+ read_implemented_dependencies ('include/psa/crypto_config.h' )
151+
131152 if not all ((dep .lstrip ('!' ) in _implemented_dependencies or
132153 not dep .lstrip ('!' ).startswith ('PSA_WANT' ))
133154 for dep in dependencies ):
0 commit comments