[PATCH nft] tests: run-tests.sh: ensure non-zero exit when $failed != 0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 tests/build/run-tests.sh | 2 +-
 tests/shell/run-tests.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/build/run-tests.sh b/tests/build/run-tests.sh
index 9ce93a8ed381..f78cc9019a30 100755
--- a/tests/build/run-tests.sh
+++ b/tests/build/run-tests.sh
@@ -52,4 +52,4 @@ done
 rm -rf $tmpdir
 
 echo "results: [OK] $ok [FAILED] $failed [TOTAL] $((ok+failed))"
-exit $failed
+[ "$failed" -eq 0 ]
diff --git a/tests/shell/run-tests.sh b/tests/shell/run-tests.sh
index 349ec6cb1b16..f77d850ef285 100755
--- a/tests/shell/run-tests.sh
+++ b/tests/shell/run-tests.sh
@@ -160,4 +160,4 @@ echo ""
 msg_info "results: [OK] $ok [FAILED] $failed [TOTAL] $((ok+failed))"
 
 kernel_cleanup
-exit $failed
+[ "$failed" -eq 0 ]

base-commit: 2139913694a9850c9160920b2c638aac4828f9bb
-- 
2.33.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux