selftests: net: exit with test failure status
Subsystems (4)
PATCH v2 1/1 selftests: net: exit with test failure status
From: Hangbin Liu <[email protected]>
The changed four tests can print [FAIL] subtests while still exiting with status 0. Their log_test(), aka log_test_expected() in lib.sh, helpers record a failure in ret, but the scripts never propagate ret to the exit code, so a kselftest runner treats the run as a pass.
Initialize ret and exit with it at the end of each script so failed subtests are reflected in the exit status.
---
The patch doesn't fix a regression, nothing is failing (or passing when it shouldn't) because of it. So target the patch to net-next.
---
Changes in v2:
- Also update fib_nexthop_multiprefix.sh (Ido Schimmel)
- Link to v1: https://lore.kernel.org/r/[email protected]
To: "David S. Miller" <[email protected]>
To: Eric Dumazet <[email protected]>
To: Jakub Kicinski <[email protected]>
To: Paolo Abeni <[email protected]>
To: Simon Horman <[email protected]>
To: Shuah Khan <[email protected]>
To: David Ahern <[email protected]>
To: Ido Schimmel <[email protected]>
Cc: Hangbin Liu <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
--- tools/testing/selftests/net/fdb_flush.sh | 3 +++ tools/testing/selftests/net/fib-onlink-tests.sh | 3 +++ tools/testing/selftests/net/fib_nexthop_multiprefix.sh | 1 + tools/testing/selftests/net/l2tp.sh | 3 +++ 4 files changed, 10 insertions(+)
tools/testing/selftests/net/fdb_flush.sh +3 -0
@@ -6,6 +6,7 @@ # some combinations of arguments. source lib.sh +ret=0 FLUSH_BY_STATE_TESTS=" vxlan_test_flush_by_permanent
@@ -778,3 +779,5 @@ for t in $TESTS do setup; $t; cleanup; done + +exit $ret
tools/testing/selftests/net/fib-onlink-tests.sh +3 -0
@@ -6,6 +6,7 @@ source lib.sh PAUSE_ON_FAIL=${PAUSE_ON_FAIL:=no} VERBOSE=0 +ret=0 # Network interfaces # - odd in current namespace; even in peer ns
@@ -473,3 +474,5 @@ if [ "$TESTS" != "none" ]; then printf "\nTests passed: %3d\n" ${nsuccess} printf "Tests failed: %3d\n" ${nfail} fi + +exit $ret
tools/testing/selftests/net/fib_nexthop_multiprefix.sh +1 -0
@@ -269,3 +269,4 @@ if [ $ret -eq 0 ]; then fi cleanup +exit $ret
tools/testing/selftests/net/l2tp.sh +3 -0
@@ -16,6 +16,7 @@ source lib.sh VERBOSE=0 PAUSE_ON_FAIL=no +ret=0 which ping6 > /dev/null 2>&1 && ping6=$(which ping6) || ping6=$(which ping)
@@ -357,3 +358,5 @@ cleanup printf "\nTests passed: %3d\n" ${nsuccess} printf "Tests failed: %3d\n" ${nfail} + +exit $ret
---
base-commit: 98c2ad4f5d805dbc1ea436a334ee59311806a48c
change-id: 20261014-self_ret-83b030f32ba3
Best regards,
Signature · 1 line
Hangbin Liu <[email protected]>
Quoted 11 lines · Hangbin Liu
From: Hangbin Liu <[email protected]>
The changed four tests can print [FAIL] subtests while still exiting with status 0. Their
log_test(), akalog_test_expected()inlib.sh, helpers record a failure in ret, but the scripts never propagate ret to the exit code, so a kselftest runner treats the run as a pass.Initialize ret and exit with it at the end of each script so failed subtests are reflected in the exit status.
Signed-off-by Hangbin Liu <[email protected]>
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Mon, 19 Oct 2026 08:41:03 +0800 you wrote:
From: Hangbin Liu <[email protected]>
The changed four tests can print [FAIL] subtests while still exiting with status 0. Their
log_test(), akalog_test_expected()inlib.sh, helpers record a failure in ret, but the scripts never propagate ret to the exit code, so a kselftest runner treats the run as a pass.[...]
Here is the summary with links:
- [net-next,v2] selftests: net: exit with test failure status
https://git.kernel.org/netdev/net-next/c/17271848c9a7
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html