All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf v4] selftests/bpf: convert test_xdp_redirect.sh to bash
@ 2021-02-11  8:20 Björn Töpel
  2021-02-11 15:30 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Björn Töpel @ 2021-02-11  8:20 UTC (permalink / raw)
  To: ast, daniel, netdev, bpf
  Cc: Björn Töpel, u9012063, rdunlap, andrii.nakryiko,
	Andrii Nakryiko

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
restructure the ping-commands, and use them as an if-expression, so
that we can capture the return value.

v4: Added missing Fixes:, and removed local variables. (Andrii)
v3: Reintroduced /bin/bash, and kept 'set -e'. (Andrii)
v2: Kept /bin/sh and removed bashisms. (Randy)

Acked-by: Andrii Nakryiko <andrii@kernel.org>
Fixes: 996139e801fd ("selftests: bpf: add a test for XDP redirect")
Signed-off-by: Björn Töpel <bjorn.topel@intel.com>
---
 tools/testing/selftests/bpf/test_xdp_redirect.sh | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/bpf/test_xdp_redirect.sh b/tools/testing/selftests/bpf/test_xdp_redirect.sh
index dd80f0c84afb..c033850886f4 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
 #
@@ -57,12 +57,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=$?
-
-	if [ $ret1 -eq 0 -a $ret2 -eq 0 ]; then
+	if ip netns exec ns1 ping -c 1 10.1.1.22 &> /dev/null &&
+	   ip netns exec ns2 ping -c 1 10.1.1.11 &> /dev/null; then
 		echo "selftests: test_xdp_redirect $xdpmode [PASS]";
 	else
 		ret=1

base-commit: 291009f656e8eaebbdfd3a8d99f6b190a9ce9deb
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf v4] selftests/bpf: convert test_xdp_redirect.sh to bash
  2021-02-11  8:20 [PATCH bpf v4] selftests/bpf: convert test_xdp_redirect.sh to bash Björn Töpel
@ 2021-02-11 15:30 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-02-11 15:30 UTC (permalink / raw)
  To: =?utf-8?b?QmrDtnJuIFTDtnBlbCA8Ympvcm4udG9wZWxAZ21haWwuY29tPg==?=
  Cc: ast, daniel, netdev, bpf, bjorn.topel, u9012063, rdunlap,
	andrii.nakryiko, andrii

Hello:

This patch was applied to bpf/bpf.git (refs/heads/master):

On Thu, 11 Feb 2021 09:20:29 +0100 you wrote:
> 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
> restructure the ping-commands, and use them as an if-expression, so
> that we can capture the return value.
> 
> [...]

Here is the summary with links:
  - [bpf,v4] selftests/bpf: convert test_xdp_redirect.sh to bash
    https://git.kernel.org/bpf/bpf/c/732fa3233066

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-11 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-11  8:20 [PATCH bpf v4] selftests/bpf: convert test_xdp_redirect.sh to bash Björn Töpel
2021-02-11 15:30 ` patchwork-bot+netdevbpf

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.