From patchwork Thu Mar 26 23:57:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 6102811 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 42AE89F2A9 for ; Thu, 26 Mar 2015 23:54:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 52D9020443 for ; Thu, 26 Mar 2015 23:54:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 508F32044B for ; Thu, 26 Mar 2015 23:54:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5429F7A007; Thu, 26 Mar 2015 16:54:09 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com [74.125.82.44]) by gabe.freedesktop.org (Postfix) with ESMTP id D13AB6EACF for ; Thu, 26 Mar 2015 16:54:03 -0700 (PDT) Received: by wgra20 with SMTP id a20so81669325wgr.3 for ; Thu, 26 Mar 2015 16:54:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=A7H1C5hQCYK1I42l/uVkRj9lOTOqPkbhGLoB2Dq6i1M=; b=gsJKkhDudqm90o3yOpOSz6m2HWfgzdzw4KblxW9UqlrejS2ahOEf6mwCkM37O6/vC/ 5+QrU5ZjoXeeBfgkCYO4uHX2S5k1UB4ep5QDMl9PhYaZEIbF+5oir8kgJS33F1y/VeoN EJ98a5/6mNcbD2z+EPyku9y6dqc+GqfG6e5JWbvuWeZ4AGvYukz4fOOtRupcZqONmvPn RRYi2RTvjjnRuD2jIFfextYlfpEkaf7CPcXEptuqr2TidtFsLXHzrVBOznSxZsgYBb0d 4MpbgKnkDEtQnxnIZPtULg71myqy/bbocSm/ztut6MGGPvIyzRHTFZSx7reT2zg7rIFQ hQrA== X-Received: by 10.194.175.39 with SMTP id bx7mr33502871wjc.22.1427414043176; Thu, 26 Mar 2015 16:54:03 -0700 (PDT) Received: from arch-x220.localdomain (cpc12-croy20-2-0-cust52.croy.cable.virginm.net. [82.44.54.53]) by mx.google.com with ESMTPSA id ey10sm1060338wib.2.2015.03.26.16.54.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Mar 2015 16:54:02 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm v2 4/8] tests/hash: return non-zero on failure Date: Thu, 26 Mar 2015 23:57:07 +0000 Message-Id: <1427414231-11385-4-git-send-email-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.3.1 In-Reply-To: <1427414231-11385-1-git-send-email-emil.l.velikov@gmail.com> References: <1427414231-11385-1-git-send-email-emil.l.velikov@gmail.com> Cc: emil.l.velikov@gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_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 ... and wire up to `make check' now that it's useful. v2: Really return non-zero on failure. Signed-off-by: Emil Velikov --- tests/Makefile.am | 10 ++++++---- tests/hash.c | 26 +++++++++++++++----------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index ea826b5..79a13c4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -29,13 +29,15 @@ LDADD = $(top_builddir)/libdrm.la check_PROGRAMS = \ dristat \ - drmstat \ - hash + drmstat if HAVE_NOUVEAU SUBDIRS += nouveau endif +TESTS = \ + hash + if HAVE_LIBUDEV check_LTLIBRARIES = libdrmtest.la @@ -62,6 +64,6 @@ TESTS = \ updatedraw \ name_from_fd -check_PROGRAMS += $(TESTS) - endif + +check_PROGRAMS += $(TESTS) diff --git a/tests/hash.c b/tests/hash.c index 1543c86..fc093c1 100644 --- a/tests/hash.c +++ b/tests/hash.c @@ -121,8 +121,8 @@ static void compute_dist(HashTablePtr table) } } -static void check_table(HashTablePtr table, - unsigned long key, void * value) +static int check_table(HashTablePtr table, + unsigned long key, void * value) { void *retval; int retcode = drmHashLookup(table, key, &retval); @@ -138,28 +138,32 @@ static void check_table(HashTablePtr table, key, value, retval); break; case 0: - if (value != retval) + if (value != retval) { printf("Bad value: key = %lu, expected = %p, returned = %p\n", key, value, retval); + retcode = -1; + } break; default: printf("Bad retcode = %d: key = %lu, expected = %p, returned = %p\n", retcode, key, value, retval); break; } + return retcode; } int main(void) { HashTablePtr table; unsigned long i; + int ret; printf("\n***** 256 consecutive integers ****\n"); table = drmHashCreate(); for (i = 0; i < 256; i++) drmHashInsert(table, i, (void *)(i << 16 | i)); for (i = 0; i < 256; i++) - check_table(table, i, (void *)(i << 16 | i)); + ret |= check_table(table, i, (void *)(i << 16 | i)); compute_dist(table); drmHashDestroy(table); @@ -168,7 +172,7 @@ int main(void) for (i = 0; i < 1024; i++) drmHashInsert(table, i, (void *)(i << 16 | i)); for (i = 0; i < 1024; i++) - check_table(table, i, (void *)(i << 16 | i)); + ret |= check_table(table, i, (void *)(i << 16 | i)); compute_dist(table); drmHashDestroy(table); @@ -177,7 +181,7 @@ int main(void) for (i = 0; i < 1024; i++) drmHashInsert(table, i*4096, (void *)(i << 16 | i)); for (i = 0; i < 1024; i++) - check_table(table, i*4096, (void *)(i << 16 | i)); + ret |= check_table(table, i*4096, (void *)(i << 16 | i)); compute_dist(table); drmHashDestroy(table); @@ -188,10 +192,10 @@ int main(void) drmHashInsert(table, random(), (void *)(i << 16 | i)); srandom(0xbeefbeef); for (i = 0; i < 1024; i++) - check_table(table, random(), (void *)(i << 16 | i)); + ret |= check_table(table, random(), (void *)(i << 16 | i)); srandom(0xbeefbeef); for (i = 0; i < 1024; i++) - check_table(table, random(), (void *)(i << 16 | i)); + ret |= check_table(table, random(), (void *)(i << 16 | i)); compute_dist(table); drmHashDestroy(table); @@ -202,12 +206,12 @@ int main(void) drmHashInsert(table, random(), (void *)(i << 16 | i)); srandom(0xbeefbeef); for (i = 0; i < 5000; i++) - check_table(table, random(), (void *)(i << 16 | i)); + ret |= check_table(table, random(), (void *)(i << 16 | i)); srandom(0xbeefbeef); for (i = 0; i < 5000; i++) - check_table(table, random(), (void *)(i << 16 | i)); + ret |= check_table(table, random(), (void *)(i << 16 | i)); compute_dist(table); drmHashDestroy(table); - return 0; + return ret; }