2014-08-05 13:24:32 +02:00
|
|
|
# CMake build script for ZeroMQ tests
|
2016-03-05 21:01:21 +01:00
|
|
|
cmake_minimum_required(VERSION "2.8.1")
|
2016-03-05 18:23:23 +01:00
|
|
|
|
2016-04-18 17:33:34 +02:00
|
|
|
# On Windows: solution file will be called tests.sln
|
2018-09-10 00:12:07 +02:00
|
|
|
project(tests)
|
2014-08-05 13:24:32 +02:00
|
|
|
|
|
|
|
set(tests
|
2020-04-14 00:03:19 +02:00
|
|
|
test_ancillaries
|
|
|
|
test_system
|
|
|
|
test_pair_inproc
|
|
|
|
test_pair_tcp
|
|
|
|
test_reqrep_inproc
|
|
|
|
test_reqrep_tcp
|
|
|
|
test_hwm
|
|
|
|
test_hwm_pubsub
|
|
|
|
test_reqrep_device
|
|
|
|
test_sub_forward
|
|
|
|
test_invalid_rep
|
|
|
|
test_msg_flags
|
|
|
|
test_msg_ffn
|
|
|
|
test_connect_resolve
|
|
|
|
test_immediate
|
|
|
|
test_last_endpoint
|
|
|
|
test_term_endpoint
|
|
|
|
test_router_mandatory
|
|
|
|
test_probe_router
|
|
|
|
test_stream
|
|
|
|
test_stream_empty
|
|
|
|
test_stream_disconnect
|
|
|
|
test_disconnect_inproc
|
|
|
|
test_unbind_wildcard
|
|
|
|
test_ctx_options
|
|
|
|
test_ctx_destroy
|
|
|
|
test_security_no_zap_handler
|
|
|
|
test_security_null
|
|
|
|
test_security_plain
|
|
|
|
test_security_zap
|
|
|
|
test_iov
|
|
|
|
test_spec_req
|
|
|
|
test_spec_rep
|
|
|
|
test_spec_dealer
|
|
|
|
test_spec_router
|
|
|
|
test_spec_pushpull
|
|
|
|
test_req_correlate
|
|
|
|
test_req_relaxed
|
|
|
|
test_conflate
|
|
|
|
test_inproc_connect
|
|
|
|
test_issue_566
|
|
|
|
test_shutdown_stress
|
|
|
|
test_timeo
|
|
|
|
test_many_sockets
|
|
|
|
test_diffserv
|
|
|
|
test_connect_rid
|
|
|
|
test_xpub_nodrop
|
|
|
|
test_pub_invert_matching
|
|
|
|
test_setsockopt
|
|
|
|
test_sockopt_hwm
|
|
|
|
test_heartbeats
|
|
|
|
test_atomics
|
|
|
|
test_bind_src_address
|
|
|
|
test_capabilities
|
|
|
|
test_metadata
|
|
|
|
test_router_handover
|
|
|
|
test_srcfd
|
|
|
|
test_stream_timeout
|
|
|
|
test_xpub_manual
|
|
|
|
test_xpub_welcome_msg
|
|
|
|
test_xpub_verbose
|
|
|
|
test_base85
|
|
|
|
test_bind_after_connect_tcp
|
|
|
|
test_sodium
|
|
|
|
test_monitor
|
|
|
|
test_socket_null
|
|
|
|
test_reconnect_ivl
|
2020-06-27 00:41:44 +02:00
|
|
|
test_reconnect_options
|
2020-09-04 10:57:26 +02:00
|
|
|
test_tcp_accept_filter
|
2020-04-14 00:03:19 +02:00
|
|
|
test_mock_pub_sub)
|
2018-09-10 00:12:07 +02:00
|
|
|
|
2019-03-22 16:34:01 +01:00
|
|
|
if(NOT WIN32)
|
2020-04-26 23:23:04 +02:00
|
|
|
list(APPEND tests test_security_gssapi test_socks test_connect_null_fuzzer test_bind_null_fuzzer test_connect_fuzzer test_bind_fuzzer)
|
2019-03-22 16:34:01 +01:00
|
|
|
endif()
|
|
|
|
|
2017-08-15 16:28:24 +02:00
|
|
|
if(ZMQ_HAVE_CURVE)
|
2021-09-21 23:07:51 +02:00
|
|
|
# TODO: always fails running under Github Actions via CMake
|
|
|
|
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
list(APPEND tests test_security_curve)
|
|
|
|
endif()
|
2020-04-26 22:59:28 +02:00
|
|
|
if(NOT WIN32)
|
2020-04-26 23:23:04 +02:00
|
|
|
list(APPEND tests test_connect_curve_fuzzer test_bind_curve_fuzzer test_z85_decode_fuzzer)
|
2020-04-26 22:59:28 +02:00
|
|
|
endif()
|
2017-08-15 16:28:24 +02:00
|
|
|
endif()
|
2018-09-10 00:12:07 +02:00
|
|
|
|
2019-10-31 10:37:22 +01:00
|
|
|
option(ENABLE_CAPSH "Run tests that require sudo and capsh (for cap_net_admin)" OFF)
|
|
|
|
if(ENABLE_CAPSH)
|
|
|
|
find_program(CAPSH_PROGRAM NAMES capsh)
|
2019-02-07 14:40:00 +01:00
|
|
|
|
2020-04-14 00:03:19 +02:00
|
|
|
if(CAPSH_PROGRAM)
|
|
|
|
list(APPEND tests test_pair_tcp_cap_net_admin)
|
2019-10-31 10:37:22 +01:00
|
|
|
else()
|
2020-04-14 00:03:19 +02:00
|
|
|
message(STATUS "capsh not found, skipping tests that require CAP_NET_ADMIN")
|
2019-10-31 10:37:22 +01:00
|
|
|
endif()
|
2019-02-07 14:40:00 +01:00
|
|
|
endif()
|
|
|
|
|
2019-10-19 14:46:53 +02:00
|
|
|
if(ZMQ_HAVE_IPC)
|
2020-04-14 00:03:19 +02:00
|
|
|
list(APPEND tests test_ipc_wildcard test_pair_ipc test_reqrep_ipc test_rebind_ipc)
|
2019-10-19 14:46:53 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT WIN32)
|
2020-04-14 00:03:19 +02:00
|
|
|
list(
|
|
|
|
APPEND
|
|
|
|
tests
|
2018-09-10 00:12:07 +02:00
|
|
|
test_proxy
|
2018-09-13 23:14:06 +02:00
|
|
|
test_proxy_hwm
|
2018-09-10 00:12:07 +02:00
|
|
|
test_proxy_single_socket
|
|
|
|
test_proxy_terminate
|
|
|
|
test_getsockopt_memset
|
|
|
|
test_filter_ipc
|
|
|
|
test_stream_exceeds_buffer
|
|
|
|
test_router_mandatory_hwm
|
|
|
|
test_use_fd
|
2020-04-14 00:03:19 +02:00
|
|
|
test_zmq_poll_fd)
|
2014-08-05 13:24:32 +02:00
|
|
|
if(HAVE_FORK)
|
|
|
|
list(APPEND tests test_fork)
|
|
|
|
endif()
|
2016-04-15 00:44:17 +02:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
2020-04-14 00:03:19 +02:00
|
|
|
list(APPEND tests test_abstract_ipc)
|
2016-04-21 12:33:20 +02:00
|
|
|
if(ZMQ_HAVE_TIPC)
|
2020-04-14 00:03:19 +02:00
|
|
|
list(
|
|
|
|
APPEND
|
|
|
|
tests
|
2018-09-10 00:12:07 +02:00
|
|
|
test_address_tipc
|
|
|
|
test_pair_tipc
|
|
|
|
test_reqrep_device_tipc
|
|
|
|
test_reqrep_tipc
|
|
|
|
test_router_mandatory_tipc
|
|
|
|
test_sub_forward_tipc
|
|
|
|
test_connect_delay_tipc
|
|
|
|
test_shutdown_stress_tipc
|
2020-04-14 00:03:19 +02:00
|
|
|
test_term_endpoint_tipc)
|
2016-04-21 12:33:20 +02:00
|
|
|
endif()
|
2016-04-15 00:44:17 +02:00
|
|
|
endif()
|
2014-08-05 13:24:32 +02:00
|
|
|
endif()
|
2015-12-07 13:19:45 +01:00
|
|
|
|
|
|
|
if(WITH_VMCI)
|
2020-04-14 00:03:19 +02:00
|
|
|
list(APPEND tests test_pair_vmci test_reqrep_vmci)
|
2015-12-07 13:19:45 +01:00
|
|
|
endif()
|
2014-08-05 13:24:32 +02:00
|
|
|
|
2018-09-10 00:12:07 +02:00
|
|
|
if(ENABLE_DRAFTS)
|
2020-04-14 00:03:19 +02:00
|
|
|
list(
|
|
|
|
APPEND
|
|
|
|
tests
|
2018-09-10 00:12:07 +02:00
|
|
|
test_poller
|
|
|
|
test_thread_safe
|
|
|
|
test_client_server
|
|
|
|
test_timers
|
|
|
|
test_radio_dish
|
|
|
|
test_scatter_gather
|
|
|
|
test_dgram
|
|
|
|
test_app_meta
|
|
|
|
test_router_notify
|
2019-05-17 23:12:32 +02:00
|
|
|
test_xpub_manual_last_value
|
2020-02-09 21:04:56 +01:00
|
|
|
test_peer
|
2020-05-09 06:44:32 +02:00
|
|
|
test_msg_init
|
|
|
|
test_channel
|
|
|
|
test_hello_msg
|
|
|
|
test_disconnect_msg
|
2021-06-06 13:28:29 +02:00
|
|
|
test_hiccup_msg
|
2020-05-09 06:44:32 +02:00
|
|
|
)
|
2021-05-15 00:05:56 +02:00
|
|
|
if(ZMQ_HAVE_BUSY_POLL)
|
|
|
|
list(APPEND tests test_busy_poll)
|
|
|
|
endif()
|
2020-04-14 00:03:19 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ZMQ_HAVE_WS)
|
|
|
|
list(APPEND tests test_ws_transport)
|
|
|
|
if(ZMQ_HAVE_WSS)
|
|
|
|
list(APPEND tests test_wss_transport)
|
|
|
|
endif()
|
2018-09-10 00:12:07 +02:00
|
|
|
endif()
|
2016-05-02 20:44:35 +02:00
|
|
|
|
2016-03-05 18:23:23 +01:00
|
|
|
# add location of platform.hpp for Windows builds
|
|
|
|
if(WIN32)
|
2018-09-10 00:12:07 +02:00
|
|
|
add_definitions(-DZMQ_CUSTOM_PLATFORM_HPP)
|
|
|
|
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)
|
|
|
|
# Same name on 64bit systems
|
|
|
|
link_libraries(ws2_32.lib)
|
2016-03-05 18:23:23 +01:00
|
|
|
endif()
|
|
|
|
|
2020-04-14 00:03:19 +02:00
|
|
|
add_library(
|
|
|
|
unity STATIC
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.c" "${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.h"
|
2018-09-10 00:12:07 +02:00
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity_internals.h")
|
2020-04-14 00:03:19 +02:00
|
|
|
set_target_properties(unity PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.h")
|
2019-02-07 16:42:16 +01:00
|
|
|
target_compile_definitions(unity PUBLIC "UNITY_USE_COMMAND_LINE_ARGS" "UNITY_EXCLUDE_FLOAT")
|
2018-09-10 00:12:07 +02:00
|
|
|
target_include_directories(unity PUBLIC "${CMAKE_CURRENT_LIST_DIR}/../external/unity")
|
|
|
|
|
2019-03-23 11:27:12 +01:00
|
|
|
set(TESTUTIL_SOURCES
|
|
|
|
testutil.cpp
|
|
|
|
testutil.hpp
|
|
|
|
testutil_monitoring.cpp
|
|
|
|
testutil_monitoring.hpp
|
|
|
|
testutil_security.cpp
|
|
|
|
testutil_security.hpp
|
|
|
|
testutil_unity.cpp
|
2020-04-14 00:03:19 +02:00
|
|
|
testutil_unity.hpp)
|
2019-03-23 11:27:12 +01:00
|
|
|
if(BUILD_STATIC)
|
2020-04-14 00:03:19 +02:00
|
|
|
add_library(testutil-static STATIC ${TESTUTIL_SOURCES})
|
|
|
|
target_link_libraries(testutil-static libzmq-static ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} unity)
|
2019-03-23 11:27:12 +01:00
|
|
|
endif()
|
|
|
|
if(BUILD_SHARED)
|
2020-04-14 00:03:19 +02:00
|
|
|
add_library(testutil STATIC ${TESTUTIL_SOURCES})
|
|
|
|
target_link_libraries(testutil libzmq ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} unity)
|
2019-03-23 11:27:12 +01:00
|
|
|
endif()
|
|
|
|
if(BUILD_STATIC AND NOT BUILD_SHARED)
|
2020-04-14 00:03:19 +02:00
|
|
|
# use testutil-static for both tests and unit tests
|
|
|
|
set(TESTUTIL_LIB testutil-static)
|
2019-03-23 11:27:12 +01:00
|
|
|
else()
|
2020-04-14 00:03:19 +02:00
|
|
|
# use testutil for tests and testutil-static for unit tests
|
|
|
|
set(TESTUTIL_LIB testutil)
|
2019-03-23 11:27:12 +01:00
|
|
|
endif()
|
|
|
|
|
2018-09-10 00:12:07 +02:00
|
|
|
if(MSVC_VERSION LESS 1700)
|
|
|
|
set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.c" PROPERTIES LANGUAGE CXX)
|
|
|
|
endif()
|
2018-03-16 12:48:00 +01:00
|
|
|
|
2018-09-10 00:12:07 +02:00
|
|
|
if(MSVC_VERSION LESS 1600)
|
|
|
|
target_compile_definitions(unity PUBLIC "UNITY_EXCLUDE_STDINT_H")
|
|
|
|
endif()
|
2018-05-24 14:10:26 +02:00
|
|
|
|
2019-03-23 11:27:12 +01:00
|
|
|
# add include dirs for all targets
|
2018-08-16 07:17:44 +02:00
|
|
|
include_directories("${ZeroMQ_SOURCE_DIR}/../include" "${ZeroMQ_BINARY_DIR}")
|
2019-03-23 13:04:57 +01:00
|
|
|
if(WIN32)
|
|
|
|
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
|
|
|
endif()
|
2016-03-05 18:23:23 +01:00
|
|
|
|
2020-04-18 12:03:15 +02:00
|
|
|
# Does not work, times out every time
|
|
|
|
if(WIN32)
|
|
|
|
list(REMOVE_ITEM tests test_many_sockets)
|
|
|
|
endif()
|
|
|
|
|
2014-08-05 13:24:32 +02:00
|
|
|
foreach(test ${tests})
|
2017-09-01 11:59:48 +02:00
|
|
|
# target_sources not supported before CMake 3.1
|
2018-09-10 00:12:07 +02:00
|
|
|
if(ZMQ_HAVE_CURVE AND ${test} MATCHES test_security_curve)
|
2020-04-14 00:03:19 +02:00
|
|
|
add_executable(${test} ${test}.cpp "../src/tweetnacl.c" "../src/err.cpp" "../src/random.cpp" "../src/clock.cpp")
|
2018-09-10 00:12:07 +02:00
|
|
|
else()
|
2019-03-23 11:27:12 +01:00
|
|
|
add_executable(${test} ${test}.cpp)
|
2018-09-10 00:12:07 +02:00
|
|
|
endif()
|
2019-03-23 11:27:12 +01:00
|
|
|
target_link_libraries(${test} ${TESTUTIL_LIB})
|
2016-03-05 18:23:23 +01:00
|
|
|
if(WIN32)
|
2020-04-14 00:03:19 +02:00
|
|
|
# This is the output for Debug dynamic builds on Visual Studio 6.0 You should provide the correct directory, don't
|
|
|
|
# know how to do it automatically
|
2016-07-12 15:54:55 +02:00
|
|
|
find_path(LIBZMQ_PATH "libzmq.lib" PATHS "../bin/Win32/Debug/v120/dynamic")
|
|
|
|
if(NOT ${LIBZMQ_PATH} STREQUAL "LIBZMQ_PATH-NOTFOUND")
|
2018-09-10 00:12:07 +02:00
|
|
|
set_target_properties(${test} PROPERTIES LINK_FLAGS "/LIBPATH:${LIBZMQ_PATH}")
|
2016-07-12 15:54:55 +02:00
|
|
|
endif()
|
2016-03-05 18:23:23 +01:00
|
|
|
else()
|
2016-04-19 13:20:59 +02:00
|
|
|
# per-test directories not generated on OS X / Darwin
|
2018-09-10 00:12:07 +02:00
|
|
|
if(NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang.*")
|
|
|
|
link_directories(${test} PRIVATE "${ZeroMQ_SOURCE_DIR}/../lib")
|
2016-04-19 13:20:59 +02:00
|
|
|
endif()
|
2016-03-05 18:23:23 +01:00
|
|
|
endif()
|
2020-02-23 18:17:22 +01:00
|
|
|
|
2014-08-05 13:24:32 +02:00
|
|
|
if(RT_LIBRARY)
|
2018-09-10 00:12:07 +02:00
|
|
|
target_link_libraries(${test} ${RT_LIBRARY})
|
2014-08-05 13:24:32 +02:00
|
|
|
endif()
|
2019-04-18 13:23:36 +02:00
|
|
|
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "QNX")
|
|
|
|
target_link_libraries(${test} socket)
|
|
|
|
target_link_libraries(${test} m)
|
|
|
|
endif()
|
|
|
|
|
2014-08-05 13:24:32 +02:00
|
|
|
if(WIN32)
|
2020-04-14 00:03:19 +02:00
|
|
|
add_test(
|
|
|
|
NAME ${test}
|
|
|
|
WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}
|
|
|
|
COMMAND ${test})
|
2014-08-05 13:24:32 +02:00
|
|
|
else()
|
2020-04-14 00:03:19 +02:00
|
|
|
if(${test} MATCHES "_cap_net_admin")
|
2019-02-07 14:40:00 +01:00
|
|
|
add_test(NAME ${test} COMMAND sh -c "sudo ${CAPSH_PROGRAM} --caps=cap_net_admin+eip -- -c $<TARGET_FILE:${test}>")
|
|
|
|
else()
|
|
|
|
add_test(NAME ${test} COMMAND ${test})
|
|
|
|
endif()
|
2014-08-05 13:24:32 +02:00
|
|
|
endif()
|
2015-10-23 00:33:27 +02:00
|
|
|
set_tests_properties(${test} PROPERTIES TIMEOUT 10)
|
2018-03-09 17:47:42 +01:00
|
|
|
set_tests_properties(${test} PROPERTIES SKIP_RETURN_CODE 77)
|
2014-08-05 13:24:32 +02:00
|
|
|
endforeach()
|
|
|
|
|
2020-04-14 00:03:19 +02:00
|
|
|
# override timeout for these tests
|
2018-04-28 16:29:54 +02:00
|
|
|
set_tests_properties(test_heartbeats PROPERTIES TIMEOUT 60)
|
2017-08-15 16:28:24 +02:00
|
|
|
|
2018-06-01 14:44:42 +02:00
|
|
|
if(WIN32 AND ENABLE_DRAFTS)
|
2018-05-23 16:31:05 +02:00
|
|
|
set_tests_properties(test_radio_dish PROPERTIES TIMEOUT 30)
|
|
|
|
endif()
|
|
|
|
|
2021-09-21 23:07:51 +02:00
|
|
|
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
if(ZMQ_HAVE_CURVE)
|
|
|
|
set_tests_properties(test_security_curve PROPERTIES TIMEOUT 60)
|
|
|
|
endif()
|
|
|
|
# add additional required flags ZMQ_USE_TWEETNACL will already be defined when not using sodium
|
|
|
|
if(ZMQ_HAVE_CURVE AND NOT ZMQ_USE_TWEETNACL)
|
|
|
|
target_compile_definitions(test_security_curve PRIVATE "-DZMQ_USE_TWEETNACL")
|
|
|
|
endif()
|
2017-08-15 16:28:24 +02:00
|
|
|
endif()
|
2017-08-04 12:07:41 +02:00
|
|
|
|
2017-08-17 11:45:18 +02:00
|
|
|
set_tests_properties(test_security_zap PROPERTIES TIMEOUT 60)
|
2020-02-03 23:19:45 +01:00
|
|
|
set_tests_properties(test_reconnect_ivl PROPERTIES TIMEOUT 15)
|
|
|
|
|
2020-04-14 00:03:19 +02:00
|
|
|
# Check whether all tests in the current folder are present
|
2015-10-23 16:14:30 +02:00
|
|
|
file(READ "${CMAKE_CURRENT_LIST_FILE}" CURRENT_LIST_FILE_CONTENT)
|
|
|
|
file(GLOB ALL_TEST_SOURCES "test_*.cpp")
|
|
|
|
foreach(TEST_SOURCE ${ALL_TEST_SOURCES})
|
|
|
|
get_filename_component(TESTNAME "${TEST_SOURCE}" NAME_WE)
|
|
|
|
string(REGEX MATCH "${TESTNAME}" MATCH_TESTNAME "${CURRENT_LIST_FILE_CONTENT}")
|
2018-09-10 00:12:07 +02:00
|
|
|
if(NOT MATCH_TESTNAME)
|
2015-10-23 16:14:30 +02:00
|
|
|
message(AUTHOR_WARNING "Test '${TESTNAME}' is not known to CTest.")
|
|
|
|
endif()
|
|
|
|
endforeach()
|