From: "Björn Töpel" <bjorn.topel@gmail.com>
To: ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org,
bpf@vger.kernel.org
Cc: "Björn Töpel" <bjorn.topel@intel.com>,
u9012063@gmail.com, rdunlap@infradead.org,
andrii.nakryiko@gmail.com
Subject: [PATCH bpf v3] selftests/bpf: convert test_xdp_redirect.sh to bash
Date: Tue, 9 Feb 2021 08:45:18 +0100 [thread overview]
Message-ID: <20210209074518.849999-1-bjorn.topel@gmail.com> (raw)
From: Björn Töpel <bjorn.topel@intel.com>
The test_xdp_redirect.sh script uses a bash feature, '&>'. On systems,
e.g. Debian, where '/bin/sh' is dash, this will not work as
expected. Use bash in the shebang to get the expected behavior.
Further, using 'set -e' means that the error of a command cannot be
captured without the command being executed with '&&' or '||'. Let us
use '||' to capture the return value of a failed command.
v3: Reintroduced /bin/bash, and kept 'set -e'. (Andrii)
v2: Kept /bin/sh and removed bashisms. (Randy)
Acked-by: William Tu <u9012063@gmail.com>
Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
---
tools/testing/selftests/bpf/test_xdp_redirect.sh | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/bpf/test_xdp_redirect.sh b/tools/testing/selftests/bpf/test_xdp_redirect.sh
index dd80f0c84afb..3f85a82f1c89 100755
--- a/tools/testing/selftests/bpf/test_xdp_redirect.sh
+++ b/tools/testing/selftests/bpf/test_xdp_redirect.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# Create 2 namespaces with two veth peers, and
# forward packets in-between using generic XDP
#
@@ -43,6 +43,8 @@ cleanup()
test_xdp_redirect()
{
local xdpmode=$1
+ local ret1=0
+ local ret2=0
setup
@@ -57,10 +59,8 @@ test_xdp_redirect()
ip link set dev veth1 $xdpmode obj test_xdp_redirect.o sec redirect_to_222 &> /dev/null
ip link set dev veth2 $xdpmode obj test_xdp_redirect.o sec redirect_to_111 &> /dev/null
- ip netns exec ns1 ping -c 1 10.1.1.22 &> /dev/null
- local ret1=$?
- ip netns exec ns2 ping -c 1 10.1.1.11 &> /dev/null
- local ret2=$?
+ ip netns exec ns1 ping -c 1 10.1.1.22 &> /dev/null || ret1=$?
+ ip netns exec ns2 ping -c 1 10.1.1.11 &> /dev/null || ret2=$?
if [ $ret1 -eq 0 -a $ret2 -eq 0 ]; then
echo "selftests: test_xdp_redirect $xdpmode [PASS]";
base-commit: 6183f4d3a0a2ad230511987c6c362ca43ec0055f
--
2.27.0
next reply other threads:[~2021-02-09 7:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-09 7:45 Björn Töpel [this message]
2021-02-10 20:13 ` [PATCH bpf v3] selftests/bpf: convert test_xdp_redirect.sh to bash Andrii Nakryiko
2021-02-11 8:06 ` Björn Töpel
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=20210209074518.849999-1-bjorn.topel@gmail.com \
--to=bjorn.topel@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@intel.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.kernel.org \
--cc=rdunlap@infradead.org \
--cc=u9012063@gmail.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 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).