]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests: traceroute: Use require_command()
authorIdo Schimmel <idosch@nvidia.com>
Mon, 8 Sep 2025 07:32:35 +0000 (10:32 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:37:19 +0000 (15:37 -0500)
[ Upstream commit 47efbac9b768553331b9459743a29861e0acd797 ]

Use require_command() so that the test will return SKIP (4) when a
required command is not present.

Before:

 # ./traceroute.sh
 SKIP: Could not run IPV6 test without traceroute6
 SKIP: Could not run IPV4 test without traceroute
 $ echo $?
 0

After:

 # ./traceroute.sh
 TEST: traceroute6 not installed                                    [SKIP]
 $ echo $?
 4

Reviewed-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20250908073238.119240-6-idosch@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/net/traceroute.sh

index 282f14760940dd7acd56513ae3686ca6c4bfa932..b50e52afa4f497a7d77915717dcf466254031746 100755 (executable)
@@ -203,11 +203,6 @@ setup_traceroute6()
 
 run_traceroute6()
 {
-       if [ ! -x "$(command -v traceroute6)" ]; then
-               echo "SKIP: Could not run IPV6 test without traceroute6"
-               return
-       fi
-
        setup_traceroute6
 
        # traceroute6 host-2 from host-1 (expects 2000:102::2)
@@ -268,11 +263,6 @@ setup_traceroute()
 
 run_traceroute()
 {
-       if [ ! -x "$(command -v traceroute)" ]; then
-               echo "SKIP: Could not run IPV4 test without traceroute"
-               return
-       fi
-
        setup_traceroute
 
        # traceroute host-2 from host-1 (expects 1.0.1.1). Takes a while.
@@ -306,6 +296,9 @@ do
        esac
 done
 
+require_command traceroute6
+require_command traceroute
+
 run_tests
 
 printf "\nTests passed: %3d\n" ${nsuccess}