[igt-dev] [RFC 3/4] tests/i915/gem_mmap_wc: Add invalid params tests

Antonio Argenziano antonio.argenziano at intel.com
Tue Mar 12 21:57:37 UTC 2019


Add some invalid parameters tests for the MMAP IOCTL when the MMAP_WC
flag is supplied.

Signed-off-by: Antonio Argenziano <antonio.argenziano at intel.com>
---
 tests/i915/gem_mmap_wc.c | 52 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/tests/i915/gem_mmap_wc.c b/tests/i915/gem_mmap_wc.c
index baa68aa8..66945c87 100644
--- a/tests/i915/gem_mmap_wc.c
+++ b/tests/i915/gem_mmap_wc.c
@@ -463,6 +463,58 @@ igt_main
 		gem_require_mmap_wc(fd);
 	}
 
+	igt_subtest_group {
+
+		igt_subtest("bad-object") {
+			int ret;
+			struct drm_i915_gem_mmap arg;
+
+			memset(&arg, 0, sizeof(arg));
+			arg.handle = 0x10101010;
+			arg.offset = 0;
+			arg.size = 4096;
+			arg.flags = I915_MMAP_WC;
+
+			errno = 0;
+
+			ret = ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &arg);
+			igt_assert(ret == -1 && errno == ENOENT);
+		}
+
+		igt_subtest("bad-offset") {
+			int ret;
+			struct drm_i915_gem_mmap arg;
+
+			memset(&arg, 0, sizeof(arg));
+			arg.handle = gem_create(fd, 4096);
+			arg.offset = 4096 + 1;
+			arg.size = 4096;
+			arg.flags = I915_MMAP_WC;
+
+			errno = 0;
+
+			ret = ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &arg);
+			arg.flags = I915_MMAP_WC;
+			igt_assert(ret == -1 && errno == EINVAL);
+		}
+
+		igt_subtest("bad-size") {
+			int ret;
+			struct drm_i915_gem_mmap arg;
+
+			memset(&arg, 0, sizeof(arg));
+			arg.handle = gem_create(fd, 4096);
+			arg.offset = 4096;
+			arg.size = 0;
+			arg.flags = I915_MMAP_WC;
+
+			errno = 0;
+
+			ret = ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &arg);
+			igt_assert(ret == -1 && errno == EINVAL);
+		}
+	}
+
 	igt_subtest("invalid-flags")
 		test_invalid_flags(fd);
 	igt_subtest("close")
-- 
2.20.1



More information about the igt-dev mailing list