Skip to content

Commit

Permalink
selftests: net: veth: make test compatible with dash
Browse files Browse the repository at this point in the history
veth.sh is a shell script that uses /bin/sh; some distro (Ubuntu for
example) use dash as /bin/sh and in this case the test reports the
following error:

 # ./veth.sh: 21: local: -r: bad variable name
 # ./veth.sh: 21: local: -r: bad variable name

This happens because dash doesn't support the option "-r" with local.

Moreover, in case of missing bpf object, the script is exiting -1, that
is an illegal number for dash:

 exit: Illegal number: -1

Change the script to be compatible both with bash and dash and prevent
the errors above.

Signed-off-by: Andrea Righi <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Andrea Righi authored and davem330 committed Jun 16, 2021
1 parent 1d2ac20 commit 0fd158b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tools/testing/selftests/net/veth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ ret=0

cleanup() {
local ns
local -r jobs="$(jobs -p)"
local jobs
readonly jobs="$(jobs -p)"
[ -n "${jobs}" ] && kill -1 ${jobs} 2>/dev/null
rm -f $STATS

Expand Down Expand Up @@ -108,7 +109,7 @@ chk_gro() {

if [ ! -f ../bpf/xdp_dummy.o ]; then
echo "Missing xdp_dummy helper. Build bpf selftest first"
exit -1
exit 1
fi

create_ns
Expand Down

0 comments on commit 0fd158b

Please sign in to comment.