2021-08-24 06:27:11 +02:00
|
|
|
|
|
|
|
# current latest GTEST version
|
|
|
|
set(OVPN_GTEST_VERSION release-1.11.0)
|
|
|
|
# use an older version of gtest for GCC < 5.1.0; 1.10.1 is the latest
|
|
|
|
# version that works with the 4.8.x compilers
|
|
|
|
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1.0)
|
|
|
|
set(OVPN_GTEST_VERSION release-1.10.0)
|
|
|
|
# Note: not all the test compilation units hit the
|
|
|
|
# "'is_trivially_copy_constructible' is not a member of 'std'"
|
|
|
|
# issue; only the following do (with line number as of this
|
|
|
|
# writing and the include on the line):
|
|
|
|
# core_tests.cpp:21: // #include <gtest/gtest.h>
|
|
|
|
# test_b64.cpp:22: // #include "test_common.h"
|
|
|
|
# test_comp.cpp:45: // #include "test_common.h"
|
|
|
|
# test_log.cpp:22: // #include "test_common.h"
|
|
|
|
# test_route_emulation.cpp:23: // #include "test_common.h"
|
|
|
|
# test_verify_x509_name.cpp:25: // #include "test_common.h"
|
|
|
|
#
|
|
|
|
# Note further: test_common.h includes gtest/gtest.h; but that is
|
|
|
|
# not a sufficient condition to hit the bust. For example,
|
|
|
|
# test_continuation.cpp includes test_common.h but does not manifest
|
|
|
|
# the issue.
|
|
|
|
endif()
|
|
|
|
|
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
|
|
|
# Extra includes/libraries that are currently only use by the core unit test
|
2019-03-15 14:19:28 +01:00
|
|
|
FIND_PATH(LZO_INCLUDE_DIR NAMES lzo/lzo1x.h)
|
|
|
|
FIND_LIBRARY(LZO_LIBRARIES NAMES lzo2)
|
|
|
|
|
|
|
|
if (LZO_INCLUDE_DIR AND LZO_LIBRARIES)
|
|
|
|
list(APPEND CORE_TEST_DEFINES -DHAVE_LZO)
|
|
|
|
list(APPEND EXTRA_LIBS ${LZO_LIBRARIES})
|
2019-05-02 13:17:58 +02:00
|
|
|
list(APPEND EXTRA_INCLUDES ${LZO_INCLUDE_DIR})
|
2019-03-15 14:19:28 +01:00
|
|
|
message("lzo found, running lzo compression tests")
|
2019-05-02 13:17:58 +02:00
|
|
|
else ()
|
2019-03-15 14:19:28 +01:00
|
|
|
message("lzo not found, skipping lzo compression tests")
|
2019-05-02 13:17:58 +02:00
|
|
|
endif ()
|
2019-02-01 18:06:30 +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}/\"
|
|
|
|
)
|
2019-04-15 12:05:23 +02:00
|
|
|
|
2020-02-20 12:53:59 +01:00
|
|
|
add_executable(coreUnitTests
|
|
|
|
core_tests.cpp
|
|
|
|
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
|
2021-07-11 03:59:05 +02:00
|
|
|
test_pktstream.cpp
|
2021-02-17 03:20:28 +01:00
|
|
|
test_remotelist.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
|
2020-02-20 12:53:59 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
if (${USE_MBEDTLS})
|
|
|
|
target_sources(coreUnitTests PRIVATE
|
|
|
|
test_mbedtls_x509certinfo.cpp
|
|
|
|
)
|
|
|
|
else ()
|
|
|
|
target_sources(coreUnitTests PRIVATE
|
|
|
|
test_openssl_x509certinfo.cpp
|
|
|
|
)
|
|
|
|
endif ()
|
|
|
|
|
2020-09-01 13:55:34 +02:00
|
|
|
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
2022-01-11 14:30:18 +01:00
|
|
|
list(APPEND EXTRA_LIBS -lcap)
|
|
|
|
|
2020-09-01 13:55:34 +02:00
|
|
|
target_sources(coreUnitTests PRIVATE test_sitnl.cpp)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (UNIX)
|
|
|
|
target_sources(coreUnitTests PRIVATE test_cpu_time.cpp)
|
|
|
|
endif ()
|
2019-04-15 12:05:23 +02:00
|
|
|
|
2020-09-01 16:07:36 +02:00
|
|
|
if (WIN32)
|
|
|
|
target_sources(coreUnitTests PRIVATE test_iphelper.cpp)
|
|
|
|
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)
|
2020-01-21 14:31:31 +01:00
|
|
|
target_link_libraries(coreUnitTests ${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})
|
2019-05-02 13:17:58 +02:00
|
|
|
target_include_directories(coreUnitTests 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)
|