]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: run-tests.sh: ensure non-zero exit when $failed != 0
authorŠtěpán Němec <snemec@redhat.com>
Wed, 20 Oct 2021 12:44:09 +0000 (14:44 +0200)
committerPhil Sutter <phil@nwl.cc>
Tue, 2 Nov 2021 21:00:38 +0000 (22:00 +0100)
POSIX [1] does not specify the behavior of `exit' with arguments
outside the 0-255 range, but what generally (bash, dash, zsh, OpenBSD
ksh, busybox) seems to happen is the shell exiting with status & 255
[2], which results in zero exit for certain non-zero arguments.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#exit
[2] https://git.savannah.gnu.org/cgit/bash.git/tree/builtins/common.c#n579

Fixes: 0c6592420586 ("tests: fix return codes")
Signed-off-by: Štěpán Němec <snemec@redhat.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
tests/build/run-tests.sh
tests/shell/run-tests.sh

index 9ce93a8ed38115cb5c26afccd9fb24f12df391b1..f78cc9019a30ebd6e5b2cf613fdfd81de2b82311 100755 (executable)
@@ -52,4 +52,4 @@ done
 rm -rf $tmpdir
 
 echo "results: [OK] $ok [FAILED] $failed [TOTAL] $((ok+failed))"
-exit $failed
+[ "$failed" -eq 0 ]
index 349ec6cb1b16125ceecb5f65e7c82f4ff36862bc..f77d850ef285083621f9485b5c033baffc2ebe83 100755 (executable)
@@ -160,4 +160,4 @@ echo ""
 msg_info "results: [OK] $ok [FAILED] $failed [TOTAL] $((ok+failed))"
 
 kernel_cleanup
-exit $failed
+[ "$failed" -eq 0 ]