The same extra long command is present twice, with one small different:
the var for the stdin file is different.
Use a new dedicated var in one command to avoid this code duplication.
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index c90d8e8b95cb..c5169020a515 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -951,6 +951,7 @@ do_transfer()
local FAILING_LINKS=${FAILING_LINKS:-""}
local fastclose=${fastclose:-""}
local speed=${speed:-"fast"}
+ local in="${sin}"
port=$(get_port)
:> "$cout"
@@ -999,16 +1000,12 @@ do_transfer()
extra_srv_args="$extra_args $extra_srv_args"
if [ "$test_linkfail" -gt 1 ];then
- timeout ${timeout_test} \
- ip netns exec ${listener_ns} \
- ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \
- $extra_srv_args "::" < "$sinfail" > "$sout" &
- else
- timeout ${timeout_test} \
- ip netns exec ${listener_ns} \
- ./mptcp_connect -t ${timeout_poll} -l -p $port -s ${srv_proto} \
- $extra_srv_args "::" < "$sin" > "$sout" &
+ in="${sinfail}"
fi
+ timeout ${timeout_test} \
+ ip netns exec ${listener_ns} \
+ ./mptcp_connect -t ${timeout_poll} -l -p ${port} -s ${srv_proto} \
+ ${extra_srv_args} "::" < "${in}" > "${sout}" &
local spid=$!
mptcp_lib_wait_local_port_listen "${listener_ns}" "${port}"
--
2.51.0
Hi Matt, On Thu, 2025-10-09 at 19:33 +0200, Matthieu Baerts (NGI0) wrote: > The same extra long command is present twice, with one small > different: > the var for the stdin file is different. > > Use a new dedicated var in one command to avoid this code > duplication. > > Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> LGTM! Reviewed-by: Geliang Tang <geliang@kernel.org> Thanks, -Geliang > --- > tools/testing/selftests/net/mptcp/mptcp_join.sh | 15 ++++++--------- > 1 file changed, 6 insertions(+), 9 deletions(-) > > diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh > b/tools/testing/selftests/net/mptcp/mptcp_join.sh > index c90d8e8b95cb..c5169020a515 100755 > --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh > +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh > @@ -951,6 +951,7 @@ do_transfer() > local FAILING_LINKS=${FAILING_LINKS:-""} > local fastclose=${fastclose:-""} > local speed=${speed:-"fast"} > + local in="${sin}" > port=$(get_port) > > :> "$cout" > @@ -999,16 +1000,12 @@ do_transfer() > > extra_srv_args="$extra_args $extra_srv_args" > if [ "$test_linkfail" -gt 1 ];then > - timeout ${timeout_test} \ > - ip netns exec ${listener_ns} \ > - ./mptcp_connect -t ${timeout_poll} - > l -p $port -s ${srv_proto} \ > - $extra_srv_args "::" < > "$sinfail" > "$sout" & > - else > - timeout ${timeout_test} \ > - ip netns exec ${listener_ns} \ > - ./mptcp_connect -t ${timeout_poll} - > l -p $port -s ${srv_proto} \ > - $extra_srv_args "::" < > "$sin" > "$sout" & > + in="${sinfail}" > fi > + timeout ${timeout_test} \ > + ip netns exec ${listener_ns} \ > + ./mptcp_connect -t ${timeout_poll} -l -p > ${port} -s ${srv_proto} \ > + ${extra_srv_args} "::" < "${in}" > > "${sout}" & > local spid=$! > > mptcp_lib_wait_local_port_listen "${listener_ns}" "${port}" >
© 2016 - 2025 Red Hat, Inc.