selftests: rtnetlink: skip ipsec offload tests if netdevsim isn't present
authorFlorian Westphal <fw@strlen.de>
Thu, 27 Jun 2019 15:12:42 +0000 (17:12 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 29 Jun 2019 19:18:52 +0000 (12:18 -0700)
running the script on systems without netdevsim now prints:

SKIP: ipsec_offload can't load netdevsim

instead of error message & failed status.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/rtnetlink.sh

index 50562888478310348542c869bdb5f9cff7ebced3..bdbf4b3125b6ae791e38f0b1e3c9e1cd802c90fd 100755 (executable)
@@ -738,13 +738,17 @@ kci_test_ipsec_offload()
        sysfsd=/sys/kernel/debug/netdevsim/netdevsim0/ports/0/
        sysfsf=$sysfsd/ipsec
        sysfsnet=/sys/bus/netdevsim/devices/netdevsim0/net/
+       probed=false
 
        # setup netdevsim since dummydev doesn't have offload support
-       modprobe netdevsim
-       check_err $?
-       if [ $ret -ne 0 ]; then
-               echo "FAIL: ipsec_offload can't load netdevsim"
-               return 1
+       if [ ! -w /sys/bus/netdevsim/new_device ] ; then
+               modprobe -q netdevsim
+               check_err $?
+               if [ $ret -ne 0 ]; then
+                       echo "SKIP: ipsec_offload can't load netdevsim"
+                       return $ksft_skip
+               fi
+               probed=true
        fi
 
        echo "0" > /sys/bus/netdevsim/new_device
@@ -824,7 +828,7 @@ EOF
        fi
 
        # clean up any leftovers
-       rmmod netdevsim
+       $probed && rmmod netdevsim
 
        if [ $ret -ne 0 ]; then
                echo "FAIL: ipsec_offload"