Skip to content

Commit d9c822f

Browse files
committed
Merge branch 'selftests-mptcp-various-improvements'
Matthieu Baerts says: ==================== selftests: mptcp: various improvements In this series from Geliang, there are various improvements in MPTCP selftests: sharing code, doing actions the same way, colours, etc. Patch 1 prints all error messages to stdout: what was done in almost all other MPTCP selftests. This can be now easily changed later if needed. Patch 2 makes sure the test counter is continuous in mptcp_connect.sh. Patch 3 aligns the messages that are printed in mptcp_connect.sh. Patch 4 prints each test results in mptcp_sockopt.sh, similar to what we have in the TAP output. Patch 5 moves the different test counters to a single one in mptcp_lib.sh, to uniform how it is used. Patch 6 moves how titles are printed from mptcp_join.sh to the lib, to be reused in patch 7 by all other MPTCP selftests. Patch 8 uses the '+=' operator to append strings instead of repeating twice the variable name: that's shorter, easier to read. Patch 9 adds colours for the [ OK ], [SKIP], [FAIL] and INFO keywords in all MPTCP selftests. Patch 10 to 12 are some preparation patches for patch 13: patch 10 modifies how some 'test_fail' helpers, patch 11 moves a helper from userspace_pm.sh to the lib, and patch 12 changes where titles are printed in userspace_pm.sh. Patch 13 moves some duplicated helpers from mptcp_join.sh and userspace_pm.sh to mptcp_lib.sh. Patch 14 moves duplicated read-only variables from mptcp_join.sh and userspace_pm.sh to mptcp_lib.sh as well. Patch 15 uses explicit variables instead of hard-coded numbers for the exit status. ==================== Link: https://lore.kernel.org/r/20240308-upstream-net-next-20240308-selftests-mptcp-unification-v1-0-4f42c347b653@kernel.org Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 0d1a7a8 + 8f7a69a commit d9c822f

File tree

8 files changed

+312
-286
lines changed

8 files changed

+312
-286
lines changed

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
. "$(dirname "${0}")/mptcp_lib.sh"
1010

1111
ns=""
12-
test_cnt=1
1312
timeout_poll=30
1413
timeout_test=$((timeout_poll * 2 + 1))
1514
ret=0
@@ -55,21 +54,20 @@ __chk_nr()
5554

5655
nr=$(eval $command)
5756

58-
printf "%-50s" "$msg"
57+
mptcp_lib_print_title "$msg"
5958
if [ "$nr" != "$expected" ]; then
6059
if [ "$nr" = "$skip" ] && ! mptcp_lib_expect_all_features; then
61-
echo "[ skip ] Feature probably not supported"
60+
mptcp_lib_pr_skip "Feature probably not supported"
6261
mptcp_lib_result_skip "${msg}"
6362
else
64-
echo "[ fail ] expected $expected found $nr"
63+
mptcp_lib_pr_fail "expected $expected found $nr"
6564
mptcp_lib_result_fail "${msg}"
6665
ret=${KSFT_FAIL}
6766
fi
6867
else
69-
echo "[ ok ]"
68+
mptcp_lib_pr_ok
7069
mptcp_lib_result_pass "${msg}"
7170
fi
72-
test_cnt=$((test_cnt+1))
7371
}
7472

7573
__chk_msk_nr()
@@ -114,20 +112,19 @@ wait_msk_nr()
114112
sleep 1
115113
done
116114

117-
printf "%-50s" "$msg"
115+
mptcp_lib_print_title "$msg"
118116
if [ $i -ge $timeout ]; then
119-
echo "[ fail ] timeout while expecting $expected max $max last $nr"
117+
mptcp_lib_pr_fail "timeout while expecting $expected max $max last $nr"
120118
mptcp_lib_result_fail "${msg} # timeout"
121119
ret=${KSFT_FAIL}
122120
elif [ $nr != $expected ]; then
123-
echo "[ fail ] expected $expected found $nr"
121+
mptcp_lib_pr_fail "expected $expected found $nr"
124122
mptcp_lib_result_fail "${msg} # unexpected result"
125123
ret=${KSFT_FAIL}
126124
else
127-
echo "[ ok ]"
125+
mptcp_lib_pr_ok
128126
mptcp_lib_result_pass "${msg}"
129127
fi
130-
test_cnt=$((test_cnt+1))
131128
}
132129

133130
chk_msk_fallback_nr()

0 commit comments

Comments
 (0)