]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests: net: move wait_local_port_listen to lib.sh
authorHangbin Liu <liuhangbin@gmail.com>
Mon, 26 May 2025 01:46:00 +0000 (01:46 +0000)
committerJakub Kicinski <kuba@kernel.org>
Wed, 28 May 2025 00:31:42 +0000 (17:31 -0700)
The function wait_local_port_listen() is the only function defined in
net_helper.sh. Since some tests source both lib.sh and net_helper.sh,
we can simplify the setup by moving wait_local_port_listen() to lib.sh.

With this change, net_helper.sh becomes redundant and can be removed.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20250526014600.9128-1-liuhangbin@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
15 files changed:
tools/testing/selftests/drivers/net/Makefile
tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh
tools/testing/selftests/drivers/net/netdevsim/peer.sh
tools/testing/selftests/net/Makefile
tools/testing/selftests/net/busy_poll_test.sh
tools/testing/selftests/net/ipv6_route_update_soft_lockup.sh
tools/testing/selftests/net/lib.sh
tools/testing/selftests/net/mptcp/Makefile
tools/testing/selftests/net/mptcp/mptcp_lib.sh
tools/testing/selftests/net/net_helper.sh [deleted file]
tools/testing/selftests/net/pmtu.sh
tools/testing/selftests/net/udpgro.sh
tools/testing/selftests/net/udpgro_bench.sh
tools/testing/selftests/net/udpgro_frglist.sh
tools/testing/selftests/net/udpgro_fwd.sh

index 17db31aa58c94280c764b6782e7bbcdaad4f727f..be780bcb73a3bcd7bb47ea48c7efd72f93ea50ef 100644 (file)
@@ -3,7 +3,6 @@ CFLAGS += $(KHDR_INCLUDES)
 
 TEST_INCLUDES := $(wildcard lib/py/*.py) \
                 $(wildcard lib/sh/*.sh) \
-                ../../net/net_helper.sh \
                 ../../net/lib.sh \
 
 TEST_GEN_FILES := \
index 3c96b022954db9e21216950b1c13431c313ed4b5..29b01b8e2215c8ec3a95c66516183a41dc7ebf06 100644 (file)
@@ -33,7 +33,6 @@ NSIM_DEV_SYS_NEW="/sys/bus/netdevsim/new_device"
 
 # Used to create and delete namespaces
 source "${LIBDIR}"/../../../../net/lib.sh
-source "${LIBDIR}"/../../../../net/net_helper.sh
 
 # Create netdevsim interfaces
 create_ifaces() {
index aed62d9e6c0a46488e303954a6a7ff515f0bfe5e..1bb46ec435d453ec67c4c0829cacbb4d6deb5eb8 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0-only
 
-source ../../../net/net_helper.sh
+source ../../../net/lib.sh
 
 NSIM_DEV_1_ID=$((256 + RANDOM % 256))
 NSIM_DEV_1_SYS=/sys/bus/netdevsim/devices/netdevsim$NSIM_DEV_1_ID
index 70a38f485d4d1c45e660ce2e09b8db7cda4f19cb..ea84b88bcb30f9b4a3d21b5ffbb1e4a09f3b46ac 100644 (file)
@@ -115,7 +115,7 @@ YNL_GEN_FILES := busy_poller netlink-dumps
 TEST_GEN_FILES += $(YNL_GEN_FILES)
 
 TEST_FILES := settings
-TEST_FILES += in_netns.sh lib.sh net_helper.sh setup_loopback.sh setup_veth.sh
+TEST_FILES += in_netns.sh lib.sh setup_loopback.sh setup_veth.sh
 
 TEST_GEN_FILES += $(patsubst %.c,%.o,$(wildcard *.bpf.c))
 
index 7db292ec4884a94677b086bde7cd070c043ed56b..7d2d40812074fb248641a14fa336cb2ef340f896 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
-source net_helper.sh
+source lib.sh
 
 NSIM_SV_ID=$((256 + RANDOM % 256))
 NSIM_SV_SYS=/sys/bus/netdevsim/devices/netdevsim$NSIM_SV_ID
index a6b2b1f9c641c9af25e8ebc97de5fd22eecfc325..c6866e42f95c8a9cb8a280ec98bcb25937b91abd 100755 (executable)
@@ -69,7 +69,6 @@
 # which can affect the conditions needed to trigger a soft lockup.
 
 source lib.sh
-source net_helper.sh
 
 TEST_DURATION=300
 ROUTING_TABLE_REFRESH_PERIOD=0.01
index 7962da06f8162e5ae1d1438a92da0bbb299612e5..006fdadcc4b9b061509a3be235ef0ed44d9a2b45 100644 (file)
@@ -595,3 +595,24 @@ bridge_vlan_add()
        bridge vlan add "$@"
        defer bridge vlan del "$@"
 }
+
+wait_local_port_listen()
+{
+       local listener_ns="${1}"
+       local port="${2}"
+       local protocol="${3}"
+       local pattern
+       local i
+
+       pattern=":$(printf "%04X" "${port}") "
+
+       # for tcp protocol additionally check the socket state
+       [ ${protocol} = "tcp" ] && pattern="${pattern}0A"
+       for i in $(seq 10); do
+               if ip netns exec "${listener_ns}" awk '{print $2" "$4}' \
+                  /proc/net/"${protocol}"* | grep -q "${pattern}"; then
+                       break
+               fi
+               sleep 0.1
+       done
+}
index 340e1a777e16a893300e01d19fdb5191fab8e00b..e47788bfa671313f21d5ba95821121cdc3e5d2c7 100644 (file)
@@ -11,7 +11,7 @@ TEST_GEN_FILES = mptcp_connect pm_nl_ctl mptcp_sockopt mptcp_inq mptcp_diag
 
 TEST_FILES := mptcp_lib.sh settings
 
-TEST_INCLUDES := ../lib.sh $(wildcard ../lib/sh/*.sh) ../net_helper.sh
+TEST_INCLUDES := ../lib.sh $(wildcard ../lib/sh/*.sh)
 
 EXTRA_CLEAN := *.pcap
 
index 55212188871e45ae616a66546a60316ad1ca4882..09cd24b2ae466205dacbdf8289eb86c08534c475 100644 (file)
@@ -2,7 +2,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
 . "$(dirname "${0}")/../lib.sh"
-. "$(dirname "${0}")/../net_helper.sh"
 
 readonly KSFT_PASS=0
 readonly KSFT_FAIL=1
diff --git a/tools/testing/selftests/net/net_helper.sh b/tools/testing/selftests/net/net_helper.sh
deleted file mode 100644 (file)
index 6596fe0..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0
-#
-# Helper functions
-
-wait_local_port_listen()
-{
-       local listener_ns="${1}"
-       local port="${2}"
-       local protocol="${3}"
-       local pattern
-       local i
-
-       pattern=":$(printf "%04X" "${port}") "
-
-       # for tcp protocol additionally check the socket state
-       [ ${protocol} = "tcp" ] && pattern="${pattern}0A"
-       for i in $(seq 10); do
-               if ip netns exec "${listener_ns}" awk '{print $2" "$4}' \
-                  /proc/net/"${protocol}"* | grep -q "${pattern}"; then
-                       break
-               fi
-               sleep 0.1
-       done
-}
index 66be7699c72c9a10a9990fcdef7f03f631400b26..88e914c4eef94c358f46b2ba646903338a6e536c 100755 (executable)
 #      Check that PMTU exceptions are created for both paths.
 
 source lib.sh
-source net_helper.sh
 
 PAUSE_ON_FAIL=no
 VERBOSE=0
index d5ffd8c9172e1d9e36dd180fa2de561637bab5ad..1dc337c709f838240eb2da28de064d273e77bffe 100755 (executable)
@@ -3,7 +3,7 @@
 #
 # Run a series of udpgro functional tests.
 
-source net_helper.sh
+source lib.sh
 
 readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
 
index 815fad8c53a84d1c9b939141bc1b2c9104119acc..54fa4821bc5efecf5ea8d2ff5b0ca69df9069f23 100755 (executable)
@@ -3,7 +3,7 @@
 #
 # Run a series of udpgro benchmarks
 
-source net_helper.sh
+source lib.sh
 
 readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
 
index 5f3d1a110d11586f3241982bb8b688f24538aab9..9a2cfec1153ec32b8261d9791c1d40add1f5731c 100755 (executable)
@@ -3,7 +3,7 @@
 #
 # Run a series of udpgro benchmarks
 
-source net_helper.sh
+source lib.sh
 
 readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
 
index f22f6c66997ef97f716362e08a76c74ae4e6a179..a39fdc4aa2ffb3039c893e401b3aef7742841a1c 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/bash
 # SPDX-License-Identifier: GPL-2.0
 
-source net_helper.sh
+source lib.sh
 
 BPF_FILE="lib/xdp_dummy.bpf.o"
 readonly BASE="ns-$(mktemp -u XXXXXX)"