Skip to content

Commit aa76947

Browse files
Geliang Tangkuba-moo
authored andcommitted
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: Geliang Tang <[email protected]> Reviewed-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Link: https://lore.kernel.org/r/20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-7-4f42c347b653@kernel.org Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3382bb0 commit aa76947

File tree

6 files changed

+16
-14
lines changed

6 files changed

+16
-14
lines changed

tools/testing/selftests/net/mptcp/diag.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ __chk_nr()
5454

5555
nr=$(eval $command)
5656

57-
printf "%-50s" "$msg"
57+
mptcp_lib_print_title "$msg"
5858
if [ "$nr" != "$expected" ]; then
5959
if [ "$nr" = "$skip" ] && ! mptcp_lib_expect_all_features; then
6060
echo "[ skip ] Feature probably not supported"
@@ -68,7 +68,6 @@ __chk_nr()
6868
echo "[ ok ]"
6969
mptcp_lib_result_pass "${msg}"
7070
fi
71-
MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
7271
}
7372

7473
__chk_msk_nr()
@@ -113,7 +112,7 @@ wait_msk_nr()
113112
sleep 1
114113
done
115114

116-
printf "%-50s" "$msg"
115+
mptcp_lib_print_title "$msg"
117116
if [ $i -ge $timeout ]; then
118117
echo "[ fail ] timeout while expecting $expected max $max last $nr"
119118
mptcp_lib_result_fail "${msg} # timeout"
@@ -126,7 +125,6 @@ wait_msk_nr()
126125
echo "[ ok ]"
127126
mptcp_lib_result_pass "${msg}"
128127
fi
129-
MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
130128
}
131129

132130
chk_msk_fallback_nr()

tools/testing/selftests/net/mptcp/mptcp_connect.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ fi
249249

250250
print_larger_title() {
251251
# here we don't have the time, a bit longer for the alignment
252-
printf "%-69s" "${@}"
252+
MPTCP_LIB_TEST_FORMAT="%02u %-69s" \
253+
mptcp_lib_print_title "${@}"
253254
}
254255

255256
check_mptcp_disabled()
@@ -320,7 +321,6 @@ do_transfer()
320321
local extra_args="$7"
321322

322323
port=$((port + 1))
323-
MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
324324

325325
if [ "$rcvbuf" -gt 0 ]; then
326326
extra_args="$extra_args -R $rcvbuf"
@@ -347,7 +347,7 @@ do_transfer()
347347
addr_port=$(printf "%s:%d" ${connect_addr} ${port})
348348
local result_msg
349349
result_msg="$(printf "%.3s %-5s -> %.3s (%-20s) %-5s" ${connector_ns} ${cl_proto} ${listener_ns} ${addr_port} ${srv_proto})"
350-
printf "%-50s" "${result_msg}"
350+
mptcp_lib_print_title "${result_msg}"
351351

352352
if $capture; then
353353
local capuser

tools/testing/selftests/net/mptcp/mptcp_sockopt.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ check_mark()
115115

116116
print_title()
117117
{
118-
printf "%-50s" "${@}"
118+
mptcp_lib_print_title "${@}"
119119
}
120120

121121
do_transfer()

tools/testing/selftests/net/mptcp/pm_netlink.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ check()
5353
local msg="$3"
5454
local rc=0
5555

56-
printf "%-50s" "$msg"
56+
mptcp_lib_print_title "$msg"
5757
mptcp_lib_check_output "${err}" "${cmd}" "${expected}" || rc=${?}
5858
if [ ${rc} -eq 2 ]; then
5959
mptcp_lib_result_fail "${msg} # error ${rc}"
@@ -189,7 +189,8 @@ subflow,backup,fullmesh 10.0.1.1" " (backup,fullmesh)"
189189
else
190190
for st in fullmesh nofullmesh backup,fullmesh; do
191191
st=" (${st})"
192-
printf "%-50s%s\n" "${st}" "[SKIP]"
192+
mptcp_lib_print_title "${st}"
193+
echo "[SKIP]"
193194
mptcp_lib_result_skip "${st}"
194195
done
195196
fi

tools/testing/selftests/net/mptcp/simult_flows.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ ns3=""
1414
capture=false
1515
timeout_poll=30
1616
timeout_test=$((timeout_poll * 2 + 1))
17+
# a bit more space: because we have more to display
18+
MPTCP_LIB_TEST_FORMAT="%02u %-60s"
1719
ret=0
1820
bail=0
1921
slack=50
@@ -126,7 +128,6 @@ do_transfer()
126128
local max_time=$3
127129
local port
128130
port=$((10000+MPTCP_LIB_TEST_COUNTER))
129-
MPTCP_LIB_TEST_COUNTER=$((MPTCP_LIB_TEST_COUNTER+1))
130131

131132
:> "$cout"
132133
:> "$sout"
@@ -238,7 +239,7 @@ run_test()
238239
# completion (see mptcp_connect): 200ms on each side, add some slack
239240
time=$((time + 400 + slack))
240241

241-
printf "%-60s" "$msg"
242+
mptcp_lib_print_title "$msg"
242243
do_transfer $small $large $time
243244
lret=$?
244245
mptcp_lib_result_code "${lret}" "${msg}"
@@ -248,7 +249,7 @@ run_test()
248249
fi
249250

250251
msg+=" - reverse direction"
251-
printf "%-60s" "${msg}"
252+
mptcp_lib_print_title "${msg}"
252253
do_transfer $large $small $time
253254
lret=$?
254255
mptcp_lib_result_code "${lret}" "${msg}"

tools/testing/selftests/net/mptcp/userspace_pm.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ ns1=""
5454
ns2=""
5555
ret=0
5656
test_name=""
57+
# a bit more space: because we have more to display
58+
MPTCP_LIB_TEST_FORMAT="%02u %-68s"
5759

5860
_printf() {
5961
stdbuf -o0 -e0 printf "${@}"
@@ -69,7 +71,7 @@ print_test()
6971
{
7072
test_name="${1}"
7173

72-
_printf "%-68s" "${test_name}"
74+
mptcp_lib_print_title "${test_name}"
7375
}
7476

7577
print_results()

0 commit comments

Comments
 (0)