• Kees Cook's avatar
    selftests/harness: Handle timeouts cleanly · c31801da
    Kees Cook authored
    When a selftest would timeout before, the program would just fall over
    and no accounting of failures would be reported (i.e. it would result in
    an incomplete TAP report). Instead, add an explicit SIGALRM handler to
    cleanly catch and report the timeout.
    
    Before:
    
    	[==========] Running 2 tests from 2 test cases.
    	[ RUN      ] timeout.finish
    	[       OK ] timeout.finish
    	[ RUN      ] timeout.too_long
    	Alarm clock
    
    After:
    
    	[==========] Running 2 tests from 2 test cases.
    	[ RUN      ] timeout.finish
    	[       OK ] timeout.finish
    	[ RUN      ] timeout.too_long
    	timeout.too_long: Test terminated by timeout
    	[     FAIL ] timeout.too_long
    	[==========] 1 / 2 tests passed.
    	[  FAILED  ]
    Signed-off-by: default avatarKees Cook <keescook@chromium.org>
    Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
    c31801da
kselftest_harness.h 21.7 KB