MPTCP Linux Development
 help / color / mirror / Atom feed
From: Matthieu Baerts <matttbe@kernel.org>
To: Gang Yan <yangang@kylinos.cn>, mptcp@lists.linux.dev
Subject: Re: [mptcp-next v3 2/2] selftests: mptcp: add a test for mptcp_diag_dump_one
Date: Fri, 21 Feb 2025 12:55:55 +0100	[thread overview]
Message-ID: <7e44ca4a-e1dc-43ce-a338-04ca918cb8da@kernel.org> (raw)
In-Reply-To: <3bce55e361d2d7cc9706db2ec1803cd3ef55791f.1740115494.git.yangang@kylinos.cn>

Hi Gang Yan,

On 21/02/2025 06:34, Gang Yan wrote:
> This patch introduces a new 'chk_diag' test in diag.sh. It retrieves
> the token for a specified MPTCP socket (msk) using the 'ss' command and
> then accesses the 'mptcp_diag_dump_one' in kernel via ./mptcp_diag
> to verify if the correct token is returned.
> 
> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/524

Before closing this ticket, did you check the new code was also covering
the 1st bullet point mentioned there?

 * subflow_get_info_size() from diag.c is not covered

> Signed-off-by: Gang Yan <yangang@kylinos.cn>
> ---
>  tools/testing/selftests/net/mptcp/diag.sh | 27 +++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh
> index 2bd0c1eb70c5..5c10fe406d91 100755
> --- a/tools/testing/selftests/net/mptcp/diag.sh
> +++ b/tools/testing/selftests/net/mptcp/diag.sh
> @@ -200,6 +200,32 @@ chk_msk_cestab()
>  		 "${expected}" "${msg}" ""
>  }
>  
> +chk_dump_one()
> +{
> +	local ss_token
> +	local token
> +	local msg
> +
> +	ss_token="$(ss -inmHMN $ns | grep 'token:' |\
> +		    head -n 1 |\
> +		    sed 's/.*token:\([0-9a-f]*\).*/\1/')"
> +
> +	token="$(ip netns exec $ns ./mptcp_diag -t $ss_token |\
> +		 awk -F':[ \t]+' '/^token/ {print $2}')"
> +
> +	msg="....chk dump_one"
> +
> +	mptcp_lib_print_title "$msg"
> +	if [ "$ss_token" != "$token" ]; then

detail: it sounds more logical to check if the result is correct first, no?

  if [ "$ss_token" = "$token" ]; then
      mptcp_lib_pr_ok
      mptcp_lib_result_pass "${msg}"
  else
      (...)
  fi

Also, just to be on the safe side, probably best to check that the
variables are not both empty, e.g. if both ss and mptcp_diag commands
are wrong or have issues.

  if [ -n "$ss_token" ] && [ "$ss_token" = "$token" ]; then
      mptcp_lib_pr_ok
      (...)
  fi

> +		mptcp_lib_pr_fail "expected $ss_token found $token"
> +		mptcp_lib_result_fail "${msg}"
> +		ret=${KSFT_FAIL}
> +	else
> +		mptcp_lib_pr_ok
> +		mptcp_lib_result_pass "${msg}"
> +	fi
> +}
> +
>  msk_info_get_value()
>  {
>  	local port="${1}"
> @@ -290,6 +316,7 @@ chk_msk_remote_key_nr 2 "....chk remote_key"
>  chk_msk_fallback_nr 0 "....chk no fallback"
>  chk_msk_inuse 2
>  chk_msk_cestab 2
> +chk_dump_one
>  flush_pids
>  
>  chk_msk_inuse 0 "2->0"
Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.


  reply	other threads:[~2025-02-21 11:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-21  5:34 [mptcp-next v3 0/2] selftests: mptcp: add tests for increasing Gang Yan
2025-02-21  5:34 ` [mptcp-next v3 1/2] selftests: mptcp: Add a tool to get specific msk_info Gang Yan
2025-02-21 11:55   ` Matthieu Baerts
2025-02-21  5:34 ` [mptcp-next v3 2/2] selftests: mptcp: add a test for mptcp_diag_dump_one Gang Yan
2025-02-21 11:55   ` Matthieu Baerts [this message]
2025-02-21  6:41 ` [mptcp-next v3 0/2] selftests: mptcp: add tests for increasing MPTCP CI
2025-02-21 11:54 ` 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=7e44ca4a-e1dc-43ce-a338-04ca918cb8da@kernel.org \
    --to=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=yangang@kylinos.cn \
    /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