selftests: mptcp: use += operator to append strings

This patch uses addition assignment operator (+=) to append strings
instead of duplicating the variable name in mptcp_connect.sh and
mptcp_join.sh.

This can make the statements shorter.

Note: in mptcp_connect.sh, add a local variable extra in do_transfer to
save the various extra warning logs, using += to append it. And add a
new variable tc_info to save various tc info, also using += to append it.
This can make the code more readable and prepare for the next commit.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://lore.kernel.org/r/20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-8-4f42c347b653@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Geliang Tang 2024-03-08 23:10:15 +01:00 committed by Jakub Kicinski
parent aa7694766f
commit e7c42bf4d3
2 changed files with 43 additions and 40 deletions

View File

@ -323,15 +323,15 @@ do_transfer()
port=$((port + 1))
if [ "$rcvbuf" -gt 0 ]; then
extra_args="$extra_args -R $rcvbuf"
extra_args+=" -R $rcvbuf"
fi
if [ "$sndbuf" -gt 0 ]; then
extra_args="$extra_args -S $sndbuf"
extra_args+=" -S $sndbuf"
fi
if [ -n "$testmode" ]; then
extra_args="$extra_args -m $testmode"
extra_args+=" -m $testmode"
fi
if [ -n "$extra_args" ] && $options_log; then
@ -451,6 +451,7 @@ do_transfer()
mptcp_lib_check_transfer $cin $sout "file received by server"
rets=$?
local extra=""
local stat_synrx_now_l
local stat_ackrx_now_l
local stat_cookietx_now
@ -484,7 +485,7 @@ do_transfer()
"${stat_ackrx_now_l}" "${expect_ackrx}"
rets=1
else
printf "[ Note ] fallback due to TCP OoO"
extra+=" [ Note ] fallback due to TCP OoO"
fi
fi
@ -507,39 +508,41 @@ do_transfer()
fi
fi
if [ $retc -eq 0 ] && [ $rets -eq 0 ]; then
printf "[ OK ]"
mptcp_lib_result_pass "${TEST_GROUP}: ${result_msg}"
else
mptcp_lib_result_fail "${TEST_GROUP}: ${result_msg}"
fi
if [ $cookies -eq 2 ];then
if [ $stat_cookietx_last -ge $stat_cookietx_now ] ;then
printf " WARN: CookieSent: did not advance"
extra+=" WARN: CookieSent: did not advance"
fi
if [ $stat_cookierx_last -ge $stat_cookierx_now ] ;then
printf " WARN: CookieRecv: did not advance"
extra+=" WARN: CookieRecv: did not advance"
fi
else
if [ $stat_cookietx_last -ne $stat_cookietx_now ] ;then
printf " WARN: CookieSent: changed"
extra+=" WARN: CookieSent: changed"
fi
if [ $stat_cookierx_last -ne $stat_cookierx_now ] ;then
printf " WARN: CookieRecv: changed"
extra+=" WARN: CookieRecv: changed"
fi
fi
if [ ${stat_synrx_now_l} -gt ${expect_synrx} ]; then
printf " WARN: SYNRX: expect %d, got %d (probably retransmissions)" \
"${expect_synrx}" "${stat_synrx_now_l}"
extra+=" WARN: SYNRX: expect ${expect_synrx},"
extra+=" got ${stat_synrx_now_l} (probably retransmissions)"
fi
if [ ${stat_ackrx_now_l} -gt ${expect_ackrx} ]; then
printf " WARN: ACKRX: expect %d, got %d (probably retransmissions)" \
"${expect_ackrx}" "${stat_ackrx_now_l}"
extra+=" WARN: ACKRX: expect ${expect_ackrx},"
extra+=" got ${stat_ackrx_now_l} (probably retransmissions)"
fi
if [ $retc -eq 0 ] && [ $rets -eq 0 ]; then
printf "[ OK ]%s\n" "${extra:1}"
mptcp_lib_result_pass "${TEST_GROUP}: ${result_msg}"
else
if [ -n "${extra}" ]; then
printf "%s\n" "${extra:1}"
fi
mptcp_lib_result_fail "${TEST_GROUP}: ${result_msg}"
fi
echo
cat "$capout"
[ $retc -eq 0 ] && [ $rets -eq 0 ]
}
@ -865,8 +868,8 @@ stop_if_error "Could not even run ping tests"
echo "[ OK ]"
[ -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 "
test "$tc_delay" -gt 0 && echo -n "delay $tc_delay ms "
tc_info="loss of $tc_loss "
test "$tc_delay" -gt 0 && tc_info+="delay $tc_delay ms "
reorder_delay=$((tc_delay / 4))
@ -877,17 +880,17 @@ if [ -z "${tc_reorder}" ]; then
if [ $reorder_delay -gt 0 ] && [ $reorder1 -lt 100 ] && [ $reorder2 -gt 0 ]; then
tc_reorder="reorder ${reorder1}% ${reorder2}%"
echo -n "$tc_reorder with delay ${reorder_delay}ms "
tc_info+="$tc_reorder with delay ${reorder_delay}ms "
fi
elif [ "$tc_reorder" = "0" ];then
tc_reorder=""
elif [ "$reorder_delay" -gt 0 ];then
# reordering requires some delay
tc_reorder="reorder $tc_reorder"
echo -n "$tc_reorder with delay ${reorder_delay}ms "
tc_info+="$tc_reorder with delay ${reorder_delay}ms "
fi
echo "on ns3eth4"
echo "INFO: Using ${tc_info}on ns3eth4"
tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${reorder_delay}ms $tc_reorder

View File

@ -754,18 +754,18 @@ pm_nl_check_endpoint()
line="${line% }"
# the dump order is: address id flags port dev
[ -n "$addr" ] && expected_line="$addr"
expected_line="$expected_line $id"
[ -n "$_flags" ] && expected_line="$expected_line ${_flags//","/" "}"
[ -n "$dev" ] && expected_line="$expected_line $dev"
[ -n "$port" ] && expected_line="$expected_line $port"
expected_line+=" $id"
[ -n "$_flags" ] && expected_line+=" ${_flags//","/" "}"
[ -n "$dev" ] && expected_line+=" $dev"
[ -n "$port" ] && expected_line+=" $port"
else
line=$(ip netns exec $ns ./pm_nl_ctl get $_id)
# the dump order is: id flags dev address port
expected_line="$id"
[ -n "$flags" ] && expected_line="$expected_line $flags"
[ -n "$dev" ] && expected_line="$expected_line $dev"
[ -n "$addr" ] && expected_line="$expected_line $addr"
[ -n "$_port" ] && expected_line="$expected_line $_port"
[ -n "$flags" ] && expected_line+=" $flags"
[ -n "$dev" ] && expected_line+=" $dev"
[ -n "$addr" ] && expected_line+=" $addr"
[ -n "$_port" ] && expected_line+=" $_port"
fi
if [ "$line" = "$expected_line" ]; then
print_ok
@ -1216,7 +1216,7 @@ chk_csum_nr()
print_check "sum"
count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtDataCsumErr")
if [ "$count" != "$csum_ns1" ]; then
extra_msg="$extra_msg ns1=$count"
extra_msg+=" ns1=$count"
fi
if [ -z "$count" ]; then
print_skip
@ -1229,7 +1229,7 @@ chk_csum_nr()
print_check "csum"
count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtDataCsumErr")
if [ "$count" != "$csum_ns2" ]; then
extra_msg="$extra_msg ns2=$count"
extra_msg+=" ns2=$count"
fi
if [ -z "$count" ]; then
print_skip
@ -1273,7 +1273,7 @@ chk_fail_nr()
print_check "ftx"
count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPFailTx")
if [ "$count" != "$fail_tx" ]; then
extra_msg="$extra_msg,tx=$count"
extra_msg+=",tx=$count"
fi
if [ -z "$count" ]; then
print_skip
@ -1287,7 +1287,7 @@ chk_fail_nr()
print_check "failrx"
count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtMPFailRx")
if [ "$count" != "$fail_rx" ]; then
extra_msg="$extra_msg,rx=$count"
extra_msg+=",rx=$count"
fi
if [ -z "$count" ]; then
print_skip
@ -1322,7 +1322,7 @@ chk_fclose_nr()
if [ -z "$count" ]; then
print_skip
elif [ "$count" != "$fclose_tx" ]; then
extra_msg="$extra_msg,tx=$count"
extra_msg+=",tx=$count"
fail_test "got $count MP_FASTCLOSE[s] TX expected $fclose_tx"
else
print_ok
@ -1333,7 +1333,7 @@ chk_fclose_nr()
if [ -z "$count" ]; then
print_skip
elif [ "$count" != "$fclose_rx" ]; then
extra_msg="$extra_msg,rx=$count"
extra_msg+=",rx=$count"
fail_test "got $count MP_FASTCLOSE[s] RX expected $fclose_rx"
else
print_ok
@ -1702,7 +1702,7 @@ chk_rm_nr()
count=$((count + cnt))
if [ "$count" != "$rm_subflow_nr" ]; then
suffix="$count in [$rm_subflow_nr:$((rm_subflow_nr*2))]"
extra_msg="$extra_msg simult"
extra_msg+=" simult"
fi
if [ $count -ge "$rm_subflow_nr" ] && \
[ "$count" -le "$((rm_subflow_nr *2 ))" ]; then