aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIdo Schimmel <idosch@mellanox.com>2019-08-17 09:28:22 -0400
committerDavid S. Miller <davem@davemloft.net>2019-08-17 15:40:09 -0400
commitbc030d9c91c3764a143fc3ac4516bbfd330b41ed (patch)
treed2d83ecbccb4ded1235c246a9ddfac49483225c6
parent9e087457048884c57c51a32b52d8aa1d9b0d7385 (diff)
selftests: forwarding: devlink_lib: Allow tests to define devlink device
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>
-rw-r--r--tools/testing/selftests/net/forwarding/devlink_lib.sh26
1 files changed, 14 insertions, 12 deletions
diff --git a/tools/testing/selftests/net/forwarding/devlink_lib.sh b/tools/testing/selftests/net/forwarding/devlink_lib.sh
index 8553a67a2322..2b9296f6aa07 100644
--- a/tools/testing/selftests/net/forwarding/devlink_lib.sh
+++ b/tools/testing/selftests/net/forwarding/devlink_lib.sh
@@ -4,19 +4,21 @@
4############################################################################## 4##############################################################################
5# Defines 5# Defines
6 6
7DEVLINK_DEV=$(devlink port show "${NETIFS[p1]}" -j \ 7if [[ ! -v DEVLINK_DEV ]]; then
8 | jq -r '.port | keys[]' | cut -d/ -f-2) 8 DEVLINK_DEV=$(devlink port show "${NETIFS[p1]}" -j \
9if [ -z "$DEVLINK_DEV" ]; then 9 | jq -r '.port | keys[]' | cut -d/ -f-2)
10 echo "SKIP: ${NETIFS[p1]} has no devlink device registered for it" 10 if [ -z "$DEVLINK_DEV" ]; then
11 exit 1 11 echo "SKIP: ${NETIFS[p1]} has no devlink device registered for it"
12fi 12 exit 1
13if [[ "$(echo $DEVLINK_DEV | grep -c pci)" -eq 0 ]]; then 13 fi
14 echo "SKIP: devlink device's bus is not PCI" 14 if [[ "$(echo $DEVLINK_DEV | grep -c pci)" -eq 0 ]]; then
15 exit 1 15 echo "SKIP: devlink device's bus is not PCI"
16fi 16 exit 1
17 fi
17 18
18DEVLINK_VIDDID=$(lspci -s $(echo $DEVLINK_DEV | cut -d"/" -f2) \ 19 DEVLINK_VIDDID=$(lspci -s $(echo $DEVLINK_DEV | cut -d"/" -f2) \
19 -n | cut -d" " -f3) 20 -n | cut -d" " -f3)
21fi
20 22
21############################################################################## 23##############################################################################
22# Sanity checks 24# Sanity checks