From: Guus Sliepen Date: Mon, 22 Oct 2018 18:31:37 +0000 (+0200) Subject: Attempt to make the test suite work with Windows executables. X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=44f30239c1650877f8f1a4d9a5b56f0dbd0e3ea2;p=oweals%2Ftinc.git Attempt to make the test suite work with Windows executables. The test suite still assumes a POSIX shell to run the tests, but now handles the case when the executables themselves are (cross-)compiled for Windows, with a .exe extension. Also, DOS line endings must be converted to UNIX line endings in some cases. Some tests now pass on Linux+Wine, but others do not, mainly due to Wine not handling services very well. --- diff --git a/.gitignore b/.gitignore index 1cf6023..b3e9397 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ /test/*.log /test/*.trs /test/splice +/test/testlib.sh Makefile Makefile.in core* diff --git a/test/Makefile.am b/test/Makefile.am index 32b2e30..dae30dc 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -15,8 +15,6 @@ TESTS = \ dist_check_SCRIPTS = $(TESTS) -EXTRA_DIST = testlib.sh - AM_CFLAGS = -iquote. check_PROGRAMS = \ diff --git a/test/commandline.test b/test/commandline.test index 44d651a..f785b22 100755 --- a/test/commandline.test +++ b/test/commandline.test @@ -16,6 +16,10 @@ read pid rest <$d1/pid (sleep 0.1; kill \$pid) & EOF +cat >$d1/tinc-up.cmd <>\$INVITATION_FILE $tinc $c1 export >>\$INVITATION_FILE EOF +cat >$d1/invitation-created.cmd <%INVITATION_FILE% +echo Ifconfig = 93.184.216.34/24 >>%INVITATION_FILE% +echo Route = 2606:2800:220:1::/64 2606:2800:220:1:248:1893:25c8:1946 >>%INVITATION_FILE% +echo Route = 1.2.3.4 1234:: >>%INVITATION_FILE% +$tinc $c1 export >>%INVITATION_FILE% +EOF + chmod u+x $d1/invitation-created -$tinc $c1 invite bar | $tinc $c2 --batch join +$tinc $c1 invite bar | tail -1 | $tinc $c2 --batch join # Test equivalence of host config files diff --git a/test/scripts.test b/test/scripts.test index 2580ced..b2b37d2 100755 --- a/test/scripts.test +++ b/test/scripts.test @@ -2,6 +2,8 @@ . "${0%/*}/testlib.sh" +echo Initializing node... + # Initialize server node $tinc $c1 <$d1/$script << EOF echo $script \$NETNAME,\$NAME,\$DEVICE,\$IFACE,\$NODE,\$REMOTEADDRESS,\$REMOTEPORT,\$SUBNET,\$WEIGHT,\$INVITATION_FILE,\$INVITATION_URL,\$DEBUG >>$OUT EOF chmod u+x $d1/$script + +cat >$d1/$script.cmd << EOF +echo $script %NETNAME%,%NAME%,%DEVICE%,%IFACE%,%NODE%,%REMOTEADDRESS%,%REMOTEPORT%,%SUBNET%,%WEIGHT%,%INVITATION_FILE%,%INVITATION_URL%,%DEBUG% >>$OUT +EOF done # Start server node +echo Starting server node... + $tinc -n netname $c1 start $r1 echo foo-started >>$OUT # Invite client node -url=`$tinc -n netname2 $c1 invite bar` +echo Inviting client node... + +url=`$tinc -n netname2 $c1 invite bar | sed 's/\r//'` file=`cd $d1/invitations; ls | grep -v ed25519_key.priv` echo bar-invited >>$OUT + +echo Joining client node... + $tinc -n netname3 $c2 join $url echo bar-joined >>$OUT # Start and stop client node +echo Starting client node... + $tinc $c2 << EOF set DeviceType dummy set Port 32760 @@ -109,4 +126,5 @@ subnet-down netname,foo,dummy,,foo,,,fec0::/64,,,,5 tinc-down netname,foo,dummy,,,,,,,,,5 EOF +sed -i 's/\r//' $OUT cmp $OUT $OUT.expected diff --git a/test/testlib.sh b/test/testlib.sh deleted file mode 100644 index 75b60a7..0000000 --- a/test/testlib.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -# Paths to executables - -tincd=../src/tincd -tinc=../src/tinc -sptps_test=../src/sptps_test -sptps_keypair=../src/sptps_keypair - -# Test directories - -scriptname=`basename $0` -d1=$PWD/$scriptname.1 -d2=$PWD/$scriptname.2 -d3=$PWD/$scriptname.3 - -# 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=$d2/log -d5" -r3="--logfile=$d3/log -d5" - -# Check for leftover tinc daemons - -[ -f $d1/pid ] && $tinc $c1 stop -[ -f $d2/pid ] && $tinc $c2 stop -[ -f $d3/pid ] && $tinc $c3 stop - -# Remove test directories - -rm -rf $d1 $d2 $d3 - -# Exit on errors, log all commands being executed - -set -ex diff --git a/test/testlib.sh.in b/test/testlib.sh.in new file mode 100644 index 0000000..6a091cf --- /dev/null +++ b/test/testlib.sh.in @@ -0,0 +1,46 @@ +#!/bin/sh + +# Paths to executables + +tincd=../src/tincd@EXEEXT@ +tinc=../src/tinc@EXEEXT@ +sptps_test=../src/sptps_test@EXEEXT@ +sptps_keypair=../src/sptps_keypair@EXEEXT@ + +# Test directories + +scriptname=`basename $0` + +n1=$scriptname.1 +n2=$scriptname.2 +n3=$scriptname.3 + +d1=$PWD/$n1 +d2=$PWD/$n2 +d3=$PWD/$n3 + +# Default arguments for both tinc and tincd + +c1="-n $n1 --config=$d1 --pidfile=$d1/pid" +c2="-n $n2 --config=$d2 --pidfile=$d2/pid" +c3="-n $n3 --config=$d3 --pidfile=$d3/pid" + +# Arguments when running tincd + +r1="--logfile=$d1/log -d5" +r2="--logfile=$d2/log -d5" +r3="--logfile=$d3/log -d5" + +# Check for leftover tinc daemons + +[ -f $d1/pid ] && $tinc $c1 stop +[ -f $d2/pid ] && $tinc $c2 stop +[ -f $d3/pid ] && $tinc $c3 stop + +# Remove test directories + +rm -rf $d1 $d2 $d3 + +# Exit on errors, log all commands being executed + +set -ex diff --git a/test/variables.test b/test/variables.test index f8656c9..6ae0b79 100755 --- a/test/variables.test +++ b/test/variables.test @@ -5,18 +5,18 @@ # Initialize one node $tinc $c1 init foo -test "`$tinc $c1 get Name`" = "foo" +test "`$tinc $c1 get Name | sed 's/\r//'`" = "foo" # Test case sensitivity $tinc $c1 set Mode switch -test "`$tinc $c1 get Mode`" = "switch" -test "`$tinc $c1 get mode`" = "switch" +test "`$tinc $c1 get Mode | sed 's/\r//'`" = "switch" +test "`$tinc $c1 get mode | sed 's/\r//'`" = "switch" $tinc $c1 set mode router -test "`$tinc $c1 get Mode`" = "router" -test "`$tinc $c1 get mode`" = "router" +test "`$tinc $c1 get Mode | sed 's/\r//'`" = "router" +test "`$tinc $c1 get mode | sed 's/\r//'`" = "router" $tinc $c1 set Mode Switch -test "`$tinc $c1 get Mode`" = "Switch" +test "`$tinc $c1 get Mode | sed 's/\r//'`" = "Switch" # Test deletion @@ -28,7 +28,7 @@ test -z "`$tinc $c1 get Mode`" $tinc $c1 add Mode switch $tinc $c1 add Mode hub -test "`$tinc $c1 get Mode`" = "hub" +test "`$tinc $c1 get Mode | sed 's/\r//'`" = "hub" # Test addition/deletion of multivalued variables @@ -36,11 +36,11 @@ $tinc $c1 add Subnet 1 $tinc $c1 add Subnet 2 $tinc $c1 add Subnet 2 $tinc $c1 add Subnet 3 -test "`$tinc $c1 get Subnet`" = "1 +test "`$tinc $c1 get Subnet | sed 's/\r//'`" = "1 2 3" $tinc $c1 del Subnet 2 -test "`$tinc $c1 get Subnet`" = "1 +test "`$tinc $c1 get Subnet | sed 's/\r//'`" = "1 3" $tinc $c1 del Subnet test -z "`$tinc $c1 get Subnet`" @@ -56,17 +56,17 @@ touch $d1/hosts/bar $tinc $c1 add bar.PMTU 1 $tinc $c1 add bar.PMTU 2 -test "`$tinc $c1 get bar.PMTU`" = "2" +test "`$tinc $c1 get bar.PMTU | sed 's/\r//'`" = "2" $tinc $c1 add bar.Subnet 1 $tinc $c1 add bar.Subnet 2 $tinc $c1 add bar.Subnet 2 $tinc $c1 add bar.Subnet 3 -test "`$tinc $c1 get bar.Subnet`" = "1 +test "`$tinc $c1 get bar.Subnet | sed 's/\r//'`" = "1 2 3" $tinc $c1 del bar.Subnet 2 -test "`$tinc $c1 get bar.Subnet`" = "1 +test "`$tinc $c1 get bar.Subnet | sed 's/\r//'`" = "1 3" $tinc $c1 del bar.Subnet test -z "`$tinc $c1 get bar.Subnet`" @@ -81,6 +81,6 @@ $tinc $c1 set qu-ux.Subnet 1 && exit 1 || true $tinc $c1 set PrivateKey 12345 && exit 1 || true $tinc $c1 --force set PrivateKey 12345 -test "`$tinc $c1 get PrivateKey`" = "12345" +test "`$tinc $c1 get PrivateKey | sed 's/\r//'`" = "12345" $tinc $c1 del PrivateKey test -z "`$tinc $c1 get PrivateKey`"