[igt-dev] [PATCH i-g-t 1/9] lib/tests: Drop NIH exit status handling
Daniel Vetter
daniel.vetter at ffwll.ch
Wed Feb 13 13:13:06 UTC 2019
On Wed, Feb 13, 2019 at 11:49 AM Chris Wilson <chris at chris-wilson.co.uk> wrote:
>
> Quoting Daniel Vetter (2019-02-13 10:35:43)
> > Spotted by Chris.
> >
> > Cc: Chris Wilson <chris at chris-wilson.co.uk>
> > Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
> > ---
> > lib/tests/igt_assert.c | 9 +++------
> > lib/tests/igt_segfault.c | 8 ++++----
> > lib/tests/igt_simulation.c | 39 +++++++++++++++++++++++---------------
> > 3 files changed, 31 insertions(+), 25 deletions(-)
> >
> > diff --git a/lib/tests/igt_assert.c b/lib/tests/igt_assert.c
> > index 306b1fb8533c..0082fda14851 100644
> > --- a/lib/tests/igt_assert.c
> > +++ b/lib/tests/igt_assert.c
> > @@ -79,10 +79,7 @@ static int do_fork(void)
> > errno == EINTR)
> > ;
> >
> > - if(WIFSIGNALED(status))
> > - return WTERMSIG(status) + 128;
> > -
> > - return WEXITSTATUS(status);
> > + return status;
> > }
> > }
> >
> > @@ -161,7 +158,7 @@ igt_main
> > test_to_run = test_cmpint_negative;
> > ret = do_fork();
> > igt_subtest("igt_cmpint_negative")
> > - internal_assert(ret == IGT_EXIT_FAILURE);
> > + internal_assert(WEXITSTATUS(ret) == IGT_EXIT_FAILURE);
>
> I don't think we can get away with plain WEXITSTATUS/WTERMSIG as they
> are simple shifts and masks.
>
> I think we need
>
> bool wexited(int status, int exitcode)
> {
> return WIFEXITED(status) && WEXITSTATUS(status) == exitcode;
> }
>
> bool wsignaled(int status, int sig)
> {
> return WIFSIGNALED(status) && WTERMSIG(status) == sig;
> }
Yeah we're essentially relying on all the signals/exit codes to be
non-zero. I figured that's kinda ok to rely on for test code, but yeah
it's not great. I guess eventually we'll need a header with a few
convenient things for library testcases (like the internal_assert and
stuff like that).
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
More information about the igt-dev
mailing list