From ea294afd8bf29424239ef05c4d77a943ca0beedc Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Thu, 21 Apr 2016 11:33:20 +0100 Subject: [PATCH 1/2] Problem: CMake does not check for TIPC support Solution: add macro in ZMQSourceRunChecks.cmake and optionally include the TIPC sources if the support is available. More importantly, only run the TIPC tests if the support is there. --- CMakeLists.txt | 6 ++++ builds/cmake/Modules/ZMQSourceRunChecks.cmake | 34 +++++++++++++++++++ tests/CMakeLists.txt | 20 ++++++----- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dfaedc4f59..90a3042130 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -282,6 +282,7 @@ zmq_check_tcp_keepcnt () zmq_check_tcp_keepidle () zmq_check_tcp_keepintvl () zmq_check_tcp_keepalive () +zmq_check_tcp_tipc () if ( CMAKE_SYSTEM_NAME MATCHES "Linux" @@ -550,6 +551,11 @@ if (WITH_VMCI) list (APPEND cxx-sources vmci_address.cpp vmci_connecter.cpp vmci_listener.cpp vmci.cpp) endif (WITH_VMCI) +if (ZMQ_HAVE_TIPC) + add_definitions (-DZMQ_HAVE_TIPC) + list (APPEND cxx-source tipc_address.cpp tipc_connecter.cpp tipc_listener.cpp) +endif (ZMQ_HAVE_TIPC) + #----------------------------------------------------------------------------- # source generators diff --git a/builds/cmake/Modules/ZMQSourceRunChecks.cmake b/builds/cmake/Modules/ZMQSourceRunChecks.cmake index 4d23a2a172..10d46d3d07 100644 --- a/builds/cmake/Modules/ZMQSourceRunChecks.cmake +++ b/builds/cmake/Modules/ZMQSourceRunChecks.cmake @@ -127,3 +127,37 @@ int main(int argc, char *argv []) " ZMQ_HAVE_TCP_KEEPALIVE) endmacro() + + +macro(zmq_check_tcp_tipc) + message(STATUS "Checking whether TIPC is supported") + check_c_source_runs( + " +#include +#include +#include +#include +#include +#include + +int main(int argc, char *argv []) +{ + struct sockaddr_tipc topsrv; + int sd = socket(AF_TIPC, SOCK_SEQPACKET, 0); + if (sd == -EAFNOSUPPORT) { + return 1; + } + memset(&topsrv, 0, sizeof(topsrv)); + topsrv.family = AF_TIPC; + topsrv.addrtype = TIPC_ADDR_NAME; + topsrv.addr.name.name.type = TIPC_TOP_SRV; + topsrv.addr.name.name.instance = TIPC_TOP_SRV; + fcntl(sd, F_SETFL, O_NONBLOCK); + if (connect(sd, (struct sockaddr *)&topsrv, sizeof(topsrv)) != 0) { + if (errno != EINPROGRESS) + return -1; + } +} +" + ZMQ_HAVE_TIPC) +endmacro() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4c959eda86..ad1e90a950 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -93,15 +93,19 @@ if(NOT WIN32) if(CMAKE_SYSTEM_NAME MATCHES "Linux") list(APPEND tests test_abstract_ipc - 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 - test_term_endpoint_tipc ) + if(ZMQ_HAVE_TIPC) + list(APPEND tests + 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 + test_term_endpoint_tipc + ) + endif() endif() endif() From a117c1f48d127a6f6de11bf9fb780481c5e2ef94 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Thu, 21 Apr 2016 11:35:43 +0100 Subject: [PATCH 2/2] Problem: Travis CI CMake build does not run tests Solution: add make test to the cmake/ci_build.sh script --- builds/cmake/ci_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builds/cmake/ci_build.sh b/builds/cmake/ci_build.sh index 05140fb5b2..35d83c0d59 100755 --- a/builds/cmake/ci_build.sh +++ b/builds/cmake/ci_build.sh @@ -28,4 +28,4 @@ elif [ $CURVE == "libsodium" ]; then fi # Build, check, and install from local source -( cd ../..; mkdir build_cmake && cd build_cmake && PKG_CONFIG_PATH=${BUILD_PREFIX}/lib/pkgconfig cmake "${CMAKE_OPTS[@]}" .. && make all VERBOSE=1 && make install ) || exit 1 +( cd ../..; mkdir build_cmake && cd build_cmake && PKG_CONFIG_PATH=${BUILD_PREFIX}/lib/pkgconfig cmake "${CMAKE_OPTS[@]}" .. && make all VERBOSE=1 && make install && make test ) || exit 1