From 212f34d27085085446ed7adfcc7fe9172f89df89 Mon Sep 17 00:00:00 2001 From: Antonio Argenziano Date: Wed, 13 Mar 2019 16:27:19 -0700 Subject: tests/i915/gem_mmap_gtt: Add invalid parameters test Add a test for an invalid handle being passed to the IOCTL. v2: - Expand test space. (Chris) Signed-off-by: Antonio Argenziano Reviewed-by: Chris Wilson Signed-off-by: Chris Wilson --- tests/i915/gem_mmap_gtt.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tests/i915') diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c index f6fbbe19..8d304808 100644 --- a/tests/i915/gem_mmap_gtt.c +++ b/tests/i915/gem_mmap_gtt.c @@ -821,6 +821,17 @@ run_without_prefault(int fd, igt_enable_prefault(); } +static int mmap_ioctl(int i915, struct drm_i915_gem_mmap_gtt *arg) +{ + int err = 0; + + if (igt_ioctl(i915, DRM_IOCTL_I915_GEM_MMAP_GTT, arg)) + err = -errno; + + errno = 0; + return err; +} + int fd; igt_main @@ -831,6 +842,26 @@ igt_main igt_fixture fd = drm_open_driver(DRIVER_INTEL); + igt_subtest("bad-object") { + 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--) { + struct drm_i915_gem_mmap_gtt arg = { + .handle = handles[i], + }; + igt_assert_eq(mmap_ioctl(fd, &arg), -ENOENT); + } + + gem_close(fd, real_handle); + } + igt_subtest("basic") test_access(fd); igt_subtest("basic-short") -- cgit v1.2.3