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

From: Benjamin Poirier <[email-masked]>
Date: Fri, 15 Dec 2023 18:30:58 -0500

On 2023-12-15 10:35 +0800, Hangbin Liu wrote:
> On Thu, Dec 14, 2023 at 05:00:31PM -0500, Benjamin Poirier wrote:
> > I started to make the adjustments to all the tests but I got stuck on
> > the dsa tests. The problem is that the tests which are symlinked (like
> > bridge_locked_port.sh) expect to source lib.sh (net/forwarding/lib.sh)
> > from the same directory. That lib.sh then expects to source net/lib.sh
> > from the parent directory. Because `rsync --copy-unsafe-links` is used,
> > all those links become regular files after export so we can't rely on
> > `readlink -f`.
> > 
> > Honestly, given how the dsa tests are organized, I don't see a clean way
> > to support these tests without error after commit 25ae948b4478
> > ("selftests/net: add lib.sh").
> 
> No worry, the last way is just make net/forwarding/lib.sh not source net/lib.sh :)
> Although this would make us copy a lot functions from net/forwarding/lib.sh to
> source net/lib.sh. So before that, let's try if we can
> 
> Move all the dsa tests back to net/forwarding (actually only needed for
> test_bridge_fdb_stress.sh). And add a forwarding.config.dsa.sample. Maybe
> a test list for dsa testing. But with this way the dsa testing will not
> able to run via run_kselftest.sh.
> 
> Or, we can remove the symlinks, and add the dsa tests with exec the relative
> forwarding path's tests directly. e.g.
> 
> ### in das test folder
> 
> $ cat bridge_mld.sh
> #!/bin/bash
> ../../../net/forwarding/bridge_mld.sh
> 
> $ cat Makefile
> # SPDX-License-Identifier: GPL-2.0+ OR MIT
> 
> TEST_PROGS = \
>         bridge_mld.sh
> 
> TEST_SH_LIBS := \
>         net/lib.sh \
>         net/forwarding/lib.sh \
>         net/forwarding/bridge_mld.sh
> 
> TEST_FILES := forwarding.config
> 
> include ../../../lib.mk
> 
> ### for net/forwarding/lib.sh looks we need source the ${PWD}/forwarding.config if run via run_kselftest.sh
> 
> if [[ -f ${PWD}/forwarding.config ]]; then
>         source "$PWD/forwarding.config"
> elif [[ -f $relative_path/forwarding.config ]]; then
>         source "$relative_path/forwarding.config"
> fi
> 
> What do you think?

That's a good idea. Thank you for your suggestion. I made a few
adjustment from what you show and the result seems to work so far.

I'm working on the full patchset. If there is no problem, I'll post it
next week.