6 test -e /dev/net/tun || exit $EXIT_SKIP_TEST
7 ip netns list || exit $EXIT_SKIP_TEST
8 command -v socat || exit $EXIT_SKIP_TEST
16 echo '[STEP] Determining supported compression levels'
18 features=$(tincd foo --version)
26 if echo "$features" | grep "comp_$algo"; then
29 bogus_levels="$bogus_levels $*"
33 add_levels zlib 1 2 3 4 5 6 7 8 9
37 echo "Supported compression levels: $levels"
38 echo "Unsupported compression levels: $bogus_levels"
40 echo [STEP] Create network namespaces
52 echo [STEP] Initialize two nodes
69 # shellcheck disable=SC2016
70 create_script foo tinc-up "
71 ip link set dev \$INTERFACE netns foo
72 ip netns exec foo ip addr add $ip_foo/$mask dev \$INTERFACE
73 ip netns exec foo ip link set \$INTERFACE up
76 # shellcheck disable=SC2016
77 create_script bar tinc-up "
78 ip link set dev \$INTERFACE netns bar
79 ip netns exec bar ip addr add $ip_bar/$mask dev \$INTERFACE
80 ip netns exec bar ip link set \$INTERFACE up
83 echo [STEP] Exchange configuration files
85 tinc foo export | tinc bar exchange | tinc foo import
87 echo [STEP] Test supported compression levels
91 create_script foo hosts/bar-up
92 create_script bar hosts/foo-up
94 for level in $levels; do
95 echo "[STEP] Testing compression level $level"
97 tinc foo set Compression "$level"
98 tinc bar set Compression "$level"
101 wait_script foo tinc-up
104 wait_script bar tinc-up
106 wait_script foo hosts/bar-up
107 wait_script bar hosts/foo-up
110 socat -u TCP4-LISTEN:$recv_port_foo,reuseaddr OPEN:"$tmp_file",creat &
113 socat -u OPEN:"$ref_file" TCP4:$ip_foo:$recv_port_foo,retry=30 &
116 diff -w "$ref_file" "$tmp_file"
122 echo '[STEP] Invalid compression levels should fail'
124 for level in $bogus_levels; do
125 echo "[STEP] Testing bogus compression level $level"
126 tinc foo set Compression "$level"
128 output=$(expect_code "$EXIT_FAILURE" start_tinc foo 2>&1)
130 if ! echo "$output" | grep -q 'Bogus compression level'; then
131 bail 'expected message about the wrong compression level'