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

selftests: mptcp: print test results with counters

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.

diag.sh:

01 no msk on netns creation                          [  ok  ]
02 listen match for dport 10000                      [  ok  ]
03 listen match for sport 10000                      [  ok  ]
04 listen match for saddr and sport                  [  ok  ]
05 all listen sockets                                [  ok  ]

mptcp_connect.sh:

01 New MPTCP socket can be blocked via sysctl                       [ OK ]
02 Validating network environment with pings                        [ OK ]
INFO: Using loss of 0.85% delay 31 ms reorder .. with delay 7ms on ns3eth4
03 ns1 MPTCP -> ns1 (10.0.1.1:10000  ) MPTCP     (duration    69ms) [ OK ]
04 ns1 MPTCP -> ns1 (10.0.1.1:10001  ) TCP       (duration    20ms) [ OK ]
05 ns1 TCP   -> ns1 (10.0.1.1:10002  ) MPTCP     (duration    16ms) [ OK ]

mptcp_sockopt.sh:

01 Transfer v4                                       [ OK ]
02 Mark v4                                           [ OK ]
03 Transfer v6                                       [ OK ]
04 Mark v6                                           [ OK ]
05 SOL_MPTCP sockopt v4                              [ OK ]

pm_netlink.sh:

01 defaults addr list                                [ OK ]
02 simple add/get addr                               [ OK ]
03 dump addrs                                        [ OK ]
04 simple del addr                                   [ OK ]
05 dump addrs after del                              [ OK ]

simult_flows.sh:

01 balanced bwidth                                     7391 max 8456 [ OK ]
02 balanced bwidth - reverse direction                 7403 max 8456 [ OK ]
03 balanced bwidth with unbalanced delay               7429 max 8456 [ OK ]
04 balanced bwidth with unbalanced delay - reverse ... 7485 max 8456 [ OK ]
05 unbalanced bwidth                                   7549 max 8456 [ OK ]

userspace_pm.sh:

01 Created network namespaces ns1, ns2                               [ OK ]
INFO: Make connections
02 Established IPv4 MPTCP Connection ns2 => ns1                      [ OK ]
03 Established IPv6 MPTCP Connection ns2 => ns1                      [ OK ]
INFO: Announce tests
04 ADD_ADDR 10.0.2.2 (ns2) => ns1, invalid token                     [ OK ]
05 ADD_ADDR id:67 10.0.2.2 (ns2) => ns1, reuse port                  [ OK ]

Having test counters helps to quickly identify issues when looking at a
long list of output logs and results.
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-7-4f42c347b653@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 3382bb09
...@@ -54,7 +54,7 @@ __chk_nr() ...@@ -54,7 +54,7 @@ __chk_nr()
nr=$(eval $command) nr=$(eval $command)
printf "%-50s" "$msg" mptcp_lib_print_title "$msg"
if [ "$nr" != "$expected" ]; then if [ "$nr" != "$expected" ]; then
if [ "$nr" = "$skip" ] && ! mptcp_lib_expect_all_features; then if [ "$nr" = "$skip" ] && ! mptcp_lib_expect_all_features; then
echo "[ skip ] Feature probably not supported" echo "[ skip ] Feature probably not supported"
...@@ -68,7 +68,6 @@ __chk_nr() ...@@ -68,7 +68,6 @@ __chk_nr()
echo "[ ok ]" echo "[ ok ]"
mptcp_lib_result_pass "${msg}" mptcp_lib_result_pass "${msg}"
fi fi
MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
} }
__chk_msk_nr() __chk_msk_nr()
...@@ -113,7 +112,7 @@ wait_msk_nr() ...@@ -113,7 +112,7 @@ wait_msk_nr()
sleep 1 sleep 1
done done
printf "%-50s" "$msg" mptcp_lib_print_title "$msg"
if [ $i -ge $timeout ]; then if [ $i -ge $timeout ]; then
echo "[ fail ] timeout while expecting $expected max $max last $nr" echo "[ fail ] timeout while expecting $expected max $max last $nr"
mptcp_lib_result_fail "${msg} # timeout" mptcp_lib_result_fail "${msg} # timeout"
...@@ -126,7 +125,6 @@ wait_msk_nr() ...@@ -126,7 +125,6 @@ wait_msk_nr()
echo "[ ok ]" echo "[ ok ]"
mptcp_lib_result_pass "${msg}" mptcp_lib_result_pass "${msg}"
fi fi
MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
} }
chk_msk_fallback_nr() chk_msk_fallback_nr()
......
...@@ -249,7 +249,8 @@ fi ...@@ -249,7 +249,8 @@ fi
print_larger_title() { print_larger_title() {
# here we don't have the time, a bit longer for the alignment # here we don't have the time, a bit longer for the alignment
printf "%-69s" "${@}" MPTCP_LIB_TEST_FORMAT="%02u %-69s" \
mptcp_lib_print_title "${@}"
} }
check_mptcp_disabled() check_mptcp_disabled()
...@@ -320,7 +321,6 @@ do_transfer() ...@@ -320,7 +321,6 @@ do_transfer()
local extra_args="$7" local extra_args="$7"
port=$((port + 1)) port=$((port + 1))
MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
if [ "$rcvbuf" -gt 0 ]; then if [ "$rcvbuf" -gt 0 ]; then
extra_args="$extra_args -R $rcvbuf" extra_args="$extra_args -R $rcvbuf"
...@@ -347,7 +347,7 @@ do_transfer() ...@@ -347,7 +347,7 @@ do_transfer()
addr_port=$(printf "%s:%d" ${connect_addr} ${port}) addr_port=$(printf "%s:%d" ${connect_addr} ${port})
local result_msg local result_msg
result_msg="$(printf "%.3s %-5s -> %.3s (%-20s) %-5s" ${connector_ns} ${cl_proto} ${listener_ns} ${addr_port} ${srv_proto})" result_msg="$(printf "%.3s %-5s -> %.3s (%-20s) %-5s" ${connector_ns} ${cl_proto} ${listener_ns} ${addr_port} ${srv_proto})"
printf "%-50s" "${result_msg}" mptcp_lib_print_title "${result_msg}"
if $capture; then if $capture; then
local capuser local capuser
......
...@@ -115,7 +115,7 @@ check_mark() ...@@ -115,7 +115,7 @@ check_mark()
print_title() print_title()
{ {
printf "%-50s" "${@}" mptcp_lib_print_title "${@}"
} }
do_transfer() do_transfer()
......
...@@ -53,7 +53,7 @@ check() ...@@ -53,7 +53,7 @@ check()
local msg="$3" local msg="$3"
local rc=0 local rc=0
printf "%-50s" "$msg" mptcp_lib_print_title "$msg"
mptcp_lib_check_output "${err}" "${cmd}" "${expected}" || rc=${?} mptcp_lib_check_output "${err}" "${cmd}" "${expected}" || rc=${?}
if [ ${rc} -eq 2 ]; then if [ ${rc} -eq 2 ]; then
mptcp_lib_result_fail "${msg} # error ${rc}" mptcp_lib_result_fail "${msg} # error ${rc}"
...@@ -189,7 +189,8 @@ subflow,backup,fullmesh 10.0.1.1" " (backup,fullmesh)" ...@@ -189,7 +189,8 @@ subflow,backup,fullmesh 10.0.1.1" " (backup,fullmesh)"
else else
for st in fullmesh nofullmesh backup,fullmesh; do for st in fullmesh nofullmesh backup,fullmesh; do
st=" (${st})" st=" (${st})"
printf "%-50s%s\n" "${st}" "[SKIP]" mptcp_lib_print_title "${st}"
echo "[SKIP]"
mptcp_lib_result_skip "${st}" mptcp_lib_result_skip "${st}"
done done
fi fi
......
...@@ -14,6 +14,8 @@ ns3="" ...@@ -14,6 +14,8 @@ ns3=""
capture=false capture=false
timeout_poll=30 timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1)) timeout_test=$((timeout_poll * 2 + 1))
# a bit more space: because we have more to display
MPTCP_LIB_TEST_FORMAT="%02u %-60s"
ret=0 ret=0
bail=0 bail=0
slack=50 slack=50
...@@ -126,7 +128,6 @@ do_transfer() ...@@ -126,7 +128,6 @@ do_transfer()
local max_time=$3 local max_time=$3
local port local port
port=$((10000+MPTCP_LIB_TEST_COUNTER)) port=$((10000+MPTCP_LIB_TEST_COUNTER))
MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
:> "$cout" :> "$cout"
:> "$sout" :> "$sout"
...@@ -238,7 +239,7 @@ run_test() ...@@ -238,7 +239,7 @@ run_test()
# completion (see mptcp_connect): 200ms on each side, add some slack # completion (see mptcp_connect): 200ms on each side, add some slack
time=$((time + 400 + slack)) time=$((time + 400 + slack))
printf "%-60s" "$msg" mptcp_lib_print_title "$msg"
do_transfer $small $large $time do_transfer $small $large $time
lret=$? lret=$?
mptcp_lib_result_code "${lret}" "${msg}" mptcp_lib_result_code "${lret}" "${msg}"
...@@ -248,7 +249,7 @@ run_test() ...@@ -248,7 +249,7 @@ run_test()
fi fi
msg+=" - reverse direction" msg+=" - reverse direction"
printf "%-60s" "${msg}" mptcp_lib_print_title "${msg}"
do_transfer $large $small $time do_transfer $large $small $time
lret=$? lret=$?
mptcp_lib_result_code "${lret}" "${msg}" mptcp_lib_result_code "${lret}" "${msg}"
......
...@@ -54,6 +54,8 @@ ns1="" ...@@ -54,6 +54,8 @@ ns1=""
ns2="" ns2=""
ret=0 ret=0
test_name="" test_name=""
# a bit more space: because we have more to display
MPTCP_LIB_TEST_FORMAT="%02u %-68s"
_printf() { _printf() {
stdbuf -o0 -e0 printf "${@}" stdbuf -o0 -e0 printf "${@}"
...@@ -69,7 +71,7 @@ print_test() ...@@ -69,7 +71,7 @@ print_test()
{ {
test_name="${1}" test_name="${1}"
_printf "%-68s" "${test_name}" mptcp_lib_print_title "${test_name}"
} }
print_results() print_results()
......
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