From patchwork Fri Aug 25 18:00:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Ekstrand X-Patchwork-Id: 9922645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A7FDA602BD for ; Fri, 25 Aug 2017 18:00:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9700F28414 for ; Fri, 25 Aug 2017 18:00:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BDA928438; Fri, 25 Aug 2017 18:00:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 337DD28414 for ; Fri, 25 Aug 2017 18:00:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 76DE46E8D9; Fri, 25 Aug 2017 18:00:47 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 78E436E8DF for ; Fri, 25 Aug 2017 18:00:45 +0000 (UTC) Received: by mail-pg0-x241.google.com with SMTP id 63so702329pgc.1 for ; Fri, 25 Aug 2017 11:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jlekstrand-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YIJmnqTm1s/ORGlkWMf3qHoZu4tbI+ZuhnADa/5ecs0=; b=w4qxg1CqMSMtYl3dVX1nkpwRJm9alM3WcMAkIdj0LJKGibRR8foE1DDnq+CEa57FjR +8m09/DtXu53AgnWraj2zT1q27g1TWIm08z6DQK01BXi7Nb6j2va9X9mUzl+SvbDKA8J UFLpZNnKqjkww+KvhSlMTgT9Q1dvP+wXMazDyQmmYNp5nXRZCpEvqlGsfNMfL2xkC/W2 NLcc9z/TPn+ZSAVMPhUk3a2ruZUFQnfkS4gGeTejo+R2RY6TQSk+TnqI/Z8GHtiFUWye mRUuuCP+LBnQULt3I9vS0n7zhdvG2/jmKR5Wu7Ir+qNsOMBk+oVkeIXhQl2zO1DwiVLb L+yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YIJmnqTm1s/ORGlkWMf3qHoZu4tbI+ZuhnADa/5ecs0=; b=H/VGaxgnRK9u1KNuY68DFmR38NvXc7PNER1zOuv/YxNCHM3v7179ssatD9wPO3wmJf vC0luQyegCNT0ZhE1FRfFAMKRLY+BMANOa6GcRKs9+R/VDHnZCk/9yYqAFcwfOj6RmY8 NPsYCW1GbxY0htCIMxaMKEC2kQcu2rp4dQZ/XWUsOw0gE30/noZEBq8WdiI0UzU8wy4z YaT5PhgVw3VPwatfpp7W5KUh1w/1fXtW7Ka9474uaC9Xkte9i7QuwOKUKYDjL71wbfyx YDbaRDvpu1PBMW8Gs9xO2ESSfGk3cg1kNyUtYmEgSq8Ogy70tgq3IoYgwv9lOsg4scua Aztw== X-Gm-Message-State: AHYfb5g/2Bgo/vnIwAU9aFk44n9XcxkO5vghT4pfyqPga8CwPLmT6+Bq 0ne535A4Sw3/sg3k/Iamrw== X-Received: by 10.101.76.78 with SMTP id l14mr9781842pgr.161.1503684044576; Fri, 25 Aug 2017 11:00:44 -0700 (PDT) Received: from omlet.jlekstrand.net (static-50-43-41-117.bvtn.or.frontiernet.net. [50.43.41.117]) by smtp.gmail.com with ESMTPSA id l22sm12517474pfj.138.2017.08.25.11.00.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Aug 2017 11:00:43 -0700 (PDT) From: Jason Ekstrand X-Google-Original-From: Jason Ekstrand To: intel-gfx@lists.freedesktop.org Date: Fri, 25 Aug 2017 11:00:35 -0700 Message-Id: <1503684037-32006-2-git-send-email-jason.ekstrand@intel.com> X-Mailer: git-send-email 2.5.0.400.gff86faf In-Reply-To: <1503684037-32006-1-git-send-email-jason.ekstrand@intel.com> References: <1503684037-32006-1-git-send-email-jason.ekstrand@intel.com> Cc: Jason Ekstrand Subject: [Intel-gfx] [PATCH i-g-t 2/4] tests/syncobj: Convert the basic test over to the helpers X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Jason Ekstrand --- tests/syncobj_basic.c | 77 +++++++++++++-------------------------------------- 1 file changed, 19 insertions(+), 58 deletions(-) diff --git a/tests/syncobj_basic.c b/tests/syncobj_basic.c index a7a6742..0a304f1 100644 --- a/tests/syncobj_basic.c +++ b/tests/syncobj_basic.c @@ -22,6 +22,7 @@ */ #include "igt.h" +#include "igt_syncobj.h" #include #include #include "drm.h" @@ -48,14 +49,11 @@ static void test_bad_handle_to_fd(int fd) { struct drm_syncobj_handle handle; - int ret; handle.handle = 0xdeadbeef; handle.flags = 0; - ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &handle); - - igt_assert(ret == -1 && errno == EINVAL); + igt_assert_eq(__syncobj_handle_to_fd(fd, &handle), -EINVAL); } /* fd to handle a bad fd */ @@ -63,14 +61,11 @@ static void test_bad_fd_to_handle(int fd) { struct drm_syncobj_handle handle; - int ret; handle.fd = -1; handle.flags = 0; - ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &handle); - - igt_assert(ret == -1 && errno == EINVAL); + igt_assert_eq(__syncobj_fd_to_handle(fd, &handle), -EINVAL); } /* fd to handle an fd but not a sync file one */ @@ -78,58 +73,47 @@ static void test_illegal_fd_to_handle(int fd) { struct drm_syncobj_handle handle; - int ret; handle.fd = fd; handle.flags = 0; - ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &handle); - - igt_assert(ret == -1 && errno == EINVAL); + igt_assert_eq(__syncobj_fd_to_handle(fd, &handle), -EINVAL); } static void test_bad_flags_fd_to_handle(int fd) { struct drm_syncobj_handle handle = { 0 }; - int ret; handle.flags = 0xdeadbeef; - ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &handle); - igt_assert(ret == -1 && errno == EINVAL); + igt_assert_eq(__syncobj_fd_to_handle(fd, &handle), -EINVAL); } static void test_bad_flags_handle_to_fd(int fd) { struct drm_syncobj_handle handle = { 0 }; - int ret; handle.flags = 0xdeadbeef; - ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &handle); - igt_assert(ret == -1 && errno == EINVAL); + igt_assert_eq(__syncobj_handle_to_fd(fd, &handle), -EINVAL); } static void test_bad_pad_handle_to_fd(int fd) { struct drm_syncobj_handle handle = { 0 }; - int ret; handle.pad = 0xdeadbeef; - ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &handle); - igt_assert(ret == -1 && errno == EINVAL); + igt_assert_eq(__syncobj_handle_to_fd(fd, &handle), -EINVAL); } static void test_bad_pad_fd_to_handle(int fd) { struct drm_syncobj_handle handle = { 0 }; - int ret; handle.pad = 0xdeadbeef; - ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &handle); - igt_assert(ret == -1 && errno == EINVAL); + igt_assert_eq(__syncobj_fd_to_handle(fd, &handle), -EINVAL); } @@ -138,24 +122,17 @@ test_bad_pad_fd_to_handle(int fd) static void test_bad_destroy_pad(int fd) { - struct drm_syncobj_create create = { 0 }; struct drm_syncobj_destroy destroy; int ret; - ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &create); - - destroy.handle = create.handle; + destroy.handle = syncobj_create(fd, 0); destroy.pad = 0xdeadbeef; ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy); igt_assert(ret == -1 && errno == EINVAL); - destroy.handle = create.handle; - destroy.pad = 0; - - ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy); - igt_assert(ret == 0); + syncobj_destroy(fd, destroy.handle); } static void @@ -176,34 +153,18 @@ test_bad_create_flags(int fd) static void test_valid_cycle(int fd) { - int ret; - struct drm_syncobj_create create = { 0 }; - struct drm_syncobj_handle handle = { 0 }; - struct drm_syncobj_destroy destroy = { 0 }; - uint32_t first_handle; - - ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &create); - igt_assert(ret == 0); + uint32_t first_handle, second_handle; + int syncobj_fd; - first_handle = create.handle; + first_handle = syncobj_create(fd, 0); + syncobj_fd = syncobj_handle_to_fd(fd, first_handle, 0); + second_handle = syncobj_fd_to_handle(fd, syncobj_fd, 0); + close(syncobj_fd); - handle.handle = create.handle; - ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &handle); - igt_assert(ret == 0); - handle.handle = 0; - ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &handle); - close(handle.fd); - igt_assert(ret == 0); + igt_assert(first_handle != second_handle); - igt_assert(handle.handle != first_handle); - - destroy.handle = handle.handle; - ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy); - igt_assert(ret == 0); - - destroy.handle = first_handle; - ret = ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &destroy); - igt_assert(ret == 0); + syncobj_destroy(fd, first_handle); + syncobj_destroy(fd, second_handle); } static bool has_syncobj(int fd)