From: Stefano Brivio <sbrivio@redhat.com>
To: David Ahern <dsahern@gmail.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Sabrina Dubroca <sd@queasysnail.net>,
Steffen Klassert <steffen.klassert@secunet.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH net-next 3/9] selftests: pmtu: Introduce support for multiple tests
Date: Fri, 16 Mar 2018 20:29:20 +0100 [thread overview]
Message-ID: <20180316202920.3dc280be@epycfail> (raw)
In-Reply-To: <b12fdfeb-87b8-ef88-11c3-7a13a352fd00@gmail.com>
On Fri, 16 Mar 2018 11:06:07 -0700
David Ahern <dsahern@gmail.com> wrote:
> On 3/15/18 9:18 AM, Stefano Brivio wrote:
> > trap cleanup EXIT
> >
> > -test_pmtu_vti6_exception
> > +exitcode=0
> > +for name in ${tests}; do
> > + echo "${name}: START"
> > + eval test_${name}
> > + ret=$?
> > + cleanup
> > +
> > + if [ $ret -eq 0 ]; then echo "${name}: FAIL"; exitcode=1
>
> ret = 0 == failure is counterintuitive for Linux.
However, in POSIX shell's AND and OR lists with function calls, a
function returning zero behaves in a similar fashion to a C function
evaluating to true, and a function returning non-zero behaves like a C
function evaluating to false [1]:
a() {
return 0
}
b() {
return 1
}
a && echo this gets printed
b && echo and this does not
This might be equally counter-intuitive for somebody. If one does a lot
of explicit error checking with early returns, my return convention is
also rather practical. E.g. in the setup() function I can do:
eval setup_${arg} && echo " ${arg} not supported" && return 0
instead of:
eval setup_${arg} || { echo " ${arg} not supported" && return 0; }
Still, I went ahead and reversed return codes in the whole script, and
it doesn't look *too* bad with the setup() function from patch 3/9. It
would have been quite ugly earlier.
So I don't have a strong preference. If you still prefer that I reverse
my return codes, I will re-spin the series (and probably I'll need a
first patch that reverses the existing logic, too).
> > + elif [ $ret -eq 1 ]; then echo "${name}: PASS"
> > + elif [ $ret -eq 2 ]; then echo "${name}: SKIP"
>
> I use printf in other scripts so that the pass/fail verdict lineup. e.g.,
> printf " %-60s [PASS]\n" "${name}"
I avoided 'printf' so far because it's not a built-in utility on some
shells (e.g. csh), being a "recent" addition to the POSIX Base
Specifications (issue 4, while 'echo' is from issue 2), and it might be
unavailable on some (embedded?) systems.
I don't have a strong preference about this either. It's a very minor
portability concern vs. a very minor readability improvement, what do
you think?
[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_03_06
--
Stefano
next prev parent reply other threads:[~2018-03-16 19:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-15 16:18 [PATCH net-next 0/9] selftests: pmtu: Add further vti/vti6 MTU and PMTU tests Stefano Brivio
2018-03-15 16:18 ` [PATCH net-next 1/9] selftests: pmtu: Use namespace command prefix to fetch route mtu Stefano Brivio
2018-03-15 16:18 ` [PATCH net-next 2/9] selftests: pmtu: Factor out MTU parsing helper Stefano Brivio
2018-03-15 16:18 ` [PATCH net-next 3/9] selftests: pmtu: Introduce support for multiple tests Stefano Brivio
2018-03-16 18:06 ` David Ahern
2018-03-16 19:29 ` Stefano Brivio [this message]
2018-03-16 19:53 ` David Ahern
2018-03-16 20:03 ` Stefano Brivio
2018-03-15 16:18 ` [PATCH net-next 4/9] selftests: pmtu: Add pmtu_vti4_default_mtu test Stefano Brivio
2018-03-15 16:18 ` [PATCH net-next 5/9] selftests: pmtu: Add pmtu_vti6_default_mtu test Stefano Brivio
2018-03-15 16:18 ` [PATCH net-next 6/9] selftests: pmtu: Add pmtu_vti4_exception test Stefano Brivio
2018-03-15 16:18 ` [PATCH net-next 7/9] selftests: pmtu: Add pmtu_vti4_link_add_mtu test Stefano Brivio
2018-03-15 16:18 ` [PATCH net-next 8/9] selftests: pmtu: Add pmtu_vti6_link_add_mtu test Stefano Brivio
2018-03-15 16:18 ` [PATCH net-next 9/9] selftests: pmtu: Add pmtu_vti6_link_change_mtu test Stefano Brivio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180316202920.3dc280be@epycfail \
--to=sbrivio@redhat.com \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=sd@queasysnail.net \
--cc=steffen.klassert@secunet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.