Commit 0521a262 authored by Petr Machata's avatar Petr Machata Committed by David S. Miller

selftests: devlink_lib: Fix bouncing of netdevsim DEVLINK_DEV

In the commit referenced below, a check was added to devlink_lib that
asserts the existence of a devlink device referenced by $DEVLINK_DEV.
Unfortunately, several netdevsim tests point DEVLINK_DEV at a device that
does not exist at the time that devlink_lib is sourced. Thus these tests
spuriously fail.

Fix this by introducing an override. By setting DEVLINK_DEV to an empty
string, the user declares their intention to handle DEVLINK_DEV management
on their own.

In all netdevsim tests that use devlink_lib and set DEVLINK_DEV, set
instead an empty DEVLINK_DEV just before sourcing devlink_lib, and set it
to the correct value right afterwards.

Fixes: 557c4d2f ("selftests: devlink_lib: add check for devlink device existence")
Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e67dfb8d
...@@ -24,13 +24,15 @@ ALL_TESTS=" ...@@ -24,13 +24,15 @@ ALL_TESTS="
NETDEVSIM_PATH=/sys/bus/netdevsim/ NETDEVSIM_PATH=/sys/bus/netdevsim/
DEV_ADDR=1337 DEV_ADDR=1337
DEV=netdevsim${DEV_ADDR} DEV=netdevsim${DEV_ADDR}
DEVLINK_DEV=netdevsim/${DEV}
DEBUGFS_DIR=/sys/kernel/debug/netdevsim/$DEV/ DEBUGFS_DIR=/sys/kernel/debug/netdevsim/$DEV/
SLEEP_TIME=1 SLEEP_TIME=1
NETDEV="" NETDEV=""
NUM_NETIFS=0 NUM_NETIFS=0
source $lib_dir/lib.sh source $lib_dir/lib.sh
DEVLINK_DEV=
source $lib_dir/devlink_lib.sh source $lib_dir/devlink_lib.sh
DEVLINK_DEV=netdevsim/${DEV}
require_command udevadm require_command udevadm
......
...@@ -33,13 +33,15 @@ ALL_TESTS=" ...@@ -33,13 +33,15 @@ ALL_TESTS="
NETDEVSIM_PATH=/sys/bus/netdevsim/ NETDEVSIM_PATH=/sys/bus/netdevsim/
DEV_ADDR=1337 DEV_ADDR=1337
DEV=netdevsim${DEV_ADDR} DEV=netdevsim${DEV_ADDR}
DEVLINK_DEV=netdevsim/${DEV}
SYSFS_NET_DIR=/sys/bus/netdevsim/devices/$DEV/net/ SYSFS_NET_DIR=/sys/bus/netdevsim/devices/$DEV/net/
NUM_NETIFS=0 NUM_NETIFS=0
source $lib_dir/lib.sh source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh
source $lib_dir/fib_offload_lib.sh source $lib_dir/fib_offload_lib.sh
DEVLINK_DEV=
source $lib_dir/devlink_lib.sh
DEVLINK_DEV=netdevsim/${DEV}
ipv4_identical_routes() ipv4_identical_routes()
{ {
fib_ipv4_identical_routes_test "testns1" fib_ipv4_identical_routes_test "testns1"
......
...@@ -44,12 +44,14 @@ ALL_TESTS=" ...@@ -44,12 +44,14 @@ ALL_TESTS="
NETDEVSIM_PATH=/sys/bus/netdevsim/ NETDEVSIM_PATH=/sys/bus/netdevsim/
DEV_ADDR=1337 DEV_ADDR=1337
DEV=netdevsim${DEV_ADDR} DEV=netdevsim${DEV_ADDR}
DEVLINK_DEV=netdevsim/${DEV}
SYSFS_NET_DIR=/sys/bus/netdevsim/devices/$DEV/net/ SYSFS_NET_DIR=/sys/bus/netdevsim/devices/$DEV/net/
DEBUGFS_NET_DIR=/sys/kernel/debug/netdevsim/$DEV/ DEBUGFS_NET_DIR=/sys/kernel/debug/netdevsim/$DEV/
NUM_NETIFS=0 NUM_NETIFS=0
source $lib_dir/lib.sh source $lib_dir/lib.sh
DEVLINK_DEV=
source $lib_dir/devlink_lib.sh source $lib_dir/devlink_lib.sh
DEVLINK_DEV=netdevsim/${DEV}
nexthop_check() nexthop_check()
{ {
......
...@@ -14,13 +14,15 @@ ALL_TESTS=" ...@@ -14,13 +14,15 @@ ALL_TESTS="
NETDEVSIM_PATH=/sys/bus/netdevsim/ NETDEVSIM_PATH=/sys/bus/netdevsim/
DEV_ADDR=1337 DEV_ADDR=1337
DEV=netdevsim${DEV_ADDR} DEV=netdevsim${DEV_ADDR}
DEVLINK_DEV=netdevsim/${DEV}
SYSFS_NET_DIR=/sys/bus/netdevsim/devices/$DEV/net/ SYSFS_NET_DIR=/sys/bus/netdevsim/devices/$DEV/net/
PSAMPLE_DIR=/sys/kernel/debug/netdevsim/$DEV/psample/ PSAMPLE_DIR=/sys/kernel/debug/netdevsim/$DEV/psample/
CAPTURE_FILE=$(mktemp) CAPTURE_FILE=$(mktemp)
NUM_NETIFS=0 NUM_NETIFS=0
source $lib_dir/lib.sh source $lib_dir/lib.sh
DEVLINK_DEV=
source $lib_dir/devlink_lib.sh source $lib_dir/devlink_lib.sh
DEVLINK_DEV=netdevsim/${DEV}
# Available at https://github.com/Mellanox/libpsample # Available at https://github.com/Mellanox/libpsample
require_command psample require_command psample
......
...@@ -18,7 +18,7 @@ if [[ ! -v DEVLINK_DEV ]]; then ...@@ -18,7 +18,7 @@ if [[ ! -v DEVLINK_DEV ]]; then
DEVLINK_VIDDID=$(lspci -s $(echo $DEVLINK_DEV | cut -d"/" -f2) \ DEVLINK_VIDDID=$(lspci -s $(echo $DEVLINK_DEV | cut -d"/" -f2) \
-n | cut -d" " -f3) -n | cut -d" " -f3)
else elif [[ ! -z "$DEVLINK_DEV" ]]; then
devlink dev show $DEVLINK_DEV &> /dev/null devlink dev show $DEVLINK_DEV &> /dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "SKIP: devlink device \"$DEVLINK_DEV\" not found" echo "SKIP: devlink device \"$DEVLINK_DEV\" not found"
......
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