Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jakub Kicinski and committed by
Shuah Khan
3abedf46 e5992f37

+1 -1
+1 -1
tools/testing/selftests/kselftest_harness.h
··· 969 969 t->passed = 1; 970 970 t->skip = 0; 971 971 t->trigger = 0; 972 - t->step = 0; 972 + t->step = 1; 973 973 t->no_print = 0; 974 974 memset(t->results->reason, 0, sizeof(t->results->reason)); 975 975