From c8cec6b88511f43b5c0301864081fe6ca6e39049 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Thu, 1 Oct 2015 13:02:38 +0100 Subject: [PATCH] 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 --- lib/drmtest.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/drmtest.h b/lib/drmtest.h index bb504087..ed384ffe 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -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)