diff mbox series

[net] kselftest: rtnetlink.sh: use grep_fail when expecting the cmd fail

Message ID 20231219065737.1725120-1-liuhangbin@gmail.com (mailing list archive)
State Accepted
Commit b8056f2ce07f27c43b9488dd1bc8bfbb60d0779d
Delegated to: Netdev Maintainers
Headers show
Series [net] kselftest: rtnetlink.sh: use grep_fail when expecting the cmd fail | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success SINGLE THREAD; Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers warning 5 maintainers not CCed: shuah@kernel.org edumazet@google.com pabeni@redhat.com kuba@kernel.org linux-kselftest@vger.kernel.org
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success net selftest script(s) already in Makefile
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Hangbin Liu Dec. 19, 2023, 6:57 a.m. UTC
run_cmd_grep_fail should be used when expecting the cmd fail, or the ret
will be set to 1, and the total test return 1 when exiting. This would cause
the result report to fail if run via run_kselftest.sh.

Before fix:
 # ./rtnetlink.sh -t kci_test_addrlft
 PASS: preferred_lft addresses have expired
 # echo $?
 1

After fix:
 # ./rtnetlink.sh -t kci_test_addrlft
 PASS: preferred_lft addresses have expired
 # echo $?
 0

Fixes: 9c2a19f71515 ("kselftest: rtnetlink.sh: add verbose flag")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 tools/testing/selftests/net/rtnetlink.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman Dec. 20, 2023, 2:06 p.m. UTC | #1
On Tue, Dec 19, 2023 at 02:57:37PM +0800, Hangbin Liu wrote:
> run_cmd_grep_fail should be used when expecting the cmd fail, or the ret
> will be set to 1, and the total test return 1 when exiting. This would cause
> the result report to fail if run via run_kselftest.sh.
> 
> Before fix:
>  # ./rtnetlink.sh -t kci_test_addrlft
>  PASS: preferred_lft addresses have expired
>  # echo $?
>  1
> 
> After fix:
>  # ./rtnetlink.sh -t kci_test_addrlft
>  PASS: preferred_lft addresses have expired
>  # echo $?
>  0
> 
> Fixes: 9c2a19f71515 ("kselftest: rtnetlink.sh: add verbose flag")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

Thanks,

I agree that this corrects inverted logic wrt setting
the global 'ret' value and in turn the exit value of the script.

I also agree that the problem was introduced by the cited commit.

Reviewed-by: Simon Horman <horms@kernel.org>
patchwork-bot+netdevbpf@kernel.org Dec. 21, 2023, 8:40 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Tue, 19 Dec 2023 14:57:37 +0800 you wrote:
> run_cmd_grep_fail should be used when expecting the cmd fail, or the ret
> will be set to 1, and the total test return 1 when exiting. This would cause
> the result report to fail if run via run_kselftest.sh.
> 
> Before fix:
>  # ./rtnetlink.sh -t kci_test_addrlft
>  PASS: preferred_lft addresses have expired
>  # echo $?
>  1
> 
> [...]

Here is the summary with links:
  - [net] kselftest: rtnetlink.sh: use grep_fail when expecting the cmd fail
    https://git.kernel.org/netdev/net/c/b8056f2ce07f

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh
index 38be9706c45f..26827ea4e3e5 100755
--- a/tools/testing/selftests/net/rtnetlink.sh
+++ b/tools/testing/selftests/net/rtnetlink.sh
@@ -297,7 +297,7 @@  kci_test_addrlft()
 	done
 
 	sleep 5
-	run_cmd_grep "10.23.11." ip addr show dev "$devdummy"
+	run_cmd_grep_fail "10.23.11." ip addr show dev "$devdummy"
 	if [ $? -eq 0 ]; then
 		check_err 1
 		end_test "FAIL: preferred_lft addresses remaining"