summaryrefslogtreecommitdiffstats
path: root/tests/shell/testcases/transactions
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2019-01-04 15:57:00 +0100
committerFlorian Westphal <fw@strlen.de>2019-01-04 16:00:31 +0100
commit4d26b6dd3c4c8354a88c4a1aef8ea33229f0a4cc (patch)
tree1e82c9b480038033c65cd7d17b08f24e149bcd82 /tests/shell/testcases/transactions
parenteb49882deb3e9ec5eccd6e6106b454e3a6394408 (diff)
tests: shell: change all test scripts to return 0
The shell-based tests currently encode a return value in the file name, i.e. foo_1 expects that the script should return '1' for the test case to pass. This is very error prone, and one test case is even broken (i.e., it returns 1, but because of a different, earlier error). do_something || exit 1 or 'set -e' are both pretty common patterns, in both cases tests should fail. In those test-cases that deliberately test for an error, nft something_should_fail || exit 0 nft something_should_fail && exit 1 or a similar constructs should be used. This initial commit modififies all '_1' scripts to return 0 on success, usually via 'nft wrong || exit 0'. All tests pass, except the one broken test case that hasn't worked before either, but where 'set -e' use made it pass (the failing command is supposed to work, and the command that is supposed to fail is never run). Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'tests/shell/testcases/transactions')
-rwxr-xr-xtests/shell/testcases/transactions/0014chain_15
-rwxr-xr-xtests/shell/testcases/transactions/0022rule_15
-rwxr-xr-xtests/shell/testcases/transactions/0023rule_15
-rwxr-xr-xtests/shell/testcases/transactions/0036set_15
4 files changed, 8 insertions, 12 deletions
diff --git a/tests/shell/testcases/transactions/0014chain_1 b/tests/shell/testcases/transactions/0014chain_1
index 802a7e63..cddc8a2e 100755
--- a/tests/shell/testcases/transactions/0014chain_1
+++ b/tests/shell/testcases/transactions/0014chain_1
@@ -1,11 +1,10 @@
#!/bin/bash
-set -e
-
RULESET="add table x
add chain x y
delete chain x y
delete chain x y"
-$NFT -f - <<< "$RULESET" 2>/dev/null
+$NFT -f - <<< "$RULESET" 2>/dev/null || exit 0
echo "E: allowing double-removal of chain" >&2
+exit 1
diff --git a/tests/shell/testcases/transactions/0022rule_1 b/tests/shell/testcases/transactions/0022rule_1
index 0e7c9a6f..07be53f2 100755
--- a/tests/shell/testcases/transactions/0022rule_1
+++ b/tests/shell/testcases/transactions/0022rule_1
@@ -1,12 +1,11 @@
#!/bin/bash
-set -e
-
RULESET="add table x
add chain x y
delete chain x y
add rule x y jump y"
# kernel must return ENOENT
-$NFT -f - <<< "$RULESET" 2>/dev/null
+$NFT -f - <<< "$RULESET" 2>/dev/null || exit 0
echo "E: allowing jump loop to unexisting chain"
+exit 1
diff --git a/tests/shell/testcases/transactions/0023rule_1 b/tests/shell/testcases/transactions/0023rule_1
index edc4e8d2..e58c088c 100755
--- a/tests/shell/testcases/transactions/0023rule_1
+++ b/tests/shell/testcases/transactions/0023rule_1
@@ -1,11 +1,10 @@
#!/bin/bash
-set -e
-
RULESET="add table x
add chain x y
add rule x y jump y"
# kernel must return ELOOP
-$NFT -f - <<< "$RULESET" 2>/dev/null
+$NFT -f - <<< "$RULESET" 2>/dev/null || exit 0
echo "E: allowing jump to chain loop"
+exit 1
diff --git a/tests/shell/testcases/transactions/0036set_1 b/tests/shell/testcases/transactions/0036set_1
index e691fa7f..45d922eb 100755
--- a/tests/shell/testcases/transactions/0036set_1
+++ b/tests/shell/testcases/transactions/0036set_1
@@ -1,13 +1,12 @@
#!/bin/bash
-set -e
-
RULESET="add table x
add set x y { type ipv4_addr; }
add element x y { 1.1.1.1, 2.2.2.2 }
delete element x y { 1.1.1.1 }
delete element x y { 1.1.1.1 }"
-$NFT -f - <<< "$RULESET" 2> /dev/null
+$NFT -f - <<< "$RULESET" 2> /dev/null || exit 0
# Kernel must return ENOENT
echo "E: allowing double-removal of element"
+exit 1