From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 848D510E815 for ; Thu, 9 Mar 2023 13:51:39 +0000 (UTC) From: =?UTF-8?q?Ma=C3=ADra=20Canal?= To: Melissa Wen , Daniel Vetter , Petri Latvala , Kamil Konieczny Date: Thu, 9 Mar 2023 10:51:16 -0300 Message-Id: <20230309135116.128602-3-mcanal@igalia.com> In-Reply-To: <20230309135116.128602-1-mcanal@igalia.com> References: <20230309135116.128602-1-mcanal@igalia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [igt-dev] [PATCH i-g-t v2 2/2] tests/vgem_basic: Add negative tests List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" List-ID: 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 --- 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