Rewrite the test suite for better compat and stability
[tinc] / test / algorithms.test
index c506a5d..04d9131 100755 (executable)
@@ -1,46 +1,56 @@
 #!/bin/sh
 
+# shellcheck source=testlib.sh
 . "${0%/*}/testlib.sh"
 
-# Initialize two nodes
+echo [STEP] Initialize two nodes
 
-$tinc $c1 <<EOF
+tinc foo <<EOF
 init foo
 set DeviceType dummy
-set Port 32755
+set Port 30070
 set Address localhost
 set ExperimentalProtocol no
 EOF
 
-$tinc $c2 <<EOF
+tinc bar <<EOF
 init bar
 set DeviceType dummy
 set Port 0
 set ExperimentalProtocol no
 EOF
 
-# Exchange configuration
+create_script foo hosts/bar-up
+create_script bar hosts/foo-up
 
-$tinc $c1 export | $tinc $c2 exchange | $tinc $c1 import
-$tinc $c2 add ConnectTo foo
-$tinc $c1 start $r1
+echo [STEP] Exchange configuration
 
-# Test various ciphers and digests
+tinc foo export | tinc bar exchange | tinc foo import
+tinc bar add ConnectTo foo
+start_tinc foo
 
-for digest in none md5 sha1 sha256 sha512; do
-       for cipher in none bf-cbc aes-128-cbc aes-256-cbc camellia-128-cbc camellia-256-cbc; do
-               echo Testing $cipher $digest
-               $tinc $c2 <<EOF
+echo [STEP] Test various ciphers and digests
+
+# The full suite results in a large test matrix and it takes a lot of time to run.
+# The list was reduced to the strongest available algorithms (and "none").
+digests="none sha256 sha512"
+ciphers="none aes-256-cbc camellia-256-cbc"
+
+for digest in $digests; do
+  for cipher in $ciphers; do
+    echo "Testing $cipher $digest"
+
+    tinc bar <<EOF
 set Digest $digest
 set Cipher $cipher
 EOF
 
-               $tinc $c2 start $r2
-               sleep 2;
-               $tinc $c1 info bar
-               $tinc $c1 info bar | grep -q 'directly with UDP'
-               $tinc $c2 stop
-       done
-done
+    start_tinc bar
+    wait_script foo hosts/bar-up
+    wait_script bar hosts/foo-up
+
+    tinc foo info bar | grep reachable
 
-$tinc $c1 stop
+    tinc bar stop
+  done
+done