From: Antonio Argenziano <antonio.argenziano@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v3 3/3] tests/i915/gem_mmap_wc: Add invalid params tests
Date: Thu, 14 Mar 2019 13:21:33 -0700 [thread overview]
Message-ID: <20190314202133.19311-3-antonio.argenziano@intel.com> (raw)
In-Reply-To: <20190314202133.19311-1-antonio.argenziano@intel.com>
Add some invalid parameters tests for the MMAP IOCTL when the MMAP_WC
flag is supplied.
v2:
- Expand test space. (Chris)
v3:
- Add local IOCTL wrapper. (Chris)
Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
tests/i915/gem_mmap_wc.c | 85 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/tests/i915/gem_mmap_wc.c b/tests/i915/gem_mmap_wc.c
index baa68aa8..8422b3b0 100644
--- a/tests/i915/gem_mmap_wc.c
+++ b/tests/i915/gem_mmap_wc.c
@@ -81,6 +81,24 @@ mmap_bo(int fd, uint32_t handle)
return ptr;
}
+static int
+err_gem_mmap_wc(int i915, uint32_t handle, uint64_t size, uint64_t offset)
+{
+ struct drm_i915_gem_mmap arg = {
+ .handle = handle,
+ .size = size,
+ .offset = offset,
+ .flags = I915_MMAP_WC
+ };
+ int err = 0;
+
+ if(ioctl(i915, DRM_IOCTL_I915_GEM_MMAP, &arg))
+ err = -errno;
+
+ errno = 0;
+ return err;
+}
+
static void *
create_pointer(int fd)
{
@@ -463,6 +481,73 @@ igt_main
gem_require_mmap_wc(fd);
}
+ igt_subtest_group {
+
+ 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 bad object. Handle: %x\n",
+ handles[i]);
+ ret = err_gem_mmap_wc(fd, handles[i], 4096, 0);
+ igt_assert_eq(ret, -EINVAL);
+ }
+ }
+
+ igt_subtest("bad-offset") {
+ int ret;
+ uint32_t handle = gem_create(fd, 4096);
+ 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++) {
+ igt_debug("Trying to mmap bad offset; size: %lu, offset %lu\n",
+ bad_offsets[i].size, bad_offsets[i].offset);
+ ret = err_gem_mmap_wc(fd, handle,
+ bad_offsets[i].size, bad_offsets[i].offset);
+ igt_assert_eq(ret, -EINVAL);
+ }
+ }
+
+ igt_subtest("bad-size") {
+ int ret;
+ uint32_t handle = gem_create(fd, 4096);
+ uint64_t offset;
+ uint64_t bad_size[] = {
+ 0,
+ -4096,
+ 4096 + 1,
+ 2 * 4096,
+ ~0,
+ };
+
+ for (int i = 0; i < ARRAY_SIZE(bad_size); i++) {
+ offset = (bad_size[i] - 1) % bad_size[i];
+
+ igt_debug("Trying to mmap bad offset; size: %lu, offset %lu\n",
+ bad_size[i], offset);
+ ret = err_gem_mmap_wc(fd, handle,
+ bad_size[i], offset);
+ igt_assert_eq(ret, -EINVAL);
+ }
+ }
+ }
+
igt_subtest("invalid-flags")
test_invalid_flags(fd);
igt_subtest("close")
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-03-14 20:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-14 20:21 [igt-dev] [PATCH i-g-t v3 1/3] tests/i915/gem_mmap_gtt: Add invalid parameters test Antonio Argenziano
2019-03-14 20:21 ` [igt-dev] [PATCH i-g-t v3 2/3] tests/i915/gem_mmap: Add invalid parameters tests Antonio Argenziano
2019-03-14 20:21 ` Antonio Argenziano [this message]
2019-03-14 20:54 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,v3,1/3] tests/i915/gem_mmap_gtt: Add invalid parameters test Patchwork
2019-03-14 22:46 ` [igt-dev] [PATCH i-g-t v3 1/3] " Chris Wilson
2019-03-15 7:54 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [i-g-t,v3,1/3] " Patchwork
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=20190314202133.19311-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox