[igt-dev] [PATCH i-g-t 1/2] tests/v3d_mmap: Improve tests from V3D's Mmap BO IOCTL
Maíra Canal
mcanal at igalia.com
Fri Dec 23 21:44:35 UTC 2022
The current tests for the V3D's Mmap IOCTL don't cover all the
possible invalid parameters on drm_v3d_mmap_bo. Therefore, add a
subtest to make sure that flags on drm_v3d_mmap_bo is zero and also
add a subtest to test the read/write coherency of a newly mapped bo.
Moreover, also adds a check to assure that the mmap's offset is a
multiple of the page size as returned by sysconf(_SC_PAGE_SIZE).
Signed-off-by: Maíra Canal <mcanal at igalia.com>
---
lib/igt_v3d.c | 2 ++
tests/v3d/v3d_mmap.c | 34 ++++++++++++++++++++++++++++++++++
tests/v3d_ci/v3d.testlist | 2 ++
3 files changed, 38 insertions(+)
diff --git a/lib/igt_v3d.c b/lib/igt_v3d.c
index 5aa583da..68d11d7f 100644
--- a/lib/igt_v3d.c
+++ b/lib/igt_v3d.c
@@ -108,6 +108,8 @@ igt_v3d_mmap_bo(int fd, uint32_t handle, uint32_t size, unsigned prot)
do_ioctl(fd, DRM_IOCTL_V3D_MMAP_BO, &mmap_bo);
+ igt_assert_eq(mmap_bo.offset % sysconf(_SC_PAGE_SIZE), 0);
+
ptr = mmap(0, size, prot, MAP_SHARED, fd, mmap_bo.offset);
if (ptr == MAP_FAILED)
return NULL;
diff --git a/tests/v3d/v3d_mmap.c b/tests/v3d/v3d_mmap.c
index 5e2385bd..8c822663 100644
--- a/tests/v3d/v3d_mmap.c
+++ b/tests/v3d/v3d_mmap.c
@@ -33,6 +33,14 @@ igt_main
igt_fixture
fd = drm_open_driver(DRIVER_V3D);
+ igt_describe("Make sure that flags is equal to zero.");
+ igt_subtest("mmap-bad-flags") {
+ struct drm_v3d_mmap_bo get = {
+ .flags = 1,
+ };
+ do_ioctl_err(fd, DRM_IOCTL_V3D_MMAP_BO, &get, EINVAL);
+ }
+
igt_describe("Make sure an invalid BO cannot be mapped.");
igt_subtest("mmap-bad-handle") {
struct drm_v3d_mmap_bo get = {
@@ -41,6 +49,32 @@ igt_main
do_ioctl_err(fd, DRM_IOCTL_V3D_MMAP_BO, &get, ENOENT);
}
+ igt_describe("Test basics of newly mapped bo like default content, write and read "
+ "coherency, mapping existence after gem_close and unmapping.");
+ igt_subtest("mmap-bo") {
+ struct v3d_bo *bo = igt_v3d_create_bo(fd, PAGE_SIZE);
+ uint8_t expected[PAGE_SIZE];
+
+ igt_v3d_bo_mmap(fd, bo);
+
+ /* Testing contents of newly created objects. */
+ memset(expected, 0, sizeof(expected));
+ igt_assert_eq(memcmp(bo->map, expected, sizeof(expected)), 0);
+
+ /* Testing coherency of writes and mmap reads. */
+ memset(bo->map, 0xd0, PAGE_SIZE);
+ memset(expected, 0xd0, PAGE_SIZE);
+ igt_assert_eq(memcmp(expected, bo->map, sizeof(expected)), 0);
+
+ /* Testing that mapping stays after close */
+ gem_close(fd, bo->handle);
+ igt_assert_eq(memcmp(expected, bo->map, sizeof(expected)), 0);
+
+ /* Testing unmapping */
+ munmap(bo->map, PAGE_SIZE);
+ free(bo);
+ }
+
igt_fixture
close(fd);
}
diff --git a/tests/v3d_ci/v3d.testlist b/tests/v3d_ci/v3d.testlist
index 64359fb7..ce8c4f6c 100644
--- a/tests/v3d_ci/v3d.testlist
+++ b/tests/v3d_ci/v3d.testlist
@@ -7,7 +7,9 @@ igt at v3d/v3d_get_bo_offset at get-bad-handle
igt at v3d/v3d_get_param at base-params
igt at v3d/v3d_get_param at get-bad-param
igt at v3d/v3d_get_param at get-bad-flags
+igt at v3d/v3d_mmap at mmap-bad-flags
igt at v3d/v3d_mmap at mmap-bad-handle
+igt at v3d/v3d_mmap at mmap-bo
igt at v3d/v3d_perfmon at create-perfmon-0
igt at v3d/v3d_perfmon at create-perfmon-exceed
igt at v3d/v3d_perfmon at create-perfmon-invalid-counters
--
2.38.1
More information about the igt-dev
mailing list