[PATCH RESEND mptcp-next v2 2/9] selftests: mptcp: rewrite backup tests

Geliang Tang posted 9 patches 4 years, 1 month ago
Maintainers: Jakub Kicinski <kuba@kernel.org>, Shuah Khan <shuah@kernel.org>, Matthieu Baerts <matthieu.baerts@tessares.net>, "David S. Miller" <davem@davemloft.net>, Mat Martineau <mathew.j.martineau@linux.intel.com>
There is a newer version of this series
[PATCH RESEND mptcp-next v2 2/9] selftests: mptcp: rewrite backup tests
Posted by Geliang Tang 4 years, 1 month ago
The original code in the backup tests only works for the output of
'pm_nl_ctl dump'. It chooses the last item in the endpoints dump
table to parse the address in it, and the address is always showed
at the end of the item.

But it dosen't work for the output of 'ip mptcp endpoint show', the
address is always showed at the front of the item. This patch rewrites
the backup tests to fit for the 'ip mptcp' output.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index b41126d4b1c6..b8c21d0b8919 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -475,12 +475,14 @@ do_transfer()
 	if [ ! -z $bkup ]; then
 		sleep 1
 		for netns in "$ns1" "$ns2"; do
-			dump=(`ip netns exec $netns ./pm_nl_ctl dump`)
-			if [ ${#dump[@]} -gt 0 ]; then
-				addr=${dump[${#dump[@]} - 1]}
-				backup="ip netns exec $netns ./pm_nl_ctl set $addr flags $bkup"
-				$backup
-			fi
+			ip netns exec $netns ./pm_nl_ctl dump | while read line; do
+				local arr=($line)
+				# 'pm_nl_ctl' shows the address at the end
+				let pos=${#arr[@]}-1
+
+				addr=${arr[$pos]}
+				ip netns exec $netns ./pm_nl_ctl set $addr flags $bkup
+			done
 		done
 	fi
 
-- 
2.31.1