2010-03-02 15:47:14 +03:00
|
|
|
project(unittests C)
|
|
|
|
|
2015-05-05 20:04:49 +03:00
|
|
|
include_directories(${OPENSSL_INCLUDE_DIR})
|
|
|
|
|
2018-09-21 14:10:54 +03:00
|
|
|
set(LIBSSH_UNIT_TESTS
|
|
|
|
torture_buffer
|
2018-09-29 15:06:00 +03:00
|
|
|
torture_bytearray
|
2018-09-21 14:10:54 +03:00
|
|
|
torture_callbacks
|
|
|
|
torture_crypto
|
|
|
|
torture_init
|
|
|
|
torture_list
|
|
|
|
torture_misc
|
|
|
|
torture_config
|
|
|
|
torture_options
|
|
|
|
torture_isipaddr
|
|
|
|
torture_knownhosts_parsing
|
|
|
|
torture_hashes
|
2018-09-07 16:26:49 +03:00
|
|
|
torture_packet_filter
|
2018-10-24 21:01:04 +03:00
|
|
|
torture_temp_dir
|
2018-11-19 15:10:48 +03:00
|
|
|
torture_temp_file
|
2018-11-20 16:01:57 +03:00
|
|
|
torture_push_pop_dir
|
2018-10-02 18:21:39 +03:00
|
|
|
torture_session_keys
|
2019-05-15 18:48:41 +03:00
|
|
|
torture_tokens
|
2018-09-21 14:10:54 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
set(LIBSSH_THREAD_UNIT_TESTS
|
|
|
|
torture_rand
|
|
|
|
torture_threads_init
|
|
|
|
torture_threads_buffer
|
|
|
|
torture_threads_crypto
|
|
|
|
)
|
2018-07-04 19:35:58 +03:00
|
|
|
|
2010-12-29 22:33:32 +03:00
|
|
|
if (UNIX AND NOT WIN32)
|
2018-09-21 14:10:54 +03:00
|
|
|
set(LIBSSH_UNIT_TESTS
|
|
|
|
${LIBSSH_UNIT_TESTS}
|
|
|
|
# this uses a socketpair
|
|
|
|
torture_packet
|
|
|
|
# requires ssh-keygen
|
|
|
|
torture_keyfiles
|
|
|
|
torture_pki
|
|
|
|
torture_pki_rsa
|
|
|
|
torture_pki_ed25519
|
|
|
|
# requires /dev/null
|
|
|
|
torture_channel
|
|
|
|
)
|
2018-01-08 23:49:49 +03:00
|
|
|
|
2019-03-01 15:15:35 +03:00
|
|
|
if (WITH_SERVER)
|
2016-06-02 12:52:19 +03:00
|
|
|
set(LIBSSH_UNIT_TESTS
|
|
|
|
${LIBSSH_UNIT_TESTS}
|
2019-03-01 15:15:35 +03:00
|
|
|
torture_bind_config)
|
|
|
|
|
|
|
|
if (WITH_GEX)
|
|
|
|
set(LIBSSH_UNIT_TESTS
|
|
|
|
${LIBSSH_UNIT_TESTS}
|
|
|
|
torture_moduli)
|
|
|
|
endif()
|
2016-06-02 12:52:19 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2018-01-08 23:49:49 +03:00
|
|
|
if (HAVE_DSA)
|
2018-09-21 14:10:54 +03:00
|
|
|
set(LIBSSH_UNIT_TESTS
|
|
|
|
${LIBSSH_UNIT_TESTS}
|
|
|
|
torture_pki_dsa
|
|
|
|
)
|
2018-01-08 23:49:49 +03:00
|
|
|
endif()
|
2018-09-21 14:10:54 +03:00
|
|
|
|
2019-12-11 00:40:53 +03:00
|
|
|
if (WITH_PKCS11_URI)
|
|
|
|
set(LIBSSH_UNIT_TESTS
|
|
|
|
${LIBSSH_UNIT_TESTS}
|
|
|
|
torture_pki_rsa_uri
|
|
|
|
torture_pki_ecdsa_uri
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2018-01-09 00:36:53 +03:00
|
|
|
if (HAVE_ECC)
|
2018-09-21 14:10:54 +03:00
|
|
|
set(LIBSSH_UNIT_TESTS
|
|
|
|
${LIBSSH_UNIT_TESTS}
|
|
|
|
torture_pki_ecdsa
|
|
|
|
)
|
2018-01-09 00:36:53 +03:00
|
|
|
endif()
|
|
|
|
|
2018-09-21 14:10:54 +03:00
|
|
|
set(LIBSSH_THREAD_UNIT_TESTS
|
|
|
|
${LIBSSH_THREAD_UNIT_TESTS}
|
|
|
|
# requires pthread
|
|
|
|
torture_threads_pki_rsa
|
|
|
|
)
|
2022-05-23 21:28:52 +03:00
|
|
|
if (WITH_SERVER)
|
|
|
|
# Not working correctly
|
|
|
|
# add_cmocka_test(torture_server_x11 torture_server_x11.c ${TEST_TARGET_LIBRARIES})
|
|
|
|
# the signals are not testable under cmocka
|
|
|
|
# set(LIBSSH_THREAD_UNIT_TESTS
|
|
|
|
# ${LIBSSH_THREAD_UNIT_TESTS}
|
|
|
|
# torture_unit_server
|
|
|
|
# )
|
|
|
|
endif (WITH_SERVER)
|
2010-12-29 22:33:32 +03:00
|
|
|
endif (UNIX AND NOT WIN32)
|
2018-09-21 14:10:54 +03:00
|
|
|
|
|
|
|
foreach(_UNIT_TEST ${LIBSSH_UNIT_TESTS})
|
|
|
|
add_cmocka_test(${_UNIT_TEST}
|
|
|
|
SOURCES ${_UNIT_TEST}.c
|
|
|
|
COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS}
|
|
|
|
LINK_LIBRARIES ${TEST_TARGET_LIBRARIES}
|
|
|
|
)
|
2022-07-08 12:10:39 +03:00
|
|
|
|
|
|
|
set_property(TEST ${_UNIT_TEST}
|
|
|
|
PROPERTY
|
2022-09-07 14:12:32 +03:00
|
|
|
ENVIRONMENT
|
|
|
|
LSAN_OPTIONS=suppressions=${libssh-tests_SOURCE_DIR}/suppressions/lsan.supp;OPENSSL_ENABLE_SHA1_SIGNATURES=1)
|
2018-09-21 14:10:54 +03:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if (CMAKE_USE_PTHREADS_INIT)
|
|
|
|
foreach(_UNIT_TEST ${LIBSSH_THREAD_UNIT_TESTS})
|
|
|
|
add_cmocka_test(${_UNIT_TEST}
|
|
|
|
SOURCES ${_UNIT_TEST}.c
|
|
|
|
COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS}
|
|
|
|
LINK_LIBRARIES ${TEST_TARGET_LIBRARIES} Threads::Threads
|
|
|
|
)
|
2022-07-08 12:10:39 +03:00
|
|
|
|
|
|
|
set_property(TEST ${_UNIT_TEST}
|
|
|
|
PROPERTY
|
2022-09-07 14:12:32 +03:00
|
|
|
ENVIRONMENT
|
|
|
|
LSAN_OPTIONS=suppressions=${libssh-tests_SOURCE_DIR}/suppressions/lsan.supp;OPENSSL_ENABLE_SHA1_SIGNATURES=1)
|
2018-09-21 14:10:54 +03:00
|
|
|
endforeach()
|
|
|
|
endif ()
|
|
|
|
|