MPTCP Linux Development
 help / color / mirror / Atom feed
From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
To: MPTCP Upstream <mptcp@lists.linux.dev>
Cc: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Subject: [PATCH mptcp-next] Squash to "selftests: mptcp: get stats just before timing out"
Date: Thu, 13 Nov 2025 12:11:15 +0100	[thread overview]
Message-ID: <20251113-slft-timeout-stats-kill-v1-1-9a09d8f46392@kernel.org> (raw)

Geliang reported that mptcp_connect.sh test runtime got increased after
this patch.

That's because the previous 'kill' command was only killing the
background job, but the 'sleep' command was still running.

It is not very clear to me why there was a delay at the end, but
switching to mptcp_lib_kill_group_wait to kill the background job and
the running command fixed the issue. The new code is also looking
clearer I think, so that's good.

Link: https://lore.kernel.org/2a6869ca39bda7ddf8b486cd03e0867b30e0d565.camel@kernel.org
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 tools/testing/selftests/net/mptcp/mptcp_connect.sh | 7 ++++++-
 tools/testing/selftests/net/mptcp/mptcp_join.sh    | 7 ++++++-
 tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 7 ++++++-
 tools/testing/selftests/net/mptcp/simult_flows.sh  | 7 ++++++-
 4 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index 458b07673910..a6447f7a31fe 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
@@ -415,7 +415,12 @@ do_transfer()
 	local retc=$?
 	wait $spid
 	local rets=$?
-	kill $timeout_pid 2>/dev/null && timeout_pid=0
+
+	if kill -0 $timeout_pid; then
+		# Finished before the timeout: kill the background job
+		mptcp_lib_kill_group_wait $timeout_pid
+		timeout_pid=0
+	fi
 
 	local stop
 	stop=$(date +%s%3N)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 222babd43682..7a72efcf1403 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -1063,7 +1063,12 @@ do_transfer()
 	local retc=$?
 	wait $spid
 	local rets=$?
-	kill $timeout_pid 2>/dev/null && timeout_pid=0
+
+	if kill -0 $timeout_pid; then
+		# Finished before the timeout: kill the background job
+		mptcp_lib_kill_group_wait $timeout_pid
+		timeout_pid=0
+	fi
 
 	cond_stop_capture
 
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
index 326466f2f6eb..ab8bce06b262 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
@@ -193,7 +193,12 @@ do_transfer()
 	local retc=$?
 	wait $spid
 	local rets=$?
-	kill $timeout_pid 2>/dev/null && timeout_pid=0
+
+	if kill -0 $timeout_pid; then
+		# Finished before the timeout: kill the background job
+		mptcp_lib_kill_group_wait $timeout_pid
+		timeout_pid=0
+	fi
 
 	mptcp_lib_nstat_get "${listener_ns}"
 	mptcp_lib_nstat_get "${connector_ns}"
diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh
index cc4d40d149e2..806aaa7d2d61 100755
--- a/tools/testing/selftests/net/mptcp/simult_flows.sh
+++ b/tools/testing/selftests/net/mptcp/simult_flows.sh
@@ -178,7 +178,12 @@ do_transfer()
 	local retc=$?
 	wait $spid
 	local rets=$?
-	kill $timeout_pid 2>/dev/null && timeout_pid=0
+
+	if kill -0 $timeout_pid; then
+		# Finished before the timeout: kill the background job
+		mptcp_lib_kill_group_wait $timeout_pid
+		timeout_pid=0
+	fi
 
 	if $capture; then
 		sleep 1

---
base-commit: 6861f291b7a3bc40235e996f5605c477f55ce9e0
change-id: 20251113-slft-timeout-stats-kill-444931425af7

Best regards,
-- 
Matthieu Baerts (NGI0) <matttbe@kernel.org>


             reply	other threads:[~2025-11-13 11:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 11:11 Matthieu Baerts (NGI0) [this message]
2025-11-13 12:33 ` [PATCH mptcp-next] Squash to "selftests: mptcp: get stats just before timing out" MPTCP CI
2025-11-14  1:30 ` Geliang Tang
2025-11-14  9:22   ` Matthieu Baerts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251113-slft-timeout-stats-kill-v1-1-9a09d8f46392@kernel.org \
    --to=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox