Commit e7c42bf4 authored by Geliang Tang's avatar Geliang Tang Committed by Jakub Kicinski

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: default avatarGeliang Tang <tanggeliang@kylinos.cn>
Reviewed-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://lore.kernel.org/r/20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-8-4f42c347b653@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent aa769476
...@@ -323,15 +323,15 @@ do_transfer() ...@@ -323,15 +323,15 @@ do_transfer()
port=$((port + 1)) port=$((port + 1))
if [ "$rcvbuf" -gt 0 ]; then if [ "$rcvbuf" -gt 0 ]; then
extra_args="$extra_args -R $rcvbuf" extra_args+=" -R $rcvbuf"
fi fi
if [ "$sndbuf" -gt 0 ]; then if [ "$sndbuf" -gt 0 ]; then
extra_args="$extra_args -S $sndbuf" extra_args+=" -S $sndbuf"
fi fi
if [ -n "$testmode" ]; then if [ -n "$testmode" ]; then
extra_args="$extra_args -m $testmode" extra_args+=" -m $testmode"
fi fi
if [ -n "$extra_args" ] && $options_log; then if [ -n "$extra_args" ] && $options_log; then
...@@ -451,6 +451,7 @@ do_transfer() ...@@ -451,6 +451,7 @@ do_transfer()
mptcp_lib_check_transfer $cin $sout "file received by server" mptcp_lib_check_transfer $cin $sout "file received by server"
rets=$? rets=$?
local extra=""
local stat_synrx_now_l local stat_synrx_now_l
local stat_ackrx_now_l local stat_ackrx_now_l
local stat_cookietx_now local stat_cookietx_now
...@@ -484,7 +485,7 @@ do_transfer() ...@@ -484,7 +485,7 @@ do_transfer()
"${stat_ackrx_now_l}" "${expect_ackrx}" "${stat_ackrx_now_l}" "${expect_ackrx}"
rets=1 rets=1
else else
printf "[ Note ] fallback due to TCP OoO" extra+=" [ Note ] fallback due to TCP OoO"
fi fi
fi fi
...@@ -507,39 +508,41 @@ do_transfer() ...@@ -507,39 +508,41 @@ do_transfer()
fi fi
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 [ $cookies -eq 2 ];then
if [ $stat_cookietx_last -ge $stat_cookietx_now ] ;then if [ $stat_cookietx_last -ge $stat_cookietx_now ] ;then
printf " WARN: CookieSent: did not advance" extra+=" WARN: CookieSent: did not advance"
fi fi
if [ $stat_cookierx_last -ge $stat_cookierx_now ] ;then if [ $stat_cookierx_last -ge $stat_cookierx_now ] ;then
printf " WARN: CookieRecv: did not advance" extra+=" WARN: CookieRecv: did not advance"
fi fi
else else
if [ $stat_cookietx_last -ne $stat_cookietx_now ] ;then if [ $stat_cookietx_last -ne $stat_cookietx_now ] ;then
printf " WARN: CookieSent: changed" extra+=" WARN: CookieSent: changed"
fi fi
if [ $stat_cookierx_last -ne $stat_cookierx_now ] ;then if [ $stat_cookierx_last -ne $stat_cookierx_now ] ;then
printf " WARN: CookieRecv: changed" extra+=" WARN: CookieRecv: changed"
fi fi
fi fi
if [ ${stat_synrx_now_l} -gt ${expect_synrx} ]; then if [ ${stat_synrx_now_l} -gt ${expect_synrx} ]; then
printf " WARN: SYNRX: expect %d, got %d (probably retransmissions)" \ extra+=" WARN: SYNRX: expect ${expect_synrx},"
"${expect_synrx}" "${stat_synrx_now_l}" extra+=" got ${stat_synrx_now_l} (probably retransmissions)"
fi fi
if [ ${stat_ackrx_now_l} -gt ${expect_ackrx} ]; then if [ ${stat_ackrx_now_l} -gt ${expect_ackrx} ]; then
printf " WARN: ACKRX: expect %d, got %d (probably retransmissions)" \ extra+=" WARN: ACKRX: expect ${expect_ackrx},"
"${expect_ackrx}" "${stat_ackrx_now_l}" 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 fi
echo
cat "$capout" cat "$capout"
[ $retc -eq 0 ] && [ $rets -eq 0 ] [ $retc -eq 0 ] && [ $rets -eq 0 ]
} }
...@@ -865,8 +868,8 @@ stop_if_error "Could not even run ping tests" ...@@ -865,8 +868,8 @@ stop_if_error "Could not even run ping tests"
echo "[ OK ]" echo "[ OK ]"
[ -n "$tc_loss" ] && tc -net "$ns2" qdisc add dev ns2eth3 root netem loss random $tc_loss delay ${tc_delay}ms [ -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 " tc_info="loss of $tc_loss "
test "$tc_delay" -gt 0 && echo -n "delay $tc_delay ms " test "$tc_delay" -gt 0 && tc_info+="delay $tc_delay ms "
reorder_delay=$((tc_delay / 4)) reorder_delay=$((tc_delay / 4))
...@@ -877,17 +880,17 @@ if [ -z "${tc_reorder}" ]; then ...@@ -877,17 +880,17 @@ if [ -z "${tc_reorder}" ]; then
if [ $reorder_delay -gt 0 ] && [ $reorder1 -lt 100 ] && [ $reorder2 -gt 0 ]; then if [ $reorder_delay -gt 0 ] && [ $reorder1 -lt 100 ] && [ $reorder2 -gt 0 ]; then
tc_reorder="reorder ${reorder1}% ${reorder2}%" tc_reorder="reorder ${reorder1}% ${reorder2}%"
echo -n "$tc_reorder with delay ${reorder_delay}ms " tc_info+="$tc_reorder with delay ${reorder_delay}ms "
fi fi
elif [ "$tc_reorder" = "0" ];then elif [ "$tc_reorder" = "0" ];then
tc_reorder="" tc_reorder=""
elif [ "$reorder_delay" -gt 0 ];then elif [ "$reorder_delay" -gt 0 ];then
# reordering requires some delay # reordering requires some delay
tc_reorder="reorder $tc_reorder" tc_reorder="reorder $tc_reorder"
echo -n "$tc_reorder with delay ${reorder_delay}ms " tc_info+="$tc_reorder with delay ${reorder_delay}ms "
fi 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 tc -net "$ns3" qdisc add dev ns3eth4 root netem delay ${reorder_delay}ms $tc_reorder
......
...@@ -754,18 +754,18 @@ pm_nl_check_endpoint() ...@@ -754,18 +754,18 @@ pm_nl_check_endpoint()
line="${line% }" line="${line% }"
# the dump order is: address id flags port dev # the dump order is: address id flags port dev
[ -n "$addr" ] && expected_line="$addr" [ -n "$addr" ] && expected_line="$addr"
expected_line="$expected_line $id" expected_line+=" $id"
[ -n "$_flags" ] && expected_line="$expected_line ${_flags//","/" "}" [ -n "$_flags" ] && expected_line+=" ${_flags//","/" "}"
[ -n "$dev" ] && expected_line="$expected_line $dev" [ -n "$dev" ] && expected_line+=" $dev"
[ -n "$port" ] && expected_line="$expected_line $port" [ -n "$port" ] && expected_line+=" $port"
else else
line=$(ip netns exec $ns ./pm_nl_ctl get $_id) line=$(ip netns exec $ns ./pm_nl_ctl get $_id)
# the dump order is: id flags dev address port # the dump order is: id flags dev address port
expected_line="$id" expected_line="$id"
[ -n "$flags" ] && expected_line="$expected_line $flags" [ -n "$flags" ] && expected_line+=" $flags"
[ -n "$dev" ] && expected_line="$expected_line $dev" [ -n "$dev" ] && expected_line+=" $dev"
[ -n "$addr" ] && expected_line="$expected_line $addr" [ -n "$addr" ] && expected_line+=" $addr"
[ -n "$_port" ] && expected_line="$expected_line $_port" [ -n "$_port" ] && expected_line+=" $_port"
fi fi
if [ "$line" = "$expected_line" ]; then if [ "$line" = "$expected_line" ]; then
print_ok print_ok
...@@ -1216,7 +1216,7 @@ chk_csum_nr() ...@@ -1216,7 +1216,7 @@ chk_csum_nr()
print_check "sum" print_check "sum"
count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtDataCsumErr") count=$(mptcp_lib_get_counter ${ns1} "MPTcpExtDataCsumErr")
if [ "$count" != "$csum_ns1" ]; then if [ "$count" != "$csum_ns1" ]; then
extra_msg="$extra_msg ns1=$count" extra_msg+=" ns1=$count"
fi fi
if [ -z "$count" ]; then if [ -z "$count" ]; then
print_skip print_skip
...@@ -1229,7 +1229,7 @@ chk_csum_nr() ...@@ -1229,7 +1229,7 @@ chk_csum_nr()
print_check "csum" print_check "csum"
count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtDataCsumErr") count=$(mptcp_lib_get_counter ${ns2} "MPTcpExtDataCsumErr")
if [ "$count" != "$csum_ns2" ]; then if [ "$count" != "$csum_ns2" ]; then
extra_msg="$extra_msg ns2=$count" extra_msg+=" ns2=$count"
fi fi
if [ -z "$count" ]; then if [ -z "$count" ]; then
print_skip print_skip
...@@ -1273,7 +1273,7 @@ chk_fail_nr() ...@@ -1273,7 +1273,7 @@ chk_fail_nr()
print_check "ftx" print_check "ftx"
count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPFailTx") count=$(mptcp_lib_get_counter ${ns_tx} "MPTcpExtMPFailTx")
if [ "$count" != "$fail_tx" ]; then if [ "$count" != "$fail_tx" ]; then
extra_msg="$extra_msg,tx=$count" extra_msg+=",tx=$count"
fi fi
if [ -z "$count" ]; then if [ -z "$count" ]; then
print_skip print_skip
...@@ -1287,7 +1287,7 @@ chk_fail_nr() ...@@ -1287,7 +1287,7 @@ chk_fail_nr()
print_check "failrx" print_check "failrx"
count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtMPFailRx") count=$(mptcp_lib_get_counter ${ns_rx} "MPTcpExtMPFailRx")
if [ "$count" != "$fail_rx" ]; then if [ "$count" != "$fail_rx" ]; then
extra_msg="$extra_msg,rx=$count" extra_msg+=",rx=$count"
fi fi
if [ -z "$count" ]; then if [ -z "$count" ]; then
print_skip print_skip
...@@ -1322,7 +1322,7 @@ chk_fclose_nr() ...@@ -1322,7 +1322,7 @@ chk_fclose_nr()
if [ -z "$count" ]; then if [ -z "$count" ]; then
print_skip print_skip
elif [ "$count" != "$fclose_tx" ]; then 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" fail_test "got $count MP_FASTCLOSE[s] TX expected $fclose_tx"
else else
print_ok print_ok
...@@ -1333,7 +1333,7 @@ chk_fclose_nr() ...@@ -1333,7 +1333,7 @@ chk_fclose_nr()
if [ -z "$count" ]; then if [ -z "$count" ]; then
print_skip print_skip
elif [ "$count" != "$fclose_rx" ]; then 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" fail_test "got $count MP_FASTCLOSE[s] RX expected $fclose_rx"
else else
print_ok print_ok
...@@ -1702,7 +1702,7 @@ chk_rm_nr() ...@@ -1702,7 +1702,7 @@ chk_rm_nr()
count=$((count + cnt)) count=$((count + cnt))
if [ "$count" != "$rm_subflow_nr" ]; then if [ "$count" != "$rm_subflow_nr" ]; then
suffix="$count in [$rm_subflow_nr:$((rm_subflow_nr*2))]" suffix="$count in [$rm_subflow_nr:$((rm_subflow_nr*2))]"
extra_msg="$extra_msg simult" extra_msg+=" simult"
fi fi
if [ $count -ge "$rm_subflow_nr" ] && \ if [ $count -ge "$rm_subflow_nr" ] && \
[ "$count" -le "$((rm_subflow_nr *2 ))" ]; then [ "$count" -le "$((rm_subflow_nr *2 ))" ]; then
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment