From fa1e9b046128db81c207c9ed920d068a144cd687 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Fri, 24 Jan 2014 16:09:32 +0100 Subject: [PATCH] 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. --- test/Makefile.am | 1 + test/ns-ping.test | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100755 test/ns-ping.test 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 <