Re: [PATCH net-next] selftests: forwarding: Import top-level lib.sh through $lib_dir

From
Petr Machata <petrm@nvidia.com>
Date
2023-12-12 17:46:11
Reply to
Hangbin Liu, 2023-12-11
Hangbin Liu [off-list ref] writes:
On Mon, Dec 11, 2023 at 01:01:06PM +0100, Petr Machata wrote:
quoted
@@ -38,7 +38,7 @@ if [[ -f $relative_path/forwarding.config ]]; then
 	source "$relative_path/forwarding.config"
 fi
 
-source ../lib.sh
+source ${lib_dir-.}/../lib.sh
 ##############################################################################
 # Sanity checks
Hi Petr,

Thanks for the report. However, this doesn't fix the soft link scenario. e.g.
The bonding tests tools/testing/selftests/drivers/net/bonding add a soft link
net_forwarding_lib.sh and source it directly in dev_addr_lists.sh.
I see, I didn't realize those exist.
quoted hunk ↗ jump to hunk
So how about something like:
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 8f6ca458af9a..7f90248e05d6 100755
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -38,7 +38,8 @@ if [[ -f $relative_path/forwarding.config ]]; then
        source "$relative_path/forwarding.config"
 fi

-source ../lib.sh
+forwarding_dir=$(dirname $(readlink -f $BASH_SOURCE))
+source ${forwarding_dir}/../lib.sh
Yep, that's gonna work.
I'll pass through our tests and send later this week.
Thread (15 messages) 15 messages, 5 authors, last reply 2023-12-22
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help