[igt-dev] [PATCH i-g-t v2 1/3] tests/i915/gem_mmap_gtt: Add invalid parameters test
Chris Wilson
chris at chris-wilson.co.uk
Wed Mar 13 23:59:46 UTC 2019
Quoting Antonio Argenziano (2019-03-13 23:27:19)
> Add a test for an invalid handle being passed to the IOCTL.
>
> v2:
> - Expand test space. (Chris)
>
> Signed-off-by: Antonio Argenziano <antonio.argenziano at intel.com>
> ---
> tests/i915/gem_mmap_gtt.c | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
>
> diff --git a/tests/i915/gem_mmap_gtt.c b/tests/i915/gem_mmap_gtt.c
> index f6fbbe19..2d6c6278 100644
> --- a/tests/i915/gem_mmap_gtt.c
> +++ b/tests/i915/gem_mmap_gtt.c
> @@ -831,6 +831,29 @@ igt_main
> igt_fixture
> fd = drm_open_driver(DRIVER_INTEL);
>
> + igt_subtest("bad-object") {
> + struct drm_i915_gem_mmap arg;
> + 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--) {
> + memset(&arg, 0, sizeof(arg));
> + arg.handle = handles[i];
> + arg.offset = 0;
> + arg.size = 4096;
> + ret = ioctl(fd, DRM_IOCTL_I915_GEM_MMAP_GTT, &arg);
> + igt_assert(ret == -1 && errno == ENOENT);
Go on, give us local functions to make these prettier.
int err_mmap_gtt(int i915, uint32_t handle, uint64_t offset, uint64_t size)
{
struct drm_i915_gem_mmap arg = {
.handle = handle,
.offset = offset,
.size = size
};
int err;
err = 0;
if (igt_ioctl(i915, DRM_IOCTL_I915_GEM_MMAP_GTT, &arg))
err = -errno;
errno = 0;
return err;
}
and similarly for err_mmap(), err_mmap_wc().
I think we can use raw_mmap() around here to differentiate against
future variations with lib wrappers, and for the moment, err_() will do
as these are expected to fail.
-Chris
More information about the igt-dev
mailing list