summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2017-06-07 13:31:51 -0700
committerEric Anholt <eric@anholt.net>2018-11-27 12:39:17 -0800
commit0a961239c27bfbd60c045e6255b2970d4bf84411 (patch)
tree418f80b2ab7e42e316922ebfd116577c1bacb55e /tests
parent51aa13456993d38e7957946880f2695f48679c06 (diff)
v3d_*: Add new tests for the V3D UABI.
These are basic non-rendering tests of the UABI. Signed-off-by: Eric Anholt <eric@anholt.net> Acked-by: Petri Latvala <petri.latvala@intel.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/Makefile.sources6
-rw-r--r--tests/meson.build3
-rw-r--r--tests/v3d_ci/README26
-rw-r--r--tests/v3d_ci/v3d.testlist6
-rw-r--r--tests/v3d_get_bo_offset.c78
-rw-r--r--tests/v3d_get_param.c80
-rw-r--r--tests/v3d_mmap.c55
8 files changed, 256 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b735c742f..48d77535b 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 5620c1d6c..eedde1e81 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 52f91a223..b8a6e61b3 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -79,6 +79,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 000000000..e03c552fb
--- /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@anholt.net).
+
+============
+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 000000000..b55e8e571
--- /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 000000000..0923dc85f
--- /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 000000000..76563406c
--- /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 000000000..a6fe7e5a7
--- /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);
+}