From: Kirill Isakov Date: Thu, 1 Jul 2021 13:35:08 +0000 (+0600) Subject: Allow running tests on macOS X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=9ca716d6270335cf44455fc1667a1647c19410ef;p=tinc Allow running tests on macOS --- diff --git a/test/invite-offline.test b/test/invite-offline.test index 82f7cb98..e515919d 100755 --- a/test/invite-offline.test +++ b/test/invite-offline.test @@ -15,7 +15,7 @@ EOF # Generate an invitation offline and let another node join the VPN -invitation=`$tinc $c1 invite bar | sed 's/\r//'` +invitation=`$tinc $c1 invite bar | tr -d '\r'` $tinc $c1 start $r1 diff --git a/test/scripts.test b/test/scripts.test index e209d691..7889e1da 100755 --- a/test/scripts.test +++ b/test/scripts.test @@ -46,7 +46,7 @@ echo foo-started >>$OUT echo Inviting client node... -url=`$tinc $c1 -n netname2 invite bar | sed 's/\r//'` +url=`$tinc $c1 -n netname2 invite bar | tr -d '\r'` file=`cd $d1/invitations; ls | grep -v ed25519_key.priv` echo bar-invited >>$OUT @@ -126,5 +126,6 @@ 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 +tr -d '\r' <$OUT >$OUT.actual + +cmp $OUT.actual $OUT.expected diff --git a/test/security.test b/test/security.test index 91d29e29..6c15bdab 100755 --- a/test/security.test +++ b/test/security.test @@ -4,7 +4,12 @@ # Skip this test if tools are missing -which socket >/dev/null || exit 77 +which nc >/dev/null || exit 77 + +if [ "$(uname)" = "Darwin" ]; then + alias timeout=gtimeout +fi + which timeout >/dev/null || exit 77 # Initialize two nodes @@ -37,29 +42,29 @@ $tinc $c2 start $r2 # No ID sent by responding node if we don't send an ID first, before the timeout -result=`(sleep 2; echo "0 bar 17.7") | timeout 3 socket localhost 32754` && exit 1 +result=`(sleep 2; echo "0 bar 17.7") | timeout 3 nc localhost 32754` && exit 1 test $? = 124 test -z "$result" # ID sent if initiator sends first, but still tarpitted -result=`echo "0 bar 17.7" | timeout 3 socket localhost 32754` && exit 1 +result=`echo "0 bar 17.7" | timeout 3 nc localhost 32754` && exit 1 test $? = 124 test "`echo "$result" | head -c 10`" = "0 foo 17.7" # No invalid IDs allowed -result=`echo "0 foo 17.7" | timeout 1 socket localhost 32754` && exit 1 +result=`echo "0 foo 17.7" | timeout 1 nc localhost 32754` && exit 1 test $? = 124 test -z "$result" -result=`echo "0 baz 17.7" | timeout 1 socket localhost 32754` && exit 1 +result=`echo "0 baz 17.7" | timeout 1 nc localhost 32754` && exit 1 test $? = 124 test -z "$result" # No NULL METAKEYs allowed -result=`printf "0 foo 17.0\n1 0 672 0 0 834188619F4D943FD0F4B1336F428BD4AC06171FEABA66BD2356BC9593F0ECD643F0E4B748C670D7750DFDE75DC9F1D8F65AB1026F5ED2A176466FBA4167CC567A2085ABD070C1545B180BDA86020E275EA9335F509C57786F4ED2378EFFF331869B856DDE1C05C461E4EECAF0E2FB97AF77B7BC2AD1B34C12992E45F5D1254BBF0C3FB224ABB3E8859594A83B6CA393ED81ECAC9221CE6BC71A727BCAD87DD80FC0834B87BADB5CB8FD3F08BEF90115A8DF1923D7CD9529729F27E1B8ABD83C4CF8818AE10257162E0057A658E265610B71F9BA4B365A20C70578FAC65B51B91100392171BA12A440A5E93C4AA62E0C9B6FC9B68F953514AAA7831B4B2C31C4\n" | timeout 3 socket localhost 32755` && exit 1 +result=`printf "0 foo 17.0\n1 0 672 0 0 834188619F4D943FD0F4B1336F428BD4AC06171FEABA66BD2356BC9593F0ECD643F0E4B748C670D7750DFDE75DC9F1D8F65AB1026F5ED2A176466FBA4167CC567A2085ABD070C1545B180BDA86020E275EA9335F509C57786F4ED2378EFFF331869B856DDE1C05C461E4EECAF0E2FB97AF77B7BC2AD1B34C12992E45F5D1254BBF0C3FB224ABB3E8859594A83B6CA393ED81ECAC9221CE6BC71A727BCAD87DD80FC0834B87BADB5CB8FD3F08BEF90115A8DF1923D7CD9529729F27E1B8ABD83C4CF8818AE10257162E0057A658E265610B71F9BA4B365A20C70578FAC65B51B91100392171BA12A440A5E93C4AA62E0C9B6FC9B68F953514AAA7831B4B2C31C4\n" | timeout 3 nc localhost 32755` && exit 1 test $? = 124 test -z "$result" # Not even the ID should be sent when the first packet contains illegal data diff --git a/test/variables.test b/test/variables.test index 6ae0b797..d9494b4f 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 | sed 's/\r//'`" = "foo" +test "`$tinc $c1 get Name | tr -d '\r'`" = "foo" # Test case sensitivity $tinc $c1 set Mode switch -test "`$tinc $c1 get Mode | sed 's/\r//'`" = "switch" -test "`$tinc $c1 get mode | sed 's/\r//'`" = "switch" +test "`$tinc $c1 get Mode | tr -d '\r'`" = "switch" +test "`$tinc $c1 get mode | tr -d '\r'`" = "switch" $tinc $c1 set mode router -test "`$tinc $c1 get Mode | sed 's/\r//'`" = "router" -test "`$tinc $c1 get mode | sed 's/\r//'`" = "router" +test "`$tinc $c1 get Mode | tr -d '\r'`" = "router" +test "`$tinc $c1 get mode | tr -d '\r'`" = "router" $tinc $c1 set Mode Switch -test "`$tinc $c1 get Mode | sed 's/\r//'`" = "Switch" +test "`$tinc $c1 get Mode | tr -d '\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 | sed 's/\r//'`" = "hub" +test "`$tinc $c1 get Mode | tr -d '\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 | sed 's/\r//'`" = "1 +test "`$tinc $c1 get Subnet | tr -d '\r'`" = "1 2 3" $tinc $c1 del Subnet 2 -test "`$tinc $c1 get Subnet | sed 's/\r//'`" = "1 +test "`$tinc $c1 get Subnet | tr -d '\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 | sed 's/\r//'`" = "2" +test "`$tinc $c1 get bar.PMTU | tr -d '\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 | sed 's/\r//'`" = "1 +test "`$tinc $c1 get bar.Subnet | tr -d '\r'`" = "1 2 3" $tinc $c1 del bar.Subnet 2 -test "`$tinc $c1 get bar.Subnet | sed 's/\r//'`" = "1 +test "`$tinc $c1 get bar.Subnet | tr -d '\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 | sed 's/\r//'`" = "12345" +test "`$tinc $c1 get PrivateKey | tr -d '\r'`" = "12345" $tinc $c1 del PrivateKey test -z "`$tinc $c1 get PrivateKey`"