selftests: mlxsw: Add mlxsw lib
authorShalom Toledo <shalomt@mellanox.com>
Thu, 27 Feb 2020 07:50:17 +0000 (08:50 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 27 Feb 2020 19:10:15 +0000 (11:10 -0800)
Add mlxsw lib for common defines, helpers etc.

Signed-off-by: Shalom Toledo <shalomt@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/drivers/net/mlxsw/mlxsw_lib.sh [new file with mode: 0644]

diff --git a/tools/testing/selftests/drivers/net/mlxsw/mlxsw_lib.sh b/tools/testing/selftests/drivers/net/mlxsw/mlxsw_lib.sh
new file mode 100644 (file)
index 0000000..cbe50f2
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+
+##############################################################################
+# Defines
+
+if [[ ! -v MLXSW_CHIP ]]; then
+       MLXSW_CHIP=$(devlink -j dev info $DEVLINK_DEV | jq -r '.[][]["driver"]')
+       if [ -z "$MLXSW_CHIP" ]; then
+               echo "SKIP: Device $DEVLINK_DEV doesn't support devlink info command"
+               exit 1
+       fi
+fi