Skip to content

Commit d9d836b

Browse files
liuhangbinkuba-moo
authored andcommitted
selftests: net: move wait_local_port_listen to lib.sh
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>
1 parent 08f8bad commit d9d836b

File tree

15 files changed

+29
-38
lines changed

15 files changed

+29
-38
lines changed

tools/testing/selftests/drivers/net/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ CFLAGS += $(KHDR_INCLUDES)
33

44
TEST_INCLUDES := $(wildcard lib/py/*.py) \
55
$(wildcard lib/sh/*.sh) \
6-
../../net/net_helper.sh \
76
../../net/lib.sh \
87

98
TEST_GEN_FILES := \

tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ NSIM_DEV_SYS_NEW="/sys/bus/netdevsim/new_device"
3333

3434
# Used to create and delete namespaces
3535
source "${LIBDIR}"/../../../../net/lib.sh
36-
source "${LIBDIR}"/../../../../net/net_helper.sh
3736

3837
# Create netdevsim interfaces
3938
create_ifaces() {

tools/testing/selftests/drivers/net/netdevsim/peer.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0-only
33

4-
source ../../../net/net_helper.sh
4+
source ../../../net/lib.sh
55

66
NSIM_DEV_1_ID=$((256 + RANDOM % 256))
77
NSIM_DEV_1_SYS=/sys/bus/netdevsim/devices/netdevsim$NSIM_DEV_1_ID

tools/testing/selftests/net/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ YNL_GEN_FILES := busy_poller netlink-dumps
115115
TEST_GEN_FILES += $(YNL_GEN_FILES)
116116

117117
TEST_FILES := settings
118-
TEST_FILES += in_netns.sh lib.sh net_helper.sh setup_loopback.sh setup_veth.sh
118+
TEST_FILES += in_netns.sh lib.sh setup_loopback.sh setup_veth.sh
119119

120120
TEST_GEN_FILES += $(patsubst %.c,%.o,$(wildcard *.bpf.c))
121121

tools/testing/selftests/net/busy_poll_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
3-
source net_helper.sh
3+
source lib.sh
44

55
NSIM_SV_ID=$((256 + RANDOM % 256))
66
NSIM_SV_SYS=/sys/bus/netdevsim/devices/netdevsim$NSIM_SV_ID

tools/testing/selftests/net/ipv6_route_update_soft_lockup.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
# which can affect the conditions needed to trigger a soft lockup.
7070

7171
source lib.sh
72-
source net_helper.sh
7372

7473
TEST_DURATION=300
7574
ROUTING_TABLE_REFRESH_PERIOD=0.01

tools/testing/selftests/net/lib.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,3 +595,24 @@ bridge_vlan_add()
595595
bridge vlan add "$@"
596596
defer bridge vlan del "$@"
597597
}
598+
599+
wait_local_port_listen()
600+
{
601+
local listener_ns="${1}"
602+
local port="${2}"
603+
local protocol="${3}"
604+
local pattern
605+
local i
606+
607+
pattern=":$(printf "%04X" "${port}") "
608+
609+
# for tcp protocol additionally check the socket state
610+
[ ${protocol} = "tcp" ] && pattern="${pattern}0A"
611+
for i in $(seq 10); do
612+
if ip netns exec "${listener_ns}" awk '{print $2" "$4}' \
613+
/proc/net/"${protocol}"* | grep -q "${pattern}"; then
614+
break
615+
fi
616+
sleep 0.1
617+
done
618+
}

tools/testing/selftests/net/mptcp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ TEST_GEN_FILES = mptcp_connect pm_nl_ctl mptcp_sockopt mptcp_inq mptcp_diag
1111

1212
TEST_FILES := mptcp_lib.sh settings
1313

14-
TEST_INCLUDES := ../lib.sh $(wildcard ../lib/sh/*.sh) ../net_helper.sh
14+
TEST_INCLUDES := ../lib.sh $(wildcard ../lib/sh/*.sh)
1515

1616
EXTRA_CLEAN := *.pcap
1717

tools/testing/selftests/net/mptcp/mptcp_lib.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# SPDX-License-Identifier: GPL-2.0
33

44
. "$(dirname "${0}")/../lib.sh"
5-
. "$(dirname "${0}")/../net_helper.sh"
65

76
readonly KSFT_PASS=0
87
readonly KSFT_FAIL=1

tools/testing/selftests/net/net_helper.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)