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)
committerShuah Khan <skhan@linuxfoundation.org>
Fri, 10 Dec 2021 23:46:01 +0000 (16:46 -0700)
commit3abedf4646fdc0036fcb8ebbc3b600667167fafe
treefa08b4d3208d94179076273c2ffa0a09aca78130
parente5992f373c6eed6d09e5858e9623df1259b3ce30
selftests: harness: avoid false negatives if test has no ASSERTs

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