[Intel-gfx] [PATCH igt 2/8] lib/igt_core: Add igt_assert_fd

Daniel Vetter daniel at ffwll.ch
Fri Oct 2 01:01:47 PDT 2015


On Thu, Oct 01, 2015 at 05:34:02PM +0100, Daniel Stone wrote:
> Skip open-coding and assert that fds are valid.
> 
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> ---
>  lib/igt_core.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/lib/igt_core.h b/lib/igt_core.h
> index 9a5d9c5..8f93e8e 100644
> --- a/lib/igt_core.h
> +++ b/lib/igt_core.h
> @@ -507,6 +507,17 @@ void igt_exit(void) __attribute__((noreturn));
>  #define igt_assert_lt(n1, n2) igt_assert_cmpint(n1, <, >=, n2)
>  
>  /**
> + * igt_assert_fd:
> + * @fd: file descriptor
> + *
> + * Fails (sub-) test if the given file descriptor is not valid.
> + *
> + * Like igt_assert(), but displays the values being compared on failure instead
> + * of simply printing the stringified expression.
> + */
> +#define igt_assert_fd(fd) igt_assert_lte(0, fd)

If we do this then I think some more verbose output would be nice, like

#igt_assert_fd(fd) igt_assert_f(fd >= 0, "file descriptor " #fd " failed\n");

Large-scale sed would be even more awesome ;-)
-Daniel

> +
> +/**
>   * igt_require:
>   * @expr: condition to test
>   *
> -- 
> 2.5.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the Intel-gfx mailing list