All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antonio Argenziano <antonio.argenziano@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v2 2/3] tests/i915/gem_mmap: Add invalid parameters tests
Date: Wed, 13 Mar 2019 16:27:20 -0700	[thread overview]
Message-ID: <20190313232721.6212-2-antonio.argenziano@intel.com> (raw)
In-Reply-To: <20190313232721.6212-1-antonio.argenziano@intel.com>

Add a couple of tests that supply invalid parameters to the mmap IOCTL.

v2:
	- Expand test space. (Chris)

Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com>
---
 tests/i915/gem_mmap.c | 78 +++++++++++++++++++++++++++++++++++++++----
 1 file changed, 72 insertions(+), 6 deletions(-)

diff --git a/tests/i915/gem_mmap.c b/tests/i915/gem_mmap.c
index 0ed15878..f6229cc5 100644
--- a/tests/i915/gem_mmap.c
+++ b/tests/i915/gem_mmap.c
@@ -35,6 +35,7 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+//#include <linux/bitops.h>
 #include "drm.h"
 
 #define OBJECT_SIZE 16384
@@ -128,12 +129,77 @@ igt_main
 		fd = drm_open_driver(DRIVER_INTEL);
 
 	igt_subtest("bad-object") {
-		memset(&arg, 0, sizeof(arg));
-		arg.handle = 0x10101010;
-		arg.offset = 0;
-		arg.size = 4096;
-		ret = ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &arg);
-		igt_assert(ret == -1 && errno == ENOENT);
+		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--) {
+			memset(&arg, 0, sizeof(arg));
+			arg.handle = handles[i];
+			arg.offset = 0;
+			arg.size = 4096;
+
+			igt_debug("Trying MMAP IOCTL with handle %x\n", handles[i]);
+			ret = ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &arg);
+
+			igt_assert_eq(errno, EINVAL);
+			igt_assert_eq(ret, -1);
+		}
+	}
+
+	igt_subtest("bad-offset") {
+		struct bad_offset {
+			uint64_t size;
+			uint64_t offset;
+		} bad_offsets[] = {
+				{4096, 4096 + 1},
+				{4096, -4096},
+				{ 2 * 4096, -4096},
+				{ 4096, ~0},
+				{}
+		};
+
+		for (int i = 0; i < ARRAY_SIZE(bad_offsets); i++) {
+			memset(&arg, 0, sizeof(arg));
+			arg.handle = gem_create(fd, 4096);
+			arg.offset = bad_offsets[i].offset;
+			arg.size = bad_offsets[i].size;
+
+			igt_debug("Trying to mmap bad offset; size: %llu, offset: %llu\n",
+					bad_offsets[i].size, bad_offsets[i].offset);
+
+			ret = ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &arg);
+			igt_assert_eq(errno, EINVAL);
+			igt_assert_eq(ret, -1);
+		}
+	}
+
+	igt_subtest("bad-size") {
+		uint64_t bad_size[] = {
+			0,
+			-4096,
+			4096 + 1,
+			2 * 4096,
+			~0,
+		};
+
+		for (int i = 0; i < ARRAY_SIZE(bad_size); i++) {
+			memset(&arg, 0, sizeof(arg));
+			arg.handle = gem_create(fd, 4096);
+			arg.offset = 4096;
+			arg.size = bad_size[i];
+
+			igt_debug("Trying to mmap bad size; size: %llu\n", bad_size[i]);
+			ret = ioctl(fd, DRM_IOCTL_I915_GEM_MMAP, &arg);
+
+			igt_assert_eq(errno, EINVAL);
+			igt_assert_eq(ret, -1);
+		}
 	}
 
 	igt_subtest("basic") {
-- 
2.20.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2019-03-13 23:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13 23:27 [igt-dev] [PATCH i-g-t v2 1/3] tests/i915/gem_mmap_gtt: Add invalid parameters test Antonio Argenziano
2019-03-13 23:27 ` Antonio Argenziano [this message]
2019-03-13 23:27 ` [igt-dev] [PATCH i-g-t v2 3/3] tests/i915/gem_mmap_wc: Add invalid params tests Antonio Argenziano
2019-03-13 23:59 ` [igt-dev] [PATCH i-g-t v2 1/3] tests/i915/gem_mmap_gtt: Add invalid parameters test Chris Wilson
2019-03-14  0:12 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v2,1/3] " Patchwork
2019-03-14  7:13 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-03-18 14:44 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,v2,1/3] tests/i915/gem_mmap_gtt: Add invalid parameters test (rev2) Patchwork
2019-03-18 17:06 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v2,1/3] tests/i915/gem_mmap_gtt: Add invalid parameters test (rev3) Patchwork
2019-03-19  1:00 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-03-19 17:28   ` Chris Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190313232721.6212-2-antonio.argenziano@intel.com \
    --to=antonio.argenziano@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.