Message ID | 20240124170222.261664-3-bpoirier@nvidia.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 6500780cffa7f221431fa4a2ec1c2f6bc51dcb6b |
Headers | show |
Series | selftests: Add TEST_INCLUDES directive and adjust tests to use it | expand |
Benjamin Poirier <bpoirier@nvidia.com> wrote: >In order to avoid duplicated files when both the bonding and forwarding >tests are exported together, add net/forwarding/lib.sh to TEST_INCLUDES and >include it via its relative path. > >Reviewed-by: Petr Machata <petrm@nvidia.com> >Tested-by: Petr Machata <petrm@nvidia.com> >Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com> >--- > tools/testing/selftests/drivers/net/bonding/Makefile | 6 ++++-- > .../selftests/drivers/net/bonding/bond-eth-type-change.sh | 2 +- > .../testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh | 2 +- > .../testing/selftests/drivers/net/bonding/dev_addr_lists.sh | 2 +- > .../drivers/net/bonding/mode-1-recovery-updelay.sh | 2 +- > .../drivers/net/bonding/mode-2-recovery-updelay.sh | 2 +- > .../selftests/drivers/net/bonding/net_forwarding_lib.sh | 1 - > 7 files changed, 9 insertions(+), 8 deletions(-) > delete mode 120000 tools/testing/selftests/drivers/net/bonding/net_forwarding_lib.sh > >diff --git a/tools/testing/selftests/drivers/net/bonding/Makefile b/tools/testing/selftests/drivers/net/bonding/Makefile >index 8a72bb7de70f..1e10a1f06faf 100644 >--- a/tools/testing/selftests/drivers/net/bonding/Makefile >+++ b/tools/testing/selftests/drivers/net/bonding/Makefile >@@ -15,7 +15,9 @@ TEST_PROGS := \ > TEST_FILES := \ > lag_lib.sh \ > bond_topo_2d1c.sh \ >- bond_topo_3d1c.sh \ >- net_forwarding_lib.sh >+ bond_topo_3d1c.sh >+ >+TEST_INCLUDES := \ >+ ../../../net/forwarding/lib.sh > > include ../../../lib.mk >diff --git a/tools/testing/selftests/drivers/net/bonding/bond-eth-type-change.sh b/tools/testing/selftests/drivers/net/bonding/bond-eth-type-change.sh >index 862e947e17c7..8293dbc7c18f 100755 >--- a/tools/testing/selftests/drivers/net/bonding/bond-eth-type-change.sh >+++ b/tools/testing/selftests/drivers/net/bonding/bond-eth-type-change.sh >@@ -11,7 +11,7 @@ ALL_TESTS=" > REQUIRE_MZ=no > NUM_NETIFS=0 > lib_dir=$(dirname "$0") >-source "$lib_dir"/net_forwarding_lib.sh >+source "$lib_dir"/../../../net/forwarding/lib.sh > > bond_check_flags() > { >diff --git a/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh b/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh >index a509ef949dcf..0eb7edfb584c 100644 >--- a/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh >+++ b/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh >@@ -28,7 +28,7 @@ > REQUIRE_MZ=no > NUM_NETIFS=0 > lib_dir=$(dirname "$0") >-source ${lib_dir}/net_forwarding_lib.sh >+source "$lib_dir"/../../../net/forwarding/lib.sh Is there a way to pass TEST_INCLUDES via the environment or as a parameter, so that it's not necessary to hard code the path name here and in the similar cases below? -J > s_ns="s-$(mktemp -u XXXXXX)" > c_ns="c-$(mktemp -u XXXXXX)" >diff --git a/tools/testing/selftests/drivers/net/bonding/dev_addr_lists.sh b/tools/testing/selftests/drivers/net/bonding/dev_addr_lists.sh >index 5cfe7d8ebc25..e6fa24eded5b 100755 >--- a/tools/testing/selftests/drivers/net/bonding/dev_addr_lists.sh >+++ b/tools/testing/selftests/drivers/net/bonding/dev_addr_lists.sh >@@ -14,7 +14,7 @@ ALL_TESTS=" > REQUIRE_MZ=no > NUM_NETIFS=0 > lib_dir=$(dirname "$0") >-source "$lib_dir"/net_forwarding_lib.sh >+source "$lib_dir"/../../../net/forwarding/lib.sh > > source "$lib_dir"/lag_lib.sh > >diff --git a/tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh b/tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh >index b76bf5030952..9d26ab4cad0b 100755 >--- a/tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh >+++ b/tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh >@@ -23,7 +23,7 @@ REQUIRE_MZ=no > REQUIRE_JQ=no > NUM_NETIFS=0 > lib_dir=$(dirname "$0") >-source "$lib_dir"/net_forwarding_lib.sh >+source "$lib_dir"/../../../net/forwarding/lib.sh > source "$lib_dir"/lag_lib.sh > > cleanup() >diff --git a/tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh b/tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh >index 8c2619002147..2d275b3e47dd 100755 >--- a/tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh >+++ b/tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh >@@ -23,7 +23,7 @@ REQUIRE_MZ=no > REQUIRE_JQ=no > NUM_NETIFS=0 > lib_dir=$(dirname "$0") >-source "$lib_dir"/net_forwarding_lib.sh >+source "$lib_dir"/../../../net/forwarding/lib.sh > source "$lib_dir"/lag_lib.sh > > cleanup() >diff --git a/tools/testing/selftests/drivers/net/bonding/net_forwarding_lib.sh b/tools/testing/selftests/drivers/net/bonding/net_forwarding_lib.sh >deleted file mode 120000 >index 39c96828c5ef..000000000000 >--- a/tools/testing/selftests/drivers/net/bonding/net_forwarding_lib.sh >+++ /dev/null >@@ -1 +0,0 @@ >-../../../net/forwarding/lib.sh >\ No newline at end of file >-- >2.43.0 > >
On 2024-01-24 10:24 -0800, Jay Vosburgh wrote: [...] > >diff --git a/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh b/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh > >index a509ef949dcf..0eb7edfb584c 100644 > >--- a/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh > >+++ b/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh > >@@ -28,7 +28,7 @@ > > REQUIRE_MZ=no > > NUM_NETIFS=0 > > lib_dir=$(dirname "$0") > >-source ${lib_dir}/net_forwarding_lib.sh > >+source "$lib_dir"/../../../net/forwarding/lib.sh > > Is there a way to pass TEST_INCLUDES via the environment or as a > parameter, so that it's not necessary to hard code the path name here > and in the similar cases below? It think would be possible but I see two issues: 1) Tests can be run in a myriad ways. Some of them (`make run_tests`, `run_kselftest.sh`) use runner.sh which would be the place to set environment variables for a test. However it's also possible to run tests directly: tools/testing/selftests/drivers/net/bonding# ./dev_addr_lists.sh In that case, there's nothing to automatically set an environment variable for the test. I think that could be addressed, for example by putting the content of TEST_INCLUDES in a file and having the test read it itself, but ... 2) As can be seen in the dsa case and in the bonding and team cases after patch 6, the relationship between the files listed in TEST_INCLUDES and the files sourced in a test is not 1:1. So automatically sourcing all files listed in TEST_INCLUDES is not generally applicable. Given these two points, I'm inclined to stick with the current approach. What do you think?
Benjamin Poirier <bpoirier@nvidia.com> wrote: >On 2024-01-24 10:24 -0800, Jay Vosburgh wrote: >[...] >> >diff --git a/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh b/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh >> >index a509ef949dcf..0eb7edfb584c 100644 >> >--- a/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh >> >+++ b/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh >> >@@ -28,7 +28,7 @@ >> > REQUIRE_MZ=no >> > NUM_NETIFS=0 >> > lib_dir=$(dirname "$0") >> >-source ${lib_dir}/net_forwarding_lib.sh >> >+source "$lib_dir"/../../../net/forwarding/lib.sh >> >> Is there a way to pass TEST_INCLUDES via the environment or as a >> parameter, so that it's not necessary to hard code the path name here >> and in the similar cases below? > >It think would be possible but I see two issues: > >1) Tests can be run in a myriad ways. Some of them (`make run_tests`, >`run_kselftest.sh`) use runner.sh which would be the place to set >environment variables for a test. However it's also possible to run >tests directly: > >tools/testing/selftests/drivers/net/bonding# ./dev_addr_lists.sh > >In that case, there's nothing to automatically set an environment >variable for the test. > >I think that could be addressed, for example by putting the content of >TEST_INCLUDES in a file and having the test read it itself, but ... > >2) >As can be seen in the dsa case and in the bonding and team cases after >patch 6, the relationship between the files listed in TEST_INCLUDES and >the files sourced in a test is not 1:1. So automatically sourcing all >files listed in TEST_INCLUDES is not generally applicable. > >Given these two points, I'm inclined to stick with the current approach. >What do you think? That rationale sounds fine; I was wondering if there was a straightforward way to centralize the naming of the "library" without having to literally hard code it all over the place, but that doesn't seem to be the case. Thanks for the explanation. -J --- -Jay Vosburgh, jay.vosburgh@canonical.com
diff --git a/tools/testing/selftests/drivers/net/bonding/Makefile b/tools/testing/selftests/drivers/net/bonding/Makefile index 8a72bb7de70f..1e10a1f06faf 100644 --- a/tools/testing/selftests/drivers/net/bonding/Makefile +++ b/tools/testing/selftests/drivers/net/bonding/Makefile @@ -15,7 +15,9 @@ TEST_PROGS := \ TEST_FILES := \ lag_lib.sh \ bond_topo_2d1c.sh \ - bond_topo_3d1c.sh \ - net_forwarding_lib.sh + bond_topo_3d1c.sh + +TEST_INCLUDES := \ + ../../../net/forwarding/lib.sh include ../../../lib.mk diff --git a/tools/testing/selftests/drivers/net/bonding/bond-eth-type-change.sh b/tools/testing/selftests/drivers/net/bonding/bond-eth-type-change.sh index 862e947e17c7..8293dbc7c18f 100755 --- a/tools/testing/selftests/drivers/net/bonding/bond-eth-type-change.sh +++ b/tools/testing/selftests/drivers/net/bonding/bond-eth-type-change.sh @@ -11,7 +11,7 @@ ALL_TESTS=" REQUIRE_MZ=no NUM_NETIFS=0 lib_dir=$(dirname "$0") -source "$lib_dir"/net_forwarding_lib.sh +source "$lib_dir"/../../../net/forwarding/lib.sh bond_check_flags() { diff --git a/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh b/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh index a509ef949dcf..0eb7edfb584c 100644 --- a/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh +++ b/tools/testing/selftests/drivers/net/bonding/bond_topo_2d1c.sh @@ -28,7 +28,7 @@ REQUIRE_MZ=no NUM_NETIFS=0 lib_dir=$(dirname "$0") -source ${lib_dir}/net_forwarding_lib.sh +source "$lib_dir"/../../../net/forwarding/lib.sh s_ns="s-$(mktemp -u XXXXXX)" c_ns="c-$(mktemp -u XXXXXX)" diff --git a/tools/testing/selftests/drivers/net/bonding/dev_addr_lists.sh b/tools/testing/selftests/drivers/net/bonding/dev_addr_lists.sh index 5cfe7d8ebc25..e6fa24eded5b 100755 --- a/tools/testing/selftests/drivers/net/bonding/dev_addr_lists.sh +++ b/tools/testing/selftests/drivers/net/bonding/dev_addr_lists.sh @@ -14,7 +14,7 @@ ALL_TESTS=" REQUIRE_MZ=no NUM_NETIFS=0 lib_dir=$(dirname "$0") -source "$lib_dir"/net_forwarding_lib.sh +source "$lib_dir"/../../../net/forwarding/lib.sh source "$lib_dir"/lag_lib.sh diff --git a/tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh b/tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh index b76bf5030952..9d26ab4cad0b 100755 --- a/tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh +++ b/tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh @@ -23,7 +23,7 @@ REQUIRE_MZ=no REQUIRE_JQ=no NUM_NETIFS=0 lib_dir=$(dirname "$0") -source "$lib_dir"/net_forwarding_lib.sh +source "$lib_dir"/../../../net/forwarding/lib.sh source "$lib_dir"/lag_lib.sh cleanup() diff --git a/tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh b/tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh index 8c2619002147..2d275b3e47dd 100755 --- a/tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh +++ b/tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh @@ -23,7 +23,7 @@ REQUIRE_MZ=no REQUIRE_JQ=no NUM_NETIFS=0 lib_dir=$(dirname "$0") -source "$lib_dir"/net_forwarding_lib.sh +source "$lib_dir"/../../../net/forwarding/lib.sh source "$lib_dir"/lag_lib.sh cleanup() diff --git a/tools/testing/selftests/drivers/net/bonding/net_forwarding_lib.sh b/tools/testing/selftests/drivers/net/bonding/net_forwarding_lib.sh deleted file mode 120000 index 39c96828c5ef..000000000000 --- a/tools/testing/selftests/drivers/net/bonding/net_forwarding_lib.sh +++ /dev/null @@ -1 +0,0 @@ -../../../net/forwarding/lib.sh \ No newline at end of file