3 # shellcheck disable=SC1090
7 test -e /dev/net/tun || exit "$EXIT_SKIP_TEST"
8 ip netns list || exit "$EXIT_SKIP_TEST"
9 command -v socat || exit "$EXIT_SKIP_TEST"
17 echo '[STEP] Determining supported compression levels'
19 features=$(tincd foo --version)
27 if echo "$features" | grep "comp_$algo"; then
30 bogus_levels="$bogus_levels $*"
34 add_levels zlib 1 2 3 4 5 6 7 8 9
38 echo "Supported compression levels: $levels"
39 echo "Unsupported compression levels: $bogus_levels"
41 echo [STEP] Create network namespaces
53 echo [STEP] Initialize two nodes
70 # shellcheck disable=SC2016
71 create_script foo tinc-up "
72 ip link set dev \$INTERFACE netns foo
73 ip netns exec foo ip addr add $ip_foo/$mask dev \$INTERFACE
74 ip netns exec foo ip link set \$INTERFACE up
77 # shellcheck disable=SC2016
78 create_script bar tinc-up "
79 ip link set dev \$INTERFACE netns bar
80 ip netns exec bar ip addr add $ip_bar/$mask dev \$INTERFACE
81 ip netns exec bar ip link set \$INTERFACE up
84 echo [STEP] Exchange configuration files
86 tinc foo export | tinc bar exchange | tinc foo import
88 echo [STEP] Test supported compression levels
92 create_script foo hosts/bar-up
93 create_script bar hosts/foo-up
95 for level in $levels; do
96 echo "[STEP] Testing compression level $level"
98 tinc foo set Compression "$level"
99 tinc bar set Compression "$level"
102 wait_script foo tinc-up
105 wait_script bar tinc-up
107 wait_script foo hosts/bar-up
108 wait_script bar hosts/foo-up
112 ip netns exec foo socat -u TCP4-LISTEN:$recv_port_foo,reuseaddr OPEN:"$tmp_file",creat &
113 ip netns exec bar socat -u OPEN:"$ref_file" TCP4:$ip_foo:$recv_port_foo,retry=30 &
117 diff -w "$ref_file" "$tmp_file"
123 echo '[STEP] Invalid compression levels should fail'
125 for level in $bogus_levels; do
126 echo "[STEP] Testing bogus compression level $level"
127 tinc foo set Compression "$level"
129 output=$(expect_code "$EXIT_FAILURE" start_tinc foo 2>&1)
131 if ! echo "$output" | grep -q 'Bogus compression level'; then
132 bail 'expected message about the wrong compression level'