]> git.meshlink.io Git - meshlink/commitdiff
Start of a test suite.
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 31 Aug 2013 22:39:14 +0000 (00:39 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 1 Sep 2013 10:48:31 +0000 (12:48 +0200)
Makefile.am
configure.ac
test/Makefile.am [new file with mode: 0644]
test/basic.test [new file with mode: 0755]
test/executables.test [new file with mode: 0755]
test/sptps_basic.test [new file with mode: 0755]
test/testlib.sh [new file with mode: 0644]

index d2e6f3fa568c424c51810bcf024443e451006b54..0a4faef3b381a31340553b815f35c9a16de59341 100644 (file)
@@ -2,7 +2,7 @@
 
 AUTOMAKE_OPTIONS = gnu
 
-SUBDIRS =  m4 src doc gui
+SUBDIRS =  m4 src doc gui test
 
 ACLOCAL_AMFLAGS = -I m4 
 
index af12f12ab5dcd8a44c2b46b0ebee807e83dc63a4..8b7c07a6488c9d44a94451336b7995fd09fd0d6d 100644 (file)
@@ -212,6 +212,6 @@ AC_ARG_ENABLE(jumbograms,
   ]
 )
 
-AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile m4/Makefile gui/Makefile])
+AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile m4/Makefile gui/Makefile test/Makefile])
 
 AC_OUTPUT
diff --git a/test/Makefile.am b/test/Makefile.am
new file mode 100644 (file)
index 0000000..69042ac
--- /dev/null
@@ -0,0 +1,9 @@
+TESTS = \
+       executables.test \
+       basic.test \
+       sptps_basic.test
+
+EXTRA_DIST = testlib.sh
+
+clean-local:
+       -rm -rf *.test.?
diff --git a/test/basic.test b/test/basic.test
new file mode 100755 (executable)
index 0000000..1277fb0
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+. ./testlib.sh
+
+# Initialize and test one node
+
+rm -rf config1
+
+$tinc $c1 init foo
+$tinc $c1 set DeviceType dummy
+$tinc $c1 set Port 0
+
+# Test running in the foreground
+
+(sleep 1; $tinc $c1 stop) &
+$tinc $c1 start $r1 -D
+
+# Test running tinc in the background
+
+$tinc $c1 start $r1
+sleep 1
+$tinc $c1 stop
diff --git a/test/executables.test b/test/executables.test
new file mode 100755 (executable)
index 0000000..35dd2bc
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. ./testlib.sh
+
+# Just test whether the executables work
+$tincd --help
+$tinc --help
+$sptps_test --help
diff --git a/test/sptps_basic.test b/test/sptps_basic.test
new file mode 100755 (executable)
index 0000000..e18d063
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+. ./testlib.sh
+
+# Generate keys
+
+mkdir -p $d1
+
+openssl ecparam -genkey -name secp521r1 -noout -out $d1/server.priv
+openssl ecparam -genkey -name secp521r1 -noout -out $d1/client.priv
+yes '' | openssl req -new -pubkey -key $d1/server.priv -noout -out $d1/server.pub
+echo
+yes '' | openssl req -new -pubkey -key $d1/client.priv -noout -out $d1/client.pub
+echo
+
+# Test transfer of a simple file.
+
+(sleep 2; cat ../README; sleep 1) | $sptps_test $d1/server.priv $d1/client.pub 32750 &
+sleep 1
+sleep 3 | $sptps_test $d1/client.priv $d1/server.pub localhost 32750 >$d1/out
+cmp $d1/out ../README
diff --git a/test/testlib.sh b/test/testlib.sh
new file mode 100644 (file)
index 0000000..e65127d
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# Paths to executables
+
+tincd=../src/tincd
+tinc=../src/tinc
+sptps_test=../src/sptps_test
+
+# Test directories
+
+d1=$PWD/$_.1
+d2=$PWD/$_.2
+d3=$PWD/$_.3
+
+# Remove test directories
+
+rm -rf $d1 $d2 $d3
+
+# Default arguments for both tinc and tincd
+
+c1="--config=$d1 --pidfile=$d1/pid"
+c2="--config=$d2 --pidfile=$d2/pid"
+c3="--config=$d3 --pidfile=$d3/pid"
+
+# Arguments when running tincd
+
+r1="--logfile=$d1/log -d5"
+r2="--logfile=$d1/log -d5"
+r3="--logfile=$d1/log -d5"
+
+# Exit on errors, log all commands being executed
+
+set -ex