Commit d4b6f87e authored by Po-Hsu Lin's avatar Po-Hsu Lin Committed by Daniel Borkmann

selftests/bpf: Use kselftest skip code for skipped tests

There are several test cases in the bpf directory are still using
exit 0 when they need to be skipped. Use kselftest framework skip
code instead so it can help us to distinguish the return status.

Criterion to filter out what should be fixed in bpf directory:
  grep -r "exit 0" -B1 | grep -i skip

This change might cause some false-positives if people are running
these test scripts directly and only checking their return codes,
which will change from 0 to 4. However I think the impact should be
small as most of our scripts here are already using this skip code.
And there will be no such issue if running them with the kselftest
framework.
Signed-off-by: default avatarPo-Hsu Lin <po-hsu.lin@canonical.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210929051250.13831-1-po-hsu.lin@canonical.com
parent e68ac008
#!/bin/sh #!/bin/sh
# Kselftest framework requirement - SKIP code is 4.
readonly KSFT_SKIP=4
cleanup() cleanup()
{ {
if [ "$?" = "0" ]; then if [ "$?" = "0" ]; then
...@@ -17,7 +20,7 @@ cleanup() ...@@ -17,7 +20,7 @@ cleanup()
ip link set dev lo xdp off 2>/dev/null > /dev/null ip link set dev lo xdp off 2>/dev/null > /dev/null
if [ $? -ne 0 ];then if [ $? -ne 0 ];then
echo "selftests: [SKIP] Could not run test without the ip xdp support" echo "selftests: [SKIP] Could not run test without the ip xdp support"
exit 0 exit $KSFT_SKIP
fi fi
set -e set -e
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# Author: Jesper Dangaard Brouer <hawk@kernel.org> # Author: Jesper Dangaard Brouer <hawk@kernel.org>
# Kselftest framework requirement - SKIP code is 4.
readonly KSFT_SKIP=4
# Allow wrapper scripts to name test # Allow wrapper scripts to name test
if [ -z "$TESTNAME" ]; then if [ -z "$TESTNAME" ]; then
TESTNAME=xdp_vlan TESTNAME=xdp_vlan
...@@ -94,7 +97,7 @@ while true; do ...@@ -94,7 +97,7 @@ while true; do
-h | --help ) -h | --help )
usage; usage;
echo "selftests: $TESTNAME [SKIP] usage help info requested" echo "selftests: $TESTNAME [SKIP] usage help info requested"
exit 0 exit $KSFT_SKIP
;; ;;
* ) * )
shift shift
...@@ -117,7 +120,7 @@ fi ...@@ -117,7 +120,7 @@ fi
ip link set dev lo xdpgeneric off 2>/dev/null > /dev/null ip link set dev lo xdpgeneric off 2>/dev/null > /dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "selftests: $TESTNAME [SKIP] need ip xdp support" echo "selftests: $TESTNAME [SKIP] need ip xdp support"
exit 0 exit $KSFT_SKIP
fi fi
# Interactive mode likely require us to cleanup netns # Interactive mode likely require us to cleanup netns
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment