diff options
author | Florian Westphal <fw@strlen.de> | 2019-01-04 15:57:00 +0100 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2019-01-04 16:00:31 +0100 |
commit | 4d26b6dd3c4c8354a88c4a1aef8ea33229f0a4cc (patch) | |
tree | 1e82c9b480038033c65cd7d17b08f24e149bcd82 /tests/shell/testcases/include | |
parent | eb49882deb3e9ec5eccd6e6106b454e3a6394408 (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/include')
4 files changed, 11 insertions, 18 deletions
diff --git a/tests/shell/testcases/include/0004endlessloop_1 b/tests/shell/testcases/include/0004endlessloop_1 index c4aba0c4..3e6789d3 100755 --- a/tests/shell/testcases/include/0004endlessloop_1 +++ b/tests/shell/testcases/include/0004endlessloop_1 @@ -14,5 +14,6 @@ RULESET="include \"$tmpfile\"" echo "$RULESET" > $tmpfile -$NFT -f $tmpfile 2>/dev/null +$NFT -f $tmpfile 2>/dev/null || exit 0 echo "E: endless include loop" >&2 +exit 1 diff --git a/tests/shell/testcases/include/0009glob_nofile_1 b/tests/shell/testcases/include/0009glob_nofile_1 index bab58305..d769155a 100755 --- a/tests/shell/testcases/include/0009glob_nofile_1 +++ b/tests/shell/testcases/include/0009glob_nofile_1 @@ -26,8 +26,6 @@ RULESET1="include \"$tmpdir/non_existent_file.nft\"" echo "$RULESET1" > $tmpfile1 -$NFT -f $tmpfile1 -if [ $? -eq 0 ] ; then - echo "E: Failed to catch a missing include directory/file" >&2 - exit 1 -fi +$NFT -f $tmpfile1 || exit 0 +echo "E: Failed to catch a missing include directory/file" >&2 +exit 1 diff --git a/tests/shell/testcases/include/0010glob_broken_file_1 b/tests/shell/testcases/include/0010glob_broken_file_1 index 9027f189..a00babf1 100755 --- a/tests/shell/testcases/include/0010glob_broken_file_1 +++ b/tests/shell/testcases/include/0010glob_broken_file_1 @@ -41,9 +41,6 @@ echo "$RULESET1" > $tmpfile1 echo "$RULESET2" > $tmpfile2 echo "$RULESET3" > $tmpfile3 -$NFT -f $tmpfile3 - -if [ $? -eq 0 ] ; then - echo "E: didn't catch a broken file in directory" >&2 - exit 1 -fi +$NFT -f $tmpfile3 || exit 0 +echo "E: didn't catch a broken file in directory" >&2 +exit 1 diff --git a/tests/shell/testcases/include/0012glob_dependency_1 b/tests/shell/testcases/include/0012glob_dependency_1 index 6cf4ba17..e4e12e27 100755 --- a/tests/shell/testcases/include/0012glob_dependency_1 +++ b/tests/shell/testcases/include/0012glob_dependency_1 @@ -44,9 +44,6 @@ echo "$RULESET1" > $tmpfile2 echo "$RULESET2" > $tmpfile1 echo "$RULESET3" > $tmpfile3 -$NFT -f $tmpfile3 - -if [ $? -eq 0 ] ; then - echo "E: did not catch wrong file order in include directory" >&2 - exit 1 -fi +$NFT -f $tmpfile3 || exit 0 +echo "E: did not catch wrong file order in include directory" >&2 +exit 1 |