All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthieu Baerts <matttbe@kernel.org>
To: Geliang Tang <geliang@kernel.org>, mptcp@lists.linux.dev
Cc: Geliang Tang <tanggeliang@kylinos.cn>
Subject: Re: [PATCH mptcp-next v7 7/8] selftests: mptcp: print test results with counters
Date: Thu, 29 Feb 2024 13:44:58 +0100	[thread overview]
Message-ID: <b40889a0-9739-4785-93aa-768ee2c25bc1@kernel.org> (raw)
In-Reply-To: <2328092277b37a0b02084860109840f91f128137.1709200070.git.tanggeliang@kylinos.cn>

Hi Geliang,

On 29/02/2024 10:51, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> This patch adds a new helper mptcp_lib_print_title(), a wrapper of
> mptcp_lib_inc_test_counter() and mptcp_lib_pr_title_counter(), to
> print out test counter in each test result and increase the counter.
> Use this helper to print out test counters for every tests in diag.sh,
> mptcp_connect.sh, mptcp_sockopt.sh, pm_netlink.sh, simult_flows.sh,
> and userspace_pm.sh.

(...)

> Having test counters helps to quickly identify issues when looking at a
> long list of output logs and results.

Nice!

(...)

> diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> index 77b0b9d5aca0..096ff8941c5b 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> @@ -131,7 +131,6 @@ ns2=""
>  ns3=""
>  ns4=""
>  
> -TEST_COUNT=0
>  TEST_GROUP=""
>  
>  # This function is used in the cleanup trap
> @@ -253,6 +252,7 @@ check_mptcp_disabled()
>  	local disabled_ns
>  	mptcp_lib_ns_init disabled_ns
>  
> +	mptcp_lib_print_title "New MPTCP socket can be blocked via sysctl"

Because you have 2 exceptions (larger titles), maybe best to use a helper:

  print_larger_title() {
      # here we don't have the time, a bit longer for the alignment
      MPTCP_LIB_TEST_FORMAT="%02u %-69s" \
          mptcp_lib_print_title "${@}"
  }

>  	# net.mptcp.enabled should be enabled by default
>  	if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ print $3 }')" -ne 1 ]; then
>  		echo -e "net.mptcp.enabled sysctl is not 1 by default\t\t[ FAIL ]"

(...)

> @@ -830,6 +828,7 @@ stop_if_error()
>  	fi
>  }
>  
> +MPTCP_LIB_TEST_FORMAT="%02u %-69s"

... so you don't have to set it here ...

>  make_file "$cin" "client"
>  make_file "$sin" "server"
>  
> @@ -837,7 +836,7 @@ check_mptcp_disabled
>  
>  stop_if_error "The kernel configuration is not valid for MPTCP"
>  
> -printf "%-69s" "Validating network environment with pings"
> +mptcp_lib_print_title "Validating network environment with pings"

(print_larger_title → clearer)

>  for sender in "$ns1" "$ns2" "$ns3" "$ns4";do
>  	do_ping "$ns1" $sender 10.0.1.1
>  	do_ping "$ns1" $sender dead:beef:1::1
> @@ -860,6 +859,7 @@ mptcp_lib_result_code "${ret}" "ping tests"
>  
>  stop_if_error "Could not even run ping tests"
>  echo "[ OK ]"
> +MPTCP_LIB_TEST_FORMAT="%02u %-50s"

... and here, just to handle 2 exceptions, and it is not clear which
format will be used.

>  
>  [ -n "$tc_loss" ] && tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $tc_loss delay ${tc_delay}ms
>  echo -n "INFO: Using loss of $tc_loss "

(...)

> diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
> index ae59136b5bb4..a797e13d3fe7 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
> @@ -161,6 +161,7 @@ do_transfer()
>  	wait $spid
>  	local rets=$?
>  
> +	mptcp_lib_print_title "Transfer ${ip}"

Please add a note in the commit message explaining that
'mptcp_sockopt.sh' now display more detailed results + why (what you had
in a former patch from v6, merged here).

(Note: to replace patch 5/8, you can also use '${ip:2}' here, maybe
prettier? A detail...)

>  	if [ ${rets} -ne 0 ] || [ ${retc} -ne 0 ]; then
>  		echo " client exit code $retc, server $rets" 1>&2
>  		echo -e "\nnetns ${listener_ns} socket stat for ${port}:" 1>&2
> @@ -174,7 +175,9 @@ do_transfer()
>  		ret=1
>  		return 1
>  	fi
> +	echo "[ OK ]"
>  
> +	mptcp_lib_print_title "Mark ${ip}"

(same here for '${ip:2}' if you want to)

>  	if [ $local_addr = "::" ];then
>  		check_mark $listener_ns 6 || retc=1
>  		check_mark $connector_ns 6 || retc=1
> @@ -190,8 +193,10 @@ do_transfer()
>  	mptcp_lib_result_code "${rets}" "transfer ${ip}"
>  
>  	if [ $retc -eq 0 ] && [ $rets -eq 0 ];then
> +		echo "[ OK ]"
>  		return 0
>  	fi
> +	echo "FAIL: Mark ${ip}"

I don't think you need to repeat 'Mark ${ip}', it is already in the
title, no?

>  
>  	return 1
>  }

(...)

> @@ -314,15 +324,7 @@ trap cleanup EXIT
>  run_tests $ns1 $ns2 10.0.1.1
>  run_tests $ns1 $ns2 dead:beef:1::1
>  
> -if [ $ret -eq 0 ];then
> -	echo "PASS: all packets had packet mark set"
> -fi
> -
>  do_mptcp_sockopt_tests
> -if [ $ret -eq 0 ];then
> -	echo "PASS: SOL_MPTCP getsockopt has expected information"
> -fi

Please also mention in the commit message that it no longer displays
'PASS:', because it is duplicated info now that the detailed are displayed.

> -
>  do_tcpinq_tests
>  
>  mptcp_lib_result_print_all_tap

(...)

> diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh
> index d5f8521b88d5..212782301c6f 100755
> --- a/tools/testing/selftests/net/mptcp/simult_flows.sh
> +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh

(...)

> @@ -205,6 +203,12 @@ do_transfer()
>  	return 1
>  }
>  
> +print_title()
> +{
> +	MPTCP_LIB_TEST_FORMAT="%02u %-55s"

Same here, can be set once above, at the beginning of the file (with a
small comment explaining why we need a bit more space: because we have
more to display :) )

> +	mptcp_lib_print_title "${*}"
> +}
> +
>  run_test()
>  {
>  	local rate1=$1
> @@ -239,7 +243,7 @@ run_test()
>  	# completion (see mptcp_connect): 200ms on each side, add some slack
>  	time=$((time + 400 + slack))
>  
> -	printf "%-60s" "$msg"
> +	print_title "$msg"
>  	do_transfer $small $large $time
>  	lret=$?
>  	mptcp_lib_result_code "${lret}" "${msg}"
> @@ -249,7 +253,7 @@ run_test()
>  	fi
>  
>  	msg+=" - reverse direction"
> -	printf "%-60s" "$(echo -n ${msg} | cut -c1-54)"
> +	print_title "$(echo -n ${msg} | cut -c1-54)"

As discussed on a previous patch, I think it is best not to cut the
title. (and if we had to, best to do that in the helper, not here)

>  	do_transfer $large $small $time
>  	lret=$?
>  	mptcp_lib_result_code "${lret}" "${msg}"

(...)

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

  reply	other threads:[~2024-02-29 12:45 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29  9:51 [PATCH mptcp-next v7 0/8] add helpers and vars in mptcp_lib.sh, part 3 Geliang Tang
2024-02-29  9:51 ` [PATCH mptcp-net v7 1/8] selftests: mptcp: diag: return KSFT_FAIL not test_cnt Geliang Tang
2024-02-29 10:51   ` Matthieu Baerts
2024-02-29  9:51 ` [PATCH mptcp-next v7 2/8] selftests: mptcp: connect: add dedicated port counter Geliang Tang
2024-02-29 11:23   ` Matthieu Baerts
2024-02-29 12:18     ` Geliang Tang
2024-02-29 12:22       ` Matthieu Baerts
2024-03-01  7:01         ` Geliang Tang
2024-02-29  9:51 ` [PATCH mptcp-next v7 3/8] selftests: mptcp: connect: fix misaligned output Geliang Tang
2024-02-29  9:51 ` [PATCH mptcp-next v7 4/8] selftests: mptcp: simult_flows: " Geliang Tang
2024-02-29 10:07   ` Geliang Tang
2024-02-29 10:27     ` Matthieu Baerts
2024-02-29 12:01       ` Geliang Tang
2024-02-29 12:18         ` Matthieu Baerts
2024-02-29 14:35           ` Matthieu Baerts
2024-02-29  9:51 ` [PATCH mptcp-next v7 5/8] selftests: mptcp: sockopt: unify ipv4/ipv6 as v4/v6 Geliang Tang
2024-02-29 11:31   ` Matthieu Baerts
2024-02-29 12:08     ` Geliang Tang
2024-02-29 12:20       ` Matthieu Baerts
2024-02-29  9:51 ` [PATCH mptcp-next v7 6/8] selftests: mptcp: add test counter helpers Geliang Tang
2024-02-29 11:58   ` Matthieu Baerts
2024-02-29 12:03     ` Matthieu Baerts
2024-02-29 12:28     ` Matthieu Baerts
2024-03-01  7:03       ` Geliang Tang
2024-02-29  9:51 ` [PATCH mptcp-next v7 7/8] selftests: mptcp: print test results with counters Geliang Tang
2024-02-29 12:44   ` Matthieu Baerts [this message]
2024-02-29  9:51 ` [PATCH mptcp-next v7 8/8] selftests: mptcp: print test results with colors Geliang Tang
2024-02-29 10:43   ` selftests: mptcp: print test results with colors: Tests Results MPTCP CI
2024-02-29 13:04   ` [PATCH mptcp-next v7 8/8] selftests: mptcp: print test results with colors Matthieu Baerts
2024-03-01  7:16     ` Geliang Tang
2024-03-04 11:12       ` 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=b40889a0-9739-4785-93aa-768ee2c25bc1@kernel.org \
    --to=matttbe@kernel.org \
    --cc=geliang@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=tanggeliang@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.