Skip to content

Commit

Permalink
selftests: forwarding: devlink_lib: Allow tests to define devlink device
Browse files Browse the repository at this point in the history
For tests that create their network interfaces dynamically or do not use
interfaces at all (as with netdevsim) it is useful to define their own
devlink device instead of deriving it from the first network interface.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Ido Schimmel authored and David S. Miller committed Aug 17, 2019
1 parent 9e08745 commit bc030d9
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions tools/testing/selftests/net/forwarding/devlink_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@
##############################################################################
# Defines

DEVLINK_DEV=$(devlink port show "${NETIFS[p1]}" -j \
| jq -r '.port | keys[]' | cut -d/ -f-2)
if [ -z "$DEVLINK_DEV" ]; then
echo "SKIP: ${NETIFS[p1]} has no devlink device registered for it"
exit 1
fi
if [[ "$(echo $DEVLINK_DEV | grep -c pci)" -eq 0 ]]; then
echo "SKIP: devlink device's bus is not PCI"
exit 1
fi
if [[ ! -v DEVLINK_DEV ]]; then
DEVLINK_DEV=$(devlink port show "${NETIFS[p1]}" -j \
| jq -r '.port | keys[]' | cut -d/ -f-2)
if [ -z "$DEVLINK_DEV" ]; then
echo "SKIP: ${NETIFS[p1]} has no devlink device registered for it"
exit 1
fi
if [[ "$(echo $DEVLINK_DEV | grep -c pci)" -eq 0 ]]; then
echo "SKIP: devlink device's bus is not PCI"
exit 1
fi

DEVLINK_VIDDID=$(lspci -s $(echo $DEVLINK_DEV | cut -d"/" -f2) \
-n | cut -d" " -f3)
DEVLINK_VIDDID=$(lspci -s $(echo $DEVLINK_DEV | cut -d"/" -f2) \
-n | cut -d" " -f3)
fi

##############################################################################
# Sanity checks
Expand Down

0 comments on commit bc030d9

Please sign in to comment.