From 44f30239c1650877f8f1a4d9a5b56f0dbd0e3ea2 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 22 Oct 2018 20:31:37 +0200 Subject: [PATCH] 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. --- .gitignore | 1 + test/Makefile.am | 2 -- test/commandline.test | 4 ++++ test/invite-offline.test | 2 +- test/invite-tinc-up.test | 10 +++++++++- test/scripts.test | 20 +++++++++++++++++++- test/{testlib.sh => testlib.sh.in} | 25 +++++++++++++++---------- test/variables.test | 26 +++++++++++++------------- 8 files changed, 62 insertions(+), 28 deletions(-) rename test/{testlib.sh => testlib.sh.in} (57%) diff --git a/.gitignore b/.gitignore index 1cf6023b..b3e93971 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 32b2e300..dae30dcf 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 44d651a5..f785b221 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 2580ced7..b2b37d21 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.in similarity index 57% rename from test/testlib.sh rename to test/testlib.sh.in index 75b60a79..6a091cff 100644 --- a/test/testlib.sh +++ b/test/testlib.sh.in @@ -2,23 +2,28 @@ # Paths to executables -tincd=../src/tincd -tinc=../src/tinc -sptps_test=../src/sptps_test -sptps_keypair=../src/sptps_keypair +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` -d1=$PWD/$scriptname.1 -d2=$PWD/$scriptname.2 -d3=$PWD/$scriptname.3 + +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="--config=$d1 --pidfile=$d1/pid" -c2="--config=$d2 --pidfile=$d2/pid" -c3="--config=$d3 --pidfile=$d3/pid" +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 diff --git a/test/variables.test b/test/variables.test index f8656c93..6ae0b797 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`" -- 2.20.1