2023-06-13 17:47:41 +02:00
|
|
|
##
|
|
|
|
## Tunable protoUnitTests parameters
|
|
|
|
##
|
|
|
|
set(TEST_PROTO_NTHREADS 1 CACHE STRING "protoUnitTests - Number of threads")
|
|
|
|
set(TEST_PROTO_RENEG 900 CACHE STRING "protoUnitTests - Renegotiation intervall")
|
|
|
|
set(TEST_PROTO_ITER 1000000 CACHE STRING "protoUnitTests - Number of iterations")
|
|
|
|
set(TEST_PROTO_SITER 1 CACHE STRING "protoUnitTests - Number of high-level iterations")
|
|
|
|
set(TEST_KEYCERT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../ssl" CACHE STRING "protoUnitTests - Certificate/private keys for testing")
|
|
|
|
option(TEST_PROTO_VERBOSE "test/ssl/proto - Enable verbose logging" OFF)
|
|
|
|
|
|
|
|
|
2023-02-14 18:20:50 +01:00
|
|
|
if (NOT BUILD_TESTING)
|
|
|
|
return()
|
|
|
|
endif()
|
2021-08-24 06:27:11 +02:00
|
|
|
|
2019-05-02 13:17:58 +02:00
|
|
|
include(dlgoogletest)
|
2019-02-12 14:04:03 +01:00
|
|
|
|
2019-05-02 13:17:58 +02:00
|
|
|
set(CORE_TEST_DEFINES
|
|
|
|
-DOPENVPN_FORCE_TUN_NULL
|
|
|
|
-DUNIT_TEST
|
|
|
|
-DUNITTEST_SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/\"
|
2022-07-01 16:00:34 +02:00
|
|
|
-DOPENVPN_RC_NOTIFY
|
2019-05-02 13:17:58 +02:00
|
|
|
)
|
2019-04-15 12:05:23 +02:00
|
|
|
|
2020-02-20 12:53:59 +01:00
|
|
|
add_executable(coreUnitTests
|
|
|
|
core_tests.cpp
|
2023-07-12 12:39:37 +02:00
|
|
|
test_acc.cpp
|
2020-02-20 12:53:59 +01:00
|
|
|
test_route_emulation.cpp
|
|
|
|
test_log.cpp
|
|
|
|
test_comp.cpp
|
|
|
|
test_b64.cpp
|
|
|
|
test_verify_x509_name.cpp
|
|
|
|
test_ssl.cpp
|
2020-09-01 13:55:34 +02:00
|
|
|
test_continuation.cpp
|
2021-09-09 22:55:37 +02:00
|
|
|
test_crypto.cpp
|
2021-02-06 04:57:52 +01:00
|
|
|
test_optfilt.cpp
|
2023-02-22 20:58:08 +01:00
|
|
|
test_clamp_typerange.cpp
|
2021-07-11 03:59:05 +02:00
|
|
|
test_pktstream.cpp
|
2021-02-17 03:20:28 +01:00
|
|
|
test_remotelist.cpp
|
2022-11-21 01:04:34 +01:00
|
|
|
test_relack.cpp
|
2021-03-30 03:41:52 +02:00
|
|
|
test_http_proxy.cpp
|
2021-04-21 05:53:24 +02:00
|
|
|
test_peer_fingerprint.cpp
|
2021-08-12 15:47:33 +02:00
|
|
|
test_safestr.cpp
|
2023-02-22 20:58:08 +01:00
|
|
|
test_numeric_cast.cpp
|
2022-01-26 15:57:32 +01:00
|
|
|
test_dns.cpp
|
2022-08-30 18:03:52 +02:00
|
|
|
test_header_deps.cpp
|
2022-07-01 16:00:34 +02:00
|
|
|
test_capture.cpp
|
|
|
|
test_cleanup.cpp
|
|
|
|
test_crypto_hashstr.cpp
|
|
|
|
test_csum.cpp
|
|
|
|
test_format.cpp
|
|
|
|
test_headredact.cpp
|
|
|
|
test_hostport.cpp
|
|
|
|
test_ip.cpp
|
2022-12-26 22:55:29 +01:00
|
|
|
test_ostream_containers.cpp
|
2022-07-01 16:00:34 +02:00
|
|
|
test_parseargv.cpp
|
|
|
|
test_path.cpp
|
|
|
|
test_pktid.cpp
|
|
|
|
test_prefixlen.cpp
|
2023-08-14 20:49:23 +02:00
|
|
|
test_randapi.cpp
|
2022-07-01 16:00:34 +02:00
|
|
|
test_rc.cpp
|
|
|
|
test_route.cpp
|
2023-10-25 17:51:24 +02:00
|
|
|
test_reliable.cpp
|
|
|
|
test_splitlines.cpp
|
2022-07-01 16:00:34 +02:00
|
|
|
test_statickey.cpp
|
|
|
|
test_streq.cpp
|
|
|
|
test_time.cpp
|
|
|
|
test_typeindex.cpp
|
2023-10-23 18:56:10 +02:00
|
|
|
test_userpass.cpp
|
2022-07-01 16:00:34 +02:00
|
|
|
test_validatecreds.cpp
|
|
|
|
test_weak.cpp
|
2022-08-30 18:03:52 +02:00
|
|
|
test_cliopt.cpp
|
2023-01-22 07:25:39 +01:00
|
|
|
test_buffer.cpp
|
2020-02-20 12:53:59 +01:00
|
|
|
)
|
|
|
|
|
2023-06-06 18:31:22 +02:00
|
|
|
add_executable(protoUnitTests
|
|
|
|
core_tests.cpp
|
|
|
|
test_proto.cpp
|
|
|
|
)
|
|
|
|
|
2023-06-13 17:47:41 +02:00
|
|
|
if (${TEST_PROTO_VERBOSE})
|
|
|
|
set(PROTO_CFLAGS_VERBOSE -DVERBOSE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
target_compile_definitions(protoUnitTests PRIVATE
|
|
|
|
${PROTO_CFLAGS_VERBOSE}
|
|
|
|
-DN_THREADS=${TEST_PROTO_NTHREADS}
|
|
|
|
-DRENEG=${TEST_PROTO_RENEG}
|
|
|
|
-DITER=${TEST_PROTO_ITER}
|
|
|
|
-DSITER=${TEST_PROTO_SITER}
|
|
|
|
-DTEST_KEYCERT_DIR=\"${TEST_KEYCERT_DIR}/\"
|
|
|
|
)
|
2023-06-06 18:31:22 +02:00
|
|
|
|
2020-02-20 12:53:59 +01:00
|
|
|
if (${USE_MBEDTLS})
|
|
|
|
target_sources(coreUnitTests PRIVATE
|
|
|
|
test_mbedtls_x509certinfo.cpp
|
2022-09-22 06:53:33 +02:00
|
|
|
test_mbedtls_authcert.cpp
|
2020-02-20 12:53:59 +01:00
|
|
|
)
|
|
|
|
else ()
|
|
|
|
target_sources(coreUnitTests PRIVATE
|
|
|
|
test_openssl_x509certinfo.cpp
|
2022-09-22 06:53:33 +02:00
|
|
|
test_openssl_authcert.cpp
|
2022-07-01 16:00:34 +02:00
|
|
|
test_opensslpki.cpp
|
|
|
|
test_session_id.cpp
|
2020-02-20 12:53:59 +01:00
|
|
|
)
|
|
|
|
endif ()
|
|
|
|
|
2020-09-01 13:55:34 +02:00
|
|
|
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
2023-02-13 15:39:48 +01:00
|
|
|
target_link_libraries(coreUnitTests cap)
|
2020-09-01 13:55:34 +02:00
|
|
|
target_sources(coreUnitTests PRIVATE test_sitnl.cpp)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (UNIX)
|
2021-12-14 14:36:47 +01:00
|
|
|
target_sources(coreUnitTests PRIVATE
|
|
|
|
# includes <arpa/inet.h>
|
|
|
|
test_buffer_ip.cpp
|
|
|
|
|
|
|
|
test_cpu_time.cpp
|
2019-04-15 12:05:23 +02:00
|
|
|
|
2022-07-01 16:00:34 +02:00
|
|
|
# directly includes tempfile.hpp
|
|
|
|
test_misc_unix.cpp
|
|
|
|
|
|
|
|
# Uses Unix Pipe semantics
|
|
|
|
test_pipe.cpp
|
2023-10-03 21:42:29 +02:00
|
|
|
|
|
|
|
# for now, only for ovpn3 servers (i.e., pgserv)
|
|
|
|
test_psid_cookie.cpp
|
2022-07-01 16:00:34 +02:00
|
|
|
)
|
2020-09-01 16:07:36 +02:00
|
|
|
endif ()
|
|
|
|
|
2020-09-01 16:07:36 +02:00
|
|
|
if (WIN32)
|
|
|
|
target_sources(coreUnitTests PRIVATE test_iphelper.cpp)
|
|
|
|
endif ()
|
|
|
|
|
2019-05-02 13:17:58 +02:00
|
|
|
add_core_dependencies(coreUnitTests)
|
2022-07-01 16:00:34 +02:00
|
|
|
add_json_library(coreUnitTests)
|
2023-06-06 18:31:22 +02:00
|
|
|
add_core_dependencies(protoUnitTests)
|
2022-07-01 16:00:34 +02:00
|
|
|
|
|
|
|
# xxHash
|
|
|
|
target_compile_definitions(coreUnitTests PRIVATE -DHAVE_XXHASH)
|
2023-02-24 15:39:15 +01:00
|
|
|
if(NOT MSVC)
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH
|
|
|
|
${DEP_DIR}/xxHash
|
|
|
|
${DEP_DIR}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
find_package(xxHash REQUIRED)
|
|
|
|
target_link_libraries(coreUnitTests xxHash::xxhash)
|
|
|
|
|
|
|
|
find_package(LZO)
|
|
|
|
if (LZO_FOUND)
|
|
|
|
target_compile_definitions(coreUnitTests PRIVATE -DHAVE_LZO)
|
|
|
|
target_link_libraries(coreUnitTests lzo::lzo)
|
2023-06-06 18:31:22 +02:00
|
|
|
target_compile_definitions(protoUnitTests PRIVATE -DHAVE_LZO)
|
|
|
|
target_link_libraries(protoUnitTests lzo::lzo)
|
2023-02-24 15:39:15 +01:00
|
|
|
message("lzo found, running lzo compression tests")
|
|
|
|
else ()
|
|
|
|
message("lzo not found, skipping lzo compression tests")
|
|
|
|
endif ()
|
2022-07-01 16:00:34 +02:00
|
|
|
|
2020-01-21 14:31:31 +01:00
|
|
|
target_link_libraries(coreUnitTests ${GTEST_LIB} ${EXTRA_LIBS})
|
2023-06-06 18:31:22 +02:00
|
|
|
target_link_libraries(protoUnitTests ${GTEST_LIB} ${EXTRA_LIBS})
|
2019-05-02 13:17:58 +02:00
|
|
|
|
2019-02-11 17:58:39 +01:00
|
|
|
target_compile_definitions(coreUnitTests PRIVATE ${CORE_TEST_DEFINES})
|
2023-06-06 18:31:22 +02:00
|
|
|
target_compile_definitions(protoUnitTests PRIVATE ${CORE_TEST_DEFINES})
|
2019-05-02 13:17:58 +02:00
|
|
|
target_include_directories(coreUnitTests PRIVATE ${EXTRA_INCLUDES})
|
2023-06-06 18:31:22 +02:00
|
|
|
target_include_directories(protoUnitTests PRIVATE ${EXTRA_INCLUDES})
|
2019-02-01 18:06:30 +01:00
|
|
|
|
2019-02-11 17:58:39 +01:00
|
|
|
add_test(NAME CoreTests COMMAND coreUnitTests)
|
2023-06-06 18:31:22 +02:00
|
|
|
add_test(NAME ProtoTests COMMAND protoUnitTests)
|