summaryrefslogtreecommitdiff
path: root/tools/testing
diff options
context:
space:
mode:
authorMatthieu Baerts <matthieu.baerts@tessares.net>2022-02-18 06:03:10 +0300
committerJakub Kicinski <kuba@kernel.org>2022-02-18 06:59:59 +0300
commit87154755d90ed60919cc5709e322b397701e4f58 (patch)
tree6cf09394c019f0879ae180ce7240bfcd0ed9691c /tools/testing
parent93827ad58f6296bf15fa72265e55fb0f335fcf84 (diff)
downloadlinux-87154755d90ed60919cc5709e322b397701e4f58.tar.xz
selftests: mptcp: join: check for tools only if needed
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 <matthieu.baerts@tessares.net> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/testing')
-rwxr-xr-xtools/testing/selftests/net/mptcp/mptcp_join.sh38
1 files changed, 20 insertions, 18 deletions
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 63340bb76920..725924012b41 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -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)
@@ -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