Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: TIPC availability check is too strict #2977

Merged
merged 3 commits into from
Mar 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ matrix:
- libsodium-dev
- asciidoc
- xmlto
- env: BUILD_TYPE=default CURVE=libsodium DRAFT=enabled GSSAPI=enabled PGM=enabled NORM=enabled
- env: BUILD_TYPE=default CURVE=libsodium DRAFT=enabled GSSAPI=enabled PGM=enabled NORM=enabled TIPC=enabled
os: linux
sudo: required
addons:
apt:
sources:
Expand Down
7 changes: 0 additions & 7 deletions builds/cmake/Modules/ZMQSourceRunChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,12 @@ 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)
Expand Down
4 changes: 4 additions & 0 deletions ci_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ if [ $BUILD_TYPE == "default" ]; then
CONFIG_OPTS+=("--with-norm=yes")
fi

if [ -n "$TIPC" ] && [ "$TIPC" == "enabled" ]; then
sudo modprobe tipc
fi

if [ -n "$POLLER" ]; then
CONFIG_OPTS+=("--with-poller=${POLLER}")
fi
Expand Down
7 changes: 0 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,12 @@ AC_RUN_IFELSE(
]],[[
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;
}
]])
],
[libzmq_tipc_support=yes],
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ foreach(test ${tests})
add_test(NAME ${test} COMMAND ${test})
endif()
set_tests_properties(${test} PROPERTIES TIMEOUT 10)
set_tests_properties(${test} PROPERTIES SKIP_RETURN_CODE 77)
endforeach()

#override timeout for these tests
Expand Down
5 changes: 5 additions & 0 deletions tests/test_address_tipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ int main ()
{
setup_test_environment ();

if (!is_tipc_available ()) {
printf ("TIPC environment unavailable, skipping test\n");
return 77;
}

UNITY_BEGIN ();
RUN_TEST (test_tipc_port_name_and_domain);
RUN_TEST (test_tipc_port_identity);
Expand Down
5 changes: 5 additions & 0 deletions tests/test_connect_delay_tipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@

int main (void)
{
if (!is_tipc_available ()) {
printf ("TIPC environment unavailable, skipping test\n");
return 77;
}

int val;
int rc;
char buffer[16];
Expand Down
5 changes: 5 additions & 0 deletions tests/test_pair_tipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@

int main (void)
{
if (!is_tipc_available ()) {
printf ("TIPC environment unavailable, skipping test\n");
return 77;
}

fprintf (stderr, "test_pair_tipc running...\n");

void *ctx = zmq_init (1);
Expand Down
5 changes: 5 additions & 0 deletions tests/test_reqrep_device_tipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@

int main (void)
{
if (!is_tipc_available ()) {
printf ("TIPC environment unavailable, skipping test\n");
return 77;
}

fprintf (stderr, "test_reqrep_device_tipc running...\n");

void *ctx = zmq_init (1);
Expand Down
5 changes: 5 additions & 0 deletions tests/test_reqrep_tipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@

int main (void)
{
if (!is_tipc_available ()) {
printf ("TIPC environment unavailable, skipping test\n");
return 77;
}

fprintf (stderr, "test_reqrep_tipc running...\n");

void *ctx = zmq_init (1);
Expand Down
5 changes: 5 additions & 0 deletions tests/test_router_mandatory_tipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@

int main (void)
{
if (!is_tipc_available ()) {
printf ("TIPC environment unavailable, skipping test\n");
return 77;
}

fprintf (stderr, "test_router_mandatory_tipc running...\n");

void *ctx = zmq_init (1);
Expand Down
5 changes: 5 additions & 0 deletions tests/test_shutdown_stress_tipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ static void *worker (void *s)

int main (void)
{
if (!is_tipc_available ()) {
printf ("TIPC environment unavailable, skipping test\n");
return 77;
}

void *ctx;
void *s1;
void *s2;
Expand Down
5 changes: 5 additions & 0 deletions tests/test_sub_forward_tipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@

int main (void)
{
if (!is_tipc_available ()) {
printf ("TIPC environment unavailable, skipping test\n");
return 77;
}

fprintf (stderr, "test_sub_forward running...\n");

void *ctx = zmq_init (1);
Expand Down
5 changes: 5 additions & 0 deletions tests/test_term_endpoint_tipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@

int main (void)
{
if (!is_tipc_available ()) {
printf ("TIPC environment unavailable, skipping test\n");
return 77;
}

int rc;
char buf[32];
const char *ep = "tipc://{5560,0,0}";
Expand Down
23 changes: 23 additions & 0 deletions tests/testutil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,29 @@ int is_ipv6_available (void)
#endif // _WIN32_WINNT < 0x0600
}

// check if tipc is available (0/false if not, 1/true if it is)
// only way to reliably check is to actually open a socket and try to bind it
// as it depends on a non-default kernel module to be already loaded
int is_tipc_available (void)
{
#ifndef ZMQ_HAVE_TIPC
return 0;
#else
int tipc = 0;

void *ctx = zmq_init (1);
assert (ctx);
void *rep = zmq_socket (ctx, ZMQ_REP);
assert (rep);
tipc = zmq_bind (rep, "tipc://{5560,0,0}");

zmq_close (rep);
zmq_ctx_term (ctx);

return tipc == 0;
#endif // ZMQ_HAVE_TIPC
}

#if defined(ZMQ_HAVE_WINDOWS)

int close (int fd)
Expand Down