]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/harness: Run TEARDOWN for ASSERT failures
authorKees Cook <keescook@chromium.org>
Thu, 24 Mar 2022 23:19:06 +0000 (16:19 -0700)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 4 Apr 2022 19:37:37 +0000 (13:37 -0600)
commit00f0f9056df827f97fe11ebc4fec53a4a07741d9
treef59175e765c1ba913867f02ea66334d3ab1dc685
parent51b2f26011a531c0c4fd1541fcfa0e21082dfeca
selftests/harness: Run TEARDOWN for ASSERT failures

The kselftest test harness has traditionally not run the registered
TEARDOWN handler when a test encountered an ASSERT. This creates
unexpected situations and tests need to be very careful about using
ASSERT, which seems a needless hurdle for test writers.

Because of the harness's design for optional failure handlers, the
original implementation of ASSERT used an abort() to immediately
stop execution, but that meant the context for running teardown was
lost. Instead, use setjmp/longjmp so that teardown can be done.

Failed SETUP routines continue to not be followed by TEARDOWN, though.

Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Will Drewry <wad@chromium.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: linux-kselftest@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/selftests/kselftest_harness.h