kselftest: rtnetlink.sh: use grep_fail when expecting the cmd fail
Subsystems (3)
PATCH 1/1 kselftest: rtnetlink.sh: use grep_fail when expecting the cmd fail
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
--- tools/testing/selftests/net/rtnetlink.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/rtnetlink.sh +1 -1
@@ -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"
Signature · 1 line
2.43.0
Quoted 10 lines · Hangbin Liu
run_cmd_grep_failshould 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 viarun_kselftest.sh.Before fix:
# ./rtnetlink.sh -t kci_test_addrlft PASS: preferred_lft addresses have expired # echo $? 1
Quoted 8 lines
After fix:
# ./rtnetlink.sh -t kci_test_addrlft PASS: preferred_lft addresses have expired # echo $? 0Fixes 9c2a19f71515 ("kselftest: rtnetlink.sh: add verbose flag")Signed-off-by Hangbin Liu <[email protected]>
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.
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 11 lines · On Tue, 19 Dec 2023 14:57:37 +0800 you wrote:
run_cmd_grep_failshould 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 viarun_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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html