aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing
diff options
context:
space:
mode:
authorPetr Machata <petrm@mellanox.com>2019-03-28 12:12:23 +0000
committerDavid S. Miller <davem@davemloft.net>2019-03-28 17:20:52 -0700
commit8e46aee69722054e85ae4b6029d0aed678016950 (patch)
treea4b2f99291df0be14f2590abc807f10a9f375936 /tools/testing
parentselftests: forwarding: devlink_lib: Avoid double sourcing of lib.sh (diff)
downloadlinux-dev-8e46aee69722054e85ae4b6029d0aed678016950.tar.xz
linux-dev-8e46aee69722054e85ae4b6029d0aed678016950.zip
selftests: forwarding: devlink_lib: Simplify deduction of DEVLINK_DEV
Use devlink -j and jq for more accurate querying. Use cut -f-2 instead of rev-cut-rev combo. Signed-off-by: Petr Machata <petrm@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing')
-rw-r--r--tools/testing/selftests/net/forwarding/devlink_lib.sh5
1 files changed, 2 insertions, 3 deletions
diff --git a/tools/testing/selftests/net/forwarding/devlink_lib.sh b/tools/testing/selftests/net/forwarding/devlink_lib.sh
index 981b897d418d..61d3579a62af 100644
--- a/tools/testing/selftests/net/forwarding/devlink_lib.sh
+++ b/tools/testing/selftests/net/forwarding/devlink_lib.sh
@@ -4,9 +4,8 @@
##############################################################################
# Defines
-DEVLINK_DEV=$(devlink port show | grep "${NETIFS[p1]}" | \
- grep -v "${NETIFS[p1]}[0-9]" | cut -d" " -f1 | \
- rev | cut -d"/" -f2- | rev)
+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