• Kees Cook's avatar
    selftests/harness: Run TEARDOWN for ASSERT failures · 63e6b2a4
    Kees Cook authored
    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: default avatarKees Cook <keescook@chromium.org>
    Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
    63e6b2a4
kselftest_harness.h 28.1 KB