From 6e3e4bd07c00ed58adcaf6c7b57ff8d696528993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Fri, 24 May 2024 14:10:29 +0200 Subject: [PATCH] tests OPTIMIZE shorten path to the UNIX socket (#1581) * build: do not hard code test repository path in multiple places * build: relocate test repositories to a shorter path ...to prevent errors when the generated paths are "too long", over 107 characters. Yes, I have these, of course. * tests: shave a few more bytes from the socket paths --- tests/CMakeLists.txt | 4 ++-- tests/np2_test_config.h.in | 2 +- tests/scripts/kill_np_server.sh.in | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c9ffbac4..805e8c8f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -10,7 +10,7 @@ get_filename_component(ROOT_DIR "${CMAKE_SOURCE_DIR}" REALPATH) # test directories that can be adjusted if(NOT NP2_TEST_ROOT_DIR) - set(NP2_TEST_ROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/repositories) + set(NP2_TEST_ROOT_DIR ${PROJECT_BINARY_DIR}/repos) endif() if(NOT NP2_TEST_MODULE_DIR) set(NP2_TEST_MODULE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/modules) @@ -102,7 +102,7 @@ if(ENABLE_TESTS) add_custom_target(test_clean COMMAND ${TEST_KILL_SERVER_COMMAND} COMMAND ${TEST_CLEAR_STATE_COMMAND} - COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/repositories + COMMAND rm -rf ${NP2_TEST_ROOT_DIR} ) endif() diff --git a/tests/np2_test_config.h.in b/tests/np2_test_config.h.in index 7c2df745..4df9359b 100644 --- a/tests/np2_test_config.h.in +++ b/tests/np2_test_config.h.in @@ -35,7 +35,7 @@ #define NP_PID_FILE "np2.pid" /* server socket path */ -#define NP_SOCKET_FILE "np2.sock" +#define NP_SOCKET_FILE "s" /* server ext data file */ #define NP_EXT_DATA_FILE "schema_mount.xml" diff --git a/tests/scripts/kill_np_server.sh.in b/tests/scripts/kill_np_server.sh.in index 44678ec6..0b100228 100755 --- a/tests/scripts/kill_np_server.sh.in +++ b/tests/scripts/kill_np_server.sh.in @@ -1,10 +1,10 @@ #!/usr/bin/env bash -NP2_TESTS_BINARY_DIR="@CMAKE_CURRENT_BINARY_DIR@" -[ -z "$NP2_TESTS_BINARY_DIR" ] && +NP2_TEST_ROOT_DIR="@NP2_TEST_ROOT_DIR@" +[ -z "$NP2_TEST_ROOT_DIR" ] && echo "Expected an argument with to the test directory" && exit 1 -for pidfile in $NP2_TESTS_BINARY_DIR/repositories/*/np2.pid +for pidfile in $NP2_TEST_ROOT_DIR/*/np2.pid do [ -f "$pidfile" ] && kill "$(cat "$pidfile")" done