selftests: forwarding: Allow lib.sh sourcing from other directories
authorYuval Mintz <yuvalm@mellanox.com>
Sat, 30 Jun 2018 00:45:19 +0000 (02:45 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 30 Jun 2018 13:06:15 +0000 (22:06 +0900)
The devlink related scripts are mlxsw-specific. As a result, they'll
reside in a different directory - but would still need the common logic
implemented in lib.sh.
So as a preliminary step, allow lib.sh to be sourced from other
directories as well.

Signed-off-by: Yuval Mintz <yuvalm@mellanox.com>
Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/forwarding/lib.sh

index d1f14f83979e07e3e09c4ba57f26a5a602922405..59272824ef37d93231bd066b8148b03f18709d44 100644 (file)
@@ -14,8 +14,13 @@ PAUSE_ON_CLEANUP=${PAUSE_ON_CLEANUP:=no}
 NETIF_TYPE=${NETIF_TYPE:=veth}
 NETIF_CREATE=${NETIF_CREATE:=yes}
 
-if [[ -f forwarding.config ]]; then
-       source forwarding.config
+relative_path="${BASH_SOURCE%/*}"
+if [[ "$relative_path" == "${BASH_SOURCE}" ]]; then
+       relative_path="."
+fi
+
+if [[ -f $relative_path/forwarding.config ]]; then
+       source "$relative_path/forwarding.config"
 fi
 
 ##############################################################################