aboutsummaryrefslogtreecommitdiff
path: root/tests/CMakeLists.txt
diff options
context:
space:
mode:
authorAnderson Toshiyuki Sasaki <ansasaki@redhat.com>2020-12-15 13:35:06 +0100
committerAnderson Toshiyuki Sasaki <ansasaki@redhat.com>2021-01-12 12:54:18 +0100
commit8e56585c72f5c8bed6e0747b35dfec4bb0208694 (patch)
tree526dcacb6889512c91f0a4ea11e9b16cabf7f441 /tests/CMakeLists.txt
parentd4258d1461d0acdca758f8df30d2f40ea6b7bf16 (diff)
downloadlibssh-8e56585c72f5c8bed6e0747b35dfec4bb0208694.tar.gz
libssh-8e56585c72f5c8bed6e0747b35dfec4bb0208694.tar.xz
libssh-8e56585c72f5c8bed6e0747b35dfec4bb0208694.zip
tests/external_override: Add override test for internal implementations
This adds a test to check if the internal implementation is not used when it is not supposed to be used. To be able to override functions using LD_PRELOAD, a shared version of the torture library was added, as well as a shared library for each of the algorithms implemented internally (ChaCha20, Poly1305, curve25519, and ed25519). Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'tests/CMakeLists.txt')
-rw-r--r--tests/CMakeLists.txt48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 208d62dd..44d4f201 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -12,6 +12,7 @@ include_directories(${OPENSSL_INCLUDE_DIR}
${libssh_BINARY_DIR}/include
${libssh_BINARY_DIR}
${libssh_SOURCE_DIR}/src
+ ${CMAKE_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}/tests)
@@ -32,6 +33,50 @@ target_compile_options(${TORTURE_LIBRARY} PRIVATE
-DSSH_PING_EXECUTABLE="${CMAKE_CURRENT_BINARY_DIR}/ssh_ping"
)
+# The shared version of the library is only useful when client testing is
+# enabled
+if (CLIENT_TESTING)
+ # create shared test library
+ set(TORTURE_SHARED_LIBRARY torture_shared)
+
+ if (MINGW)
+ set(USE_ATTRIBUTE_WEAK "-DUSE_ATTRIBUTE_WEAK")
+ endif ()
+
+ # Create a list of symbols that should be wrapped for override test
+ set(WRAP_SYMBOLS "")
+ list(APPEND WRAP_SYMBOLS
+ "-Wl,--wrap=chacha_keysetup"
+ "-Wl,--wrap=chacha_ivsetup"
+ "-Wl,--wrap=chacha_encrypt_bytes")
+ list(APPEND WRAP_SYMBOLS "-Wl,--wrap=poly1305_auth")
+ list(APPEND WRAP_SYMBOLS
+ "-Wl,--wrap=crypto_sign_ed25519_keypair"
+ "-Wl,--wrap=crypto_sign_ed25519"
+ "-Wl,--wrap=crypto_sign_ed25519_open")
+ list(APPEND WRAP_SYMBOLS
+ "-Wl,--wrap=crypto_scalarmult_base"
+ "-Wl,--wrap=crypto_scalarmult")
+
+ add_library(${TORTURE_SHARED_LIBRARY}
+ SHARED
+ cmdline.c
+ torture.c
+ torture_key.c
+ torture_pki.c
+ torture_cmocka.c
+ )
+ target_link_libraries(${TORTURE_SHARED_LIBRARY}
+ ${CMOCKA_LIBRARY}
+ ssh::static
+ ${WRAP_SYMBOLS}
+ )
+ target_compile_options(${TORTURE_SHARED_LIBRARY} PRIVATE
+ -DSSH_PING_EXECUTABLE="${CMAKE_CURRENT_BINARY_DIR}/ssh_ping"
+ ${USE_ATTRIBUTE_WEAK}
+ )
+endif ()
+
if (ARGP_LIBRARY)
target_link_libraries(${TORTURE_LIBRARY}
${ARGP_LIBRARY}
@@ -259,6 +304,9 @@ endif ()
if (CLIENT_TESTING)
add_subdirectory(client)
+
+ # Only add override testing if testing the client
+ add_subdirectory(external_override)
endif ()
if (WITH_SERVER AND SERVER_TESTING)