From 9d3a14412eb329b118dfd27025e3d592d36b0fcf Mon Sep 17 00:00:00 2001 From: Valerio Setti Date: Wed, 29 Jan 2025 17:22:34 +0100 Subject: [PATCH] test_psa_constant_names.py: reconcile 3.6 and development branches The script had small differences between the development branch and the mbedtls-3.6 ones. The goal of this commit is to reconcile those differences in order to make it usable from both branches. This is necessary now that the scripts lives in the framework repo. Signed-off-by: Valerio Setti --- scripts/test_psa_compliance.py | 20 +++++++++-------- scripts/test_psa_constant_names.py | 35 +++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/scripts/test_psa_compliance.py b/scripts/test_psa_compliance.py index 98ec7597e..c5e9748ca 100755 --- a/scripts/test_psa_compliance.py +++ b/scripts/test_psa_compliance.py @@ -50,6 +50,17 @@ def main(library_build_dir: str): library_subdir + '/' + 'lib' + crypto_name + '.a') + # Temporary while the PSA compliance test suite is still run as part + # of Mbed TLS testing. When it is not the case anymore, the last case + # can be removed. + if in_tf_psa_crypto_repo: + extra_includes = ';{}/drivers/builtin/include'.format(root_dir) + elif build_tree.is_mbedtls_3_6(): + extra_includes = '' + else: + extra_includes = ';{}/tf-psa-crypto/include'.format(root_dir) + \ + (';{}/tf-psa-crypto/drivers/builtin/include'.format(root_dir)) + if not os.path.exists(crypto_lib_filename): #pylint: disable=bad-continuation subprocess.check_call([ @@ -78,15 +89,6 @@ def main(library_build_dir: str): os.mkdir(build_dir) os.chdir(build_dir) - # Temporary while the PSA compliance test suite is still run as part - # of Mbed TLS testing. When it is not the case anymore, the second case - # can be removed. - if in_tf_psa_crypto_repo: - extra_includes = ';{}/drivers/builtin/include'.format(root_dir) - elif os.path.isdir(os.path.join(root_dir, 'tf-psa-crypto')): - extra_includes = ';{}/tf-psa-crypto/include'.format(root_dir) + \ - (';{}/tf-psa-crypto/drivers/builtin/include'.format(root_dir)) - #pylint: disable=bad-continuation subprocess.check_call([ 'cmake', '..', diff --git a/scripts/test_psa_constant_names.py b/scripts/test_psa_constant_names.py index 228a61fb9..ad1311041 100755 --- a/scripts/test_psa_constant_names.py +++ b/scripts/test_psa_constant_names.py @@ -18,6 +18,7 @@ import subprocess import sys from typing import Iterable, List, Optional, Tuple +from mbedtls_framework import build_tree from mbedtls_framework import c_build_helper from mbedtls_framework.macro_collector import InputsForTest, PSAMacroEnumerator from mbedtls_framework import typing_util @@ -155,25 +156,39 @@ class Tests: out.write(' PASS\n') HEADERS = ['psa/crypto.h', 'psa/crypto_extra.h', 'psa/crypto_values.h'] -TEST_SUITES = ['tf-psa-crypto/tests/suites/test_suite_psa_crypto_metadata.data'] + +if build_tree.is_mbedtls_3_6(): + TEST_SUITES = ['tests/suites/test_suite_psa_crypto_metadata.data'] +else: + TEST_SUITES = ['tf-psa-crypto/tests/suites/test_suite_psa_crypto_metadata.data'] def main(): parser = argparse.ArgumentParser(description=globals()['__doc__']) - parser.add_argument('--include', '-I', - action='append', default=['tf-psa-crypto/include', - 'tf-psa-crypto/drivers/builtin/include', - 'tf-psa-crypto/drivers/everest/include', - 'include'], - help='Directory for header files') + if build_tree.is_mbedtls_3_6(): + parser.add_argument('--include', '-I', + action='append', default=['include'], + help='Directory for header files') + else: + parser.add_argument('--include', '-I', + action='append', default=['tf-psa-crypto/include', + 'tf-psa-crypto/drivers/builtin/include', + 'tf-psa-crypto/drivers/everest/include', + 'include'], + help='Directory for header files') parser.add_argument('--keep-c', action='store_true', dest='keep_c', default=False, help='Keep the intermediate C file') parser.add_argument('--no-keep-c', action='store_false', dest='keep_c', help='Don\'t keep the intermediate C file (default)') - parser.add_argument('--program', - default='tf-psa-crypto/programs/psa/psa_constant_names', - help='Program to test') + if build_tree.is_mbedtls_3_6(): + parser.add_argument('--program', + default='programs/psa/psa_constant_names', + help='Program to test') + else: + parser.add_argument('--program', + default='tf-psa-crypto/programs/psa/psa_constant_names', + help='Program to test') parser.add_argument('--show', action='store_true', help='Show tested values on stdout')