Skip to content

Commit

Permalink
selftests: mptcp: join: check for tools only if needed
Browse files Browse the repository at this point in the history
To allow showing the 'help' menu even if these tools are not available.

While at it, also avoid launching the command then checking $?. Instead,
the check is directly done in the 'if'.

Signed-off-by: Matthieu Baerts <[email protected]>
Signed-off-by: Mat Martineau <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
matttbe authored and kuba-moo committed Feb 18, 2022
1 parent 93827ad commit 8715475
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions tools/testing/selftests/net/mptcp/mptcp_join.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,29 @@ cleanup_partial()
done
}

check_tools()
{
if ! ip -Version &> /dev/null; then
echo "SKIP: Could not run test without ip tool"
exit $ksft_skip
fi

if ! iptables -V &> /dev/null; then
echo "SKIP: Could not run all tests without iptables tool"
exit $ksft_skip
fi

if ! ip6tables -V &> /dev/null; then
echo "SKIP: Could not run all tests without ip6tables tool"
exit $ksft_skip
fi
}

init() {
init=1

check_tools

sin=$(mktemp)
sout=$(mktemp)
cin=$(mktemp)
Expand Down Expand Up @@ -183,24 +203,6 @@ reset_with_allow_join_id0()
ip netns exec $ns2 sysctl -q net.mptcp.allow_join_initial_addr_port=$ns2_enable
}

ip -Version > /dev/null 2>&1
if [ $? -ne 0 ];then
echo "SKIP: Could not run test without ip tool"
exit $ksft_skip
fi

iptables -V > /dev/null 2>&1
if [ $? -ne 0 ];then
echo "SKIP: Could not run all tests without iptables tool"
exit $ksft_skip
fi

ip6tables -V > /dev/null 2>&1
if [ $? -ne 0 ];then
echo "SKIP: Could not run all tests without ip6tables tool"
exit $ksft_skip
fi

print_file_err()
{
ls -l "$1" 1>&2
Expand Down

0 comments on commit 8715475

Please sign in to comment.