Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests: net: lib: Do not overwrite error messages

ret_set_ksft_status() calls ksft_status_merge() with the current return
status and the last one. It treats a non-zero return code from
ksft_status_merge() as an indication that the return status was
overwritten by the last one and therefore overwrites the return message
with the last one.

Currently, ksft_status_merge() returns a non-zero return code even if
the current return status and the last one are equal. This results in
return messages being overwritten which is counter-productive since we
are more interested in the first failure message and not the last one.

Fix by changing ksft_status_merge() to only return a non-zero return
code if the current return status was actually changed.

Add a test case which checks that the first error message is not
overwritten.

Before:

# ./lib_sh_test.sh
[...]
TEST: RET tfail2 tfail -> fail [FAIL]
retmsg=tfail expected tfail2
[...]
# echo $?
1

After:

# ./lib_sh_test.sh
[...]
TEST: RET tfail2 tfail -> fail [ OK ]
[...]
# echo $?
0

Fixes: 596c8819cb78 ("selftests: forwarding: Have RET track kselftest framework constants")
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Link: https://patch.msgid.link/20251116081029.69112-1-idosch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Ido Schimmel and committed by
Jakub Kicinski
bed22c7b da02a182

+8 -1
+7
tools/testing/selftests/net/forwarding/lib_sh_test.sh
··· 30 30 do_test "tfail" false 31 31 } 32 32 33 + tfail2() 34 + { 35 + do_test "tfail2" false 36 + } 37 + 33 38 txfail() 34 39 { 35 40 FAIL_TO_XFAIL=yes do_test "txfail" false ··· 137 132 ret_subtest $ksft_fail "tfail" txfail tfail 138 133 139 134 ret_subtest $ksft_xfail "txfail" txfail txfail 135 + 136 + ret_subtest $ksft_fail "tfail2" tfail2 tfail 140 137 } 141 138 142 139 exit_status_tests_run()
+1 -1
tools/testing/selftests/net/lib.sh
··· 43 43 weights[$i]=$((weight++)) 44 44 done 45 45 46 - if [[ ${weights[$a]} > ${weights[$b]} ]]; then 46 + if [[ ${weights[$a]} -ge ${weights[$b]} ]]; then 47 47 echo "$a" 48 48 return 0 49 49 else