[PATCH mptcp-net 3/3] selftests: mptcp: sockopt: fix variable check in error reporting

Geliang Tang posted 3 patches 2 weeks, 1 day ago
There is a newer version of this series
[PATCH mptcp-net 3/3] selftests: mptcp: sockopt: fix variable check in error reporting
Posted by Geliang Tang 2 weeks, 1 day ago
From: Geliang Tang <tanggeliang@kylinos.cn>

The error message for mptcpi_bytes_acked comparison incorrectly
references 'ret2' instead of 'ret'. Since the comparison is between
mptcpi_bytes_acked and 'ret', the error output should consistently
use 'ret' for both the expected value and difference calculation.

This patch corrects the variable usage in the error output to ensure
accurate debugging information when the assertion fails.

Fixes: 5dcff89e1455 ("selftests: mptcp: explicitly tests aggregate counters")
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
index 8d590629a8e9..a61508270a5c 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
@@ -680,8 +680,8 @@ static void process_one_client(int fd, int pipefd)
 			       s.last_sample.mptcpi_bytes_received - ret);
 		if (s.last_sample.mptcpi_bytes_acked != ret)
 			xerror("mptcpi_bytes_acked %" PRIu64 ", expect %" PRIu64,
-			       s.last_sample.mptcpi_bytes_acked, ret2,
-			       s.last_sample.mptcpi_bytes_acked - ret2);
+			       s.last_sample.mptcpi_bytes_acked, ret,
+			       s.last_sample.mptcpi_bytes_acked - ret);
 	}
 
 	close(fd);
-- 
2.48.1
Re: [PATCH mptcp-net 3/3] selftests: mptcp: sockopt: fix variable check in error reporting
Posted by Matthieu Baerts 2 weeks, 1 day ago
Hi Geliang,

On 02/09/2025 03:38, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> The error message for mptcpi_bytes_acked comparison incorrectly
> references 'ret2' instead of 'ret'. Since the comparison is between
> mptcpi_bytes_acked and 'ret', the error output should consistently
> use 'ret' for both the expected value and difference calculation.
> 
> This patch corrects the variable usage in the error output to ensure
> accurate debugging information when the assertion fails.
> 
> Fixes: 5dcff89e1455 ("selftests: mptcp: explicitly tests aggregate counters")
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
>  tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
> index 8d590629a8e9..a61508270a5c 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
> +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
> @@ -680,8 +680,8 @@ static void process_one_client(int fd, int pipefd)
>  			       s.last_sample.mptcpi_bytes_received - ret);
>  		if (s.last_sample.mptcpi_bytes_acked != ret)
>  			xerror("mptcpi_bytes_acked %" PRIu64 ", expect %" PRIu64,
> -			       s.last_sample.mptcpi_bytes_acked, ret2,
> -			       s.last_sample.mptcpi_bytes_acked - ret2);
> +			       s.last_sample.mptcpi_bytes_acked, ret,
> +			       s.last_sample.mptcpi_bytes_acked - ret);

Good catch! But I also just noticed there is one extra argument: you
have 2 "%", but 3 arguments after the string.

I guess the error should be:

  "mptcpi_bytes_acked %" PRIu64 ", expect %" PRIu64 ", diff %" PRIu64,
  (...)

(Same for the others above.) If yes, can you add this as part of the
same commit?

  selftests: mptcp: sockopt: fix error messages

(with a note about the fact the wrong variable was used)

>  	}
>  
>  	close(fd);

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.