From 1451a76958b3347902144e81a2f150742e0786cb Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 10 Jun 2024 16:02:04 +0200 Subject: [PATCH] Adapt libtestdriver1 build Signed-off-by: Ronald Cron --- tests/Makefile | 14 +++++++++----- tests/src/drivers/test_driver_key_agreement.c | 2 +- .../psa/crypto_driver_contexts_composites.h | 2 +- .../psa/crypto_driver_contexts_primitives.h | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index 6367b3eb8..d1d5ed972 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -7,6 +7,7 @@ TEST_FLAGS ?= $(if $(filter-out 0 OFF Off off NO No no FALSE False false N n,$(C # Also include library headers, for the sake of invasive tests. LOCAL_CFLAGS += -I../library + # Enable definition of various functions used throughout the testsuite # (gethostname, strdup, fileno...) even when compiling with -std=c99. Harmless # on non-POSIX platforms. @@ -216,7 +217,8 @@ include/alt-extra/%_alt.h: ../tf-psa-crypto/include/%.h # library. Add a LIBTESTDRIVER1_/libtestdriver1_ to mbedtls_xxx and psa_xxx # symbols. define libtestdriver1_rewrite := - s!^(\s*#\s*include\s*[\"<])(mbedtls|psa)/!$${1}libtestdriver1/include/$${2}/!; \ + s!^(\s*#\s*include\s*[\"<])mbedtls/!$${1}libtestdriver1/include/mbedtls/!; \ + s!^(\s*#\s*include\s*[\"<])psa/!$${1}libtestdriver1/tf-psa-crypto/include/psa/!; \ next if /^\s*#\s*include/; \ s/\b(?=MBEDTLS_|PSA_)/LIBTESTDRIVER1_/g; \ s/\b(?=mbedtls_|psa_)/libtestdriver1_/g; @@ -229,6 +231,7 @@ libtestdriver1.a: mkdir ./libtestdriver1 cp -Rf ../library ./libtestdriver1 cp -Rf ../include ./libtestdriver1 + cp -Rf ../tf-psa-crypto ./libtestdriver1 cp -Rf ../scripts ./libtestdriver1 mkdir ./libtestdriver1/3rdparty touch ./libtestdriver1/3rdparty/Makefile.inc @@ -241,16 +244,17 @@ libtestdriver1.a: # library the test library is intended to be linked with extended by # ./include/test/drivers/crypto_config_test_driver_extension.h to # mirror the PSA_ACCEL_* macros. - mv ./libtestdriver1/include/psa/crypto_config.h ./libtestdriver1/include/psa/crypto_config.h.bak - head -n -1 ./libtestdriver1/include/psa/crypto_config.h.bak > ./libtestdriver1/include/psa/crypto_config.h - cat ./include/test/drivers/crypto_config_test_driver_extension.h >> ./libtestdriver1/include/psa/crypto_config.h - echo "#endif /* PSA_CRYPTO_CONFIG_H */" >> ./libtestdriver1/include/psa/crypto_config.h + mv ./libtestdriver1/tf-psa-crypto/include/psa/crypto_config.h ./libtestdriver1/tf-psa-crypto/include/psa/crypto_config.h.bak + head -n -1 ./libtestdriver1/tf-psa-crypto/include/psa/crypto_config.h.bak > ./libtestdriver1/tf-psa-crypto/include/psa/crypto_config.h + cat ./include/test/drivers/crypto_config_test_driver_extension.h >> ./libtestdriver1/tf-psa-crypto/include/psa/crypto_config.h + echo "#endif /* PSA_CRYPTO_CONFIG_H */" >> ./libtestdriver1/tf-psa-crypto/include/psa/crypto_config.h # Prefix MBEDTLS_* PSA_* symbols with LIBTESTDRIVER1_ as well as # mbedtls_* psa_* symbols with libtestdriver1_ to avoid symbol clash # when this test driver library is linked with the Mbed TLS library. perl -pi -e '$(libtestdriver1_rewrite)' ./libtestdriver1/library/*.[ch] perl -pi -e '$(libtestdriver1_rewrite)' ./libtestdriver1/include/*/*.h + perl -pi -e '$(libtestdriver1_rewrite)' ./libtestdriver1/tf-psa-crypto/include/*/*.h $(MAKE) -C ./libtestdriver1/library CFLAGS="-I../../ $(CFLAGS)" LDFLAGS="$(LDFLAGS)" libmbedcrypto.a cp ./libtestdriver1/library/libmbedcrypto.a ../library/libtestdriver1.a diff --git a/tests/src/drivers/test_driver_key_agreement.c b/tests/src/drivers/test_driver_key_agreement.c index 8471959e2..594fcd51d 100644 --- a/tests/src/drivers/test_driver_key_agreement.c +++ b/tests/src/drivers/test_driver_key_agreement.c @@ -20,7 +20,7 @@ #include #if defined(MBEDTLS_TEST_LIBTESTDRIVER1) -#include "libtestdriver1/include/psa/crypto.h" +#include "libtestdriver1/tf-psa-crypto/include/psa/crypto.h" #include "libtestdriver1/library/psa_crypto_ecp.h" #include "libtestdriver1/library/psa_crypto_ffdh.h" #endif diff --git a/tf-psa-crypto/include/psa/crypto_driver_contexts_composites.h b/tf-psa-crypto/include/psa/crypto_driver_contexts_composites.h index d717c5190..5a484fcec 100644 --- a/tf-psa-crypto/include/psa/crypto_driver_contexts_composites.h +++ b/tf-psa-crypto/include/psa/crypto_driver_contexts_composites.h @@ -31,7 +31,7 @@ * declared during the autogeneration process. */ #if defined(MBEDTLS_TEST_LIBTESTDRIVER1) -#include +#include #endif #if defined(PSA_CRYPTO_DRIVER_TEST) diff --git a/tf-psa-crypto/include/psa/crypto_driver_contexts_primitives.h b/tf-psa-crypto/include/psa/crypto_driver_contexts_primitives.h index c90a5fbe7..281e0a185 100644 --- a/tf-psa-crypto/include/psa/crypto_driver_contexts_primitives.h +++ b/tf-psa-crypto/include/psa/crypto_driver_contexts_primitives.h @@ -30,7 +30,7 @@ * declared during the autogeneration process. */ #if defined(MBEDTLS_TEST_LIBTESTDRIVER1) -#include +#include #endif #if defined(PSA_CRYPTO_DRIVER_TEST)