]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
selftests: harness: avoid false negatives if test has no ASSERTs
authorJakub Kicinski <kuba@kernel.org>
Wed, 24 Nov 2021 22:39:16 +0000 (14:39 -0800)
committerPaolo Pisati <paolo.pisati@canonical.com>
Fri, 28 Jan 2022 09:59:31 +0000 (10:59 +0100)
commitb5edfeb0f09fed22ce04f1d0f962ccf83df498bc
tree1814a3c6324adad31377212755c8df20d26c35bd
parente57f77237aaced8281a3531ba7f6bd26d54d865e
selftests: harness: avoid false negatives if test has no ASSERTs

BugLink: https://bugs.launchpad.net/bugs/1959376
[ Upstream commit 3abedf4646fdc0036fcb8ebbc3b600667167fafe ]

Test can fail either immediately when ASSERT() failed or at the
end if one or more EXPECT() was not met. The exact return code
is decided based on the number of successful ASSERT()s.

If test has no ASSERT()s, however, the return code will be 0,
as if the test did not fail. Start counting ASSERT()s from 1.

Fixes: 369130b63178 ("selftests: Enhance kselftest_harness.h to print which assert failed")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
tools/testing/selftests/kselftest_harness.h