1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-07-31 00:03:07 +03:00
Files
libssh/tests/pkd/CMakeLists.txt
Jon Simons 29ad26db26 tests/pkd: use -L in CMakeLists.txt
Use the new `-L` flag for the pkd tests so that they use a
unique temporary directory for scratch space while running.

Note the choice of `pkd_scratch_XXXXXX` in contrast to a
path living under `/tmp`: by using a relative path, one can
gather the full set of log artifacts from the GitLab CI jobs
in the event that there is a test failure.  The logs contain
lots of information to help pinpoint what went wrong.

Resolves https://gitlab.com/libssh/libssh-mirror/-/issues/143.

Testing notes:
 - In the GitLab CI jobs I can see the flag being used, and
   can observe that I am able to gather the full set of
   detailed `pkd` logs in the event of a legitimate test
   failure.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 4f6aa53b16)
2023-05-15 14:45:02 +02:00

56 lines
1.8 KiB
CMake

project(pkd C)
if (WITH_SERVER AND UNIX AND NOT WIN32)
include_directories(${libssh_SOURCE_DIR}/include
${libssh_BINARY_DIR}/include
${CMOCKA_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${CMAKE_BINARY_DIR}
${libssh_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR})
set(pkd_hello_src
pkd_daemon.c
pkd_hello.c
pkd_keyutil.c
pkd_util.c
)
set(pkd_libs
${CMOCKA_LIBRARY}
ssh::static
${ARGP_LIBRARIES}
pthread
)
add_executable(pkd_hello ${pkd_hello_src})
target_compile_options(pkd_hello PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(pkd_hello ${pkd_libs})
#
# pkd_hello_i1 runs only one iteration per algorithm combination for
# sake of speeding up overall test run time. More iterations can be
# specified with `-i` and may be helpful for chasing down bugs that
# are not 100% reproducible.
#
add_test(pkd_hello_i1 ${CMAKE_CURRENT_BINARY_DIR}/pkd_hello -e -o -i1 -w /tmp/pkd_socket_wrapper_XXXXXX -L pkd_scratch_XXXXXX)
#
# Configure environment for cwrap socket wrapper.
#
if (OSX)
set(PKD_ENVIRONMENT "DYLD_FORCE_FLAT_NAMESPACE=1;DYLD_INSERT_LIBRARIES=${SOCKET_WRAPPER_LIBRARY}")
else ()
set(PKD_ENVIRONMENT "LD_PRELOAD=${SOCKET_WRAPPER_LIBRARY};OPENSSL_ENABLE_SHA1_SIGNATURES=1")
endif ()
message(STATUS "PKD_ENVIRONMENT=${PKD_ENVIRONMENT}")
set_property(TEST pkd_hello_i1 PROPERTY ENVIRONMENT ${PKD_ENVIRONMENT})
#
# pkd_hello_rekey is used to test server-side implementation of rekeying.
#
add_test(pkd_hello_rekey ${CMAKE_CURRENT_BINARY_DIR}/pkd_hello -t torture_pkd_openssh_rsa_rsa_default -i1 --rekey=16 -v -v -v -w /tmp/pkd_socket_wrapper_XXXXXX -L pkd_scratch_XXXXXX)
set_property(TEST pkd_hello_rekey PROPERTY ENVIRONMENT OPENSSL_ENABLE_SHA1_SIGNATURES=1)
endif (WITH_SERVER AND UNIX AND NOT WIN32)