From 2016d66741afc709010a125999f6b42027e75885 Mon Sep 17 00:00:00 2001 From: Valerio Setti Date: Mon, 5 Aug 2024 15:57:43 +0200 Subject: [PATCH] psasim: small fixes to all.sh and test bash scripts Signed-off-by: Valerio Setti --- .../psasim/test/kill_servers.sh | 3 + .../psa-client-server/psasim/test/run_test.sh | 5 +- tests/scripts/all.sh | 3 +- tests/scripts/components-psasim.sh | 61 ++++++++++--------- 4 files changed, 37 insertions(+), 35 deletions(-) diff --git a/tests/psa-client-server/psasim/test/kill_servers.sh b/tests/psa-client-server/psasim/test/kill_servers.sh index e84fd39ea10c..d72263791f9d 100755 --- a/tests/psa-client-server/psasim/test/kill_servers.sh +++ b/tests/psa-client-server/psasim/test/kill_servers.sh @@ -7,6 +7,9 @@ set -e pkill psa_server || true +# Remove temporary files +rm -f psa_notify_* + # Remove all IPCs # Not just ipcrm -all=msg as it is not supported on macOS. # Filter out header and empty lines, choosing to select based on keys being diff --git a/tests/psa-client-server/psasim/test/run_test.sh b/tests/psa-client-server/psasim/test/run_test.sh index ac9c4c86ca04..f54e35253200 100755 --- a/tests/psa-client-server/psasim/test/run_test.sh +++ b/tests/psa-client-server/psasim/test/run_test.sh @@ -16,10 +16,9 @@ cd "$(dirname "$0")" CLIENT_BIN=$1 shift -ipcs | grep q | awk '{ printf " -q " $2 }' | xargs ipcrm > /dev/null 2>&1 || true +./kill_servers.sh ./start_server.sh ./$CLIENT_BIN "$@" -# Kill server once client exited -pkill psa_server +./kill_servers.sh diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index f216f162f712..7f4c2a3d010f 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -379,8 +379,7 @@ cleanup() helper_psasim_cleanup_before_client() { # Clean up library files make -C library clean - # Clean up intermediate files that were used to build the server - make -C $PSASIM_PATH clean_server_intermediate_files + # Restore files that were backup before building library files. This # includes $CONFIG_H and $CRYPTO_CONFIG_H. for x in $files_to_back_up; do diff --git a/tests/scripts/components-psasim.sh b/tests/scripts/components-psasim.sh index 4fe54701bf45..ba8ab331d205 100644 --- a/tests/scripts/components-psasim.sh +++ b/tests/scripts/components-psasim.sh @@ -10,37 +10,37 @@ ################################################################ # Helper function for controlling (start & stop) the psasim server. -helper_psasim_server () { +helper_psasim_server() { OPERATION=$1 if [ "$OPERATION" == "start" ]; then - ( - cd tests msg "start server in tests" - psa-client-server/psasim/test/start_server.sh + ( + cd tests + ../$PSASIM_PATH/test/start_server.sh + ) msg "start server in tf-psa-crypto/tests" - cd ../tf-psa-crypto/tests - ../../tests/psa-client-server/psasim/test/start_server.sh - ) + ( + cd tf-psa-crypto/tests + ../../$PSASIM_PATH/test/start_server.sh + ) else - ( - msg "terminate servers and cleanup" - tests/psa-client-server/psasim//test/kill_servers.sh - - # Remove temporary files and logs - cd tests - rm -f psa_notify_* - rm -f psa_service_* - rm -f psa_server.log - - cd ../tf-psa-crypto/tests - rm -f psa_notify_* - rm -f psa_service_* - rm -f psa_server.log - ) + msg "terminate server in tests" + ( + # This will kill both servers and clean up all the message queues, + # and clear temporary files in tests + cd tests + ../$PSASIM_PATH/test/kill_servers.sh + ) + msg "terminate server in tf-psa-crypto/tests" + ( + # This just clears temporary files in tf-psa-crypto/tests + cd tf-psa-crypto/tests + ../../$PSASIM_PATH/test/kill_servers.sh + ) fi } -component_test_psasim () { +component_test_psasim() { msg "build server library and application" scripts/config.py crypto helper_psasim_config server @@ -53,19 +53,21 @@ component_test_psasim () { helper_psasim_build client msg "build basic psasim client" - make -C tests/psa-client-server/psasim CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS" test/psa_client_base + make -C $PSASIM_PATH CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS" test/psa_client_base msg "test basic psasim client" - tests/psa-client-server/psasim/test/run_test.sh psa_client_base + $PSASIM_PATH/test/run_test.sh psa_client_base msg "build full psasim client" - make -C tests/psa-client-server/psasim CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS" test/psa_client_full + make -C $PSASIM_PATH CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS" test/psa_client_full msg "test full psasim client" - tests/psa-client-server/psasim/test/run_test.sh psa_client_full + $PSASIM_PATH/test/run_test.sh psa_client_full - make -C tests/psa-client-server/psasim clean + helper_psasim_server kill + make -C $PSASIM_PATH clean } -component_test_suite_with_psasim () { +component_test_suite_with_psasim() +{ msg "build server library and application" helper_psasim_config server # Modify server's library configuration here (if needed) @@ -83,7 +85,6 @@ component_test_suite_with_psasim () { msg "build test suites" make PSASIM=1 CFLAGS="$ASAN_CFLAGS" LDFLAGS="$ASAN_CFLAGS" tests - helper_psasim_server kill helper_psasim_server start # psasim takes an extremely long execution time on some test suites so we