From: Guus Sliepen Date: Mon, 17 Apr 2017 11:54:02 +0000 (+0200) Subject: Fix tests on *BSD. X-Git-Tag: release-1.1pre15~22 X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=commitdiff_plain;h=a14414731925cd59e64b3a90309b5a9ec60ac690 Fix tests on *BSD. --- diff --git a/src/ifconfig.c b/src/ifconfig.c index 7688a3c6..06f2c629 100644 --- a/src/ifconfig.c +++ b/src/ifconfig.c @@ -104,13 +104,6 @@ void ifconfig_address(FILE *out, const char *value) { case SUBNET_IPV6: fprintf(out, "ip addr replace %s dev \"$INTERFACE\"\n", address_str); break; default: return; } -#elif defined(HAVE_BSD) - switch(address.type) { - case SUBNET_MAC: fprintf(out, "ifconfig \"$INTERFACE\" link %s\n", address_str); break; - case SUBNET_IPV4: fprintf(out, "ifconfig \"$INTERFACE\" %s\n", address_str); break; - case SUBNET_IPV6: fprintf(out, "ifconfig \"$INTERFACE\" inet6 %s\n", address_str); break; - default: return; - } #elif defined(HAVE_MINGW) || defined(HAVE_CYGWIN) switch(address.type) { case SUBNET_MAC: fprintf(out, "ip link set \"$INTERFACE\" address %s\n", address_str); break; @@ -118,6 +111,13 @@ void ifconfig_address(FILE *out, const char *value) { case SUBNET_IPV6: fprintf(out, "netsh inetface ipv6 set address \"$INTERFACE\" static %s\n", address_str); break; default: return; } +#else // assume BSD + switch(address.type) { + case SUBNET_MAC: fprintf(out, "ifconfig \"$INTERFACE\" link %s\n", address_str); break; + case SUBNET_IPV4: fprintf(out, "ifconfig \"$INTERFACE\" %s\n", address_str); break; + case SUBNET_IPV6: fprintf(out, "ifconfig \"$INTERFACE\" inet6 %s\n", address_str); break; + default: return; + } #endif } @@ -152,8 +152,21 @@ void ifconfig_route(FILE *out, const char *value) { default: return; } } -#elif defined(HAVE_BSD) - // BSD route command is silly and doesn't accept an interface name as a destination. +#elif defined(HAVE_MINGW) || defined(HAVE_CYGWIN) + if(*gateway_str) { + switch(subnet.type) { + case SUBNET_IPV4: fprintf(out, "netsh inetface ipv4 add route %s \"%%INTERFACE%%\" %s\n", subnet_str, gateway_str); break; + case SUBNET_IPV6: fprintf(out, "netsh inetface ipv6 add route %s \"%%INTERFACE%%\" %s\n", subnet_str, gateway_str); break; + default: return; + } + } else { + switch(subnet.type) { + case SUBNET_IPV4: fprintf(out, "netsh inetface ipv4 add route %s \"%%INTERFACE%%\"\n", subnet_str); break; + case SUBNET_IPV6: fprintf(out, "netsh inetface ipv6 add route %s \"%%INTERFACE%%\"\n", subnet_str); break; + default: return; + } + } +#else // assume BSD if(!*gateway_str) { switch(subnet.type) { case SUBNET_IPV4: @@ -180,19 +193,5 @@ void ifconfig_route(FILE *out, const char *value) { case SUBNET_IPV6: fprintf(out, "route add -inet6 %s %s\n", subnet_str, gateway_str); break; default: return; } -#elif defined(HAVE_MINGW) || defined(HAVE_CYGWIN) - if(*gateway_str) { - switch(subnet.type) { - case SUBNET_IPV4: fprintf(out, "netsh inetface ipv4 add route %s \"%%INTERFACE%%\" %s\n", subnet_str, gateway_str); break; - case SUBNET_IPV6: fprintf(out, "netsh inetface ipv6 add route %s \"%%INTERFACE%%\" %s\n", subnet_str, gateway_str); break; - default: return; - } - } else { - switch(subnet.type) { - case SUBNET_IPV4: fprintf(out, "netsh inetface ipv4 add route %s \"%%INTERFACE%%\"\n", subnet_str); break; - case SUBNET_IPV6: fprintf(out, "netsh inetface ipv6 add route %s \"%%INTERFACE%%\"\n", subnet_str); break; - default: return; - } - } #endif } diff --git a/test/executables.test b/test/executables.test index 35dd2bc8..801de58c 100755 --- a/test/executables.test +++ b/test/executables.test @@ -5,4 +5,6 @@ # Just test whether the executables work $tincd --help $tinc --help -$sptps_test --help +if [ -e $sptps_test ]; then + $sptps_test --help +fi diff --git a/test/sptps-basic.test b/test/sptps-basic.test index 644a31e0..28c0c404 100755 --- a/test/sptps-basic.test +++ b/test/sptps-basic.test @@ -2,6 +2,10 @@ . ./testlib.sh +# Skip this test if we did not compile sptps_test + +test -e $sptps_test || exit 77 + # Generate keys mkdir -p $d1 diff --git a/test/testlib.sh b/test/testlib.sh index 31033352..75b60a79 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -9,18 +9,10 @@ sptps_keypair=../src/sptps_keypair # Test directories -case "$_" in - /*) - d1=$_.1 - d2=$_.2 - d3=$_.3 - ;; - *) - d1=$PWD/$_.1 - d2=$PWD/$_.2 - d3=$PWD/$_.3 - ;; -esac +scriptname=`basename $0` +d1=$PWD/$scriptname.1 +d2=$PWD/$scriptname.2 +d3=$PWD/$scriptname.3 # Default arguments for both tinc and tincd