diff options
author | Daniel Stone <daniels@collabora.com> | 2015-10-01 13:26:36 +0100 |
---|---|---|
committer | Daniel Stone <daniels@collabora.com> | 2015-10-07 17:57:26 +0100 |
commit | 6ead44d70bde0aed4ceac5311f3eec599125a554 (patch) | |
tree | c5c3e4f5c5f1d46ad59dd5ef4cf762dbef75b703 /lib/igt_core.h | |
parent | 715a17bb35a09a6889664bc7df14495bc068e06d (diff) |
lib/igt_core: Add igt_assert_fd
Skip open-coding and assert that fds are valid.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Diffstat (limited to 'lib/igt_core.h')
-rw-r--r-- | lib/igt_core.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/igt_core.h b/lib/igt_core.h index b3e846c8..5ae09653 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -507,6 +507,18 @@ 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 invalid. + * + * 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_f(fd >= 0, "file descriptor " #fd " failed\n"); + +/** * igt_require: * @expr: condition to test * |