From: Guus Sliepen Date: Fri, 24 Jan 2014 15:09:32 +0000 (+0100) Subject: Test two tinc daemons using network namespaces. X-Git-Tag: release-1.1pre10~11 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=fa1e9b046128db81c207c9ed920d068a144cd687;p=tinc Test two tinc daemons using network namespaces. Testing multiple daemons connecting to each other on the same computer is usually difficult, because connections to local IP addresses will bypass most of the network stack. However, recent versions of Linux support network namespaces, which can isolate network interfaces. We use this to isolate the virtual interface of the daemons from each other, so we get the behaviour as if the daemons were each running on their own machine. This can also be used for more complicated tests (including those with firewall rules) without disturbing the real network setup of the host computer. --- diff --git a/test/Makefile.am b/test/Makefile.am index a9c3895b..5457b2fc 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -4,6 +4,7 @@ TESTS = \ executables.test \ import-export.test \ invite-join.test \ + ns-ping.test \ ping.test \ sptps-basic.test \ variables.test diff --git a/test/ns-ping.test b/test/ns-ping.test new file mode 100755 index 00000000..d5f9c7ff --- /dev/null +++ b/test/ns-ping.test @@ -0,0 +1,70 @@ +#!/bin/sh + +. ./testlib.sh + +# Skip this test if we aren't root or if "ip netns" does not exist + +test "`id -u`" = "0" || exit 77 +ip netns list || exit 77 + +# Initialize two nodes + +$tinc $c1 <$d1/tinc-up <$d2/tinc-up <