From cfe507c299935bd231be698b8a426cc730f52936 Mon Sep 17 00:00:00 2001 From: Kirill Isakov Date: Tue, 20 Jul 2021 18:00:49 +0600 Subject: [PATCH] Add compression.test --- test/Makefile.am | 1 + test/algorithms.test | 1 - test/basic.test | 1 - test/commandline.test | 1 - test/compression.test | 132 ++++++++++++++++++++++++++++++++++++++ test/executables.test | 1 - test/import-export.test | 1 - test/invite-join.test | 1 - test/invite-offline.test | 1 - test/invite-tinc-up.test | 1 - test/legacy-protocol.test | 1 - test/ns-ping.test | 1 - test/scripts.test | 1 - test/security.test | 1 - test/sptps-basic.test | 1 - test/variables.test | 1 - 16 files changed, 133 insertions(+), 14 deletions(-) create mode 100755 test/compression.test diff --git a/test/Makefile.am b/test/Makefile.am index 8c8d08fe..da77fb79 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -2,6 +2,7 @@ TESTS = \ basic.test \ executables.test \ commandline.test \ + compression.test \ import-export.test \ invite-join.test \ invite-offline.test \ diff --git a/test/algorithms.test b/test/algorithms.test index bf073a56..dcf055a0 100755 --- a/test/algorithms.test +++ b/test/algorithms.test @@ -1,6 +1,5 @@ #!/bin/sh -# shellcheck source=testlib.sh . ./testlib.sh echo [STEP] Initialize two nodes diff --git a/test/basic.test b/test/basic.test index b2a3e472..87c57842 100755 --- a/test/basic.test +++ b/test/basic.test @@ -1,6 +1,5 @@ #!/bin/sh -# shellcheck source=testlib.sh . ./testlib.sh echo [STEP] Initialize and test one node diff --git a/test/commandline.test b/test/commandline.test index 5e9fb85a..241cb25f 100755 --- a/test/commandline.test +++ b/test/commandline.test @@ -1,6 +1,5 @@ #!/bin/sh -# shellcheck source=testlib.sh . ./testlib.sh echo [STEP] Initialize one node diff --git a/test/compression.test b/test/compression.test new file mode 100755 index 00000000..77efd6d3 --- /dev/null +++ b/test/compression.test @@ -0,0 +1,132 @@ +#!/bin/sh + +. ./testlib.sh + +test "$(id -u)" = "0" || exit $EXIT_SKIP_TEST +test -e /dev/net/tun || exit $EXIT_SKIP_TEST +ip netns list || exit $EXIT_SKIP_TEST +command -v socat || exit $EXIT_SKIP_TEST + +ip_foo=192.168.1.1 +ip_bar=192.168.1.2 +port_foo=30100 +recv_port_foo=30101 +mask=24 + +echo '[STEP] Determining supported compression levels' + +features=$(tincd foo --version) +bogus_levels="-1 13" +levels=0 + +add_levels() { + algo=$1 + shift + + if echo "$features" | grep "comp_$algo"; then + levels="$levels $*" + else + bogus_levels="$bogus_levels $*" + fi +} + +add_levels zlib 1 2 3 4 5 6 7 8 9 +add_levels lzo 10 11 +add_levels lz4 12 + +echo "Supported compression levels: $levels" +echo "Unsupported compression levels: $bogus_levels" + +echo [STEP] Create network namespaces + +ip netns add foo +ip netns add bar +tmp_file=$(mktemp) + +cleanup_hook() { + ip netns del foo + ip netns del bar + rm -f "$tmp_file" +} + +echo [STEP] Initialize two nodes + +tinc foo <&1) + + if ! echo "$output" | grep -q 'Bogus compression level'; then + bail 'expected message about the wrong compression level' + fi +done diff --git a/test/executables.test b/test/executables.test index bc53aed2..96aad992 100755 --- a/test/executables.test +++ b/test/executables.test @@ -1,6 +1,5 @@ #!/bin/sh -# shellcheck source=testlib.sh . ./testlib.sh echo [STEP] Just test whether the executables work diff --git a/test/import-export.test b/test/import-export.test index 9b44e7af..9fdfa497 100755 --- a/test/import-export.test +++ b/test/import-export.test @@ -1,6 +1,5 @@ #!/bin/sh -# shellcheck source=testlib.sh . ./testlib.sh echo [STEP] Initialize three nodes diff --git a/test/invite-join.test b/test/invite-join.test index 58edd4a6..3a9e3a33 100755 --- a/test/invite-join.test +++ b/test/invite-join.test @@ -1,6 +1,5 @@ #!/bin/sh -# shellcheck source=testlib.sh . ./testlib.sh echo [STEP] Initialize one node diff --git a/test/invite-offline.test b/test/invite-offline.test index 2d7878d5..aea39b41 100755 --- a/test/invite-offline.test +++ b/test/invite-offline.test @@ -1,6 +1,5 @@ #!/bin/sh -# shellcheck source=testlib.sh . ./testlib.sh echo [STEP] Initialize one node diff --git a/test/invite-tinc-up.test b/test/invite-tinc-up.test index 8f09f5ed..a288d6e7 100755 --- a/test/invite-tinc-up.test +++ b/test/invite-tinc-up.test @@ -1,6 +1,5 @@ #!/bin/sh -# shellcheck source=testlib.sh . ./testlib.sh echo [STEP] Initialize one node diff --git a/test/legacy-protocol.test b/test/legacy-protocol.test index 1aef8f28..396fc56d 100755 --- a/test/legacy-protocol.test +++ b/test/legacy-protocol.test @@ -1,6 +1,5 @@ #!/bin/sh -# shellcheck source=testlib.sh . ./testlib.sh echo [STEP] Initialize two nodes diff --git a/test/ns-ping.test b/test/ns-ping.test index 417ed328..bb76ed39 100755 --- a/test/ns-ping.test +++ b/test/ns-ping.test @@ -1,6 +1,5 @@ #!/bin/sh -# shellcheck source=testlib.sh . ./testlib.sh echo "[STEP] Skip this test if we aren't root or if 'ip netns' does not exist" diff --git a/test/scripts.test b/test/scripts.test index 9ef64164..a76356ae 100755 --- a/test/scripts.test +++ b/test/scripts.test @@ -1,6 +1,5 @@ #!/bin/sh -# shellcheck source=testlib.sh . ./testlib.sh echo [STEP] Initializing server node diff --git a/test/security.test b/test/security.test index 76b825dc..ee7bd46d 100755 --- a/test/security.test +++ b/test/security.test @@ -1,6 +1,5 @@ #!/bin/sh -# shellcheck source=testlib.sh . ./testlib.sh echo [STEP] Skip this test if tools are missing diff --git a/test/sptps-basic.test b/test/sptps-basic.test index 87aee021..56e3cd00 100755 --- a/test/sptps-basic.test +++ b/test/sptps-basic.test @@ -1,6 +1,5 @@ #!/bin/sh -# shellcheck source=testlib.sh . ./testlib.sh echo [STEP] Skip this test if we did not compile sptps_test diff --git a/test/variables.test b/test/variables.test index 0164e27a..bcec9fb2 100755 --- a/test/variables.test +++ b/test/variables.test @@ -1,6 +1,5 @@ #!/bin/sh -# shellcheck source=testlib.sh . ./testlib.sh echo [STEP] Initialize one node -- 2.20.1