AUTOMAKE_OPTIONS = gnu
-SUBDIRS = m4 src doc gui
+SUBDIRS = m4 src doc gui test
ACLOCAL_AMFLAGS = -I m4
]
)
-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
--- /dev/null
+TESTS = \
+ executables.test \
+ basic.test \
+ sptps_basic.test
+
+EXTRA_DIST = testlib.sh
+
+clean-local:
+ -rm -rf *.test.?
--- /dev/null
+#!/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
--- /dev/null
+#!/bin/sh
+
+. ./testlib.sh
+
+# Just test whether the executables work
+$tincd --help
+$tinc --help
+$sptps_test --help
--- /dev/null
+#!/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
--- /dev/null
+#!/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