2014-08-05 13:24:32 +02:00
|
|
|
# CMake build script for ZeroMQ tests
|
2016-03-05 14:01:21 -06:00
|
|
|
cmake_minimum_required(VERSION "2.8.1")
|
2016-03-05 11:23:23 -06:00
|
|
|
|
2016-04-18 16:33:34 +01: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
|
2022-11-29 13:00:11 +01: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
|
|
|
|
test_reconnect_options
|
|
|
|
test_tcp_accept_filter
|
|
|
|
test_mock_pub_sub)
|
2018-09-10 00:12:07 +02:00
|
|
|
|
2019-03-22 11:34:01 -04:00
|
|
|
if(NOT WIN32)
|
2020-04-26 22:23:04 +01: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 11:34:01 -04:00
|
|
|
endif()
|
|
|
|
|
2017-08-15 16:28:24 +02:00
|
|
|
if(ZMQ_HAVE_CURVE)
|
2021-09-21 22:07:51 +01:00
|
|
|
# TODO: always fails running under Github Actions via CMake
|
|
|
|
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
list(APPEND tests test_security_curve)
|
|
|
|
endif()
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2020-04-26 21:59:28 +01:00
|
|
|
if(NOT WIN32)
|
2020-04-26 22:23:04 +01:00
|
|
|
list(APPEND tests test_connect_curve_fuzzer test_bind_curve_fuzzer test_z85_decode_fuzzer)
|
2020-04-26 21:59:28 +01:00
|
|
|
endif()
|
2017-08-15 16:28:24 +02:00
|
|
|
endif()
|
2018-09-10 00:12:07 +02:00
|
|
|
|
2019-10-31 09:37:22 +00:00
|
|
|
option(ENABLE_CAPSH "Run tests that require sudo and capsh (for cap_net_admin)" OFF)
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2019-10-31 09:37:22 +00:00
|
|
|
if(ENABLE_CAPSH)
|
|
|
|
find_program(CAPSH_PROGRAM NAMES capsh)
|
2019-02-07 08:40:00 -05:00
|
|
|
|
2020-04-14 00:03:19 +02:00
|
|
|
if(CAPSH_PROGRAM)
|
|
|
|
list(APPEND tests test_pair_tcp_cap_net_admin)
|
2019-10-31 09:37:22 +00: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 09:37:22 +00:00
|
|
|
endif()
|
2019-02-07 08:40:00 -05: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)
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2014-08-05 13:24:32 +02:00
|
|
|
if(HAVE_FORK)
|
|
|
|
list(APPEND tests test_fork)
|
|
|
|
endif()
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2016-04-14 23:44:17 +01:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
|
2020-04-14 00:03:19 +02:00
|
|
|
list(APPEND tests test_abstract_ipc)
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2016-04-21 11:33:20 +01: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 11:33:20 +01:00
|
|
|
endif()
|
2016-04-14 23:44:17 +01:00
|
|
|
endif()
|
2014-08-05 13:24:32 +02:00
|
|
|
endif()
|
2015-12-07 18:19:45 +06:00
|
|
|
|
|
|
|
if(WITH_VMCI)
|
2020-04-14 00:03:19 +02:00
|
|
|
list(APPEND tests test_pair_vmci test_reqrep_vmci)
|
2015-12-07 18:19:45 +06: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-18 05:12:32 +08:00
|
|
|
test_xpub_manual_last_value
|
2020-02-09 22:04:56 +02:00
|
|
|
test_peer
|
2020-05-09 07:44:32 +03:00
|
|
|
test_msg_init
|
|
|
|
test_channel
|
|
|
|
test_hello_msg
|
|
|
|
test_disconnect_msg
|
2021-06-06 14:28:29 +03:00
|
|
|
test_hiccup_msg
|
2021-09-16 17:20:24 +02:00
|
|
|
test_zmq_ppoll_fd
|
2021-11-04 15:18:49 +01:00
|
|
|
test_xsub_verbose
|
2022-11-29 13:00:11 +01:00
|
|
|
test_pubsub_topics_count
|
|
|
|
)
|
|
|
|
|
2021-09-16 17:20:24 +02:00
|
|
|
if(HAVE_FORK)
|
|
|
|
list(APPEND tests test_zmq_ppoll_signals)
|
|
|
|
endif()
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2021-05-15 06:05:56 +08: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)
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2020-04-14 00:03:19 +02:00
|
|
|
if(ZMQ_HAVE_WSS)
|
|
|
|
list(APPEND tests test_wss_transport)
|
|
|
|
endif()
|
2018-09-10 00:12:07 +02:00
|
|
|
endif()
|
2016-05-02 19:44:35 +01:00
|
|
|
|
2016-03-05 11:23:23 -06: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)
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2018-09-10 00:12:07 +02:00
|
|
|
# Same name on 64bit systems
|
|
|
|
link_libraries(ws2_32.lib)
|
2016-03-05 11:23:23 -06: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 10:42:16 -05: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 06:27:12 -04:00
|
|
|
set(TESTUTIL_SOURCES
|
2022-11-29 13:00:11 +01:00
|
|
|
testutil.cpp
|
|
|
|
testutil.hpp
|
|
|
|
testutil_monitoring.cpp
|
|
|
|
testutil_monitoring.hpp
|
|
|
|
testutil_security.cpp
|
|
|
|
testutil_security.hpp
|
|
|
|
testutil_unity.cpp
|
|
|
|
testutil_unity.hpp)
|
|
|
|
|
2019-03-23 06:27:12 -04: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 06:27:12 -04:00
|
|
|
endif()
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2019-03-23 06:27:12 -04:00
|
|
|
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 06:27:12 -04:00
|
|
|
endif()
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2019-03-23 06:27:12 -04:00
|
|
|
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 06:27:12 -04: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 06:27:12 -04: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 06:27:12 -04:00
|
|
|
# add include dirs for all targets
|
2018-08-16 13:17:44 +08:00
|
|
|
include_directories("${ZeroMQ_SOURCE_DIR}/../include" "${ZeroMQ_BINARY_DIR}")
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2019-03-23 08:04:57 -04:00
|
|
|
if(WIN32)
|
|
|
|
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
|
|
|
endif()
|
2016-03-05 11:23:23 -06:00
|
|
|
|
2020-04-18 11:03:15 +01: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 10:59:48 +01: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)
|
2023-02-18 13:43:16 +00:00
|
|
|
add_executable(${test} ${test}.cpp "../src/err.cpp" "../src/random.cpp" "../src/clock.cpp")
|
2018-09-10 00:12:07 +02:00
|
|
|
else()
|
2019-03-23 06:27:12 -04:00
|
|
|
add_executable(${test} ${test}.cpp)
|
2018-09-10 00:12:07 +02:00
|
|
|
endif()
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2019-03-23 06:27:12 -04:00
|
|
|
target_link_libraries(${test} ${TESTUTIL_LIB})
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2016-03-05 11:23:23 -06: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")
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2016-07-12 15:54:55 +02:00
|
|
|
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 11:23:23 -06:00
|
|
|
else()
|
2016-04-19 12:20:59 +01:00
|
|
|
# per-test directories not generated on OS X / Darwin
|
2023-02-01 05:37:59 +08:00
|
|
|
if(NOT APPLE)
|
2018-09-10 00:12:07 +02:00
|
|
|
link_directories(${test} PRIVATE "${ZeroMQ_SOURCE_DIR}/../lib")
|
2016-04-19 12:20:59 +01:00
|
|
|
endif()
|
2016-03-05 11:23:23 -06:00
|
|
|
endif()
|
2020-02-23 12:17:22 -05: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 08:40:00 -05: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()
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2015-10-23 00:33:27 +02:00
|
|
|
set_tests_properties(${test} PROPERTIES TIMEOUT 10)
|
2018-03-09 16:47:42 +00:00
|
|
|
set_tests_properties(${test} PROPERTIES SKIP_RETURN_CODE 77)
|
2023-04-11 15:27:11 -04:00
|
|
|
|
|
|
|
if(QNX)
|
|
|
|
install(TARGETS ${test} RUNTIME DESTINATION bin/)
|
|
|
|
endif()
|
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 15:29:54 +01: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 22:07:51 +01:00
|
|
|
if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
|
|
if(ZMQ_HAVE_CURVE)
|
|
|
|
set_tests_properties(test_security_curve PROPERTIES TIMEOUT 60)
|
|
|
|
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")
|
2022-11-29 13:00:11 +01:00
|
|
|
|
2015-10-23 16:14:30 +02:00
|
|
|
foreach(TEST_SOURCE ${ALL_TEST_SOURCES})
|
|
|
|
get_filename_component(TESTNAME "${TEST_SOURCE}" NAME_WE)
|
|
|
|
string(REGEX MATCH "${TESTNAME}" MATCH_TESTNAME "${CURRENT_LIST_FILE_CONTENT}")
|
2022-11-29 13:00:11 +01:00
|
|
|
|
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()
|