From c04c2ed2eb6bb78650e4ee99a97f6ff7f94b0ea5 Mon Sep 17 00:00:00 2001 From: Ronald Cron Date: Mon, 22 Jul 2024 08:48:17 +0200 Subject: [PATCH] Revert "Adapt psasim" This reverts commit b6f6cc89d08b01eddc1b1f20aa9e6ee56f566bc7. The usage of files /tmp/ could result in race conditions if several several are run on the same machine. Signed-off-by: Ronald Cron --- tests/psa-client-server/psasim/Makefile | 2 +- tests/psa-client-server/psasim/include/util.h | 2 +- tests/psa-client-server/psasim/src/psa_ff_server.c | 6 +++--- tests/psa-client-server/psasim/test/kill_server.sh | 4 ++-- tests/psa-client-server/psasim/test/start_server.sh | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/psa-client-server/psasim/Makefile b/tests/psa-client-server/psasim/Makefile index c23017fa82..ec6691f422 100644 --- a/tests/psa-client-server/psasim/Makefile +++ b/tests/psa-client-server/psasim/Makefile @@ -77,5 +77,5 @@ clean_server_intermediate_files: clean: clean_server_intermediate_files rm -f test/psa_client_base test/psa_client_full test/psa_server rm -rf client_libs server_libs - rm -f test/*.log + rm -f test/psa_service_* test/psa_notify_* test/*.log rm -f test/seedfile diff --git a/tests/psa-client-server/psasim/include/util.h b/tests/psa-client-server/psasim/include/util.h index bbff3ca9c5..5eb8238c5c 100644 --- a/tests/psa-client-server/psasim/include/util.h +++ b/tests/psa-client-server/psasim/include/util.h @@ -28,4 +28,4 @@ #define PROJECT_ID 'M' #define PATHNAMESIZE 256 -#define TMP_FILE_BASE_PATH "/tmp/" +#define TMP_FILE_BASE_PATH "./" diff --git a/tests/psa-client-server/psasim/src/psa_ff_server.c b/tests/psa-client-server/psasim/src/psa_ff_server.c index 00c5272646..b106092441 100644 --- a/tests/psa-client-server/psasim/src/psa_ff_server.c +++ b/tests/psa-client-server/psasim/src/psa_ff_server.c @@ -605,9 +605,9 @@ void __init_psasim(const char **array, key_t key; int qid; FILE *fp; - char doorbell_file[PATHNAMESIZE] = { 0 }; + char doorbell_path[PATHNAMESIZE] = { 0 }; char queue_path[PATHNAMESIZE]; - snprintf(doorbell_file, PATHNAMESIZE, "psa_notify_%u", getpid()); + snprintf(doorbell_path, PATHNAMESIZE, TMP_FILE_BASE_PATH "psa_notify_%u", getpid()); if (library_initialised > 0) { return; @@ -619,7 +619,7 @@ void __init_psasim(const char **array, FATAL("Unsupported value. Aborting."); } - array[3] = doorbell_file; + array[3] = doorbell_path; for (int i = 0; i < 32; i++) { if (strncmp(array[i], "", 1) != 0) { diff --git a/tests/psa-client-server/psasim/test/kill_server.sh b/tests/psa-client-server/psasim/test/kill_server.sh index 0425282c13..7aba5a32ed 100755 --- a/tests/psa-client-server/psasim/test/kill_server.sh +++ b/tests/psa-client-server/psasim/test/kill_server.sh @@ -8,8 +8,8 @@ set -e pkill psa_server || true # Remove temporary files and logs -rm -f /tmp/psa_notify_* -rm -f /tmp/psa_service_* +rm -f psa_notify_* +rm -f psa_service_* rm -f psa_server.log # Remove all IPCs diff --git a/tests/psa-client-server/psasim/test/start_server.sh b/tests/psa-client-server/psasim/test/start_server.sh index 58ab8506bf..fcc8a97e9c 100755 --- a/tests/psa-client-server/psasim/test/start_server.sh +++ b/tests/psa-client-server/psasim/test/start_server.sh @@ -8,7 +8,7 @@ set -e # The server creates some local files when it starts up so we can wait for this # event as signal that the server is ready so that we can start client(s). function wait_for_server_startup() { - while [ -z $(find /tmp -maxdepth 1 -name "psa_notify_*" -printf 1 -quit) ]; do + while [ $(find . -name "psa_notify_*" | wc -l) -eq 0 ]; do sleep 0.1 done }