mbox series

[0/2] selftests/harness: Handle timeouts cleanly

Message ID 20200311211733.21211-1-keescook@chromium.org (mailing list archive)
Headers show
Series selftests/harness: Handle timeouts cleanly | expand

Message

Kees Cook March 11, 2020, 9:17 p.m. UTC
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  ]

-Kees

Kees Cook (2):
  selftests/seccomp: Move test child waiting logic
  selftests/harness: Handle timeouts cleanly

 tools/testing/selftests/kselftest_harness.h | 144 ++++++++++++++------
 1 file changed, 99 insertions(+), 45 deletions(-)

Comments

Shuah March 13, 2020, 5:25 p.m. UTC | #1
Hi Kees,

On 3/11/20 3:17 PM, Kees Cook wrote:
> 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  ]
> 

This is good info. to capturein the commit logs for the patches.
Please add them and send v2. You can also fix the subject prefix
at the same time :)

thanks,
-- Shuah
Kees Cook March 13, 2020, 11:10 p.m. UTC | #2
On Fri, Mar 13, 2020 at 11:25:58AM -0600, shuah wrote:
> Hi Kees,
> 
> On 3/11/20 3:17 PM, Kees Cook wrote:
> > 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  ]
> > 
> 
> This is good info. to capturein the commit logs for the patches.

The cover letter is an exact copy of patch 2's commit log. :)

> Please add them and send v2. You can also fix the subject prefix
> at the same time :)

I'll resend a v2 with fixed prefix regardless.