Skip to content

Commit

Permalink
Problem: test_pair_tcp_cap_net_admin requires sudo but is enabled by …
Browse files Browse the repository at this point in the history
…default in CMake

Solution: add an option to enable it, and default to false. Enable it in
the CI so we don't lose coverage, as it works on Travis.

Fixes zeromq#3725
  • Loading branch information
bluca committed Oct 31, 2019
1 parent 805564b commit bfa8cf3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions builds/cmake/ci_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ CMAKE_OPTS+=("-DCMAKE_INSTALL_PREFIX:PATH=${BUILD_PREFIX}")
CMAKE_OPTS+=("-DCMAKE_PREFIX_PATH:PATH=${BUILD_PREFIX}")
CMAKE_OPTS+=("-DCMAKE_LIBRARY_PATH:PATH=${BUILD_PREFIX}/lib")
CMAKE_OPTS+=("-DCMAKE_INCLUDE_PATH:PATH=${BUILD_PREFIX}/include")
CMAKE_OPTS+=("-DENABLE_CAPSH=ON")

if [ "$CLANG_FORMAT" != "" ] ; then
CMAKE_OPTS+=("-DCLANG_FORMAT=${CLANG_FORMAT}")
Expand Down
17 changes: 10 additions & 7 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,17 @@ if(ZMQ_HAVE_CURVE)
test_security_curve)
endif()

find_program(CAPSH_PROGRAM NAMES capsh)
option(ENABLE_CAPSH "Run tests that require sudo and capsh (for cap_net_admin)" OFF)
if(ENABLE_CAPSH)
find_program(CAPSH_PROGRAM NAMES capsh)

if (CAPSH_PROGRAM)
list(APPEND tests
test_pair_tcp_cap_net_admin
)
else()
message(STATUS "capsh not found, skipping tests that require CAP_NET_ADMIN")
if (CAPSH_PROGRAM)
list(APPEND tests
test_pair_tcp_cap_net_admin
)
else()
message(STATUS "capsh not found, skipping tests that require CAP_NET_ADMIN")
endif()
endif()

if(ZMQ_HAVE_IPC)
Expand Down

0 comments on commit bfa8cf3

Please sign in to comment.