From: Ido Schimmel <idosch@nvidia.com>
To: <netdev@vger.kernel.org>
Cc: <davem@davemloft.net>, <kuba@kernel.org>, <pabeni@redhat.com>,
<edumazet@google.com>, <horms@kernel.org>, <paul@paul-moore.com>,
<dsahern@kernel.org>, <petrm@nvidia.com>,
<linux-security-module@vger.kernel.org>,
Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH net-next v2 4/8] selftests: traceroute: Return correct value on failure
Date: Mon, 8 Sep 2025 10:32:34 +0300 [thread overview]
Message-ID: <20250908073238.119240-5-idosch@nvidia.com> (raw)
In-Reply-To: <20250908073238.119240-1-idosch@nvidia.com>
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>
---
tools/testing/selftests/net/traceroute.sh | 38 ++++++-----------------
1 file changed, 9 insertions(+), 29 deletions(-)
diff --git a/tools/testing/selftests/net/traceroute.sh b/tools/testing/selftests/net/traceroute.sh
index 282f14760940..46cb37e124ce 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
@@ -210,9 +188,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
}
@@ -275,9 +256,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
}
@@ -294,9 +278,6 @@ run_tests()
################################################################################
# main
-declare -i nfail=0
-declare -i nsuccess=0
-
while getopts :pv o
do
case $o in
@@ -308,5 +289,4 @@ done
run_tests
-printf "\nTests passed: %3d\n" ${nsuccess}
-printf "Tests failed: %3d\n" ${nfail}
+exit "${EXIT_STATUS}"
--
2.51.0
next prev parent reply other threads:[~2025-09-08 7:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-08 7:32 [PATCH net-next v2 0/8] ipv4: icmp: Fix source IP derivation in presence of VRFs Ido Schimmel
2025-09-08 7:32 ` [PATCH net-next v2 1/8] ipv4: cipso: Simplify IP options handling in cipso_v4_error() Ido Schimmel
2025-09-08 7:51 ` Eric Dumazet
2025-09-08 7:32 ` [PATCH net-next v2 2/8] ipv4: icmp: Pass IPv4 control block structure as an argument to __icmp_send() Ido Schimmel
2025-09-08 7:55 ` Eric Dumazet
2025-09-08 7:32 ` [PATCH net-next v2 3/8] ipv4: icmp: Fix source IP derivation in presence of VRFs Ido Schimmel
2025-09-08 7:32 ` Ido Schimmel [this message]
2025-09-08 7:32 ` [PATCH net-next v2 5/8] selftests: traceroute: Use require_command() Ido Schimmel
2025-09-08 7:32 ` [PATCH net-next v2 6/8] selftests: traceroute: Reword comment Ido Schimmel
2025-09-08 7:32 ` [PATCH net-next v2 7/8] selftests: traceroute: Test traceroute with different source IPs Ido Schimmel
2025-09-08 7:32 ` [PATCH net-next v2 8/8] selftests: traceroute: Add VRF tests Ido Schimmel
2025-09-11 10:40 ` [PATCH net-next v2 0/8] ipv4: icmp: Fix source IP derivation in presence of VRFs patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250908073238.119240-5-idosch@nvidia.com \
--to=idosch@nvidia.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paul@paul-moore.com \
--cc=petrm@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox