[igt-dev] [PATCH i-g-t v3 1/3] tests/i915/gem_mmap_gtt: Add invalid parameters test
Antonio Argenziano
antonio.argenziano at intel.com
Thu Mar 14 20:21:31 UTC 2019
Add a test for an invalid handle being passed to the IOCTL.
v2:
- Expand test space. (Chris)
v3:
- Add local IOCTL wrapper. (Chris)
Signed-off-by: Antonio Argenziano <antonio.argenziano at intel.com>
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
tests/i915/gem_mmap_gtt.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
index f6fbbe19..237308a2 100644
--- a/tests/i915/gem_mmap_gtt.c
+++ b/tests/i915/gem_mmap_gtt.c
@@ -821,6 +821,23 @@ run_without_prefault(int fd,
igt_enable_prefault();
}
+static int
+err_gem_mmap_gtt(int i915, uint32_t handle, uint64_t size, uint64_t offset)
+{
+ struct drm_i915_gem_mmap arg = {
+ .handle = handle,
+ .size = size,
+ .offset = offset
+ };
+ int err = 0;
+
+ if(ioctl(i915, DRM_IOCTL_I915_GEM_MMAP_GTT, &arg))
+ err = -errno;
+
+ errno = 0;
+ return err;
+}
+
int fd;
igt_main
@@ -831,6 +848,25 @@ igt_main
igt_fixture
fd = drm_open_driver(DRIVER_INTEL);
+ igt_subtest("bad-object") {
+ int ret;
+
+ uint32_t real_handle = gem_create(fd, 4096);
+ uint32_t handles[20];
+ int i = 0;
+
+ handles[i++] = 0xdeadbeef;
+ for(int bit = 0; bit < 16; bit++)
+ handles[i++] = real_handle | (1 << (bit + 16));
+ handles[i] = real_handle + 1;
+
+ for (; i < 0; i--) {
+ igt_debug("Trying to mmap_gtt invalid handle: %x.\n", handles[i]);
+ ret = err_gem_mmap_gtt(fd, handles[i], 0, 4096);
+ igt_assert_eq(ret, -ENOENT);
+ }
+ }
+
igt_subtest("basic")
test_access(fd);
igt_subtest("basic-short")
--
2.20.1
More information about the igt-dev
mailing list