selftests: net: move wait_local_port_listen to lib.sh
Subsystems (4)
PATCH 1/1 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.
--- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/busy_poll_test.sh | 2 +- .../net/ipv6_route_update_soft_lockup.sh | 1 - tools/testing/selftests/net/lib.sh | 21 ++++++++++++++++ tools/testing/selftests/net/mptcp/Makefile | 2 +- .../testing/selftests/net/mptcp/mptcp_lib.sh | 1 - tools/testing/selftests/net/net_helper.sh | 25 ------------------- tools/testing/selftests/net/pmtu.sh | 1 - tools/testing/selftests/net/udpgro.sh | 2 +- tools/testing/selftests/net/udpgro_bench.sh | 2 +- tools/testing/selftests/net/udpgro_frglist.sh | 2 +- tools/testing/selftests/net/udpgro_fwd.sh | 2 +- 12 files changed, 28 insertions(+), 35 deletions(-) delete mode 100644 tools/testing/selftests/net/net_helper.sh
tools/testing/selftests/net/Makefile +1 -1
@@ -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))
tools/testing/selftests/net/busy_poll_test.sh +1 -1
@@ -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
tools/testing/selftests/net/ipv6_route_update_soft_lockup.sh +0 -1
@@ -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
tools/testing/selftests/net/lib.sh +21 -0
@@ -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 +}
tools/testing/selftests/net/mptcp/Makefile +1 -1
@@ -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
tools/testing/selftests/net/mptcp/mptcp_lib.sh +0 -1
@@ -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
tools/testing/selftests/net/net_helper.sh deleted +0 -25
@@ -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 -}
tools/testing/selftests/net/pmtu.sh +0 -1
@@ -205,7 +205,6 @@ # Check that PMTU exceptions are created for both paths. source lib.sh -source net_helper.sh PAUSE_ON_FAIL=no VERBOSE=0
tools/testing/selftests/net/udpgro.sh +1 -1
@@ -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)"
tools/testing/selftests/net/udpgro_bench.sh +1 -1
@@ -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)"
tools/testing/selftests/net/udpgro_frglist.sh +1 -1
@@ -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)"
tools/testing/selftests/net/udpgro_fwd.sh +1 -1
@@ -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)"
Signature · 1 line
2.46.0
Hi Hangbin,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Critical: Global Timeout ❌
- KVM Validation: debug: Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/15202060946
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/6dae34f54456
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=965637
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Hi Hangbin,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/15202060946
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/6dae34f54456
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=965637
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Matthieu Baerts
maintainerHi Hangbin,
Quoted 5 lines · Hangbin Liu
The function
wait_local_port_listen()is the only function defined innet_helper.sh. Since some tests source bothlib.shandnet_helper.sh, we can simplify the setup by movingwait_local_port_listen()tolib.sh.With this change,
net_helper.shbecomes redundant and can be removed.
Thank you for the modifications! I wanted to do the same at some points, then I forgot :)
Quoted 16 lines
Signed-off-by Hangbin Liu <[email protected]>--- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/busy_poll_test.sh | 2 +- .../net/ipv6_route_update_soft_lockup.sh | 1 - tools/testing/selftests/net/lib.sh | 21 ++++++++++++++++ tools/testing/selftests/net/mptcp/Makefile | 2 +- .../testing/selftests/net/mptcp/mptcp_lib.sh | 1 - tools/testing/selftests/net/net_helper.sh | 25 ------------------- tools/testing/selftests/net/pmtu.sh | 1 - tools/testing/selftests/net/udpgro.sh | 2 +- tools/testing/selftests/net/udpgro_bench.sh | 2 +- tools/testing/selftests/net/udpgro_frglist.sh | 2 +- tools/testing/selftests/net/udpgro_fwd.sh | 2 +- 12 files changed, 28 insertions(+), 35 deletions(-) delete mode 100644 tools/testing/selftests/net/net_helper.sh
The changes in MPTCP and others look good to me, except that I think you forgot to modify files in tools/testing/selftests/drivers/net as well:
Quoted 3 lines
tools/testing/selftests/drivers/net/Makefile:../../net/net_helper.sh\
tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh:source "${LIBDIR}"/../../../../net/net_helper.sh tools/testing/selftests/drivers/net/netdevsim/peer.sh:source../../../net/net_helper.sh
pw-bot: cr
Note that the "netdev/check_selftest" NIPA check will not handle this case where a shell script is removed. But that's OK, it can be ignored.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Quoted 4 lines · Matthieu Baerts
Quoted 1 line
delete mode 100644 tools/testing/selftests/net/net_helper.shThe changes in MPTCP and others look good to me, except that I think you forgot to modify files in
tools/testing/selftests/drivers/netas well:
Ah, thank your for this reminder. I missed this directory. Will fix it in next version.
Regards
Hangbin