lib/drmtest: Add do_ioctl_err to expect failure

do_ioctl demands that the ioctl returns success; add a variant named
do_ioctl_err, which expects the ioctl to fail, and demands a particular
result.

Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
Daniel Stone 2015-10-01 13:02:38 +01:00
parent 31821fce59
commit c8cec6b885

View File

@ -101,7 +101,23 @@ void gem_quiescent_gpu(int fd);
* successfully executed.
*/
#define do_ioctl(fd, ioc, ioc_data) do { \
igt_assert(drmIoctl((fd), (ioc), (ioc_data)) == 0); \
igt_assert_eq(drmIoctl((fd), (ioc), (ioc_data)), 0); \
errno = 0; \
} while (0)
/**
* do_ioctl_err:
* @fd: open i915 drm file descriptor
* @ioc: ioctl op definition from drm headers
* @ioc_data: data pointer for the ioctl operation
* @err: value to expect in errno
*
* This macro wraps drmIoctl() and uses igt_assert to check that it fails,
* returning a particular value in errno.
*/
#define do_ioctl_err(fd, ioc, ioc_data, err) do { \
igt_assert_eq(drmIoctl((fd), (ioc), (ioc_data)), -1); \
igt_assert_eq(errno, err); \
errno = 0; \
} while (0)