Skip to content

Commit 0b842b9

Browse files
Paolo Abenigregkh
authored andcommitted
selftests: mptcp: more stable diag tests
commit 42fb6cd upstream. The mentioned test-case still use an hard-coded-len sleep to wait for a relative large number of connection to be established. On very slow VM and with debug build such timeout could be exceeded, causing failures in our CI. Address the issue polling for the expected condition several times, up to an unreasonable high amount of time. On reasonably fast system the self-tests will be faster then before, on very slow one we will still catch the correct condition. Fixes: df62f2e ("selftests/mptcp: add diag interface tests") Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 536d2a6 commit 0b842b9

File tree

1 file changed

+40
-8
lines changed
  • tools/testing/selftests/net/mptcp

1 file changed

+40
-8
lines changed

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

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,39 @@ chk_msk_nr()
6161
__chk_nr "grep -c token:" $*
6262
}
6363

64+
wait_msk_nr()
65+
{
66+
local condition="grep -c token:"
67+
local expected=$1
68+
local timeout=20
69+
local msg nr
70+
local max=0
71+
local i=0
72+
73+
shift 1
74+
msg=$*
75+
76+
while [ $i -lt $timeout ]; do
77+
nr=$(ss -inmHMN $ns | $condition)
78+
[ $nr == $expected ] && break;
79+
[ $nr -gt $max ] && max=$nr
80+
i=$((i + 1))
81+
sleep 1
82+
done
83+
84+
printf "%-50s" "$msg"
85+
if [ $i -ge $timeout ]; then
86+
echo "[ fail ] timeout while expecting $expected max $max last $nr"
87+
ret=$test_cnt
88+
elif [ $nr != $expected ]; then
89+
echo "[ fail ] expected $expected found $nr"
90+
ret=$test_cnt
91+
else
92+
echo "[ ok ]"
93+
fi
94+
test_cnt=$((test_cnt+1))
95+
}
96+
6497
chk_msk_fallback_nr()
6598
{
6699
__chk_nr "grep -c fallback" $*
@@ -109,15 +142,15 @@ ip -n $ns link set dev lo up
109142
echo "a" | \
110143
timeout ${timeout_test} \
111144
ip netns exec $ns \
112-
./mptcp_connect -p 10000 -l -t ${timeout_poll} \
145+
./mptcp_connect -p 10000 -l -t ${timeout_poll} -w 20 \
113146
0.0.0.0 >/dev/null &
114147
wait_local_port_listen $ns 10000
115148
chk_msk_nr 0 "no msk on netns creation"
116149

117150
echo "b" | \
118151
timeout ${timeout_test} \
119152
ip netns exec $ns \
120-
./mptcp_connect -p 10000 -r 0 -t ${timeout_poll} \
153+
./mptcp_connect -p 10000 -r 0 -t ${timeout_poll} -w 20 \
121154
127.0.0.1 >/dev/null &
122155
wait_connected $ns 10000
123156
chk_msk_nr 2 "after MPC handshake "
@@ -129,13 +162,13 @@ flush_pids
129162
echo "a" | \
130163
timeout ${timeout_test} \
131164
ip netns exec $ns \
132-
./mptcp_connect -p 10001 -l -s TCP -t ${timeout_poll} \
165+
./mptcp_connect -p 10001 -l -s TCP -t ${timeout_poll} -w 20 \
133166
0.0.0.0 >/dev/null &
134167
wait_local_port_listen $ns 10001
135168
echo "b" | \
136169
timeout ${timeout_test} \
137170
ip netns exec $ns \
138-
./mptcp_connect -p 10001 -r 0 -t ${timeout_poll} \
171+
./mptcp_connect -p 10001 -r 0 -t ${timeout_poll} -w 20 \
139172
127.0.0.1 >/dev/null &
140173
wait_connected $ns 10001
141174
chk_msk_fallback_nr 1 "check fallback"
@@ -146,7 +179,7 @@ for I in `seq 1 $NR_CLIENTS`; do
146179
echo "a" | \
147180
timeout ${timeout_test} \
148181
ip netns exec $ns \
149-
./mptcp_connect -p $((I+10001)) -l -w 10 \
182+
./mptcp_connect -p $((I+10001)) -l -w 20 \
150183
-t ${timeout_poll} 0.0.0.0 >/dev/null &
151184
done
152185
wait_local_port_listen $ns $((NR_CLIENTS + 10001))
@@ -155,12 +188,11 @@ for I in `seq 1 $NR_CLIENTS`; do
155188
echo "b" | \
156189
timeout ${timeout_test} \
157190
ip netns exec $ns \
158-
./mptcp_connect -p $((I+10001)) -w 10 \
191+
./mptcp_connect -p $((I+10001)) -w 20 \
159192
-t ${timeout_poll} 127.0.0.1 >/dev/null &
160193
done
161-
sleep 1.5
162194

163-
chk_msk_nr $((NR_CLIENTS*2)) "many msk socket present"
195+
wait_msk_nr $((NR_CLIENTS*2)) "many msk socket present"
164196
flush_pids
165197

166198
exit $ret

0 commit comments

Comments
 (0)