Commit 6d4d6949 authored by Antonio Argenziano's avatar Antonio Argenziano Committed by Chris Wilson

tests/i915/gem_mmap_wc: Add invalid params tests

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

v2:
	- Expand test space. (Chris)
Signed-off-by: Antonio Argenziano's avatarAntonio Argenziano <antonio.argenziano@intel.com>
Reviewed-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
parent 964e3915
Pipeline #24901 failed with stages
in 8 minutes and 11 seconds
...@@ -451,6 +451,17 @@ run_without_prefault(int fd, ...@@ -451,6 +451,17 @@ run_without_prefault(int fd,
igt_enable_prefault(); igt_enable_prefault();
} }
static int mmap_ioctl(int i915, struct drm_i915_gem_mmap *arg)
{
int err = 0;
if (igt_ioctl(i915, DRM_IOCTL_I915_GEM_MMAP, arg))
err = -errno;
errno = 0;
return err;
}
int fd; int fd;
igt_main igt_main
...@@ -463,6 +474,77 @@ igt_main ...@@ -463,6 +474,77 @@ igt_main
gem_require_mmap_wc(fd); gem_require_mmap_wc(fd);
} }
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 arg = {
.handle = handles[i],
.size = 4096,
.flags = I915_MMAP_WC,
};
igt_assert_eq(mmap_ioctl(fd, &arg), -EINVAL);
}
gem_close(fd, real_handle);
}
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++) {
struct drm_i915_gem_mmap arg = {
.handle = gem_create(fd, 4096),
.offset = bad_offsets[i].offset,
.size = bad_offsets[i].size,
.flags = I915_MMAP_WC,
};
igt_assert_eq(mmap_ioctl(fd, &arg), -EINVAL);
gem_close(fd, arg.handle);
}
}
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++) {
struct drm_i915_gem_mmap arg = {
.handle = gem_create(fd, 4096),
.offset = 4096,
.size = bad_size[i],
.flags = I915_MMAP_WC,
};
igt_assert_eq(mmap_ioctl(fd, &arg), -EINVAL);
gem_close(fd, arg.handle);
}
}
igt_subtest("invalid-flags") igt_subtest("invalid-flags")
test_invalid_flags(fd); test_invalid_flags(fd);
igt_subtest("close") igt_subtest("close")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment