2018-12-30 03:33:15 +01:00
|
|
|
#
|
|
|
|
# Author: Benjamin Sergeant
|
|
|
|
# Copyright (c) 2018 Machine Zone, Inc. All rights reserved.
|
|
|
|
#
|
2020-09-26 22:55:03 +02:00
|
|
|
cmake_minimum_required (VERSION 3.14)
|
2019-01-08 03:04:28 +01:00
|
|
|
project (ixwebsocket_unittest)
|
2018-12-30 03:33:15 +01:00
|
|
|
|
2020-11-16 06:08:45 +01:00
|
|
|
set (CMAKE_CXX_STANDARD 11)
|
2018-12-30 03:33:15 +01:00
|
|
|
|
2020-09-26 22:51:19 +02:00
|
|
|
option(USE_TLS "Add TLS support" ON)
|
2018-12-30 03:33:15 +01:00
|
|
|
|
2019-01-05 23:40:17 +01:00
|
|
|
# Shared sources
|
2020-11-11 20:11:34 +01:00
|
|
|
set (TEST_TARGET_NAMES
|
|
|
|
IXSocketTest
|
|
|
|
IXSocketConnectTest
|
|
|
|
IXWebSocketServerTest
|
|
|
|
IXWebSocketTestConnectionDisconnection
|
|
|
|
IXUrlParserTest
|
|
|
|
IXHttpClientTest
|
|
|
|
IXHttpServerTest
|
|
|
|
IXUnityBuildsTest
|
|
|
|
IXHttpTest
|
|
|
|
IXDNSLookupTest
|
|
|
|
IXWebSocketSubProtocolTest
|
|
|
|
IXSentryClientTest
|
|
|
|
IXWebSocketChatTest
|
|
|
|
IXWebSocketBroadcastTest
|
|
|
|
IXWebSocketPerMessageDeflateCompressorTest
|
|
|
|
IXStreamSqlTest
|
2020-11-16 17:41:08 +01:00
|
|
|
IXStrCaseCompareTest
|
2018-12-30 03:33:15 +01:00
|
|
|
)
|
|
|
|
|
2019-01-05 23:40:17 +01:00
|
|
|
# Some unittest don't work on windows yet
|
2020-03-23 03:36:29 +01:00
|
|
|
# Windows without TLS does not have hmac yet
|
2019-05-14 01:51:58 +02:00
|
|
|
if (UNIX)
|
2020-11-11 20:11:34 +01:00
|
|
|
list(APPEND TEST_TARGET_NAMES
|
|
|
|
IXWebSocketCloseTest
|
|
|
|
IXCobraChatTest
|
|
|
|
IXCobraMetricsPublisherTest
|
|
|
|
IXCobraToSentryBotTest
|
|
|
|
IXCobraToStatsdBotTest
|
|
|
|
IXCobraToStdoutBotTest
|
2019-01-05 23:40:17 +01:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2019-06-02 02:41:48 +02:00
|
|
|
# Ping test fails intermittently, disabling them for now
|
2020-06-19 10:16:07 +02:00
|
|
|
# IXWebSocketPingTest.cpp
|
2019-06-02 02:41:48 +02:00
|
|
|
# IXWebSocketPingTimeoutTest.cpp
|
|
|
|
|
2020-11-16 17:41:08 +01:00
|
|
|
# IXWebSocketLeakTest.cpp # commented until we have a fix for #224 /
|
|
|
|
# that was was fixed but now the test does not compile
|
|
|
|
|
2019-05-16 04:19:13 +02:00
|
|
|
# Disable tests for now that are failing or not reliable
|
2019-05-14 02:01:22 +02:00
|
|
|
|
2020-11-11 20:11:34 +01:00
|
|
|
find_package(JsonCpp)
|
|
|
|
if (NOT JSONCPP_FOUND)
|
|
|
|
set(JSONCPP_SOURCES ../third_party/jsoncpp/jsoncpp.cpp)
|
2019-12-04 01:01:46 +01:00
|
|
|
endif()
|
|
|
|
|
2020-06-25 19:05:02 +02:00
|
|
|
if (USE_PYTHON)
|
|
|
|
find_package(Python COMPONENTS Development)
|
|
|
|
if (NOT Python_FOUND)
|
|
|
|
message(FATAL_ERROR "Python3 not found")
|
|
|
|
endif()
|
|
|
|
message("Python_FOUND:${Python_FOUND}")
|
|
|
|
message("Python_VERSION:${Python_VERSION}")
|
|
|
|
message("Python_Development_FOUND:${Python_Development_FOUND}")
|
|
|
|
message("Python_LIBRARIES:${Python_LIBRARIES}")
|
2020-06-25 08:21:19 +02:00
|
|
|
endif()
|
|
|
|
|
2020-11-11 20:11:34 +01:00
|
|
|
add_library(ixwebsocket_test)
|
|
|
|
target_sources(ixwebsocket_test PRIVATE
|
|
|
|
${JSONCPP_SOURCES}
|
|
|
|
test_runner.cpp
|
|
|
|
IXTest.cpp
|
|
|
|
../third_party/msgpack11/msgpack11.cpp
|
|
|
|
)
|
|
|
|
target_compile_definitions(ixwebsocket_test PRIVATE ${TEST_PROGRAMS_DEFINITIONS})
|
|
|
|
target_include_directories(ixwebsocket_test PRIVATE
|
|
|
|
${PROJECT_SOURCE_DIR}/Catch2/single_include
|
|
|
|
../third_party
|
|
|
|
)
|
|
|
|
target_link_libraries(ixwebsocket_test ixsnake)
|
|
|
|
target_link_libraries(ixwebsocket_test ixcobra)
|
|
|
|
target_link_libraries(ixwebsocket_test ixwebsocket)
|
2020-11-11 20:16:19 +01:00
|
|
|
target_link_libraries(ixwebsocket_test ixcrypto)
|
2020-11-11 20:11:34 +01:00
|
|
|
target_link_libraries(ixwebsocket_test spdlog)
|
|
|
|
|
|
|
|
foreach(TEST_TARGET_NAME ${TEST_TARGET_NAMES})
|
|
|
|
add_executable(${TEST_TARGET_NAME}
|
|
|
|
${TEST_TARGET_NAME}.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories(${TEST_TARGET_NAME} PRIVATE
|
|
|
|
${PROJECT_SOURCE_DIR}/Catch2/single_include
|
|
|
|
../third_party
|
|
|
|
../third_party/msgpack11
|
|
|
|
)
|
|
|
|
|
|
|
|
target_compile_definitions(${TEST_TARGET_NAME} PRIVATE SPDLOG_COMPILED_LIB=1)
|
|
|
|
|
|
|
|
if (NOT JSONCPP_FOUND)
|
|
|
|
target_include_directories(${TEST_TARGET_NAME} PRIVATE ../third_party/jsoncpp)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (APPLE AND USE_TLS)
|
|
|
|
target_link_libraries(${TEST_TARGET_NAME} "-framework foundation" "-framework security")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# library with the most dependencies come first
|
2020-11-11 20:23:51 +01:00
|
|
|
target_link_libraries(${TEST_TARGET_NAME} ixwebsocket_test)
|
2020-11-11 20:11:34 +01:00
|
|
|
target_link_libraries(${TEST_TARGET_NAME} ixbots)
|
|
|
|
target_link_libraries(${TEST_TARGET_NAME} ixsnake)
|
|
|
|
target_link_libraries(${TEST_TARGET_NAME} ixcobra)
|
|
|
|
target_link_libraries(${TEST_TARGET_NAME} ixsentry)
|
2020-11-11 20:23:51 +01:00
|
|
|
|
|
|
|
if (JSONCPP_FOUND)
|
|
|
|
target_include_directories(${TEST_TARGET_NAME} PRIVATE ${JSONCPP_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(${TEST_TARGET_NAME} ${JSONCPP_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
2020-11-11 20:11:34 +01:00
|
|
|
target_link_libraries(${TEST_TARGET_NAME} ixredis)
|
|
|
|
target_link_libraries(${TEST_TARGET_NAME} ixwebsocket)
|
|
|
|
target_link_libraries(${TEST_TARGET_NAME} ixcrypto)
|
|
|
|
target_link_libraries(${TEST_TARGET_NAME} ixcore)
|
|
|
|
|
|
|
|
target_link_libraries(${TEST_TARGET_NAME} spdlog)
|
|
|
|
if (USE_PYTHON)
|
|
|
|
target_link_libraries(${TEST_TARGET_NAME} ${Python_LIBRARIES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_test(NAME ${TEST_TARGET_NAME}
|
|
|
|
COMMAND ${TEST_TARGET_NAME}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
2019-12-25 18:03:57 +01:00
|
|
|
|
2020-11-11 20:11:34 +01:00
|
|
|
endforeach()
|