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 v2 2/2] tests/vgem_basic: Add negative tests
Date: Thu, 9 Mar 2023 10:51:16 -0300 [thread overview]
Message-ID: <20230309135116.128602-3-mcanal@igalia.com> (raw)
In-Reply-To: <20230309135116.128602-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
next prev parent reply other threads:[~2023-03-09 13:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-09 13:51 [igt-dev] [PATCH i-g-t v2 0/2] Add negative tests to VGEM Maíra Canal
2023-03-09 13:51 ` [igt-dev] [PATCH i-g-t v2 1/2] lib/igt_vgem: Use UAPI header Maíra Canal
2023-03-16 18:12 ` Kamil Konieczny
2023-03-09 13:51 ` Maíra Canal [this message]
2023-03-16 18:19 ` [igt-dev] [PATCH i-g-t v2 2/2] tests/vgem_basic: Add negative tests Kamil Konieczny
2023-03-09 14:26 ` [igt-dev] ✓ Fi.CI.BAT: success for Add negative tests to VGEM (rev2) Patchwork
2023-03-11 3:56 ` [igt-dev] ✓ Fi.CI.IGT: " 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=20230309135116.128602-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