Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Maíra Canal" <mcanal@igalia.com>
To: Melissa Wen <mwen@igalia.com>, Daniel Vetter <daniel@ffwll.ch>,
	Petri Latvala <adrinael@adrinael.net>,
	Kamil Konieczny <kamil.konieczny@linux.intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 2/2] tests/vgem_basic: Add negative tests
Date: Thu,  9 Mar 2023 10:39:23 -0300	[thread overview]
Message-ID: <20230309133923.124095-3-mcanal@igalia.com> (raw)
In-Reply-To: <20230309133923.124095-1-mcanal@igalia.com>

Currently, the vgem_basic tests don't cover any negative tests. So, add
tests covering possible error paths of the driver by inputting invalid
arguments and checking if the driver is returning the correct values.

Signed-off-by: Maíra Canal <mcanal@igalia.com>
---
 tests/vgem_basic.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/tests/vgem_basic.c b/tests/vgem_basic.c
index 2a2900f8..4f371b3d 100644
--- a/tests/vgem_basic.c
+++ b/tests/vgem_basic.c
@@ -152,6 +152,27 @@ static void test_dmabuf_export(int fd)
 	close(other);
 }
 
+static void test_busy_fence(int fd)
+{
+	struct drm_vgem_fence_attach arg = {};
+	struct vgem_bo bo;
+
+	bo.width = 1024;
+	bo.height = 1;
+	bo.bpp = 32;
+	vgem_create(fd, &bo);
+
+	/* Attach a fence for reading */
+	vgem_fence_attach(fd, &bo, 0);
+
+	/* Attach a fence for writing, so it should be an exclusive fence */
+	arg.handle = bo.handle;
+	arg.flags = VGEM_FENCE_WRITE;
+
+	/* As the fence is not exclusive, return -EBUSY, indicating a conflicting fence */
+	do_ioctl_err(fd, DRM_IOCTL_VGEM_FENCE_ATTACH, &arg, EBUSY);
+}
+
 static void test_dmabuf_mmap(int fd)
 {
 	struct vgem_bo bo;
@@ -434,6 +455,48 @@ igt_main
 	igt_subtest_f("mmap")
 		test_mmap(fd);
 
+	igt_describe("Make sure a fence cannot be attached and signaled with invalid flags.");
+	igt_subtest("bad-flag") {
+		struct drm_vgem_fence_attach attach = {
+			.flags = 0xff,
+		};
+
+		struct drm_vgem_fence_signal signal = {
+			.flags = 0xff,
+		};
+
+		do_ioctl_err(fd, DRM_IOCTL_VGEM_FENCE_ATTACH, &attach, EINVAL);
+		do_ioctl_err(fd, DRM_IOCTL_VGEM_FENCE_SIGNAL, &signal, EINVAL);
+	}
+
+	igt_describe("Make sure the pad is zero.");
+	igt_subtest("bad-pad") {
+		struct drm_vgem_fence_attach arg = {
+			.pad = 0x01,
+		};
+		do_ioctl_err(fd, DRM_IOCTL_VGEM_FENCE_ATTACH, &arg, EINVAL);
+	}
+
+	igt_describe("Make sure a fence cannot be attached to a invalid handle.");
+	igt_subtest("bad-handle") {
+		struct drm_vgem_fence_attach arg = {
+			.handle = 0xff,
+		};
+		do_ioctl_err(fd, DRM_IOCTL_VGEM_FENCE_ATTACH, &arg, ENOENT);
+	}
+
+	igt_describe("Make sure a non-existent fence cannot be signaled.");
+	igt_subtest("bad-fence") {
+		struct drm_vgem_fence_signal arg = {
+			.fence = 0xff,
+		};
+		do_ioctl_err(fd, DRM_IOCTL_VGEM_FENCE_SIGNAL, &arg, ENOENT);
+	}
+
+	igt_describe("Make sure a conflicting fence cannot be attached.");
+	igt_subtest("busy-fence")
+		test_busy_fence(fd);
+
 	igt_subtest_group {
 		igt_fixture {
 			igt_require(has_prime_export(fd));
-- 
2.39.2

  parent reply	other threads:[~2023-03-09 13:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09 13:39 [igt-dev] [PATCH i-g-t 0/2] Add negative tests to VGEM Maíra Canal
2023-03-09 13:39 ` [igt-dev] [PATCH i-g-t 1/2] lib/igt_vgem: Use UAPI header Maíra Canal
2023-03-09 13:39 ` Maíra Canal [this message]
2023-03-09 13:43 ` [igt-dev] ✗ Fi.CI.BUILD: failure for Add negative tests to VGEM Patchwork

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=20230309133923.124095-3-mcanal@igalia.com \
    --to=mcanal@igalia.com \
    --cc=adrinael@adrinael.net \
    --cc=daniel@ffwll.ch \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=mwen@igalia.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