Add support of IPv6 disabling

This commit is contained in:
Diadlo 2017-11-15 12:48:48 +03:00
parent d037f93811
commit b39cc55d37
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
4 changed files with 40 additions and 0 deletions

View File

@ -148,6 +148,11 @@ else()
add_dllflag("-Wl,-z,defs") add_dllflag("-Wl,-z,defs")
endif() endif()
option(USE_IPV6 "Use IPv6 in tests" ON)
if(NOT USE_IPV6)
add_definitions(-DUSE_IPV6=0)
endif()
option(BUILD_TOXAV "Whether to build the tox AV library" ON) option(BUILD_TOXAV "Whether to build the tox AV library" ON)
include(Dependencies) include(Dependencies)

View File

@ -193,6 +193,16 @@ AC_ARG_ENABLE([[epoll]],
[enable_epoll='auto'] [enable_epoll='auto']
) )
AC_ARG_ENABLE([[ipv6]],
[AS_HELP_STRING([[--disable-ipv6[=ARG]]], [use ipv4 in tests (yes, no, auto) [auto]])],
[use_ipv6=${enableval}],
[use_ipv6='auto']
)
if test "$use_ipv6" != "yes"; then
AC_DEFINE([USE_IPV6],[0],[define to 0 to force ipv4])
fi
AX_HAVE_EPOLL AX_HAVE_EPOLL
if test "$enable_epoll" != "no"; then if test "$enable_epoll" != "no"; then
if test "${ax_cv_have_epoll}" = "yes"; then if test "${ax_cv_have_epoll}" = "yes"; then

View File

@ -1,5 +1,16 @@
#!/bin/sh #!/bin/sh
if perl -e '
use Socket qw(PF_INET6 SOCK_STREAM pack_sockaddr_in6 IN6ADDR_LOOPBACK);
socket(S, PF_INET6, SOCK_STREAM, 0) || exit 1;
bind(S, pack_sockaddr_in6(0, IN6ADDR_LOOPBACK)) || exit 1;
'; then
IPV6_FLAG="--enable-ipv6"
else
IPV6_FLAG="--disable-ipv6"
fi
# Build toxcore with some custom flags here. Note that this does *not* run the # Build toxcore with some custom flags here. Note that this does *not* run the
# tests, so any flags passed here are irrelevant to testing. This only checks # tests, so any flags passed here are irrelevant to testing. This only checks
# that we can build toxcore with the specified flags. Tests run with default # that we can build toxcore with the specified flags. Tests run with default
@ -12,6 +23,7 @@
--enable-daemon \ --enable-daemon \
--enable-logging \ --enable-logging \
--enable-ntox \ --enable-ntox \
$IPV6_FLAG \
--with-log-level=TRACE --with-log-level=TRACE
# We use make instead of RUN $MAKE here, because the autotools build will only # We use make instead of RUN $MAKE here, because the autotools build will only

View File

@ -22,6 +22,18 @@ for i in `seq 0 7`; do
RUN rm -rf $BUILD_DIR RUN rm -rf $BUILD_DIR
done done
if perl -e '
use Socket qw(PF_INET6 SOCK_STREAM pack_sockaddr_in6 IN6ADDR_LOOPBACK);
socket(S, PF_INET6, SOCK_STREAM, 0) || exit 1;
bind(S, pack_sockaddr_in6(0, IN6ADDR_LOOPBACK)) || exit 1;
'; then
USE_IPV6=yes
else
USE_IPV6=no
fi
# Build toxcore and run tests. # Build toxcore and run tests.
RUN $CMAKE \ RUN $CMAKE \
-B$BUILD_DIR \ -B$BUILD_DIR \
@ -32,6 +44,7 @@ RUN $CMAKE \
-DSTRICT_ABI=ON \ -DSTRICT_ABI=ON \
-DTEST_TIMEOUT_SECONDS=120 \ -DTEST_TIMEOUT_SECONDS=120 \
-DTRACE=ON \ -DTRACE=ON \
-DUSE_IPV6=$USE_IPV6 \
$CMAKE_EXTRA_FLAGS $CMAKE_EXTRA_FLAGS
export CTEST_OUTPUT_ON_FAILURE=1 export CTEST_OUTPUT_ON_FAILURE=1