[igt-dev] [PATCH i-g-t v3 6/7] tests/v3d_create_bo: Create test for V3D's Create BO IOCTL

Maíra Canal mcanal at igalia.com
Tue Nov 29 18:40:37 UTC 2022


Add three igt_subtests for the DRM_IOCTL_V3D_CREATE_BO, which tests the
creation of a zeroed BO and a 4096 bytes BO, and tests if the BO is
properly cleaned.

Reviewed-by: Melissa Wen <mwen at igalia.com>
Signed-off-by: Maíra Canal <mcanal at igalia.com>
---
 tests/v3d/meson.build     |  1 +
 tests/v3d/v3d_create_bo.c | 71 +++++++++++++++++++++++++++++++++++++++
 tests/v3d_ci/v3d.testlist |  4 +++
 3 files changed, 76 insertions(+)
 create mode 100644 tests/v3d/v3d_create_bo.c

diff --git a/tests/v3d/meson.build b/tests/v3d/meson.build
index 45f73a88..66d5290e 100644
--- a/tests/v3d/meson.build
+++ b/tests/v3d/meson.build
@@ -1,4 +1,5 @@
 v3d_progs = [
+	'v3d_create_bo',
 	'v3d_get_bo_offset',
 	'v3d_get_param',
 	'v3d_mmap',
diff --git a/tests/v3d/v3d_create_bo.c b/tests/v3d/v3d_create_bo.c
new file mode 100644
index 00000000..4142fb5f
--- /dev/null
+++ b/tests/v3d/v3d_create_bo.c
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2022 Igalia S.L.
+ */
+
+#include "igt.h"
+#include "igt_v3d.h"
+
+IGT_TEST_DESCRIPTION("Tests for the V3D's Create BO IOCTL");
+
+igt_main
+{
+	int fd;
+
+	igt_fixture
+		fd = drm_open_driver(DRIVER_V3D);
+
+	igt_describe("Make sure a BO cannot be created with flags different than zero.");
+	igt_subtest("create-bo-invalid-flags") {
+		struct drm_v3d_create_bo create = {
+			.flags = 0x0a,
+		};
+		do_ioctl_err(fd, DRM_IOCTL_V3D_CREATE_BO, &create, EINVAL);
+	}
+
+	igt_describe("Make sure a BO cannot be created with size zero.");
+	igt_subtest("create-bo-0") {
+		struct drm_v3d_create_bo create = {
+			.size = 0,
+		};
+		do_ioctl_err(fd, DRM_IOCTL_V3D_CREATE_BO, &create, EINVAL);
+	}
+
+	igt_describe("Sanity check for creating a BO with size 4096.");
+	igt_subtest("create-bo-4096") {
+		struct v3d_bo *bo = igt_v3d_create_bo(fd, PAGE_SIZE);
+		igt_v3d_free_bo(fd, bo);
+	}
+
+	igt_describe("Make sure that BOs can be allocated in different fd without "
+		     "carrying old contents from one another.");
+	igt_subtest("create-bo-zeroed") {
+		int fd2 = drm_open_driver(DRIVER_V3D);
+		struct v3d_bo *bo;
+		/* A size different from any used in our other tests, to try
+		 * to convince it to land as the only one of its size in the
+		 * kernel BO cache
+		 */
+		size_t size = 3 * PAGE_SIZE, i;
+
+		/* Make a BO and free it on our main fd. */
+		bo = igt_v3d_create_bo(fd, size);
+		bo->map = igt_v3d_mmap_bo(fd, bo->handle, size, PROT_READ | PROT_WRITE);
+		memset(bo->map, 0xd0, size);
+		igt_v3d_free_bo(fd, bo);
+
+		/* Now, allocate a BO on the other fd and make sure it doesn't
+		 * have the old contents.
+		 */
+		bo = igt_v3d_create_bo(fd2, size);
+		bo->map = igt_v3d_mmap_bo(fd2, bo->handle, size, PROT_READ | PROT_WRITE);
+		for (i = 0; i < size / 4; i++)
+			igt_assert_eq_u32(((uint32_t *)bo->map)[i], 0x0);
+		igt_v3d_free_bo(fd2, bo);
+
+		close(fd2);
+	}
+
+	igt_fixture
+		close(fd);
+}
diff --git a/tests/v3d_ci/v3d.testlist b/tests/v3d_ci/v3d.testlist
index 442fd731..53898aa5 100644
--- a/tests/v3d_ci/v3d.testlist
+++ b/tests/v3d_ci/v3d.testlist
@@ -1,3 +1,7 @@
+igt at v3d/v3d_create_bo at create-bo-invalid-flags
+igt at v3d/v3d_create_bo at create-bo-0
+igt at v3d/v3d_create_bo at create-bo-4096
+igt at v3d/v3d_create_bo at create-bo-zeroed
 igt at v3d/v3d_get_bo_offset at create-get-offsets
 igt at v3d/v3d_get_bo_offset at get-bad-handle
 igt at v3d/v3d_get_param at base-params
-- 
2.38.1



More information about the igt-dev mailing list