Make all.sh PSA-crypto-friendly

Introduce changes needed to run all.sh in the psa-crypto repo. Where
behaviour must differ, detect that we are in the psa-crypto repo by
checking for the 'core' directory.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
David Horstmann 2023-07-14 12:30:00 +01:00
parent 41d689f389
commit 9a6c45b436

View file

@ -123,15 +123,23 @@ set -e -o pipefail -u
# Enable ksh/bash extended file matching patterns
shopt -s extglob
in_psa_crypto_repo () {
test -d core
}
pre_check_environment () {
if [ -d library -a -d include -a -d tests ]; then :; else
echo "Must be run from mbed TLS root" >&2
if [ \( -d library -o -d core \) -a -d include -a -d tests ]; then :; else
echo "Must be run from Mbed TLS root" >&2
exit 1
fi
}
pre_initialize_variables () {
CONFIG_H='include/mbedtls/mbedtls_config.h'
if in_psa_crypto_repo; then
CONFIG_H='drivers/builtin/include/mbedtls/mbedtls_config.h'
else
CONFIG_H='include/mbedtls/mbedtls_config.h'
fi
CRYPTO_CONFIG_H='include/psa/crypto_config.h'
CONFIG_TEST_DRIVER_H='tests/include/test/drivers/config_test_driver.h'
@ -141,8 +149,10 @@ pre_initialize_variables () {
backup_suffix='.all.bak'
# Files clobbered by config.py
files_to_back_up="$CONFIG_H $CRYPTO_CONFIG_H $CONFIG_TEST_DRIVER_H"
# Files clobbered by in-tree cmake
files_to_back_up="$files_to_back_up Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile"
if ! in_psa_crypto_repo; then
# Files clobbered by in-tree cmake
files_to_back_up="$files_to_back_up Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile"
fi
append_outcome=0
MEMORY=0
@ -299,7 +309,9 @@ EOF
# Does not remove generated source files.
cleanup()
{
command make clean
if ! in_psa_crypto_repo; then
command make clean
fi
# Remove CMake artefacts
find . -name .git -prune -o \
@ -556,7 +568,7 @@ pre_check_git () {
fi
if ! git diff --quiet "$CONFIG_H"; then
err_msg "Warning - the configuration file 'include/mbedtls/mbedtls_config.h' has been edited. "
err_msg "Warning - the configuration file '$CONFIG_H' has been edited. "
echo "You can either delete or preserve your work, or force the test by rerunning the"
echo "script as: $0 --force"
exit 1
@ -5264,7 +5276,9 @@ pre_prepare_outcome_file
pre_print_configuration
pre_check_tools
cleanup
pre_generate_files
if ! in_psa_crypto_repo; then
pre_generate_files
fi
# Run the requested tests.
for ((error_test_i=1; error_test_i <= error_test; error_test_i++)); do