Skip to content

Commit 557c4d2

Browse files
Jiri Pirkokuba-moo
authored andcommitted
selftests: devlink_lib: add check for devlink device existence
If user passes devlink handle over DEVLINK_DEV variable, check if the device exists. Signed-off-by: Jiri Pirko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b14b27f commit 557c4d2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/testing/selftests/net/forwarding/devlink_lib.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ if [[ ! -v DEVLINK_DEV ]]; then
1818

1919
DEVLINK_VIDDID=$(lspci -s $(echo $DEVLINK_DEV | cut -d"/" -f2) \
2020
-n | cut -d" " -f3)
21+
else
22+
devlink dev show $DEVLINK_DEV &> /dev/null
23+
if [ $? -ne 0 ]; then
24+
echo "SKIP: devlink device \"$DEVLINK_DEV\" not found"
25+
exit 1
26+
fi
2127
fi
2228

2329
##############################################################################

0 commit comments

Comments
 (0)