mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-13 10:52:56 +01:00
Problem: TIPC availability check is too strict (#2977)
* Problem: TIPC availability check is too strict Solution: at build time only check if the API is available. In the tests do a first check and a skip if the functionality is not available. TIPC needs an in-tree but not loaded by default kernel module, tipc.ko to be loaded, which requires root, so it is unlikely to be available on any build system by default. This will allow most distributions to ship with TIPC support built in, and to avoid tests failure if the module is not there. * Problem: no Travis tests for TIPC Solution: mark one job with sudo: required and load the kernel module * Problem: CMake fails when test returns 77 (skip) Solution: set property to let it mark the test as skipped as intended
This commit is contained in:
parent
7abb8388d6
commit
19060345e4
@ -57,8 +57,9 @@ matrix:
|
|||||||
- libsodium-dev
|
- libsodium-dev
|
||||||
- asciidoc
|
- asciidoc
|
||||||
- xmlto
|
- 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
|
os: linux
|
||||||
|
sudo: required
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
sources:
|
sources:
|
||||||
|
@ -195,19 +195,12 @@ int main(int argc, char *argv [])
|
|||||||
{
|
{
|
||||||
struct sockaddr_tipc topsrv;
|
struct sockaddr_tipc topsrv;
|
||||||
int sd = socket(AF_TIPC, SOCK_SEQPACKET, 0);
|
int sd = socket(AF_TIPC, SOCK_SEQPACKET, 0);
|
||||||
if (sd == -EAFNOSUPPORT) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
memset(&topsrv, 0, sizeof(topsrv));
|
memset(&topsrv, 0, sizeof(topsrv));
|
||||||
topsrv.family = AF_TIPC;
|
topsrv.family = AF_TIPC;
|
||||||
topsrv.addrtype = TIPC_ADDR_NAME;
|
topsrv.addrtype = TIPC_ADDR_NAME;
|
||||||
topsrv.addr.name.name.type = TIPC_TOP_SRV;
|
topsrv.addr.name.name.type = TIPC_TOP_SRV;
|
||||||
topsrv.addr.name.name.instance = TIPC_TOP_SRV;
|
topsrv.addr.name.name.instance = TIPC_TOP_SRV;
|
||||||
fcntl(sd, F_SETFL, O_NONBLOCK);
|
fcntl(sd, F_SETFL, O_NONBLOCK);
|
||||||
if (connect(sd, (struct sockaddr *)&topsrv, sizeof(topsrv)) != 0) {
|
|
||||||
if (errno != EINPROGRESS)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
ZMQ_HAVE_TIPC)
|
ZMQ_HAVE_TIPC)
|
||||||
|
@ -48,6 +48,10 @@ if [ $BUILD_TYPE == "default" ]; then
|
|||||||
CONFIG_OPTS+=("--with-norm=yes")
|
CONFIG_OPTS+=("--with-norm=yes")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "$TIPC" ] && [ "$TIPC" == "enabled" ]; then
|
||||||
|
sudo modprobe tipc
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "$POLLER" ]; then
|
if [ -n "$POLLER" ]; then
|
||||||
CONFIG_OPTS+=("--with-poller=${POLLER}")
|
CONFIG_OPTS+=("--with-poller=${POLLER}")
|
||||||
fi
|
fi
|
||||||
|
@ -93,19 +93,12 @@ AC_RUN_IFELSE(
|
|||||||
]],[[
|
]],[[
|
||||||
struct sockaddr_tipc topsrv;
|
struct sockaddr_tipc topsrv;
|
||||||
int sd = socket(AF_TIPC, SOCK_SEQPACKET, 0);
|
int sd = socket(AF_TIPC, SOCK_SEQPACKET, 0);
|
||||||
if (sd == -EAFNOSUPPORT) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
memset(&topsrv, 0, sizeof(topsrv));
|
memset(&topsrv, 0, sizeof(topsrv));
|
||||||
topsrv.family = AF_TIPC;
|
topsrv.family = AF_TIPC;
|
||||||
topsrv.addrtype = TIPC_ADDR_NAME;
|
topsrv.addrtype = TIPC_ADDR_NAME;
|
||||||
topsrv.addr.name.name.type = TIPC_TOP_SRV;
|
topsrv.addr.name.name.type = TIPC_TOP_SRV;
|
||||||
topsrv.addr.name.name.instance = TIPC_TOP_SRV;
|
topsrv.addr.name.name.instance = TIPC_TOP_SRV;
|
||||||
fcntl(sd, F_SETFL, O_NONBLOCK);
|
fcntl(sd, F_SETFL, O_NONBLOCK);
|
||||||
if (connect(sd, (struct sockaddr *)&topsrv, sizeof(topsrv)) != 0) {
|
|
||||||
if (errno != EINPROGRESS)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
]])
|
]])
|
||||||
],
|
],
|
||||||
[libzmq_tipc_support=yes],
|
[libzmq_tipc_support=yes],
|
||||||
|
@ -203,6 +203,7 @@ foreach(test ${tests})
|
|||||||
add_test(NAME ${test} COMMAND ${test})
|
add_test(NAME ${test} COMMAND ${test})
|
||||||
endif()
|
endif()
|
||||||
set_tests_properties(${test} PROPERTIES TIMEOUT 10)
|
set_tests_properties(${test} PROPERTIES TIMEOUT 10)
|
||||||
|
set_tests_properties(${test} PROPERTIES SKIP_RETURN_CODE 77)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
#override timeout for these tests
|
#override timeout for these tests
|
||||||
|
@ -131,6 +131,11 @@ int main ()
|
|||||||
{
|
{
|
||||||
setup_test_environment ();
|
setup_test_environment ();
|
||||||
|
|
||||||
|
if (!is_tipc_available ()) {
|
||||||
|
printf ("TIPC environment unavailable, skipping test\n");
|
||||||
|
return 77;
|
||||||
|
}
|
||||||
|
|
||||||
UNITY_BEGIN ();
|
UNITY_BEGIN ();
|
||||||
RUN_TEST (test_tipc_port_name_and_domain);
|
RUN_TEST (test_tipc_port_name_and_domain);
|
||||||
RUN_TEST (test_tipc_port_identity);
|
RUN_TEST (test_tipc_port_identity);
|
||||||
|
@ -31,6 +31,11 @@
|
|||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
|
if (!is_tipc_available ()) {
|
||||||
|
printf ("TIPC environment unavailable, skipping test\n");
|
||||||
|
return 77;
|
||||||
|
}
|
||||||
|
|
||||||
int val;
|
int val;
|
||||||
int rc;
|
int rc;
|
||||||
char buffer[16];
|
char buffer[16];
|
||||||
|
@ -32,6 +32,11 @@
|
|||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
|
if (!is_tipc_available ()) {
|
||||||
|
printf ("TIPC environment unavailable, skipping test\n");
|
||||||
|
return 77;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf (stderr, "test_pair_tipc running...\n");
|
fprintf (stderr, "test_pair_tipc running...\n");
|
||||||
|
|
||||||
void *ctx = zmq_init (1);
|
void *ctx = zmq_init (1);
|
||||||
|
@ -31,6 +31,11 @@
|
|||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
|
if (!is_tipc_available ()) {
|
||||||
|
printf ("TIPC environment unavailable, skipping test\n");
|
||||||
|
return 77;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf (stderr, "test_reqrep_device_tipc running...\n");
|
fprintf (stderr, "test_reqrep_device_tipc running...\n");
|
||||||
|
|
||||||
void *ctx = zmq_init (1);
|
void *ctx = zmq_init (1);
|
||||||
|
@ -31,6 +31,11 @@
|
|||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
|
if (!is_tipc_available ()) {
|
||||||
|
printf ("TIPC environment unavailable, skipping test\n");
|
||||||
|
return 77;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf (stderr, "test_reqrep_tipc running...\n");
|
fprintf (stderr, "test_reqrep_tipc running...\n");
|
||||||
|
|
||||||
void *ctx = zmq_init (1);
|
void *ctx = zmq_init (1);
|
||||||
|
@ -32,6 +32,11 @@
|
|||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
|
if (!is_tipc_available ()) {
|
||||||
|
printf ("TIPC environment unavailable, skipping test\n");
|
||||||
|
return 77;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf (stderr, "test_router_mandatory_tipc running...\n");
|
fprintf (stderr, "test_router_mandatory_tipc running...\n");
|
||||||
|
|
||||||
void *ctx = zmq_init (1);
|
void *ctx = zmq_init (1);
|
||||||
|
@ -49,6 +49,11 @@ static void *worker (void *s)
|
|||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
|
if (!is_tipc_available ()) {
|
||||||
|
printf ("TIPC environment unavailable, skipping test\n");
|
||||||
|
return 77;
|
||||||
|
}
|
||||||
|
|
||||||
void *ctx;
|
void *ctx;
|
||||||
void *s1;
|
void *s1;
|
||||||
void *s2;
|
void *s2;
|
||||||
|
@ -31,6 +31,11 @@
|
|||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
|
if (!is_tipc_available ()) {
|
||||||
|
printf ("TIPC environment unavailable, skipping test\n");
|
||||||
|
return 77;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf (stderr, "test_sub_forward running...\n");
|
fprintf (stderr, "test_sub_forward running...\n");
|
||||||
|
|
||||||
void *ctx = zmq_init (1);
|
void *ctx = zmq_init (1);
|
||||||
|
@ -31,6 +31,11 @@
|
|||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
|
if (!is_tipc_available ()) {
|
||||||
|
printf ("TIPC environment unavailable, skipping test\n");
|
||||||
|
return 77;
|
||||||
|
}
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
char buf[32];
|
char buf[32];
|
||||||
const char *ep = "tipc://{5560,0,0}";
|
const char *ep = "tipc://{5560,0,0}";
|
||||||
|
@ -389,6 +389,29 @@ int is_ipv6_available (void)
|
|||||||
#endif // _WIN32_WINNT < 0x0600
|
#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)
|
#if defined(ZMQ_HAVE_WINDOWS)
|
||||||
|
|
||||||
int close (int fd)
|
int close (int fd)
|
||||||
|
Loading…
Reference in New Issue
Block a user