Message ID | 20210308101627.2161839-1-matthieu.baerts@tessares.net |
---|---|
State | Accepted, archived |
Commit | 908234a713efd0f2c620e24c3e733ca6e7951ae1 |
Delegated to: | Matthieu Baerts |
Headers | show |
Series | [mptcp-next] Squash to "selftests: mptcp: launch mptcp_connect with timeout" | expand |
On Mon, 2021-03-08 at 11:16 +0100, Matthieu Baerts wrote: > In diag.sh, we want to send signals to mptcp_connect instances that have > been started in the netns. But we cannot send this signal to 'timeout' > otherwise that will stop the timeout and print something like: > > # ./diag.sh: line 1: 9536 Done echo a > # 9537 User defined signal 1 | timeout ${timeout_test} ip netns (...) > > Instead of trying to find the right PID and storing them in an array, we > can simply use the output of 'ip netns pids' and send a signal to all > these PIDs. > > Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> > --- > > Notes: > to be squashed in "selftests: mptcp: launch mptcp_connect with timeout" Nice cleanup! LGTM! Thanks! Paolo
Hi Paolo, On 08/03/2021 11:23, Paolo Abeni wrote: > On Mon, 2021-03-08 at 11:16 +0100, Matthieu Baerts wrote: >> In diag.sh, we want to send signals to mptcp_connect instances that have >> been started in the netns. But we cannot send this signal to 'timeout' >> otherwise that will stop the timeout and print something like: >> >> # ./diag.sh: line 1: 9536 Done echo a >> # 9537 User defined signal 1 | timeout ${timeout_test} ip netns (...) >> >> Instead of trying to find the right PID and storing them in an array, we >> can simply use the output of 'ip netns pids' and send a signal to all >> these PIDs. >> >> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> >> --- >> >> Notes: >> to be squashed in "selftests: mptcp: launch mptcp_connect with timeout" > > Nice cleanup! LGTM! Thank you for the quick review! - 908234a713ef: "squashed" in "selftests: mptcp: launch mptcp_connect with timeout" - 0e661d1c15c6: tg:msg: notice about diag.sh modif - Results: ec0b131d1b83..917144c5a66a Tests + export have been started! Cheers, Matt
diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh index 35846f89cdad..2674ba20d524 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -8,7 +8,6 @@ test_cnt=1 timeout_poll=100 timeout_test=$((timeout_poll * 2 + 1)) ret=0 -pids=() flush_pids() { @@ -16,18 +15,14 @@ flush_pids() # give it some time sleep 1.1 - for pid in ${pids[@]}; do - [ -d /proc/$pid ] && kill -SIGUSR1 $pid >/dev/null 2>&1 - done - pids=() + ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGUSR1 &>/dev/null } cleanup() { + ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGKILL &>/dev/null + ip netns del $ns - for pid in ${pids[@]}; do - [ -d /proc/$pid ] && kill -9 $pid >/dev/null 2>&1 - done } ip -Version > /dev/null 2>&1 @@ -87,7 +82,6 @@ echo "a" | \ ./mptcp_connect -p 10000 -l -t ${timeout_poll} \ 0.0.0.0 >/dev/null & sleep 0.1 -pids[0]=$! chk_msk_nr 0 "no msk on netns creation" echo "b" | \ @@ -96,7 +90,6 @@ echo "b" | \ ./mptcp_connect -p 10000 -j -t ${timeout_poll} \ 127.0.0.1 >/dev/null & sleep 0.1 -pids[1]=$! chk_msk_nr 2 "after MPC handshake " chk_msk_remote_key_nr 2 "....chk remote_key" chk_msk_fallback_nr 0 "....chk no fallback" @@ -108,14 +101,12 @@ echo "a" | \ ip netns exec $ns \ ./mptcp_connect -p 10001 -l -s TCP -t ${timeout_poll} \ 0.0.0.0 >/dev/null & -pids[0]=$! sleep 0.1 echo "b" | \ timeout ${timeout_test} \ ip netns exec $ns \ ./mptcp_connect -p 10001 -j -t ${timeout_poll} \ 127.0.0.1 >/dev/null & -pids[1]=$! sleep 0.1 chk_msk_fallback_nr 1 "check fallback" flush_pids @@ -127,7 +118,6 @@ for I in `seq 1 $NR_CLIENTS`; do ip netns exec $ns \ ./mptcp_connect -p $((I+10001)) -l -w 10 \ -t ${timeout_poll} 0.0.0.0 >/dev/null & - pids[$((I*2))]=$! done sleep 0.1 @@ -137,7 +127,6 @@ for I in `seq 1 $NR_CLIENTS`; do ip netns exec $ns \ ./mptcp_connect -p $((I+10001)) -w 10 \ -t ${timeout_poll} 127.0.0.1 >/dev/null & - pids[$((I*2 + 1))]=$! done sleep 1.5
In diag.sh, we want to send signals to mptcp_connect instances that have been started in the netns. But we cannot send this signal to 'timeout' otherwise that will stop the timeout and print something like: # ./diag.sh: line 1: 9536 Done echo a # 9537 User defined signal 1 | timeout ${timeout_test} ip netns (...) Instead of trying to find the right PID and storing them in an array, we can simply use the output of 'ip netns pids' and send a signal to all these PIDs. Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net> --- Notes: to be squashed in "selftests: mptcp: launch mptcp_connect with timeout" tools/testing/selftests/net/mptcp/diag.sh | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)