Commit 9f2af915 authored by Benjamin Poirier's avatar Benjamin Poirier Committed by David S. Miller

selftests: forwarding: Redefine relative_path variable

The following code which is part of lib.sh:
relative_path="${BASH_SOURCE%/*}"
if [[ "$relative_path" == "${BASH_SOURCE}" ]]; then
       relative_path="."
fi

reimplements functionality that is part of `dirname`:
$ dirname ""
.

To avoid this duplication, replace "relative_path" by "net_forwarding_dir",
a new variable defined using dirname.

Furthermore, to avoid the potential confusion about what "relative_path" is
about (cwd, test script directory or test library directory), define
"net_forwarding_dir" as the absolute path to net/forwarding/.
Tested-by: default avatarPetr Machata <petrm@nvidia.com>
Reviewed-by: default avatarHangbin Liu <liuhangbin@gmail.com>
Signed-off-by: default avatarBenjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4a24560a
...@@ -29,13 +29,10 @@ STABLE_MAC_ADDRS=${STABLE_MAC_ADDRS:=no} ...@@ -29,13 +29,10 @@ STABLE_MAC_ADDRS=${STABLE_MAC_ADDRS:=no}
TCPDUMP_EXTRA_FLAGS=${TCPDUMP_EXTRA_FLAGS:=} TCPDUMP_EXTRA_FLAGS=${TCPDUMP_EXTRA_FLAGS:=}
TROUTE6=${TROUTE6:=traceroute6} TROUTE6=${TROUTE6:=traceroute6}
relative_path="${BASH_SOURCE%/*}" net_forwarding_dir=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")
if [[ "$relative_path" == "${BASH_SOURCE}" ]]; then
relative_path="."
fi
if [[ -f $relative_path/forwarding.config ]]; then if [[ -f $net_forwarding_dir/forwarding.config ]]; then
source "$relative_path/forwarding.config" source "$net_forwarding_dir/forwarding.config"
fi fi
# Kselftest framework requirement - SKIP code is 4. # Kselftest framework requirement - SKIP code is 4.
......
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
source "$relative_path/mirror_lib.sh" source "$net_forwarding_dir/mirror_lib.sh"
quick_test_span_gre_dir_ips() quick_test_span_gre_dir_ips()
{ {
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
# | | # | |
# +-------------------------------------------------------------------------+ # +-------------------------------------------------------------------------+
source "$relative_path/mirror_topo_lib.sh" source "$net_forwarding_dir/mirror_topo_lib.sh"
mirror_gre_topo_h3_create() mirror_gre_topo_h3_create()
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment