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 4/5] selftests: mptcp: join: dump stats from history
Date: Mon, 03 Nov 2025 20:19:34 +0100	[thread overview]
Message-ID: <20251103-slft-nstat-cache-v1-4-56025c09e56a@kernel.org> (raw)
In-Reply-To: <20251103-slft-nstat-cache-v1-0-56025c09e56a@kernel.org>

In case of errors, dump the stats from history instead of using nstat.

There are multiple advantages to that:

- The same filters from pr_err_stats are used, e.g. the unused 'rate'
  column is not displayed.

- The counters are closer to the ones from when the test stopped.

- While at it, the errors can be better presented: error colours, a
  small indentation to distinguish the different parts, extra new lines.

Even if it should only happen in rare cases -- internal errors, or netns
issues -- if no history is available, 'nstat' is used like before, just
in case.

Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 16 ++++++++++++----
 tools/testing/selftests/net/mptcp/mptcp_lib.sh  |  6 +++++-
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index ad0981e0b377..6afcf6ad2788 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -1163,12 +1163,20 @@ run_tests()
 	do_transfer ${listener_ns} ${connector_ns} MPTCP MPTCP ${connect_addr}
 }
 
+_dump_stats()
+{
+	local ns="${1}"
+	local side="${2}"
+
+	mptcp_lib_print_err "${side} ns stats (${ns2})"
+	mptcp_lib_pr_nstat "${ns}"
+	echo
+}
+
 dump_stats()
 {
-	echo Server ns stats
-	ip netns exec $ns1 nstat -as | grep Tcp
-	echo Client ns stats
-	ip netns exec $ns2 nstat -as | grep Tcp
+	_dump_stats "${ns1}" "Server"
+	_dump_stats "${ns2}" "Client"
 }
 
 chk_csum_nr()
diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index f59268b25707..603f33885f8e 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -110,7 +110,11 @@ mptcp_lib_pr_nstat() {
 	local ns="${1}"
 	local hist="/tmp/${ns}.out"
 
-	cat "${hist}"
+	if [ -f "${hist}" ]; then
+		awk '{ print "  "$0 }' "${hist}"
+	else
+		ip netns exec "${ns}" nstat -as | grep Tcp
+	fi
 }
 
 # $1-2: listener/connector ns ; $3 port

-- 
2.51.0


  parent reply	other threads:[~2025-11-03 19:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-03 19:19 [PATCH mptcp-next 0/5] selftests: mptcp: get counters from nstat history Matthieu Baerts (NGI0)
2025-11-03 19:19 ` [PATCH mptcp-next 1/5] selftests: mptcp: lib: introduce 'nstat_{init,get}' Matthieu Baerts (NGI0)
2025-11-03 19:19 ` [PATCH mptcp-next 2/5] selftests: mptcp: lib: remove stats files args Matthieu Baerts (NGI0)
2025-11-03 19:19 ` [PATCH mptcp-next 3/5] selftests: mptcp: lib: stats: remove nstat rate columns Matthieu Baerts (NGI0)
2025-11-03 19:19 ` Matthieu Baerts (NGI0) [this message]
2025-11-03 19:19 ` [PATCH mptcp-next 5/5] selftests: mptcp: lib: get counters from nstat history Matthieu Baerts (NGI0)
2025-11-03 20:58 ` [PATCH mptcp-next 0/5] selftests: mptcp: " MPTCP CI
2025-11-04 21:13   ` Paolo Abeni
2025-11-05 10:58     ` 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=20251103-slft-nstat-cache-v1-4-56025c09e56a@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