summaryrefslogtreecommitdiffstats
path: root/tests/shell/testcases/rule_management
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/rule_management
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/rule_management')
-rwxr-xr-xtests/shell/testcases/rule_management/0002addinsertlocation_14
-rwxr-xr-xtests/shell/testcases/rule_management/0005replace_14
-rwxr-xr-xtests/shell/testcases/rule_management/0006replace_14
-rwxr-xr-xtests/shell/testcases/rule_management/0008delete_14
-rwxr-xr-xtests/shell/testcases/rule_management/0009delete_14
5 files changed, 14 insertions, 6 deletions
diff --git a/tests/shell/testcases/rule_management/0002addinsertlocation_1 b/tests/shell/testcases/rule_management/0002addinsertlocation_1
index b48d3d66..920032f2 100755
--- a/tests/shell/testcases/rule_management/0002addinsertlocation_1
+++ b/tests/shell/testcases/rule_management/0002addinsertlocation_1
@@ -17,7 +17,7 @@ for cmd in add insert; do
$NFT $cmd rule t c $keyword 5 drop 2>/dev/null || continue
echo "E: invalid $keyword value allowed in $cmd command" >&2
- exit 0
+ exit 1
done
done
-exit 1
+exit 0
diff --git a/tests/shell/testcases/rule_management/0005replace_1 b/tests/shell/testcases/rule_management/0005replace_1
index e82995a5..d8d64477 100755
--- a/tests/shell/testcases/rule_management/0005replace_1
+++ b/tests/shell/testcases/rule_management/0005replace_1
@@ -7,5 +7,7 @@ set -e
$NFT add table t
$NFT add chain t c
# kernel should return ENOENT
-$NFT replace rule t c handle 2 drop 2>/dev/null
+
+$NFT replace rule t c handle 2 drop 2>/dev/null || exit 0
echo "E: missing kernel ENOENT" >&2
+exit 1
diff --git a/tests/shell/testcases/rule_management/0006replace_1 b/tests/shell/testcases/rule_management/0006replace_1
index 5dfcba02..b728310f 100755
--- a/tests/shell/testcases/rule_management/0006replace_1
+++ b/tests/shell/testcases/rule_management/0006replace_1
@@ -6,6 +6,8 @@
set -e
$NFT add table t
$NFT add chain t c
+
# position keyword with replace action is not allowed, this should fail
-$NFT replace rule t c position 2 drop 2>/dev/null
+$NFT replace rule t c position 2 drop 2>/dev/null || exit 0
echo "E: allowed replace with position specification" >&2
+exit 1
diff --git a/tests/shell/testcases/rule_management/0008delete_1 b/tests/shell/testcases/rule_management/0008delete_1
index 3dce2191..d1900d66 100755
--- a/tests/shell/testcases/rule_management/0008delete_1
+++ b/tests/shell/testcases/rule_management/0008delete_1
@@ -6,6 +6,8 @@
set -e
$NFT add table t
$NFT add chain t c
+
# this should fail, we don't allow delete with position
-$NFT delete rule t c position 2 drop 2>/dev/null
+$NFT delete rule t c position 2 drop 2>/dev/null || exit 0
echo "E: allowed position spec with delete action" >&2
+exit 1
diff --git a/tests/shell/testcases/rule_management/0009delete_1 b/tests/shell/testcases/rule_management/0009delete_1
index 87fec605..8751fec3 100755
--- a/tests/shell/testcases/rule_management/0009delete_1
+++ b/tests/shell/testcases/rule_management/0009delete_1
@@ -6,6 +6,8 @@
set -e
$NFT add table t
$NFT add chain t c
+
# kernel ENOENT
-$NFT delete rule t c handle 3333 2>/dev/null
+$NFT delete rule t c handle 3333 2>/dev/null || exit 0
echo "E: missing kernel ENOENT" >&2
+exit 1