From patchwork Sun Mar 22 22:03:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 6067821 Return-Path: X-Original-To: patchwork-dri-devel@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 47363BF90F for ; Sun, 22 Mar 2015 22:00:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 546832024C for ; Sun, 22 Mar 2015 22:00:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 5B2002022D for ; Sun, 22 Mar 2015 22:00:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 808676E3D9; Sun, 22 Mar 2015 15:00:49 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-we0-f176.google.com (mail-we0-f176.google.com [74.125.82.176]) by gabe.freedesktop.org (Postfix) with ESMTP id 160C26E3C7 for ; Sun, 22 Mar 2015 15:00:46 -0700 (PDT) Received: by weop45 with SMTP id p45so123606613weo.0 for ; Sun, 22 Mar 2015 15:00:45 -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=cBwDYndJu6M1cPYEtqATiKTW24PC/1POdeePBFe9jcI=; b=lc8Z4Xr0Eknf2clQjWQDAR5mtnBK68RHT2ZLlmjzDEjeQ9qOmDuogxs4HWiZicNJ6u on+gZ4LbSuWcsvmpZGnxyOEO3sojHBSjxRoF5+/eOqAXRBzCVcjxRDDy201dd/MOAYrz eFIAjUz5u80Usyr0P4VWqKC8rB5XShnTK5Qp9k+c6EU4wytW8+AT2nSue5HGvlGjiQw9 SQzdFKuN3e3v8CWVM9MCGPJPq+ZjaWimUINLIQOuFl0cndUXY1T8rf+7AGIu+I/QCdV8 i8jNLMldXmCNhYkMgQ9SPnwUFlYIUE37gS6JL2aTfam7jlQyFE3dZmdNedp1uWJMoKDH Vjsg== X-Received: by 10.194.90.7 with SMTP id bs7mr141974346wjb.7.1427061645525; Sun, 22 Mar 2015 15:00:45 -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 dq8sm8281654wib.9.2015.03.22.15.00.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 22 Mar 2015 15:00:44 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 5/9] tests/hash: return non-zero on failure Date: Sun, 22 Mar 2015 22:03:41 +0000 Message-Id: <1427061825-27470-6-git-send-email-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.3.1 In-Reply-To: <1427061825-27470-1-git-send-email-emil.l.velikov@gmail.com> References: <1427061825-27470-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. Signed-off-by: Emil Velikov Reviewed-by: Jan Vesely --- tests/Makefile.am | 12 +++++++----- tests/hash.c | 26 +++++++++++++++----------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index ea826b5..392abf5 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 @@ -53,7 +55,7 @@ XFAIL_TESTS = \ auth \ lock -TESTS = \ +TESTS += \ openclose \ getversion \ getclient \ @@ -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 fa9264a..46f52f8 100644 --- a/tests/hash.c +++ b/tests/hash.c @@ -142,7 +142,7 @@ static void compute_dist(HashTablePtr table) } } -static void check_table(HashTablePtr table, +static int check_table(HashTablePtr table, unsigned long key, unsigned long value) { unsigned long *retval; @@ -159,28 +159,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 = %lu, returned = %lu\n", key, value, *retval); + retcode = -1; + } break; default: printf("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n", retcode, key, value, *retval); break; } + return retcode; } int main(void) { - HashTablePtr table; - unsigned long i; + HashTablePtr table; + unsigned long i; + int ret = 0; printf("\n***** 256 consecutive integers ****\n"); table = drmHashCreate(); for (i = 0; i < 256; i++) drmHashInsert(table, i, (void *)&i); for (i = 0; i < 256; i++) - check_table(table, i, i); + ret = check_table(table, i, i) && ret; compute_dist(table); drmHashDestroy(table); @@ -189,7 +193,7 @@ int main(void) for (i = 0; i < 1024; i++) drmHashInsert(table, i, (void *)&i); for (i = 0; i < 1024; i++) - check_table(table, i, i); + ret = check_table(table, i, i) && ret; compute_dist(table); drmHashDestroy(table); @@ -198,7 +202,7 @@ int main(void) for (i = 0; i < 1024; i++) drmHashInsert(table, i*4096, (void *)&i); for (i = 0; i < 1024; i++) - check_table(table, i*4096, i); + ret = check_table(table, i*4096, i) && ret; compute_dist(table); drmHashDestroy(table); @@ -209,10 +213,10 @@ int main(void) drmHashInsert(table, random(), (void *)&i); srandom(0xbeefbeef); for (i = 0; i < 1024; i++) - check_table(table, random(), i); + ret = check_table(table, random(), i) && ret; srandom(0xbeefbeef); for (i = 0; i < 1024; i++) - check_table(table, random(), i); + ret = check_table(table, random(), i) && ret; compute_dist(table); drmHashDestroy(table); @@ -223,10 +227,10 @@ int main(void) drmHashInsert(table, random(), (void *)&i); srandom(0xbeefbeef); for (i = 0; i < 5000; i++) - check_table(table, random(), i); + ret = check_table(table, random(), i) && ret; srandom(0xbeefbeef); for (i = 0; i < 5000; i++) - check_table(table, random(), i); + ret = check_table(table, random(), i) && ret; compute_dist(table); drmHashDestroy(table);