From: Matthieu Baerts <matttbe@kernel.org>
To: Geliang Tang <geliang.tang@suse.com>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v3 22/29] selftests: mptcp: add mptcp_lib_evts_*
Date: Sun, 8 Oct 2023 12:54:38 +0200 [thread overview]
Message-ID: <f4086286-6870-48a3-89a3-118efbea50fa@kernel.org> (raw)
In-Reply-To: <8b57e996491a1057c9b1385797f7c96dec2225ed.1695631132.git.geliang.tang@suse.com>
Hi Geliang,
On 25/09/2023 10:42, Geliang Tang wrote:
> This patch unifies "pm_nl_ctl events" related code in userspace_pm.sh
> and mptcp_join.sh into four functions: _init, _start, _kill and _remove.
> Define them in mptcp_lib.sh and use these new helper in both scripts.
Good idea to avoid duplicated code!
(...)
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> index 8051ac5507dc..899c21ced5a3 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> @@ -220,6 +220,11 @@ mptcp_lib_evts_get_info() {
> cat "${2}" | mptcp_lib_get_info_value "${1}" "^type:${3:-1},"
> }
>
> +server_evts=""
> +client_evts=""
> +server_evts_pid=0
> +client_evts_pid=0
I wonder if it wouldn't be clearer to prefix these variables with
'mptcp_lib_': we would avoid overriding global variables by mistake from
other fiels and it would be clearer to know where these variables have
been defined. But I guess if we do that, we would need to do quite a few
modifications in userspace_pm.sh and we want to avoid that, no?
Or passing them as arguments to 'mptcp_lib_evts_XXX()'? It would be more
explicit but maybe not worth it?
An alternative could be to keep these variables declared in the
different files and keep these helpers as they are here. In this case,
it would be good to add a comment before mptcp_lib_evts_init()
explaining that these variables are needed.
Please also make sure shellcheck if happy with that, e.g. by adding a
'?' in the variable name like ${server_evts?} or explicitly at the
beginning of the function with something like ': "${var?}"' or ':
"${var:?}"' if it has to be non empty, e.g.
mptcp_lib_evts_init() {
: "${server_evts?}"
: "${client_evts?}"
(...)
}
mptcp_lib_evts_start() {
: "${server_evts:?}"
: "${client_evts:?}"
: "${server_evts_pid:?}"
: "${client_evts_pid:?}"
(...)
}
mptcp_lib_evts_kill() {
mptcp_lib_kill_wait "${server_evts_pid:?}"
mptcp_lib_kill_wait "${client_evts_pid:?}"
}
mptcp_lib_evts_remove() {
rm -rf "${server_evts:?}" "${client_evts:?}"
}
> +
> mptcp_lib_kill_wait() {
> [ $1 -eq 0 ] && return 0
>
> @@ -227,3 +232,38 @@ mptcp_lib_kill_wait() {
> kill $1 > /dev/null 2>&1
> wait $1 2>/dev/null
> }
> +
> +mptcp_lib_evts_init() {
> + if [ -z "$server_evts" ]; then
Same here and below for the {}. (see comment from patch 21/29)
+ the double quotes below to keep shellcheck happy and be safer.
> + server_evts=$(mktemp)
> + fi
> + if [ -z "$client_evts" ]; then
> + client_evts=$(mktemp)
> + fi
> +}
> +
> +mptcp_lib_evts_start() {
> + :>"$server_evts"
> + :>"$client_evts"
> +
> + if [ $server_evts_pid -ne 0 ]; then
> + mptcp_lib_kill_wait $server_evts_pid
> + fi
> + ip netns exec "$ns1" ./pm_nl_ctl events >> "$server_evts" 2>&1 &
I think ${ns1} and ${ns2} should be passed as argument to this function.
> + server_evts_pid=$!
> +
> + if [ $client_evts_pid -ne 0 ]; then
> + mptcp_lib_kill_wait $client_evts_pid
> + fi
> + ip netns exec "$ns2" ./pm_nl_ctl events >> "$client_evts" 2>&1 &
> + client_evts_pid=$!
> +}
> +
> +mptcp_lib_evts_kill() {
> + mptcp_lib_kill_wait $server_evts_pid
> + mptcp_lib_kill_wait $client_evts_pid
Should we eventually set the pid to 0 after that just to be on the safe
side?
server_evts_pid=0
client_evts_pid=0
It was not needed before, maybe fine not to do that? Up to you (but if
you do, please add a note in the commit message)
> +}
> +
> +mptcp_lib_evts_remove() {
> + rm -rf $server_evts $client_evts
> +}
Cheers,
Matt
--
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net
next prev parent reply other threads:[~2023-10-08 10:54 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-25 8:41 [PATCH mptcp-next v3 00/29] userspace pm enhancements Geliang Tang
2023-09-25 8:41 ` [PATCH mptcp-next v3 01/29] mptcp: drop useless ssk in pm_subflow_check_next Geliang Tang
2023-09-25 8:41 ` [PATCH mptcp-next v3 02/29] mptcp: use mptcp_check_fallback helper Geliang Tang
2023-09-25 8:41 ` [PATCH mptcp-next v3 03/29] mptcp: use mptcp_get_ext helper Geliang Tang
2023-09-25 8:41 ` [PATCH mptcp-next v3 04/29] mptcp: move sk assignment statement ahead Geliang Tang
2023-09-25 8:41 ` [PATCH mptcp-next v3 05/29] mptcp: define more local variables sk Geliang Tang
2023-09-25 8:41 ` [PATCH mptcp-next v3 06/29] selftests: mptcp: sockopt: drop mptcp_connect var Geliang Tang
2023-09-25 8:41 ` [PATCH mptcp-next v3 07/29] selftests: mptcp: display simult in extra_msg Geliang Tang
2023-09-28 20:54 ` Matthieu Baerts
2023-09-25 8:41 ` [PATCH mptcp-next v3 08/29] mptcp: add mptcpi_subflows_total counter Geliang Tang
2023-09-25 8:41 ` [PATCH mptcp-next v3 09/29] selftests: mptcp: add evts_get_info helper Geliang Tang
2023-09-25 8:41 ` [PATCH mptcp-next v3 10/29] selftests: mptcp: add chk_subflows_total helper Geliang Tang
2023-09-28 21:12 ` Matthieu Baerts
2023-09-25 8:41 ` [PATCH mptcp-next v3 11/29] selftests: mptcp: update userspace pm test helpers Geliang Tang
2023-09-28 20:56 ` Matthieu Baerts
2023-09-25 8:41 ` [PATCH mptcp-next v3 12/29] selftests: mptcp: userspace pm remove id 0 subflow Geliang Tang
2023-09-28 20:58 ` Matthieu Baerts
2023-10-05 8:32 ` Geliang Tang
2023-10-05 9:46 ` Matthieu Baerts
2023-09-25 8:41 ` [PATCH mptcp-next v3 13/29] mptcp: userspace pm allow creating " Geliang Tang
2023-09-25 8:41 ` [PATCH mptcp-next v3 14/29] selftests: mptcp: userspace pm create " Geliang Tang
2023-09-25 8:41 ` [PATCH mptcp-next v3 15/29] mptcp: userspace pm remove id 0 address Geliang Tang
2023-09-28 21:00 ` Matthieu Baerts
2023-10-05 8:35 ` Geliang Tang
2023-10-05 9:49 ` Matthieu Baerts
2023-09-25 8:41 ` [PATCH mptcp-next v3 16/29] selftests: " Geliang Tang
2023-09-28 21:01 ` Matthieu Baerts
2023-09-25 8:41 ` [PATCH mptcp-next v3 17/29] mptcp: add userspace_pm_get_entry helper Geliang Tang
2023-10-07 21:00 ` Matthieu Baerts
2023-09-25 8:41 ` [PATCH mptcp-next v3 18/29] mptcp: add userspace pm addr entry refcount Geliang Tang
2023-10-07 21:04 ` Matthieu Baerts
2023-10-07 21:09 ` Matthieu Baerts
2023-09-25 8:41 ` [PATCH mptcp-next v3 19/29] mptcp: add netlink " Geliang Tang
2023-10-07 21:05 ` Matthieu Baerts
2023-09-25 8:41 ` [PATCH mptcp-next v3 20/29] selftests: mptcp: add userspace pm fullmesh tests Geliang Tang
2023-10-07 21:06 ` Matthieu Baerts
2023-09-25 8:42 ` [PATCH mptcp-next v3 21/29] selftests: mptcp: add mptcp_lib_kill_wait Geliang Tang
2023-10-08 10:49 ` Matthieu Baerts
2023-09-25 8:42 ` [PATCH mptcp-next v3 22/29] selftests: mptcp: add mptcp_lib_evts_* Geliang Tang
2023-10-08 10:54 ` Matthieu Baerts [this message]
2023-09-25 8:42 ` [PATCH mptcp-next v3 23/29] selftests: mptcp: userspace: print colored results Geliang Tang
2023-10-08 10:55 ` Matthieu Baerts
2023-09-25 8:42 ` [PATCH mptcp-next v3 24/29] selftests: mptcp: add mptcp_lib_verify_listener_events Geliang Tang
2023-10-08 10:56 ` Matthieu Baerts
2023-09-25 8:42 ` [PATCH mptcp-next v3 25/29] selftests: mptcp: add mptcp_lib_is_v6 Geliang Tang
2023-10-08 10:56 ` Matthieu Baerts
2023-09-25 8:42 ` [PATCH mptcp-next v3 26/29] selftests: mptcp: add mptcp_lib_get_counter Geliang Tang
2023-10-08 10:56 ` Matthieu Baerts
2023-09-25 8:42 ` [PATCH mptcp-next v3 27/29] selftests: mptcp: add mptcp_lib_make_file Geliang Tang
2023-10-08 10:58 ` Matthieu Baerts
2023-09-25 8:42 ` [PATCH mptcp-next v3 28/29] selftests: mptcp: add mptcp_lib_check_transfer Geliang Tang
2023-10-08 10:59 ` Matthieu Baerts
2023-09-25 8:42 ` [PATCH mptcp-next v3 29/29] selftests: mptcp: add mptcp_lib_wait_local_port_listen Geliang Tang
2023-09-25 9:54 ` selftests: mptcp: add mptcp_lib_wait_local_port_listen: Tests Results MPTCP CI
2023-09-28 21:26 ` selftests: mptcp: add mptcp_lib_wait_local_port_listen: Build Failure MPTCP CI
2023-09-28 22:04 ` selftests: mptcp: add mptcp_lib_wait_local_port_listen: Tests Results MPTCP CI
2023-10-08 10:59 ` [PATCH mptcp-next v3 29/29] selftests: mptcp: add mptcp_lib_wait_local_port_listen Matthieu Baerts
2023-09-28 20:54 ` [PATCH mptcp-next v3 00/29] userspace pm enhancements Matthieu Baerts
2023-09-28 21:37 ` Matthieu Baerts
2023-10-05 15:53 ` Matthieu Baerts
2023-10-06 10:42 ` Geliang Tang
2023-10-31 17:40 ` Matthieu Baerts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f4086286-6870-48a3-89a3-118efbea50fa@kernel.org \
--to=matttbe@kernel.org \
--cc=geliang.tang@suse.com \
--cc=mptcp@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox