From patchwork Thu Nov 20 17:43:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 41257 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CF62F241C9 for ; Thu, 20 Nov 2014 17:44:36 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id p9sf1244353lbv.5 for ; Thu, 20 Nov 2014 09:44:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=YDouv47bJWJh7m8RX6z92veHErHyh/veWNg9T5Y2KYs=; b=If/VHBIudqQMO0PpBl9rWl35ij+ml5OYQJzkQaJCe9/8U8TQHVvpOgCA3Pl8VD4pzU GI/oouCbnYCJyRGj+R29kNzxMgnfRHNbmEVnBvwmlx9eM+Yyb4Nm3sWK2LFG5HIQixe+ BdxHKmRAdQWSmvvBE2ylInHpKGPzYYDVeYhq2RdkJQh2ed247WLb24Bx3WRceEKjLKF4 wCKmpshb66C5Dv3sB1ayu9aXWw94FlHAPYffRNfEk7ePxGVuqKSgX3T3KliBX0iIRpC+ pyz9GJV3E5AMcOhEKYJlsd4TyvAF5yl4+Cq/73LlpGPtexu2JgNlQ+E+PCYVYf+TiyZ6 cKvg== X-Gm-Message-State: ALoCoQnIQmjRa+ogm37DdpFC6L19jGdRa5JsCrH/rQxuPCXUTuDQBhsRjAsA7UbQhIcgnwtoR1FQ X-Received: by 10.180.106.67 with SMTP id gs3mr9604857wib.3.1416505475771; Thu, 20 Nov 2014 09:44:35 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.1 with SMTP id lk1ls104812lac.9.gmail; Thu, 20 Nov 2014 09:44:35 -0800 (PST) X-Received: by 10.112.172.97 with SMTP id bb1mr12413060lbc.38.1416505475603; Thu, 20 Nov 2014 09:44:35 -0800 (PST) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id b4si2730416lbd.70.2014.11.20.09.44.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Nov 2014 09:44:35 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by mail-lb0-f170.google.com with SMTP id w7so2700687lbi.15 for ; Thu, 20 Nov 2014 09:44:35 -0800 (PST) X-Received: by 10.112.52.37 with SMTP id q5mr12370131lbo.32.1416505475366; Thu, 20 Nov 2014 09:44:35 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp306130lbc; Thu, 20 Nov 2014 09:44:34 -0800 (PST) X-Received: by 10.236.198.231 with SMTP id v67mr1351222yhn.158.1416505474036; Thu, 20 Nov 2014 09:44:34 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id t8si3371532qae.53.2014.11.20.09.44.33 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 20 Nov 2014 09:44:34 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XrVmS-0000wQ-6W; Thu, 20 Nov 2014 17:44:32 +0000 Received: from service87.mimecast.com ([91.220.42.44]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XrVmL-0000vB-TV for lng-odp@lists.linaro.org; Thu, 20 Nov 2014 17:44:26 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Thu, 20 Nov 2014 17:44:25 +0000 Received: from e106441.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 20 Nov 2014 17:44:23 +0000 From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Thu, 20 Nov 2014 17:43:44 +0000 Message-Id: <1416505424-583-1-git-send-email-stuart.haslam@arm.com> X-Mailer: git-send-email 2.1.1 X-OriginalArrivalTime: 20 Nov 2014 17:44:23.0796 (UTC) FILETIME=[9F29EB40:01D004E9] X-MC-Unique: 114112017442500201 X-Topics: patch Subject: [lng-odp] [PATCH v2] cunit: fix exit status so failures are caught by make check X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stuart.haslam@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Running "make check" from the top level currently does not detect test failures as the individual test applications report an exit status of 0 even when failures occur. Stop using CU_get_error() as it reports framework errors rather than test / suite failures, and the CU_cleanup_registry() clears the error anyway. Instead exit with a failure code on framework errors, and only exit with 0 if no tests or test suite init/cleanup functions failed. Signed-off-by: Stuart Haslam --- Change in v2: print to stderr on framework errors test/cunit/odp_init.c | 38 ++++++++++++++++++++++++++------------ test/cunit/odp_queue.c | 31 +++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/test/cunit/odp_init.c b/test/cunit/odp_init.c index 88e6235..07002df 100644 --- a/test/cunit/odp_init.c +++ b/test/cunit/odp_init.c @@ -31,26 +31,40 @@ static int finalise(void) return 0; } -int main(void) +static int register_tests(void) { CU_pSuite ptr_suite = NULL; + /* initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) - return CU_get_error(); - /* add a suite to the registry */ + return -1; + + /* add the tests to the queue suite */ ptr_suite = CU_add_suite(__FILE__, init, finalise); - if (NULL == ptr_suite) { - CU_cleanup_registry(); - return CU_get_error(); - } - /* add the tests to the suite */ - if (NULL == CU_ADD_TEST(ptr_suite, test_odp_init_global)) { - CU_cleanup_registry(); - return CU_get_error(); + if (NULL == ptr_suite) + return -1; + + if (NULL == CU_ADD_TEST(ptr_suite, test_odp_init_global)) + return -1; + + return 0; +} + +int main(void) +{ + int ret; + + if (register_tests() != 0) { + fprintf(stderr, "%s: framework error: %s\n", + __FILE__, CU_get_error_msg()); + exit(EXIT_FAILURE); } + /* Run all tests using the CUnit Basic interface */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); + ret = (CU_get_number_of_failure_records() != 0); CU_cleanup_registry(); - return CU_get_error(); + + return ret; } diff --git a/test/cunit/odp_queue.c b/test/cunit/odp_queue.c index 4d233e0..46e7a2e 100644 --- a/test/cunit/odp_queue.c +++ b/test/cunit/odp_queue.c @@ -129,29 +129,40 @@ static int finalize(void) return 0; } -int main(void) +static int register_tests(void) { CU_pSuite ptr_suite = NULL; /* initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) - return CU_get_error(); + return -1; /* add the tests to the queue suite */ ptr_suite = CU_add_suite(__FILE__, init, finalize); - if (NULL == ptr_suite) { - CU_cleanup_registry(); - return CU_get_error(); - } + if (NULL == ptr_suite) + return -1; - if (NULL == CU_ADD_TEST(ptr_suite, test_odp_queue_sunnyday)) { - CU_cleanup_registry(); - return CU_get_error(); + if (NULL == CU_ADD_TEST(ptr_suite, test_odp_queue_sunnyday)) + return -1; + + return 0; +} + +int main(void) +{ + int ret; + + if (register_tests() != 0) { + fprintf(stderr, "%s: framework error: %s\n", + __FILE__, CU_get_error_msg()); + exit(EXIT_FAILURE); } /* Run all tests using the CUnit Basic interface */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); + ret = (CU_get_number_of_failure_records() != 0); CU_cleanup_registry(); - return CU_get_error(); + + return ret; }