[PATCH i-g-t 4/4] igt/v3d_*: Add new tests for the V3D UABI.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



These are basic non-rendering tests of the UABI.

Signed-off-by: Eric Anholt <eric@xxxxxxxxxx>
---
 lib/igt_v3d.c             |  4 --
 tests/Makefile.am         |  2 +
 tests/Makefile.sources    |  6 +++
 tests/meson.build         |  3 ++
 tests/v3d_ci/README       | 26 +++++++++++++
 tests/v3d_ci/v3d.testlist |  6 +++
 tests/v3d_get_bo_offset.c | 78 ++++++++++++++++++++++++++++++++++++++
 tests/v3d_get_param.c     | 80 +++++++++++++++++++++++++++++++++++++++
 tests/v3d_mmap.c          | 55 +++++++++++++++++++++++++++
 9 files changed, 256 insertions(+), 4 deletions(-)
 create mode 100644 tests/v3d_ci/README
 create mode 100644 tests/v3d_ci/v3d.testlist
 create mode 100644 tests/v3d_get_bo_offset.c
 create mode 100644 tests/v3d_get_param.c
 create mode 100644 tests/v3d_mmap.c

diff --git a/lib/igt_v3d.c b/lib/igt_v3d.c
index 1a5ede1bd5fc..619c072c0e47 100644
--- a/lib/igt_v3d.c
+++ b/lib/igt_v3d.c
@@ -40,10 +40,6 @@
 #include "intel_chipset.h"
 #include "v3d_drm.h"
 
-#if NEW_CONTEXT_PARAM_NO_ERROR_CAPTURE_API
-#define LOCAL_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4
-#endif
-
 /**
  * SECTION:igt_v3d
  * @short_description: V3D support library
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3d1ce0bc1af8..a6b2ba51ea4f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -14,6 +14,8 @@ if BUILD_VC4
     TESTS_progs += $(VC4_TESTS)
 endif
 
+TESTS_progs += $(V3D_TESTS)
+
 if HAVE_CHAMELIUM
 TESTS_progs += \
 	kms_chamelium \
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index d007ebc74ab9..3ed60e7c30c7 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -15,6 +15,12 @@ VC4_TESTS = \
 	vc4_wait_seqno \
 	$(NULL)
 
+V3D_TESTS = \
+	v3d_get_bo_offset \
+	v3d_get_param \
+	v3d_mmap \
+	$(NULL)
+
 AMDGPU_TESTS = \
 	amdgpu/amd_basic \
 	amdgpu/amd_cs_nop \
diff --git a/tests/meson.build b/tests/meson.build
index 3020f7984d7a..4472536aef65 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -85,6 +85,9 @@ test_progs = [
 	'syncobj_wait',
 	'template',
 	'tools_test',
+	'v3d_get_bo_offset',
+	'v3d_get_param',
+	'v3d_mmap',
 	'vc4_create_bo',
 	'vc4_dmabuf_poll',
 	'vc4_label_bo',
diff --git a/tests/v3d_ci/README b/tests/v3d_ci/README
new file mode 100644
index 000000000000..e03c552fb972
--- /dev/null
+++ b/tests/v3d_ci/README
@@ -0,0 +1,26 @@
+This directory contains test lists to be used for v3d's DRM support. The files
+are passed to piglit with the --test-list parameter directly.
+
+The test lists are contained in the IGT repository for several
+reasons:
+
+- The lists stay synchronized with the IGT codebase.
+- Public availability. Kernel developers can see what tests are run,
+  and can see what changes are done to the set, when, and why.
+- Explicit test lists in general make it possible to implement a new
+  test without having it run by everyone else before the tests and / or setup
+  are ready for it.
+
+Changing the test lists should only happen with approval from the v3d
+maintainer, Eric Anholt (eric@xxxxxxxxxx).
+
+============
+v3d.testlist
+============
+
+This test list is meant as a general test suite without any time
+restriction for the v3d DRM driver, combining generic DRM and KMS
+tests.  As a reminder, you can run this with the meson build using:
+
+./build/runner/igt_runner --test-list tests/v3d_ci/v3d.testlist \
+  build/tests -o results
diff --git a/tests/v3d_ci/v3d.testlist b/tests/v3d_ci/v3d.testlist
new file mode 100644
index 000000000000..b55e8e571d7d
--- /dev/null
+++ b/tests/v3d_ci/v3d.testlist
@@ -0,0 +1,6 @@
+igt@v3d_get_bo_offset@create-get-offsets
+igt@v3d_get_bo_offset@get-bad-handle
+igt@v3d_get_param@base-params
+igt@v3d_get_param@get-bad-param
+igt@v3d_get_param@get-bad-flags
+igt@v3d_mmap@mmap-bad-handle
diff --git a/tests/v3d_get_bo_offset.c b/tests/v3d_get_bo_offset.c
new file mode 100644
index 000000000000..0923dc85f0d0
--- /dev/null
+++ b/tests/v3d_get_bo_offset.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright © 2017 Broadcom
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "igt.h"
+#include "igt_v3d.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <poll.h>
+#include "v3d_drm.h"
+#include "igt_v3d.h"
+
+igt_main
+{
+	int fd;
+
+	igt_fixture
+		fd = drm_open_driver(DRIVER_V3D);
+
+	igt_subtest("create-get-offsets") {
+		struct v3d_bo *bos[2] = {
+			igt_v3d_create_bo(fd, 4096),
+			igt_v3d_create_bo(fd, 4096),
+		};
+		uint32_t offsets[2] = {
+			igt_v3d_get_bo_offset(fd, bos[0]->handle),
+			igt_v3d_get_bo_offset(fd, bos[1]->handle),
+		};
+
+		igt_assert_neq(bos[0]->handle, bos[1]->handle);
+		igt_assert_neq(bos[0]->offset, bos[1]->offset);
+		igt_assert_eq(bos[0]->offset, offsets[0]);
+		igt_assert_eq(bos[1]->offset, offsets[1]);
+
+		/* 0 is an invalid offset for BOs to be placed at. */
+		igt_assert_neq(bos[0]->offset, 0);
+		igt_assert_neq(bos[1]->offset, 0);
+
+		igt_v3d_free_bo(fd, bos[0]);
+		igt_v3d_free_bo(fd, bos[1]);
+	}
+
+	igt_subtest("get-bad-handle") {
+		struct drm_v3d_get_bo_offset get = {
+			.handle = 0xd0d0d0d0,
+		};
+		do_ioctl_err(fd, DRM_IOCTL_V3D_GET_BO_OFFSET, &get, ENOENT);
+	}
+
+	igt_fixture
+		close(fd);
+}
diff --git a/tests/v3d_get_param.c b/tests/v3d_get_param.c
new file mode 100644
index 000000000000..76563406c0a1
--- /dev/null
+++ b/tests/v3d_get_param.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright © 2017 Broadcom
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "igt.h"
+#include "igt_v3d.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <poll.h>
+#include "v3d_drm.h"
+#include "igt_v3d.h"
+
+igt_main
+{
+	int fd;
+
+	igt_fixture
+		fd = drm_open_driver(DRIVER_V3D);
+
+	igt_subtest("base-params") {
+		enum drm_v3d_param last_base_param =
+			DRM_V3D_PARAM_V3D_CORE0_IDENT2;
+
+		uint32_t results[last_base_param];
+
+		for (int i = 0; i < ARRAY_SIZE(results); i++)
+			results[i] = igt_v3d_get_param(fd, i);
+
+		/* HUB TVER field */
+		igt_assert_lte(3, results[DRM_V3D_PARAM_V3D_HUB_IDENT1] & 0xf);
+
+		/* CORE's ident, has VER field but also an ID. */
+		igt_assert_eq(results[DRM_V3D_PARAM_V3D_CORE0_IDENT0] & 0xffffff,
+			      0x443356 /* "V3D" */);
+	}
+
+	igt_subtest("get-bad-param") {
+		struct drm_v3d_get_param get = {
+			.param = 0xd0d0d0d0,
+		};
+		do_ioctl_err(fd, DRM_IOCTL_V3D_GET_PARAM, &get, EINVAL);
+	}
+
+	igt_subtest("get-bad-flags") {
+		struct drm_v3d_get_param get = {
+			.param = DRM_V3D_PARAM_V3D_HUB_IDENT1,
+			.pad = 1,
+		};
+		do_ioctl_err(fd, DRM_IOCTL_V3D_GET_PARAM, &get, EINVAL);
+	}
+
+	igt_fixture
+		close(fd);
+}
diff --git a/tests/v3d_mmap.c b/tests/v3d_mmap.c
new file mode 100644
index 000000000000..a6fe7e5a7322
--- /dev/null
+++ b/tests/v3d_mmap.c
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2017 Broadcom
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "igt.h"
+#include "igt_v3d.h"
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <poll.h>
+#include "v3d_drm.h"
+#include "igt_v3d.h"
+
+igt_main
+{
+	int fd;
+
+	igt_fixture
+		fd = drm_open_driver(DRIVER_V3D);
+
+	igt_subtest("mmap-bad-handle") {
+		struct drm_v3d_mmap_bo get = {
+			.handle = 0xd0d0d0d0,
+		};
+		do_ioctl_err(fd, DRM_IOCTL_V3D_MMAP_BO, &get, ENOENT);
+	}
+
+	igt_fixture
+		close(fd);
+}
-- 
2.19.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux