From patchwork Tue Aug 11 20:59:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiago Vignatti X-Patchwork-Id: 6994701 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7FCE2C05AC for ; Tue, 11 Aug 2015 20:59:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8666A20686 for ; Tue, 11 Aug 2015 20:59:55 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 9490C206A5 for ; Tue, 11 Aug 2015 20:59:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C3F1D6EA1F; Tue, 11 Aug 2015 13:59:53 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A5AD6EA22; Tue, 11 Aug 2015 13:59:51 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 11 Aug 2015 13:59:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,655,1432623600"; d="scan'208";a="540024336" Received: from tvignatt-mobl3.amr.corp.intel.com ([10.254.185.61]) by FMSMGA003.fm.intel.com with ESMTP; 11 Aug 2015 13:59:48 -0700 From: Tiago Vignatti To: dri-devel@lists.freedesktop.org Date: Tue, 11 Aug 2015 17:59:25 -0300 Message-Id: <1439326768-5611-7-git-send-email-tiago.vignatti@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1439326768-5611-1-git-send-email-tiago.vignatti@intel.com> References: <1439326768-5611-1-git-send-email-tiago.vignatti@intel.com> Cc: daniel.vetter@ffwll.ch, intel-gfx@lists.freedesktop.org, daniel.thompson@linaro.org Subject: [Intel-gfx] [PATCH i-g-t 2/5] prime_mmap: Fix a few misc stuff 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-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP - Remove pattern_check(), which was walking through a useless iterator - Remove superfluous PROT_WRITE from gem_mmap, in test_correct() - Add binary file to .gitignore Signed-off-by: Tiago Vignatti --- tests/.gitignore | 1 + tests/prime_mmap.c | 37 ++++++++++++------------------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/tests/.gitignore b/tests/.gitignore index 0af0899..5bc4a58 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -163,6 +163,7 @@ pm_sseu prime_nv_api prime_nv_pcopy prime_nv_test +prime_mmap prime_self_import prime_udl template diff --git a/tests/prime_mmap.c b/tests/prime_mmap.c index 4dc2055..dc59e8f 100644 --- a/tests/prime_mmap.c +++ b/tests/prime_mmap.c @@ -65,19 +65,6 @@ fill_bo(uint32_t handle, size_t size) } } -static int -pattern_check(char *ptr, size_t size) -{ - off_t i; - for (i = 0; i < size; i+=sizeof(pattern)) - { - if (memcmp(ptr, pattern, sizeof(pattern)) != 0) - return 1; - } - - return 0; -} - static void test_correct(void) { @@ -92,14 +79,14 @@ test_correct(void) igt_assert(errno == 0); /* Check correctness vs GEM_MMAP_GTT */ - ptr1 = gem_mmap(fd, handle, BO_SIZE, PROT_READ | PROT_WRITE); + ptr1 = gem_mmap(fd, handle, BO_SIZE, PROT_READ); ptr2 = mmap(NULL, BO_SIZE, PROT_READ, MAP_SHARED, dma_buf_fd, 0); igt_assert(ptr1 != MAP_FAILED); igt_assert(ptr2 != MAP_FAILED); igt_assert(memcmp(ptr1, ptr2, BO_SIZE) == 0); /* Check pattern correctness */ - igt_assert(pattern_check(ptr2, BO_SIZE) == 0); + igt_assert(memcmp(ptr2, pattern, sizeof(pattern)) == 0); munmap(ptr1, BO_SIZE); munmap(ptr2, BO_SIZE); @@ -122,13 +109,13 @@ test_map_unmap(void) ptr = mmap(NULL, BO_SIZE, PROT_READ, MAP_SHARED, dma_buf_fd, 0); igt_assert(ptr != MAP_FAILED); - igt_assert(pattern_check(ptr, BO_SIZE) == 0); + igt_assert(memcmp(ptr, pattern, sizeof(pattern)) == 0); /* Unmap and remap */ munmap(ptr, BO_SIZE); ptr = mmap(NULL, BO_SIZE, PROT_READ, MAP_SHARED, dma_buf_fd, 0); igt_assert(ptr != MAP_FAILED); - igt_assert(pattern_check(ptr, BO_SIZE) == 0); + igt_assert(memcmp(ptr, pattern, sizeof(pattern)) == 0); munmap(ptr, BO_SIZE); close(dma_buf_fd); @@ -151,16 +138,16 @@ test_reprime(void) ptr = mmap(NULL, BO_SIZE, PROT_READ, MAP_SHARED, dma_buf_fd, 0); igt_assert(ptr != MAP_FAILED); - igt_assert(pattern_check(ptr, BO_SIZE) == 0); + igt_assert(memcmp(ptr, pattern, sizeof(pattern)) == 0); close (dma_buf_fd); - igt_assert(pattern_check(ptr, BO_SIZE) == 0); + igt_assert(memcmp(ptr, pattern, sizeof(pattern)) == 0); munmap(ptr, BO_SIZE); dma_buf_fd = prime_handle_to_fd(fd, handle); ptr = mmap(NULL, BO_SIZE, PROT_READ, MAP_SHARED, dma_buf_fd, 0); igt_assert(ptr != MAP_FAILED); - igt_assert(pattern_check(ptr, BO_SIZE) == 0); + igt_assert(memcmp(ptr, pattern, sizeof(pattern)) == 0); munmap(ptr, BO_SIZE); close(dma_buf_fd); @@ -184,7 +171,7 @@ test_forked(void) igt_fork(childno, 1) { ptr = mmap(NULL, BO_SIZE, PROT_READ, MAP_SHARED, dma_buf_fd, 0); igt_assert(ptr != MAP_FAILED); - igt_assert(pattern_check(ptr, BO_SIZE) == 0); + igt_assert(memcmp(ptr, pattern, sizeof(pattern)) == 0); munmap(ptr, BO_SIZE); close(dma_buf_fd); } @@ -210,7 +197,7 @@ test_refcounting(void) ptr = mmap(NULL, BO_SIZE, PROT_READ, MAP_SHARED, dma_buf_fd, 0); igt_assert(ptr != MAP_FAILED); - igt_assert(pattern_check(ptr, BO_SIZE) == 0); + igt_assert(memcmp(ptr, pattern, sizeof(pattern)) == 0); munmap(ptr, BO_SIZE); close (dma_buf_fd); } @@ -231,7 +218,7 @@ test_dup(void) ptr = mmap(NULL, BO_SIZE, PROT_READ, MAP_SHARED, dma_buf_fd, 0); igt_assert(ptr != MAP_FAILED); - igt_assert(pattern_check(ptr, BO_SIZE) == 0); + igt_assert(memcmp(ptr, pattern, sizeof(pattern)) == 0); munmap(ptr, BO_SIZE); gem_close(fd, handle); close (dma_buf_fd); @@ -310,7 +297,7 @@ test_aperture_limit(void) igt_assert(errno == 0); ptr1 = mmap(NULL, size1, PROT_READ, MAP_SHARED, dma_buf_fd1, 0); igt_assert(ptr1 != MAP_FAILED); - igt_assert(pattern_check(ptr1, BO_SIZE) == 0); + igt_assert(memcmp(ptr1, pattern, sizeof(pattern)) == 0); handle2 = gem_create(fd, size1); fill_bo(handle2, BO_SIZE); @@ -318,7 +305,7 @@ test_aperture_limit(void) igt_assert(errno == 0); ptr2 = mmap(NULL, size2, PROT_READ, MAP_SHARED, dma_buf_fd2, 0); igt_assert(ptr2 != MAP_FAILED); - igt_assert(pattern_check(ptr2, BO_SIZE) == 0); + igt_assert(memcmp(ptr2, pattern, sizeof(pattern)) == 0); igt_assert(memcmp(ptr1, ptr2, BO_SIZE) == 0);