diff mbox series

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

Message ID 20181114222832.22839-4-eric@anholt.net (mailing list archive)
State New, archived
Headers show
Series [i-g-t,1/4] kms_content_protection: Fix log bug on 32-bit platforms. | expand

Commit Message

Eric Anholt Nov. 14, 2018, 10:28 p.m. UTC
These are basic non-rendering tests of the UABI.

Signed-off-by: Eric Anholt <eric@anholt.net>
---
 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

Comments

Petri Latvala Nov. 21, 2018, 10:13 a.m. UTC | #1
On Wed, Nov 14, 2018 at 02:28:32PM -0800, Eric Anholt wrote:
> These are basic non-rendering tests of the UABI.
> 
> Signed-off-by: Eric Anholt <eric@anholt.net>
> ---
>  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 +++++++++++++++++++++++++++


Do you need a separate directory for v3d or can you use the vc4
directory for v3d as well? Renamed to 'broadcom-ci' maybe?



>  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.


Note to self: Change this piglit reference to igt_runner (or both) in
intel-ci/README...
Eric Anholt Nov. 26, 2018, 8:46 p.m. UTC | #2
Petri Latvala <petri.latvala@intel.com> writes:

> On Wed, Nov 14, 2018 at 02:28:32PM -0800, Eric Anholt wrote:
>> These are basic non-rendering tests of the UABI.
>> 
>> Signed-off-by: Eric Anholt <eric@anholt.net>
>> ---
>>  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 +++++++++++++++++++++++++++
>
>
> Do you need a separate directory for v3d or can you use the vc4
> directory for v3d as well? Renamed to 'broadcom-ci' maybe?

Do we really need to introduce the vendor name separate from the driver
name?  I guess intel_ci makes some sense if it's used by Intel's CI, but
these are just the test lists for anyone that happens to use igt for
this driver.
Petri Latvala Nov. 27, 2018, 10:16 a.m. UTC | #3
On Mon, Nov 26, 2018 at 12:46:46PM -0800, Eric Anholt wrote:
> Petri Latvala <petri.latvala@intel.com> writes:
> 
> > On Wed, Nov 14, 2018 at 02:28:32PM -0800, Eric Anholt wrote:
> >> These are basic non-rendering tests of the UABI.
> >> 
> >> Signed-off-by: Eric Anholt <eric@anholt.net>
> >> ---
> >>  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 +++++++++++++++++++++++++++
> >
> >
> > Do you need a separate directory for v3d or can you use the vc4
> > directory for v3d as well? Renamed to 'broadcom-ci' maybe?
> 
> Do we really need to introduce the vendor name separate from the driver
> name?  I guess intel_ci makes some sense if it's used by Intel's CI, but
> these are just the test lists for anyone that happens to use igt for
> this driver.

Fair enough, I was assuming there's an active CI somewhere that used
both at the same time.



Acked-by: Petri Latvala <petri.latvala@intel.com>
Eric Anholt Nov. 27, 2018, 8:46 p.m. UTC | #4
Petri Latvala <petri.latvala@intel.com> writes:

> On Mon, Nov 26, 2018 at 12:46:46PM -0800, Eric Anholt wrote:
>> Petri Latvala <petri.latvala@intel.com> writes:
>> 
>> > On Wed, Nov 14, 2018 at 02:28:32PM -0800, Eric Anholt wrote:
>> >> These are basic non-rendering tests of the UABI.
>> >> 
>> >> Signed-off-by: Eric Anholt <eric@anholt.net>
>> >> ---
>> >>  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 +++++++++++++++++++++++++++
>> >
>> >
>> > Do you need a separate directory for v3d or can you use the vc4
>> > directory for v3d as well? Renamed to 'broadcom-ci' maybe?
>> 
>> Do we really need to introduce the vendor name separate from the driver
>> name?  I guess intel_ci makes some sense if it's used by Intel's CI, but
>> these are just the test lists for anyone that happens to use igt for
>> this driver.
>
> Fair enough, I was assuming there's an active CI somewhere that used
> both at the same time.
>
>
>
> Acked-by: Petri Latvala <petri.latvala@intel.com>

Thanks for taking a look at these and acking them!
diff mbox series

Patch

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@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 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);
+}