From: Guus Sliepen Date: Sat, 31 Aug 2013 22:39:14 +0000 (+0200) Subject: Start of a test suite. X-Git-Tag: release-1.1pre9~20 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=05a7f0b2fb07f8ee7752604a2a87b85f2430aaa3;p=tinc Start of a test suite. --- diff --git a/Makefile.am b/Makefile.am index d2e6f3fa..0a4faef3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = gnu -SUBDIRS = m4 src doc gui +SUBDIRS = m4 src doc gui test ACLOCAL_AMFLAGS = -I m4 diff --git a/configure.ac b/configure.ac index af12f12a..8b7c07a6 100644 --- a/configure.ac +++ b/configure.ac @@ -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 index 00000000..69042ac8 --- /dev/null +++ b/test/Makefile.am @@ -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 index 00000000..1277fb0d --- /dev/null +++ b/test/basic.test @@ -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 index 00000000..35dd2bc8 --- /dev/null +++ b/test/executables.test @@ -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 index 00000000..e18d063a --- /dev/null +++ b/test/sptps_basic.test @@ -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 index 00000000..e65127d6 --- /dev/null +++ b/test/testlib.sh @@ -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