From patchwork Fri Apr 24 12:54:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 47559 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DE1762121F for ; Fri, 24 Apr 2015 12:55:46 +0000 (UTC) Received: by wixv7 with SMTP id v7sf3978302wix.0 for ; Fri, 24 Apr 2015 05:55:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:cc: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=RsPAVhWjUZTrbBVzIkz+LJFgsqiolY8Y/9hzruuqehU=; b=k9KVQbPkR6Mjh7mlE1Fg5zINNfNklicxH4FjL1dCUWkB0KffRDmBtTpvlnzRu3KXtq SVfGXVv/BpfbIycbo3fZVSGOfH/0ESlkWmpKJlyIYgoN/EWM2ik4T0r7vI42k6/43BHP mwN245aMs2oyc9mwbd+ukKVLesaHkpTzCfbxlYl2l4yqm3eMqACyQORUUcCGJbLeJ//H ze99KYfGH5tmaBnC0UVx7MU72kLoB5jQ3YZPzth7AvLapd2CeRknE6pV4JrmTpDb/FJm BHQBLZmOPUrwUqhM33CPG7Je1xAHArJHn7RJXUxmy3CMv5rAzpVNz9XD222cdcxxT3O0 mOkA== X-Gm-Message-State: ALoCoQmBIRzR6fHVD202nWKlvuQI3ZRDXHO/mhG9ueKh5XpLHfBLH9Oz7Q5untrm7HEgOxpKVJ7q X-Received: by 10.180.88.226 with SMTP id bj2mr1059097wib.7.1429880146178; Fri, 24 Apr 2015 05:55:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.184.8 with SMTP id eq8ls530782lac.91.gmail; Fri, 24 Apr 2015 05:55:45 -0700 (PDT) X-Received: by 10.152.183.200 with SMTP id eo8mr6907653lac.57.1429880145909; Fri, 24 Apr 2015 05:55:45 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id w6si8203018lbj.46.2015.04.24.05.55.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Apr 2015 05:55:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by lagv1 with SMTP id v1so34492370lag.3 for ; Fri, 24 Apr 2015 05:55:45 -0700 (PDT) X-Received: by 10.153.8.167 with SMTP id dl7mr6850250lad.86.1429880145805; Fri, 24 Apr 2015 05:55:45 -0700 (PDT) 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.67.65 with SMTP id l1csp1172765lbt; Fri, 24 Apr 2015 05:55:44 -0700 (PDT) X-Received: by 10.229.185.193 with SMTP id cp1mr9591009qcb.18.1429880144331; Fri, 24 Apr 2015 05:55:44 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d69si11277643qhc.129.2015.04.24.05.55.43; Fri, 24 Apr 2015 05:55:44 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id 8D46262060; Fri, 24 Apr 2015 12:55:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 7954061CAB; Fri, 24 Apr 2015 12:55:35 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id DFEF061F9F; Fri, 24 Apr 2015 12:55:33 +0000 (UTC) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com [209.85.217.179]) by lists.linaro.org (Postfix) with ESMTPS id B611461FA2 for ; Fri, 24 Apr 2015 12:55:09 +0000 (UTC) Received: by lbbzk7 with SMTP id zk7so35749806lbb.0 for ; Fri, 24 Apr 2015 05:55:08 -0700 (PDT) X-Received: by 10.112.137.164 with SMTP id qj4mr6755152lbb.105.1429880108227; Fri, 24 Apr 2015 05:55:08 -0700 (PDT) Received: from erachmi-VirtualBox.ki.sw.ericsson.se (c-83-233-90-46.cust.bredband2.com. [83.233.90.46]) by mx.google.com with ESMTPSA id 7sm2603829lax.44.2015.04.24.05.55.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Apr 2015 05:55:07 -0700 (PDT) From: Christophe Milard To: anders.roxell@linaro.org, mike.holmes@linaro.org, stuart.haslam@linaro.org, maxim.uvarov@linaro.org Date: Fri, 24 Apr 2015 14:54:54 +0200 Message-Id: <1429880094-13769-2-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1429880094-13769-1-git-send-email-christophe.milard@linaro.org> References: <1429880094-13769-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Cc: lng-odp@lists.linaro.org Subject: [lng-odp] [PATCH 2/2] validation: init tests using common main X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christophe.milard@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 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 The 3 init tests (init, abort,log) now links with common/odp_cunit_common, as other tests. In main, ODP init is now performed via weak functions which are overloaded (to do nothing) by the 3 init tests. Signed-off-by: Christophe Milard --- test/validation/Makefile.am | 6 ++--- test/validation/common/odp_cunit_common.c | 41 +++++++++++++++++++++---------- test/validation/common/odp_cunit_common.h | 20 ++++++++++++++- test/validation/init/odp_init.c | 34 ++++++++++--------------- test/validation/init/odp_init_abort.c | 35 +++++++++++--------------- test/validation/init/odp_init_log.c | 35 +++++++++++--------------- 6 files changed, 91 insertions(+), 80 deletions(-) diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am index 7ea86c4..ba622c3 100644 --- a/test/validation/Makefile.am +++ b/test/validation/Makefile.am @@ -48,9 +48,9 @@ dist_odp_classification_SOURCES = classification/odp_classification_tests.c \ odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto dist_odp_crypto_SOURCES = crypto/odp_crypto_test_inp.c \ odp_crypto.c $(ODP_CU_COMMON) -dist_odp_init_SOURCES = init/odp_init.c -dist_odp_init_abort_SOURCES = init/odp_init_abort.c -dist_odp_init_log_SOURCES = init/odp_init_log.c +dist_odp_init_SOURCES = init/odp_init.c $(ODP_CU_COMMON) +dist_odp_init_abort_SOURCES = init/odp_init_abort.c $(ODP_CU_COMMON) +dist_odp_init_log_SOURCES = init/odp_init_log.c $(ODP_CU_COMMON) dist_odp_queue_SOURCES = odp_queue.c $(ODP_CU_COMMON) dist_odp_random_SOURCES = odp_random.c $(ODP_CU_COMMON) dist_odp_schedule_SOURCES = odp_schedule.c $(ODP_CU_COMMON) diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c index 2af4410..7eca422 100644 --- a/test/validation/common/odp_cunit_common.c +++ b/test/validation/common/odp_cunit_common.c @@ -49,12 +49,8 @@ __attribute__((__weak__)) int tests_global_term(void) return 0; } -int main(void) +__attribute__((__weak__)) int tests_odp_init(void) { - int ret; - - printf("\tODP API version: %s\n", odp_version_api_str()); - printf("\tODP implementation version: %s\n", odp_version_impl_str()); if (0 != odp_init_global(NULL, NULL)) { fprintf(stderr, "error: odp_init_global() failed.\n"); @@ -64,6 +60,32 @@ int main(void) fprintf(stderr, "error: odp_init_local() failed.\n"); return -1; } + return 0; +} + +__attribute__((__weak__)) int tests_odp_term(void) +{ + if (0 != odp_term_local()) { + fprintf(stderr, "error: odp_term_local() failed.\n"); + return -1; + } + + if (0 != odp_term_global()) { + fprintf(stderr, "error: odp_term_global() failed.\n"); + return -1; + } + return 0; +} + +int main(void) +{ + int ret; + + printf("\tODP API version: %s\n", odp_version_api_str()); + printf("\tODP implementation version: %s\n", odp_version_impl_str()); + + if (0 != tests_odp_init()) + return -1; ret = tests_global_init(); if (ret) @@ -83,15 +105,8 @@ int main(void) if (0 != tests_global_term()) return -1; - if (0 != odp_term_local()) { - fprintf(stderr, "error: odp_term_local() failed.\n"); + if (0 != tests_odp_term()) return -1; - } - - if (0 != odp_term_global()) { - fprintf(stderr, "error: odp_term_global() failed.\n"); - return -1; - } return (ret) ? -1 : 0; } diff --git a/test/validation/common/odp_cunit_common.h b/test/validation/common/odp_cunit_common.h index 127020d..852d9ba 100644 --- a/test/validation/common/odp_cunit_common.h +++ b/test/validation/common/odp_cunit_common.h @@ -37,9 +37,27 @@ typedef struct { int numthrds; /**< no of pthreads to create */ } pthrd_arg; -/** create thread fro start_routine function */ +/** create thread for start_routine function */ extern int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg); extern int odp_cunit_thread_exit(pthrd_arg *); + +/** + * Global tests ODP initialization. + * + * ODP initialization/terminaison functions used by this main program. + * Default weak definition does both global and local ODP init/terminaison, + * (which is what most of the test cases want). Override it by defining + * a strong version. + * + * @note: This function is a workaround for Init tests and other applications + * should try not to use it, because it will complicate migration to a + * single test application in future. Normally each testsuite have to + * prepare its environment in its own init function. + */ +extern int tests_odp_init(void); + +extern int tests_odp_term(void); + /** * Global tests initialization. * diff --git a/test/validation/init/odp_init.c b/test/validation/init/odp_init.c index 82f8849..e0d7b2e 100644 --- a/test/validation/init/odp_init.c +++ b/test/validation/init/odp_init.c @@ -7,10 +7,23 @@ #include #include #include +#include "odp_cunit_common.h" #define DEFAULT_MSG_POOL_SIZE (4*1024*1024) #define DEFAULT_MSG_SIZE (8) +/* overwrite common default so as not to perform odp init in main */ +int tests_odp_init(void) +{ + return 0; +} + +/* overwrite common default so as not to perform odp term in main */ +int tests_odp_term(void) +{ + return 0; +} + static void test_odp_init_global(void) { int status; @@ -30,24 +43,3 @@ CU_SuiteInfo odp_testsuites[] = { {"Init", NULL, NULL, NULL, NULL, test_odp_init}, CU_SUITE_INFO_NULL, }; - -int main(void) -{ - int ret; - - printf("\tODP API version: %s\n", odp_version_api_str()); - printf("\tODP implementation version: %s\n", odp_version_impl_str()); - - CU_set_error_action(CUEA_ABORT); - - CU_initialize_registry(); - CU_register_suites(odp_testsuites); - CU_basic_set_mode(CU_BRM_VERBOSE); - CU_basic_run_tests(); - - ret = CU_get_number_of_failure_records(); - - CU_cleanup_registry(); - - return ret; -} diff --git a/test/validation/init/odp_init_abort.c b/test/validation/init/odp_init_abort.c index ceb82b5..2e5efb4 100644 --- a/test/validation/init/odp_init_abort.c +++ b/test/validation/init/odp_init_abort.c @@ -8,6 +8,20 @@ #include #include #include +#include "odp_cunit_common.h" + +/* overwrite common default so as not to perform odp init in main */ +int tests_odp_init(void) +{ + return 0; +} + +/* overwrite common default so as not to perform odp term in main */ +int tests_odp_term(void) +{ + return 0; +} + static void odp_init_abort(void) ODP_NORETURN; @@ -36,27 +50,6 @@ CU_SuiteInfo odp_testsuites[] = { CU_SUITE_INFO_NULL, }; -int main(void) -{ - int ret; - - printf("\tODP API version: %s\n", odp_version_api_str()); - printf("\tODP implementation version: %s\n", odp_version_impl_str()); - - CU_set_error_action(CUEA_ABORT); - - CU_initialize_registry(); - CU_register_suites(odp_testsuites); - CU_basic_set_mode(CU_BRM_VERBOSE); - CU_basic_run_tests(); - - ret = CU_get_number_of_failure_records(); - - CU_cleanup_registry(); - - return ret; -} - void odp_init_abort(void) { abort(); diff --git a/test/validation/init/odp_init_log.c b/test/validation/init/odp_init_log.c index 275d343..c313252 100644 --- a/test/validation/init/odp_init_log.c +++ b/test/validation/init/odp_init_log.c @@ -7,9 +7,23 @@ #include #include #include +#include "odp_cunit_common.h" int replacement_logging_used; +/* overwrite common default so as not to perform odp init in main */ +int tests_odp_init(void) +{ + return 0; +} + +/* overwrite common default so as not to perform odp term in main */ +int tests_odp_term(void) +{ + return 0; +} + + ODP_PRINTF_FORMAT(2, 3) static int odp_init_log(odp_log_level_e level , const char *fmt, ...); @@ -42,27 +56,6 @@ CU_SuiteInfo odp_testsuites[] = { CU_SUITE_INFO_NULL, }; -int main(void) -{ - int ret; - - printf("\tODP API version: %s\n", odp_version_api_str()); - printf("\tODP implementation version: %s\n", odp_version_impl_str()); - - CU_set_error_action(CUEA_ABORT); - - CU_initialize_registry(); - CU_register_suites(odp_testsuites); - CU_basic_set_mode(CU_BRM_VERBOSE); - CU_basic_run_tests(); - - ret = CU_get_number_of_failure_records(); - - CU_cleanup_registry(); - - return ret; -} - int odp_init_log(odp_log_level_e level __attribute__((unused)), const char *fmt, ...) {