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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 10:03:33 +0000 (11:03 +0100)
commitf857f6cc5fbf9783b3df5354e18e9d0e55f03802
treec3b725e394af214d019070f13fc9b9d1afe3ea6c
parentc0dbfef7e63fa1760e96eca45e32a400e1de661c
selftests: harness: avoid false negatives if test has no ASSERTs

[ 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>
tools/testing/selftests/kselftest_harness.h