* [PATCH nft] tests: run-tests.sh: ensure non-zero exit when $failed != 0
@ 2021-10-20 12:44 Štěpán Němec
2021-10-20 15:06 ` Phil Sutter
0 siblings, 1 reply; 6+ messages in thread
From: Štěpán Němec @ 2021-10-20 12:44 UTC (permalink / raw)
To: netfilter-devel, Pablo Neira Ayuso
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>
---
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
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH nft] tests: run-tests.sh: ensure non-zero exit when $failed != 0 2021-10-20 12:44 [PATCH nft] tests: run-tests.sh: ensure non-zero exit when $failed != 0 Štěpán Němec @ 2021-10-20 15:06 ` Phil Sutter 2021-10-27 9:09 ` Pablo Neira Ayuso 0 siblings, 1 reply; 6+ messages in thread From: Phil Sutter @ 2021-10-20 15:06 UTC (permalink / raw) To: Štěpán Němec; +Cc: netfilter-devel, Pablo Neira Ayuso Hi, On Wed, Oct 20, 2021 at 02:44:09PM +0200, Štěpán Němec wrote: > 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. Standards aside, failed=256 is an actual bug: | % bash -c "exit 255"; echo $? | 255 | % bash -c "exit 256"; echo $? | 0 | % bash -c "exit 257"; echo $? | 1 Thanks, Phil ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH nft] tests: run-tests.sh: ensure non-zero exit when $failed != 0 2021-10-20 15:06 ` Phil Sutter @ 2021-10-27 9:09 ` Pablo Neira Ayuso 2021-11-02 20:31 ` Phil Sutter 0 siblings, 1 reply; 6+ messages in thread From: Pablo Neira Ayuso @ 2021-10-27 9:09 UTC (permalink / raw) To: Phil Sutter, Štěpán Němec, netfilter-devel Hi Phil, On Wed, Oct 20, 2021 at 05:06:41PM +0200, Phil Sutter wrote: > Hi, > > On Wed, Oct 20, 2021 at 02:44:09PM +0200, Štěpán Němec wrote: > > 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. > > Standards aside, failed=256 is an actual bug: > > | % bash -c "exit 255"; echo $? > | 255 > | % bash -c "exit 256"; echo $? > | 0 > | % bash -c "exit 257"; echo $? > | 1 This is extra information you provided here for the commit message for completion? Thanks. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH nft] tests: run-tests.sh: ensure non-zero exit when $failed != 0 2021-10-27 9:09 ` Pablo Neira Ayuso @ 2021-11-02 20:31 ` Phil Sutter 2021-11-02 20:44 ` Pablo Neira Ayuso 0 siblings, 1 reply; 6+ messages in thread From: Phil Sutter @ 2021-11-02 20:31 UTC (permalink / raw) To: Pablo Neira Ayuso; +Cc: Štěpán Němec, netfilter-devel Hi Pablo, On Wed, Oct 27, 2021 at 11:09:23AM +0200, Pablo Neira Ayuso wrote: > On Wed, Oct 20, 2021 at 05:06:41PM +0200, Phil Sutter wrote: > > On Wed, Oct 20, 2021 at 02:44:09PM +0200, Štěpán Němec wrote: > > > 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. > > > > Standards aside, failed=256 is an actual bug: > > > > | % bash -c "exit 255"; echo $? > > | 255 > > | % bash -c "exit 256"; echo $? > > | 0 > > | % bash -c "exit 257"; echo $? > > | 1 > > This is extra information you provided here for the commit message for > completion? No need to extend the commit message IMO. I was just curious and played a bit with exit values in bash. So although unlikely, the unpatched code indeed confuses a result of 256 errors for a pass. :) Cheers, Phil ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH nft] tests: run-tests.sh: ensure non-zero exit when $failed != 0 2021-11-02 20:31 ` Phil Sutter @ 2021-11-02 20:44 ` Pablo Neira Ayuso 2021-11-02 21:01 ` Phil Sutter 0 siblings, 1 reply; 6+ messages in thread From: Pablo Neira Ayuso @ 2021-11-02 20:44 UTC (permalink / raw) To: Phil Sutter, Štěpán Němec, netfilter-devel On Tue, Nov 02, 2021 at 09:31:15PM +0100, Phil Sutter wrote: > Hi Pablo, > > On Wed, Oct 27, 2021 at 11:09:23AM +0200, Pablo Neira Ayuso wrote: > > On Wed, Oct 20, 2021 at 05:06:41PM +0200, Phil Sutter wrote: > > > On Wed, Oct 20, 2021 at 02:44:09PM +0200, Štěpán Němec wrote: > > > > 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. > > > > > > Standards aside, failed=256 is an actual bug: > > > > > > | % bash -c "exit 255"; echo $? > > > | 255 > > > | % bash -c "exit 256"; echo $? > > > | 0 > > > | % bash -c "exit 257"; echo $? > > > | 1 > > > > This is extra information you provided here for the commit message for > > completion? > > No need to extend the commit message IMO. I was just curious and played > a bit with exit values in bash. So although unlikely, the unpatched code > indeed confuses a result of 256 errors for a pass. :) OK, then please go push out this patch if you're fine with it. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH nft] tests: run-tests.sh: ensure non-zero exit when $failed != 0 2021-11-02 20:44 ` Pablo Neira Ayuso @ 2021-11-02 21:01 ` Phil Sutter 0 siblings, 0 replies; 6+ messages in thread From: Phil Sutter @ 2021-11-02 21:01 UTC (permalink / raw) To: Pablo Neira Ayuso; +Cc: Štěpán Němec, netfilter-devel On Tue, Nov 02, 2021 at 09:44:47PM +0100, Pablo Neira Ayuso wrote: > On Tue, Nov 02, 2021 at 09:31:15PM +0100, Phil Sutter wrote: > > Hi Pablo, > > > > On Wed, Oct 27, 2021 at 11:09:23AM +0200, Pablo Neira Ayuso wrote: > > > On Wed, Oct 20, 2021 at 05:06:41PM +0200, Phil Sutter wrote: > > > > On Wed, Oct 20, 2021 at 02:44:09PM +0200, Štěpán Němec wrote: > > > > > 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. > > > > > > > > Standards aside, failed=256 is an actual bug: > > > > > > > > | % bash -c "exit 255"; echo $? > > > > | 255 > > > > | % bash -c "exit 256"; echo $? > > > > | 0 > > > > | % bash -c "exit 257"; echo $? > > > > | 1 > > > > > > This is extra information you provided here for the commit message for > > > completion? > > > > No need to extend the commit message IMO. I was just curious and played > > a bit with exit values in bash. So although unlikely, the unpatched code > > indeed confuses a result of 256 errors for a pass. :) > > OK, then please go push out this patch if you're fine with it. DONE. Sorry for the confusion. Cheers, Phil ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-11-02 21:01 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-10-20 12:44 [PATCH nft] tests: run-tests.sh: ensure non-zero exit when $failed != 0 Štěpán Němec 2021-10-20 15:06 ` Phil Sutter 2021-10-27 9:09 ` Pablo Neira Ayuso 2021-11-02 20:31 ` Phil Sutter 2021-11-02 20:44 ` Pablo Neira Ayuso 2021-11-02 21:01 ` Phil Sutter
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).