chiark / gitweb /
test-example: Provide test which uses unshare(8)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 13 Apr 2014 14:10:28 +0000 (15:10 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 24 Apr 2014 00:45:24 +0000 (01:45 +0100)
This allows more realistic testing, with the "outside" copy of secnet
in a separate environment with its own instance of the network stack.

We have to go through some contortions to get the user a shell in the
"outside" environment, since unshare -n also breaks AF_UNIX, and we
want to keep the terminal secnet is invoked in just for secnet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/changelog
test-example/README
test-example/fake-userv [new file with mode: 0755]
test-example/outside-unshare.conf [new file with mode: 0644]

index 9f02f1e1b18f05b7cd5d1cf04398887f59cdb417..f9792393b5b9f75f17a69fc8422be602241d4b61 100644 (file)
@@ -5,6 +5,7 @@ secnet (0.3.1~~unstable) unstable; urgency=low
   * Internal code rearrangements and improvements.
   * Fix netlink SEGV on clientless netlinks (i.e. configuration error).
   * Fix formatting error in p-t-p startup message.
+  * Additions to the test-example suite.
 
  --
 
index 4c2eca30ada234c967c7c05ed577347d1b2c157d..7ec95eabf5217ed57ad57ff5d12475e2e017d581 100644 (file)
@@ -24,3 +24,8 @@ For running under valgrind memcheck, do something like this:
     --leak-check=full --suppressions=test-example/memcheck.suppressions \
     ./secnet -dvnc test-example/outside.conf
 NB that --num-callers is needed as secnet's stack can be deep.
+
+The config file outside-unshare.conf can be used on Linux in
+conjunction with test-example/fake-userv and a built checkout of
+userv-utils.git to run the "outside" copy of secnet in a new "network
+namespace".
diff --git a/test-example/fake-userv b/test-example/fake-userv
new file mode 100755 (executable)
index 0000000..6f5da40
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+set -e
+echo >&2 "$0: invoked as $0 $*"
+shift
+shift
+exec 3<&0 4>&1 5>&2 >&2 </dev/null
+exec xterm -T netns -e unshare -n -- sh -xc '
+  ../userv-utils.git/ipif/service \* -- "$@" <&3 >&4 2>&5 &
+  sleep 0.1
+  env - bash -i
+' x "$@"
diff --git a/test-example/outside-unshare.conf b/test-example/outside-unshare.conf
new file mode 100644 (file)
index 0000000..c6c3b6f
--- /dev/null
@@ -0,0 +1,16 @@
+netlink userv-ipif {
+       name "netlink-ipif"; # Printed in log messages from this netlink
+       local-address "172.18.232.1";
+       secnet-address "172.18.232.2";
+       remote-networks "172.18.232.0/28";
+       mtu 1000;
+       buffer sysbuffer(2048);
+       userv-path "test-example/fake-userv";
+};
+comm udp {
+       port 16900;
+       buffer sysbuffer(4096);
+};
+local-name "test-example/outside/outside";
+local-key rsa-private("test-example/outside.key");
+include test-example/common.conf