selftests: net: forwarding: replace bash brace expansion with seq
Subsystems (4)
PATCH 1/1 selftests: net: forwarding: replace bash brace expansion with seq
{1..16384} is bash-specific brace expansion and will not work with POSIX shells like dash or busybox ash. This breaks the flowlabel test when /bin/sh is not bash.
Use $(seq 1 16384) for portable iteration. Fix the same issue in custom_multipath_hash.sh, gre_custom_multipath_hash.sh and ip6gre_custom_multipath_hash.sh.
--- .../selftests/net/forwarding/custom_multipath_hash.sh | 8 ++++---- .../selftests/net/forwarding/gre_custom_multipath_hash.sh | 8 ++++---- .../net/forwarding/ip6gre_custom_multipath_hash.sh | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-)
tools/testing/selftests/net/forwarding/custom_multipath_hash.sh +4 -4
@@ -224,10 +224,10 @@ send_dst_ipv6() send_flowlabel() { # Generate 16384 echo requests, each with a random flow label. - ip vrf exec v$h1 sh -c \ - "for _ in {1..16384}; do \ - $PING6 -F 0 -c 1 -q 2001:db8:4::2 >/dev/null 2>&1; \ - done" + ip vrf exec v$h1 sh -c ' + for _ in $(seq 1 16384); do + '"$PING6"' -F 0 -c 1 -q 2001:db8:4::2 >/dev/null 2>&1 + done' } send_src_udp6()
tools/testing/selftests/net/forwarding/gre_custom_multipath_hash.sh +4 -4
@@ -319,10 +319,10 @@ send_dst_ipv6() send_flowlabel() { # Generate 16384 echo requests, each with a random flow label. - ip vrf exec v$h1 sh -c \ - "for _ in {1..16384}; do \ - $PING6 -F 0 -c 1 -q 2001:db8:2::2 >/dev/null 2>&1; \ - done" + ip vrf exec v$h1 sh -c ' + for _ in $(seq 1 16384); do + '"$PING6"' -F 0 -c 1 -q 2001:db8:2::2 >/dev/null 2>&1 + done' } send_src_udp6()
tools/testing/selftests/net/forwarding/ip6gre_custom_multipath_hash.sh +4 -4
@@ -321,10 +321,10 @@ send_dst_ipv6() send_flowlabel() { # Generate 16384 echo requests, each with a random flow label. - ip vrf exec v$h1 sh -c \ - "for _ in {1..16384}; do \ - $PING6 -F 0 -c 1 -q 2001:db8:2::2 >/dev/null 2>&1; \ - done" + ip vrf exec v$h1 sh -c ' + for _ in $(seq 1 16384); do + '"$PING6"' -F 0 -c 1 -q 2001:db8:2::2 >/dev/null 2>&1 + done' } send_src_udp6()
Signature · 1 line
2.53.0
Quoted 8 lines · Jin Li
{1..16384} is bash-specific brace expansion and will not work with POSIX shells like dash or busybox ash. This breaks the flowlabel test when
/bin/shis not bash.Use $(seq 1 16384) for portable iteration. Fix the same issue in
custom_multipath_hash.sh,gre_custom_multipath_hash.shandip6gre_custom_multipath_hash.sh.
As Sashiko suggested, I think it makes sense to add
Quoted 66 lines
Signed-off-by Jin Li <[email protected]>--- .../selftests/net/forwarding/custom_multipath_hash.sh | 8 ++++---- .../selftests/net/forwarding/gre_custom_multipath_hash.sh | 8 ++++---- .../net/forwarding/ip6gre_custom_multipath_hash.sh | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-)tools/testing/selftests/net/forwarding/custom_multipath_hash.sh +4
-4@@ -224,10 +224,10 @@ send_dst_ipv6() send_flowlabel() { # Generate 16384 echo requests, each with a random flow label. - ip vrf exec v$h1 sh -c \ - "for _ in {1..16384}; do \ - $PING6 -F 0 -c 1 -q 2001:db8:4::2 >/dev/null 2>&1; \ - done" + ip vrf exec v$h1 sh -c ' + for _ in $(seq 1 16384); do + '"$PING6"' -F 0 -c 1 -q 2001:db8:4::2 >/dev/null 2>&1 + done' } send_src_udp6()tools/testing/selftests/net/forwarding/gre_custom_multipath_hash.sh +4
-4@@ -319,10 +319,10 @@ send_dst_ipv6() send_flowlabel() { # Generate 16384 echo requests, each with a random flow label. - ip vrf exec v$h1 sh -c \ - "for _ in {1..16384}; do \ - $PING6 -F 0 -c 1 -q 2001:db8:2::2 >/dev/null 2>&1; \ - done" + ip vrf exec v$h1 sh -c ' + for _ in $(seq 1 16384); do + '"$PING6"' -F 0 -c 1 -q 2001:db8:2::2 >/dev/null 2>&1 + done' } send_src_udp6()tools/testing/selftests/net/forwarding/ip6gre_custom_multipath_hash.sh +4
-4@@ -321,10 +321,10 @@ send_dst_ipv6() send_flowlabel() { # Generate 16384 echo requests, each with a random flow label. - ip vrf exec v$h1 sh -c \ - "for _ in {1..16384}; do \ - $PING6 -F 0 -c 1 -q 2001:db8:2::2 >/dev/null 2>&1; \ - done" + ip vrf exec v$h1 sh -c ' + for _ in $(seq 1 16384); do + '"$PING6"' -F 0 -c 1 -q 2001:db8:2::2 >/dev/null 2>&1 + done' } send_src_udp6()Signature · 1 line
2.53.0