From 9933dc543628b1531ac30b30b9894a16c86a0b7a Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Tue, 26 Jun 2018 21:36:10 +0200 Subject: tests: adapt test suite to run with legacy+nftables based binaries While at it, make following changes/fixes: 1. run each test in a fresh net namespace 2. remove rmmod use, its very distuptive and not needed after 1. 3. avoid -e use if possible 4. make sure we exit 0 when test is expected to fail 5. set XT_LIBDIR so we point at the correct extensions to be used Also delete 0003duplicate_1, its same test as 0001duplicate_1. NB: I don't think its good to have this 'encode retval in name' scheme. These are scripts, so they should always return 0, i.e. do iptables --this-command-should-fail || exit 0 echo "succeess, should fail" exit 1 Much simpler, imo. This was inherited from nft shell tests though and changing it there is rather intrusive so use same scheme for now. Signed-off-by: Florian Westphal --- iptables/tests/shell/testcases/chain/0001duplicate_1 | 10 ++++------ iptables/tests/shell/testcases/chain/0002duplicate_0 | 9 --------- iptables/tests/shell/testcases/chain/0003duplicate_1 | 11 ----------- iptables/tests/shell/testcases/chain/0005rename_1 | 14 +++++--------- 4 files changed, 9 insertions(+), 35 deletions(-) delete mode 100755 iptables/tests/shell/testcases/chain/0002duplicate_0 delete mode 100755 iptables/tests/shell/testcases/chain/0003duplicate_1 (limited to 'iptables/tests/shell/testcases') diff --git a/iptables/tests/shell/testcases/chain/0001duplicate_1 b/iptables/tests/shell/testcases/chain/0001duplicate_1 index 6d42cecf..e88f82ad 100755 --- a/iptables/tests/shell/testcases/chain/0001duplicate_1 +++ b/iptables/tests/shell/testcases/chain/0001duplicate_1 @@ -1,11 +1,9 @@ #!/bin/bash -set -e +set -x $IPTABLES -t filter -N c1 -$IPTABLES -t filter -N c1 +$IPTABLES -t filter -N c1 || exit 1 -if [ $? -eq 0 ]; then - echo "E: Duplicate chains" >&2 - exit 0 -fi +echo "E: Duplicate chains" >&2 +exit 0 diff --git a/iptables/tests/shell/testcases/chain/0002duplicate_0 b/iptables/tests/shell/testcases/chain/0002duplicate_0 deleted file mode 100755 index 025114ea..00000000 --- a/iptables/tests/shell/testcases/chain/0002duplicate_0 +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -$IPTABLES -t filter -N c1 || exit 1 -$IPTABLES -t filter -N c1 - -if [ $? -eq 0 ]; then - echo "E: Duplicate chains" >&2 - exit 0 -fi diff --git a/iptables/tests/shell/testcases/chain/0003duplicate_1 b/iptables/tests/shell/testcases/chain/0003duplicate_1 deleted file mode 100755 index 6d42cecf..00000000 --- a/iptables/tests/shell/testcases/chain/0003duplicate_1 +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -set -e - -$IPTABLES -t filter -N c1 -$IPTABLES -t filter -N c1 - -if [ $? -eq 0 ]; then - echo "E: Duplicate chains" >&2 - exit 0 -fi diff --git a/iptables/tests/shell/testcases/chain/0005rename_1 b/iptables/tests/shell/testcases/chain/0005rename_1 index 7261b6dc..f2f6e55a 100755 --- a/iptables/tests/shell/testcases/chain/0005rename_1 +++ b/iptables/tests/shell/testcases/chain/0005rename_1 @@ -1,12 +1,8 @@ #!/bin/bash -set -e +$IPTABLES -N c1 || exit 0 +$IPTABLES -N c2 || exit 0 +$IPTABLES -E c1 c2 || exit 1 -$IPTABLES -N c1 -$IPTABLES -N c2 -$IPTABLES -E c1 c2 - -if [ $? -eq 0 ] ; then - echo "E: Renamed with existing chain" >&2 - exit 0 -fi +echo "E: Renamed with existing chain" >&2 +exit 0 -- cgit v1.2.3