diff options
author | Eric Anholt <eric@anholt.net> | 2017-06-07 13:31:51 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2017-08-31 16:10:11 -0700 |
commit | e2a888b48fbffa45ea4519aeedfca64d3f4cd61c (patch) | |
tree | 4a182c6f95c6082f3f453affaf61859a195a0f1a | |
parent | 0cdf98798148ad3e26bb499a9afa542911050081 (diff) |
igt/vc5_*: Add new tests for the VC5 UABI.vc5
Signed-off-by: Eric Anholt <eric@anholt.net>
-rw-r--r-- | tests/Makefile.am | 10 | ||||
-rw-r--r-- | tests/Makefile.sources | 6 | ||||
-rw-r--r-- | tests/vc5_get_bo_offset.c | 69 | ||||
-rw-r--r-- | tests/vc5_get_param.c | 79 | ||||
-rw-r--r-- | tests/vc5_mmap.c | 55 |
5 files changed, 219 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 726e2b27..abcdbae8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -14,6 +14,9 @@ if HAVE_LIBDRM_VC4 TESTS_progs += $(VC4_TESTS) endif +#XXX: conditional build + TESTS_progs += $(VC5_TESTS) + if HAVE_CHAMELIUM TESTS_progs += \ chamelium \ @@ -138,6 +141,13 @@ vc4_wait_bo_LDADD = $(LDADD) $(DRM_VC4_LIBS) vc4_wait_seqno_CFLAGS = $(AM_CFLAGS) $(DRM_VC4_CFLAGS) vc4_wait_seqno_LDADD = $(LDADD) $(DRM_VC4_LIBS) +vc5_get_bo_offset_CFLAGS = $(AM_CFLAGS) $(DRM_VC5_CFLAGS) +vc5_get_bo_offset_LDADD = $(LDADD) $(DRM_VC5_LIBS) +vc5_get_param_CFLAGS = $(AM_CFLAGS) $(DRM_VC5_CFLAGS) +vc5_get_param_LDADD = $(LDADD) $(DRM_VC5_LIBS) +vc5_get_mmap_bo_CFLAGS = $(AM_CFLAGS) $(DRM_VC5_CFLAGS) +vc5_get_mmap_bo_LDADD = $(LDADD) $(DRM_VC5_LIBS) + chamelium_CFLAGS = $(AM_CFLAGS) $(XMLRPC_CFLAGS) $(LIBUDEV_CFLAGS) chamelium_LDADD = $(LDADD) $(XMLRPC_LIBS) $(LIBUDEV_LIBS) diff --git a/tests/Makefile.sources b/tests/Makefile.sources index 0f4e39af..ad004c92 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -12,6 +12,12 @@ VC4_TESTS = \ vc4_wait_seqno \ $(NULL) +VC5_TESTS = \ + vc5_get_bo_offset \ + vc5_get_param \ + vc5_mmap \ + $(NULL) + AMDGPU_TESTS = \ amdgpu/amd_basic \ amdgpu/amd_cs_nop \ diff --git a/tests/vc5_get_bo_offset.c b/tests/vc5_get_bo_offset.c new file mode 100644 index 00000000..0fdef120 --- /dev/null +++ b/tests/vc5_get_bo_offset.c @@ -0,0 +1,69 @@ +/* + * 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_vc5.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 "vc5_drm.h" +#include "igt_vc5.h" + +igt_main +{ + int fd; + + igt_fixture + fd = drm_open_driver(DRIVER_VC5); + + igt_subtest("create_get_offsets") { + uint32_t offset_0, offset_1; + int handle_0 = igt_vc5_create_bo(fd, 4096, &offset_0); + int handle_1 = igt_vc5_create_bo(fd, 4096, &offset_1); + + uint32_t get_offset_0 = igt_vc5_get_bo_offset(fd, handle_0); + uint32_t get_offset_1 = igt_vc5_get_bo_offset(fd, handle_1); + + igt_assert_neq(handle_0, handle_1); + igt_assert_neq(offset_0, offset_1); + igt_assert_eq(offset_0, get_offset_0); + igt_assert_eq(offset_1, get_offset_1); + } + + igt_subtest("get-bad-handle") { + struct drm_vc5_get_bo_offset get = { + .handle = 0xd0d0d0d0, + }; + do_ioctl_err(fd, DRM_IOCTL_VC5_GET_BO_OFFSET, &get, ENOENT); + } + + igt_fixture + close(fd); +} diff --git a/tests/vc5_get_param.c b/tests/vc5_get_param.c new file mode 100644 index 00000000..48a948b0 --- /dev/null +++ b/tests/vc5_get_param.c @@ -0,0 +1,79 @@ +/* + * 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_vc5.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 "vc5_drm.h" +#include "igt_vc5.h" + +igt_main +{ + int fd; + + igt_fixture + fd = drm_open_driver(DRIVER_VC5); + + igt_subtest("base_params") { + enum drm_vc5_param last_base_param = + DRM_VC5_PARAM_V3D_CORE0_IDENT2; + + uint32_t results[last_base_param]; + + for (int i = 0; i < ARRAY_SIZE(results); i++) + results[i] = igt_vc5_get_param(fd, i); + + /* TVER field */ + igt_assert_eq(results[DRM_VC5_PARAM_V3D_HUB_IDENT1] & 0xf, 3); + + /* VER field */ + igt_assert_eq(results[DRM_VC5_PARAM_V3D_CORE0_IDENT0] >> 24, 3); + } + + igt_subtest("get-bad-param") { + struct drm_vc5_get_param get = { + .param = 0xd0d0d0d0, + }; + do_ioctl_err(fd, DRM_IOCTL_VC5_GET_PARAM, &get, EINVAL); + } + + igt_subtest("get-bad-flags") { + struct drm_vc5_get_param get = { + .param = DRM_VC5_PARAM_V3D_HUB_IDENT1, + .pad = 1, + }; + do_ioctl_err(fd, DRM_IOCTL_VC5_GET_PARAM, &get, EINVAL); + } + + igt_fixture + close(fd); +} diff --git a/tests/vc5_mmap.c b/tests/vc5_mmap.c new file mode 100644 index 00000000..f12d0008 --- /dev/null +++ b/tests/vc5_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_vc5.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 "vc5_drm.h" +#include "igt_vc5.h" + +igt_main +{ + int fd; + + igt_fixture + fd = drm_open_driver(DRIVER_VC5); + + igt_subtest("mmap_bad_handle") { + struct drm_vc5_mmap_bo get = { + .handle = 0xd0d0d0d0, + }; + do_ioctl_err(fd, DRM_IOCTL_VC5_MMAP_BO, &get, ENOENT); + } + + igt_fixture + close(fd); +} |