[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231222135836.992841-4-bpoirier@nvidia.com>
Date: Fri, 22 Dec 2023 08:58:29 -0500
From: Benjamin Poirier <bpoirier@...dia.com>
To: netdev@...r.kernel.org
Cc: Shuah Khan <shuah@...nel.org>,
Petr Machata <petrm@...dia.com>,
Hangbin Liu <liuhangbin@...il.com>,
Vladimir Oltean <vladimir.oltean@....com>
Subject: [RFC PATCH net-next 03/10] selftests: forwarding: Import top-level lib.sh through absolute path
From: Petr Machata <petrm@...dia.com>
The commit cited below moved code from net/forwarding/lib.sh to net/lib.sh,
and had the former source the latter. This causes issues with selftests
from directories other than net/forwarding/, in particular drivers/net/...
For those files, the line "source ../lib.sh" would look for lib.sh in the
directory above the script file's one, which is incorrect.
Instead, use $BASH_SOURCE and dirname to determine which directory the
forwarding/lib.sh resides in, and use that to find net/lib.sh.
Some selftests (namely drivers/net/bonding) use a symbolic link to
forwarding/lib.sh, and source that instead. Therefore pass $BASH_SOURCE
through readlink to resolve to the ultimate file.
Fixes: 25ae948b4478 ("selftests/net: add lib.sh")
Suggested-by: Hangbin Liu <liuhangbin@...il.com>
Signed-off-by: Petr Machata <petrm@...dia.com>
Signed-off-by: Benjamin Poirier <bpoirier@...dia.com>
---
tools/testing/selftests/net/forwarding/lib.sh | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index e3740163c384..f9e32152f23d 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -38,7 +38,9 @@ if [[ -f $relative_path/forwarding.config ]]; then
source "$relative_path/forwarding.config"
fi
-source ../lib.sh
+libdir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
+source "$libdir"/../lib.sh
+
##############################################################################
# Sanity checks
--
2.43.0
Powered by blists - more mailing lists