psasim: small fixes to all.sh and test bash scripts
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
diff --git a/tests/psa-client-server/psasim/test/kill_servers.sh b/tests/psa-client-server/psasim/test/kill_servers.sh
index e84fd39..d722637 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 @@
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 ac9c4c8..f54e352 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 @@
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 f216f16..7f4c2a3 100755
--- a/tests/scripts/all.sh
+++ b/tests/scripts/all.sh
@@ -379,8 +379,7 @@
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 4fe5470..ba8ab33 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 @@
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 @@
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