From: Erico Nunes <nunes.erico@gmail.com>
To: igt-dev@lists.freedesktop.org
Cc: anarsoul@gmail.com, yuq825@gmail.com, lima@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v2 3/3] tests/lima: Add initial tests for lima
Date: Fri, 26 May 2023 15:00:01 +0200 [thread overview]
Message-ID: <20230526130001.71730-4-nunes.erico@gmail.com> (raw)
In-Reply-To: <20230526130001.71730-1-nunes.erico@gmail.com>
Some gem tests based on the panfrost and v3d ones.
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
---
tests/lima_gem_new.c | 78 ++++++++++++++++++++++++++++++++++++++++++++
tests/meson.build | 1 +
2 files changed, 79 insertions(+)
create mode 100644 tests/lima_gem_new.c
diff --git a/tests/lima_gem_new.c b/tests/lima_gem_new.c
new file mode 100644
index 00000000..3b054317
--- /dev/null
+++ b/tests/lima_gem_new.c
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2023 Erico Nunes
+ */
+
+#include "igt.h"
+#include "igt_lima.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 "lima_drm.h"
+
+igt_main
+{
+ int fd;
+
+ igt_fixture {
+ fd = drm_open_driver(DRIVER_LIMA);
+ }
+
+ igt_describe("Sanity check for creating a BO with size 4096.");
+ igt_subtest("gem-new-4096") {
+ struct lima_bo *bo = igt_lima_gem_new(fd, 4096);
+
+ igt_lima_free_bo(fd, bo);
+ }
+
+ igt_describe("Make sure a BO cannot be created with size zero.");
+ igt_subtest("gem-new-0") {
+ struct drm_lima_gem_create arg = {
+ .size = 0,
+ };
+
+ do_ioctl_err(fd, DRM_IOCTL_LIMA_GEM_CREATE, &arg, EINVAL);
+ }
+
+ igt_describe("Make sure that BOs can be allocated in different fd without "
+ "carrying old contents from one another.");
+ igt_subtest("gem-new-zeroed") {
+ int fd2 = drm_open_driver(DRIVER_LIMA);
+ struct lima_bo *bo;
+ uint32_t *map;
+ /* 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 * 4096;
+ size_t i;
+
+ /* Make a BO and free it on our main fd. */
+ bo = igt_lima_gem_new(fd, size);
+ map = igt_lima_mmap_bo(fd, bo->handle, size, PROT_READ | PROT_WRITE);
+ memset(map, 0xd0, size);
+ munmap(map, size);
+ igt_lima_free_bo(fd, bo);
+
+ /* Now, allocate a BO on the other fd and make sure it doesn't
+ * have the old contents.
+ */
+ bo = igt_lima_gem_new(fd2, size);
+ map = igt_lima_mmap_bo(fd2, bo->handle, size, PROT_READ | PROT_WRITE);
+ for (i = 0; i < size / 4; i++)
+ igt_assert_eq_u32(map[i], 0x0);
+ munmap(map, size);
+ igt_lima_free_bo(fd2, bo);
+
+ close(fd2);
+ }
+
+ igt_fixture
+ close(fd);
+}
diff --git a/tests/meson.build b/tests/meson.build
index f71be1db..980e77e9 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -62,6 +62,7 @@ test_progs = [
'kms_vblank',
'kms_vrr',
'kms_writeback',
+ 'lima_gem_new',
'meta_test',
'panfrost_get_param',
'panfrost_gem_new',
--
2.40.1
next prev parent reply other threads:[~2023-05-26 13:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 12:59 [igt-dev] [PATCH i-g-t v2 0/3] Initial tests for the lima drm driver Erico Nunes
2023-05-26 12:59 ` [igt-dev] [PATCH i-g-t v2 1/3] lib: Add support for opening lima devices Erico Nunes
2023-06-05 10:51 ` Kamil Konieczny
2023-05-26 13:00 ` [igt-dev] [PATCH i-g-t v2 2/3] lib/lima: Add lima helpers Erico Nunes
2023-06-05 11:03 ` Kamil Konieczny
2023-05-26 13:00 ` Erico Nunes [this message]
2023-06-05 11:17 ` [igt-dev] [PATCH i-g-t v2 3/3] tests/lima: Add initial tests for lima Kamil Konieczny
2023-06-06 14:51 ` Erico Nunes
2023-05-26 13:12 ` [igt-dev] ✗ GitLab.Pipeline: warning for Initial tests for the lima drm driver (rev2) Patchwork
2023-05-26 13:34 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-05-27 7:17 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2023-06-04 19:05 ` [igt-dev] [PATCH i-g-t v2 0/3] Initial tests for the lima drm driver Erico Nunes
2023-06-05 9:22 ` Zbigniew Kempczyński
2023-06-06 14:43 ` Erico Nunes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230526130001.71730-4-nunes.erico@gmail.com \
--to=nunes.erico@gmail.com \
--cc=anarsoul@gmail.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=lima@lists.freedesktop.org \
--cc=yuq825@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox