From: Petr Machata Date: Thu, 28 Mar 2019 12:12:23 +0000 (+0000) Subject: selftests: forwarding: devlink_lib: Simplify deduction of DEVLINK_DEV X-Git-Tag: v5.15~6431^2~284^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e46aee69722054e85ae4b6029d0aed678016950;p=platform%2Fkernel%2Flinux-starfive.git 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 Signed-off-by: Ido Schimmel Signed-off-by: David S. Miller --- diff --git a/tools/testing/selftests/net/forwarding/devlink_lib.sh b/tools/testing/selftests/net/forwarding/devlink_lib.sh index 981b897..61d3579 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