[PATCH mptcp-next v4 2/6] selftests: mptcp: rename ns to _ns in get_counter

Geliang Tang posted 6 patches 3 months, 3 weeks ago
There is a newer version of this series
[PATCH mptcp-next v4 2/6] selftests: mptcp: rename ns to _ns in get_counter
Posted by Geliang Tang 3 months, 3 weeks ago
From: Geliang Tang <tanggeliang@kylinos.cn>

If "setup_ns ns" is used in diag.sh, it fails with errors:

 ./mptcp_lib.sh: line 289: local: ns: readonly variable
 13 ....chk 2 cestab                                  [ OK ]
 14 ....chk 2->0 msk in use after flush               [ OK ]

That is because "ns" is also a local variable in mptcp_lib_get_counter.
To solve this, this patch renames it as "_ns".

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 tools/testing/selftests/net/mptcp/mptcp_lib.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index 6ffa9b7a3260..3397bf511f41 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -312,11 +312,11 @@ mptcp_lib_is_v6() {
 
 # $1: ns, $2: MIB counter
 mptcp_lib_get_counter() {
-	local ns="${1}"
+	local _ns="${1}"
 	local counter="${2}"
 	local count
 
-	count=$(ip netns exec "${ns}" nstat -asz "${counter}" |
+	count=$(ip netns exec "${_ns}" nstat -asz "${counter}" |
 		awk 'NR==1 {next} {print $2}')
 	if [ -z "${count}" ]; then
 		mptcp_lib_fail_if_expected_feature "${counter} counter"
-- 
2.43.0
Re: [PATCH mptcp-next v4 2/6] selftests: mptcp: rename ns to _ns in get_counter
Posted by Matthieu Baerts 3 months, 3 weeks ago
Hi Geliang,

On 24/05/2024 08:48, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> If "setup_ns ns" is used in diag.sh, it fails with errors:
> 
>  ./mptcp_lib.sh: line 289: local: ns: readonly variable

Mmh, that's due to Bash not allowing local variables with the same name
as readonly ones. Maybe we can avoid using the "readonly" variable,
because we use 'ns' in many other helpers in mptcp_lib.sh, let me check
that, I will come back to you later.

>  13 ....chk 2 cestab                                  [ OK ]
>  14 ....chk 2->0 msk in use after flush               [ OK ]
> 
> That is because "ns" is also a local variable in mptcp_lib_get_counter.
> To solve this, this patch renames it as "_ns".
Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.