selftests: forwarding: Remove duplicated lib.sh content
authorPetr Machata <petrm@nvidia.com>
Fri, 26 Jan 2024 23:21:23 +0000 (18:21 -0500)
committerDavid S. Miller <davem@davemloft.net>
Wed, 31 Jan 2024 10:55:11 +0000 (10:55 +0000)
commit 25ae948b4478 ("selftests/net: add lib.sh") added net/lib.sh to
contain code shared by tests under net/ and net/forwarding/. However, this
caused issues with selftests from directories other than net/forwarding/,
in particular those under drivers/net/. Those issues were avoided in a
simple way by duplicating some content in commit 2114e83381d3 ("selftests:
forwarding: Avoid failures to source net/lib.sh").

In order to remove the duplicated content, restore the inclusion of
net/lib.sh from net/forwarding/lib.sh but with the following changes:

* net/lib.sh is imported through the net_forwarding_dir path
The original expression "source ../lib.sh" would look for lib.sh in the
directory above the script file's one, which did not work for tests under
drivers/net/.

* net/lib.sh is added to TEST_INCLUDES
Since net/forwarding/lib.sh now sources net/lib.sh, both of those files
must be exported along with tests which source net/forwarding/lib.sh.

Suggested-by: Hangbin Liu <liuhangbin@gmail.com>
Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/drivers/net/bonding/Makefile
tools/testing/selftests/drivers/net/dsa/Makefile
tools/testing/selftests/drivers/net/team/Makefile
tools/testing/selftests/net/forwarding/Makefile
tools/testing/selftests/net/forwarding/lib.sh

index 1e10a1f06faf565b80490cbacb972e51eaff9a66..03a089165d3fb4b1c00fcfa9e6de0ceed68087ab 100644 (file)
@@ -18,6 +18,7 @@ TEST_FILES := \
        bond_topo_3d1c.sh
 
 TEST_INCLUDES := \
-       ../../../net/forwarding/lib.sh
+       ../../../net/forwarding/lib.sh \
+       ../../../net/lib.sh
 
 include ../../../lib.mk
index 83da1d721017dd254e96bd44808d6b4419451127..cd6817fe5be6c6fc8f1f265991b41d1c62178f86 100644 (file)
@@ -26,6 +26,7 @@ TEST_INCLUDES := \
        ../../../net/forwarding/local_termination.sh \
        ../../../net/forwarding/no_forwarding.sh \
        ../../../net/forwarding/tc_actions.sh \
-       ../../../net/forwarding/tc_common.sh
+       ../../../net/forwarding/tc_common.sh \
+       ../../../net/lib.sh
 
 include ../../../lib.mk
index 708bdfce37f5bd6f10d596f0fa8f60ba3150c926..2d5a76d9918104a5f39ae54a76b5ba97757c78dd 100644 (file)
@@ -5,6 +5,7 @@ TEST_PROGS := dev_addr_lists.sh
 
 TEST_INCLUDES := \
        ../bonding/lag_lib.sh \
-       ../../../net/forwarding/lib.sh
+       ../../../net/forwarding/lib.sh \
+       ../../../net/lib.sh
 
 include ../../../lib.mk
index 452693514be4b06842dbe32088c5495c2c933f0b..1fba2717738de0a03a2d333142a44712fccd4177 100644 (file)
@@ -129,4 +129,7 @@ TEST_PROGS_EXTENDED := devlink_lib.sh \
        sch_tbf_etsprio.sh \
        tc_common.sh
 
+TEST_INCLUDES := \
+       ../lib.sh
+
 include ../../lib.mk
index cf0ba4bfe50d8bff0b1ca4302e18fc6a43c91646..a7ecfc8cae985b5c8fabe317ac32f7f1e8b725e4 100644 (file)
@@ -35,31 +35,7 @@ if [[ -f $net_forwarding_dir/forwarding.config ]]; then
        source "$net_forwarding_dir/forwarding.config"
 fi
 
-# Kselftest framework requirement - SKIP code is 4.
-ksft_skip=4
-
-busywait()
-{
-       local timeout=$1; shift
-
-       local start_time="$(date -u +%s%3N)"
-       while true
-       do
-               local out
-               out=$("$@")
-               local ret=$?
-               if ((!ret)); then
-                       echo -n "$out"
-                       return 0
-               fi
-
-               local current_time="$(date -u +%s%3N)"
-               if ((current_time - start_time > timeout)); then
-                       echo -n "$out"
-                       return 1
-               fi
-       done
-}
+source "$net_forwarding_dir/../lib.sh"
 
 ##############################################################################
 # Sanity checks