[PATCH i-g-t v5 02/10] tests/imagination: Add GEM mmap tests
Robert Mazur <[email protected]> Tue, 28 Jul 2026 09:18:57 +0200
| Newsgroups | org.freedesktop.lists.igt-dev |
|---|---|
| Message-ID | <20260728-test-imagination-add-support-v5-2-33049f0d1937@imgtec.com> |
From: Matt Coster <[email protected]> Add subtests for mmap operations on GEM buffer objects. Signed-off-by: Matt Coster <[email protected]> Signed-off-by: Robert Mazur <[email protected]> Acked-by: Kamil Konieczny <[email protected]> --- tests/imagination/pvr_gem.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/imagination/pvr_gem.c b/tests/imagination/pvr_gem.c index 273f4d56f..74bfd4eee 100644 --- a/tests/imagination/pvr_gem.c +++ b/tests/imagination/pvr_gem.c @@ -59,6 +59,50 @@ int igt_main() do_ioctl_err(fd, DRM_IOCTL_PVR_CREATE_BO, &arg, EINVAL); } + igt_describe("Test valid buffer object mapping"); + igt_subtest("mmap-bo-4096") + { + size_t size = 4096; + uint32_t handle = igt_pvr_ioctl_create_bo(fd, &size); + + off_t offset = igt_pvr_ioctl_get_bo_mmap_offset(fd, handle); + + char *mapped = mmap(NULL, size, PROT_WRITE, MAP_SHARED, + fd, offset); + igt_assert(mapped != MAP_FAILED); + + /* Test writing to beginning and end of mapped range. */ + mapped[0] = 0xff; + mapped[size - 1] = 0xff; + + munmap(mapped, size); + gem_close(fd, handle); + } + + igt_describe("Test buffer object mapping with bad handle"); + igt_subtest("mmap-bo-bad-handle") + { + struct drm_pvr_ioctl_get_bo_mmap_offset_args arg = { + .handle = 0xbad6bad6, + }; + + do_ioctl_err(fd, DRM_IOCTL_PVR_GET_BO_MMAP_OFFSET, &arg, ENOENT); + } + + igt_describe("Test buffer object mapping with bad padding"); + igt_subtest("mmap-bo-bad-padding") + { + size_t size = 4096; + uint32_t handle = igt_pvr_ioctl_create_bo(fd, &size); + + struct drm_pvr_ioctl_get_bo_mmap_offset_args arg = { + .handle = handle, + ._padding_4 = 0xbad6bad6, + }; + + do_ioctl_err(fd, DRM_IOCTL_PVR_GET_BO_MMAP_OFFSET, &arg, EINVAL); + } + igt_fixture() { drm_close_driver(fd); -- 2.43.0