After having started mptcp_connect in listening mode,
'mptcp_lib_wait_local_port_listen' can be used to wait for the listening
socket to be ready.

This is better than using the 'sleep' command, not to pause for a fixed
amount of time, but waiting for an event. This helper is used in all
other MPTCP selftests, but not in these two.

Reviewed-by: Geliang Tang <[email protected]>
Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
---
 tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 2 +-
 tools/testing/selftests/net/mptcp/userspace_pm.sh  | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh 
b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
index 42d533b95ec7..6cde7429104b 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
@@ -178,7 +178,7 @@ do_transfer()
                                ${local_addr} < "$sin" > "$sout" &
        local spid=$!
 
-       sleep 1
+       mptcp_lib_wait_local_port_listen "${listener_ns}" "${port}"
 
        timeout ${timeout_test} \
                ip netns exec ${connector_ns} \
diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh 
b/tools/testing/selftests/net/mptcp/userspace_pm.sh
index 87323942cb8a..e9ae1806ab07 100755
--- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
+++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
@@ -211,7 +211,8 @@ make_connection()
        ip netns exec "$ns1" \
           ./mptcp_connect -s MPTCP -w 300 -p $app_port -l $listen_addr > 
/dev/null 2>&1 &
        local server_pid=$!
-       sleep 0.5
+
+       mptcp_lib_wait_local_port_listen "${ns1}" "${port}"
 
        # Run the client, transfer $file and stay connected to the server
        # to conduct tests

-- 
2.51.0


Reply via email to