summaryrefslogtreecommitdiff
path: root/tools/testing
diff options
context:
space:
mode:
authorIdo Schimmel <idosch@nvidia.com>2025-09-08 10:32:34 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-11-13 15:34:22 -0500
commit317d3bbc222200abca6117a9ab8e0c0e2016b07c (patch)
treebc8924db369213200e9792557a4674f5ca7e04aa /tools/testing
parent51d35366f917502dc247c534d31a53575fe13aa7 (diff)
downloadlinux-317d3bbc222200abca6117a9ab8e0c0e2016b07c.tar.gz
linux-317d3bbc222200abca6117a9ab8e0c0e2016b07c.tar.bz2
linux-317d3bbc222200abca6117a9ab8e0c0e2016b07c.zip
selftests: traceroute: Return correct value on failure
[ Upstream commit c068ba9d3ded56cb1ba4d5135ee84bf8039bd563 ] The test always returns success even if some tests were modified to fail. Fix by converting the test to use the appropriate library functions instead of using its own functions. Before: # ./traceroute.sh TEST: IPV6 traceroute [FAIL] TEST: IPV4 traceroute [ OK ] Tests passed: 1 Tests failed: 1 $ echo $? 0 After: # ./traceroute.sh TEST: IPv6 traceroute [FAIL] traceroute6 did not return 2000:102::2 TEST: IPv4 traceroute [ OK ] $ echo $? 1 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-5-idosch@nvidia.com Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools/testing')
-rwxr-xr-xtools/testing/selftests/net/traceroute.sh38
1 files changed, 9 insertions, 29 deletions
diff --git a/tools/testing/selftests/net/traceroute.sh b/tools/testing/selftests/net/traceroute.sh
index b50e52afa4f4..1ac91eebd16f 100755
--- a/tools/testing/selftests/net/traceroute.sh
+++ b/tools/testing/selftests/net/traceroute.sh
@@ -10,28 +10,6 @@ PAUSE_ON_FAIL=no
################################################################################
#
-log_test()
-{
- local rc=$1
- local expected=$2
- local msg="$3"
-
- if [ ${rc} -eq ${expected} ]; then
- printf "TEST: %-60s [ OK ]\n" "${msg}"
- nsuccess=$((nsuccess+1))
- else
- ret=1
- nfail=$((nfail+1))
- printf "TEST: %-60s [FAIL]\n" "${msg}"
- if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
- echo
- echo "hit enter to continue, 'q' to quit"
- read a
- [ "$a" = "q" ] && exit 1
- fi
- fi
-}
-
run_cmd()
{
local ns
@@ -205,9 +183,12 @@ run_traceroute6()
{
setup_traceroute6
+ RET=0
+
# traceroute6 host-2 from host-1 (expects 2000:102::2)
run_cmd $h1 "traceroute6 2000:103::4 | grep -q 2000:102::2"
- log_test $? 0 "IPV6 traceroute"
+ check_err $? "traceroute6 did not return 2000:102::2"
+ log_test "IPv6 traceroute"
cleanup_traceroute6
}
@@ -265,9 +246,12 @@ run_traceroute()
{
setup_traceroute
+ RET=0
+
# traceroute host-2 from host-1 (expects 1.0.1.1). Takes a while.
run_cmd $h1 "traceroute 1.0.2.4 | grep -q 1.0.1.1"
- log_test $? 0 "IPV4 traceroute"
+ check_err $? "traceroute did not return 1.0.1.1"
+ log_test "IPv4 traceroute"
cleanup_traceroute
}
@@ -284,9 +268,6 @@ run_tests()
################################################################################
# main
-declare -i nfail=0
-declare -i nsuccess=0
-
while getopts :pv o
do
case $o in
@@ -301,5 +282,4 @@ require_command traceroute
run_tests
-printf "\nTests passed: %3d\n" ${nsuccess}
-printf "Tests failed: %3d\n" ${nfail}
+exit "${EXIT_STATUS}"