diff mbox series

[mptcp-next,v1,2/2] Squash to "selftests: mptcp: add path_manager sysctl tests"

Message ID c1d665b388561f7d91b2f4d45a86499eb2cd974e.1741347453.git.tanggeliang@kylinos.cn (mailing list archive)
State Superseded
Headers show
Series cleanups for BPF PM part 5 v10 | expand

Commit Message

Geliang Tang March 7, 2025, 11:39 a.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

Check pm_type mapping in ns2 too.
Move set_path_manager to mptcp_lib.sh.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 .../testing/selftests/net/mptcp/mptcp_lib.sh  | 13 +++++++++++
 .../selftests/net/mptcp/userspace_pm.sh       | 22 ++++---------------
 2 files changed, 17 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index 051e289d7967..ed2c27e345f7 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -693,3 +693,16 @@  mptcp_lib_pm_nl_change_endpoint() {
 		ip netns exec "${ns}" ./pm_nl_ctl set id "${id}" flags "${flags}"
 	fi
 }
+
+mptcp_lib_set_path_manager()
+{
+	local ns=$1
+	local pm=$2
+
+	if ! ip netns exec ${ns} sysctl net.mptcp.available_path_managers |
+	     grep -wq "${pm}"; then
+		test_fail "path manager ${pm} not found"
+		return 1
+	fi
+	ip netns exec ${ns} sysctl -q net.mptcp.path_manager="${pm}"
+}
diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh
index 35ba4edc0fa2..b8dec1ce5762 100755
--- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
+++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
@@ -119,19 +119,6 @@  trap cleanup EXIT
 # Create and configure network namespaces for testing
 mptcp_lib_ns_init ns1 ns2
 
-set_path_manager()
-{
-	local ns=$1
-	local pm=$2
-
-	if ! ip netns exec ${ns} sysctl net.mptcp.available_path_managers |
-	     grep -wq "${pm}"; then
-		test_fail "path manager ${pm} not found"
-		return 1
-	fi
-	ip netns exec ${ns} sysctl -q net.mptcp.path_manager="${pm}"
-}
-
 if [ -f /proc/sys/net/mptcp/path_manager ]; then
 	ip netns exec "$ns1" sysctl -q net.mptcp.pm_type=0
 	pm_name="$(ip netns exec "$ns1" sysctl -n net.mptcp.path_manager)"
@@ -149,23 +136,22 @@  if [ -f /proc/sys/net/mptcp/path_manager ]; then
 		exit ${KSFT_FAIL}
 	fi
 
-	set_path_manager "$ns1" "kernel"
-	pm_type="$(ip netns exec "$ns1" sysctl -n net.mptcp.pm_type)"
+	mptcp_lib_set_path_manager "$ns2" "kernel"
+	pm_type="$(ip netns exec "$ns2" sysctl -n net.mptcp.pm_type)"
 	if [ "${pm_type}" != "0" ]; then
 		test_fail "unexpected pm_type: ${pm_type}"
 		mptcp_lib_result_print_all_tap
 		exit ${KSFT_FAIL}
 	fi
 
-	set_path_manager "$ns1" "userspace"
-	pm_type="$(ip netns exec "$ns1" sysctl -n net.mptcp.pm_type)"
+	mptcp_lib_set_path_manager "$ns2" "userspace"
+	pm_type="$(ip netns exec "$ns2" sysctl -n net.mptcp.pm_type)"
 	if [ "${pm_type}" != "1" ]; then
 		test_fail "unexpected pm_type: ${pm_type}"
 		mptcp_lib_result_print_all_tap
 		exit ${KSFT_FAIL}
 	fi
 
-	set_path_manager "$ns2" "userspace"
 	print_test "check path_manager and pm_type sysctl mapping"
 	test_pass
 else