From patchwork Wed Jun 24 11:51:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 50266 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 09E6121575 for ; Wed, 24 Jun 2015 11:58:45 +0000 (UTC) Received: by wilk19 with SMTP id k19sf12798853wil.3 for ; Wed, 24 Jun 2015 04:58:44 -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: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=adzIkvA7wMxIMD91k4bWLzB5dMrrJmgJZ8vTRRCFg6k=; b=M0QDt+nWpatr7zMGUeKNqf0vmcRiOsWLfOSta7Jo49Y5k7K7kR39ALRoVxaDxGazJl B9IUkZ0+sInZSgOZ2X+T9TubpjWprfcR7qliHpbCCcuzmMuCEICQT6Rjyb/bcTDacbOq 5mjbRksJqKg+Eq6ctuR0obR/wEfXse+R7GsTLJnm8oAGaEheJz0lQ5PnbLfUW+hkibVr XZ5I/ghd9cqsjhCCCTQyaKC9I8qOfHpIz0IC8TpnxMW+CuaiJS7QALjvjJkBF29YqJPr sI+ab3e0DSBaU0+MDmq9V1hNipdWGIajdvaM+Lizt8fiOGcOAeYCHtCpTAyYDBB0P03+ hfDg== X-Gm-Message-State: ALoCoQnbJvDj1ClhdnhQ+h23NvyNB8eKfU3g4v8aZeRAHLLjWSDzPbEurF8Ru+kIEWpuVfpSviZw X-Received: by 10.112.40.45 with SMTP id u13mr35711370lbk.0.1435147124276; Wed, 24 Jun 2015 04:58:44 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.7 with SMTP id bc7ls190524lab.74.gmail; Wed, 24 Jun 2015 04:58:44 -0700 (PDT) X-Received: by 10.112.156.97 with SMTP id wd1mr38488650lbb.30.1435147124125; Wed, 24 Jun 2015 04:58:44 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id ug3si21841930lbb.130.2015.06.24.04.58.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jun 2015 04:58:43 -0700 (PDT) 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 lbnk3 with SMTP id k3so24841398lbn.1 for ; Wed, 24 Jun 2015 04:58:43 -0700 (PDT) X-Received: by 10.152.44.166 with SMTP id f6mr39815069lam.86.1435147123694; Wed, 24 Jun 2015 04:58:43 -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.108.230 with SMTP id hn6csp3732295lbb; Wed, 24 Jun 2015 04:58:42 -0700 (PDT) X-Received: by 10.140.201.4 with SMTP id w4mr53640294qha.11.1435147122071; Wed, 24 Jun 2015 04:58:42 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f92si25443604qge.71.2015.06.24.04.58.41; Wed, 24 Jun 2015 04:58:42 -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 F2EAD61E56; Wed, 24 Jun 2015 11:58:40 +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=disabled 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 13DE761DA5; Wed, 24 Jun 2015 11:58:25 +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 7B68E61B63; Wed, 24 Jun 2015 11:58:18 +0000 (UTC) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com [209.85.215.52]) by lists.linaro.org (Postfix) with ESMTPS id CFD0261B63 for ; Wed, 24 Jun 2015 11:51:46 +0000 (UTC) Received: by lacny3 with SMTP id ny3so24315529lac.3 for ; Wed, 24 Jun 2015 04:51:45 -0700 (PDT) X-Received: by 10.112.137.1 with SMTP id qe1mr38920163lbb.22.1435146705082; Wed, 24 Jun 2015 04:51:45 -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 at2sm6291049lbc.12.2015.06.24.04.51.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Jun 2015 04:51:44 -0700 (PDT) From: Christophe Milard To: anders.roxell@linaro.org, mike.holmes@linaro.org, stuart.haslam@linaro.org, maxim.uvarov@linaro.org Date: Wed, 24 Jun 2015 13:51:37 +0200 Message-Id: <1435146697-2520-1-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Cc: lng-odp@lists.linaro.org Subject: [lng-odp] [PATCH] validation: new functions to register hooks 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.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 Two new functions are introduced in odp_cunit_common.c: odp_cunit_register_global_init() is to be used to register test executable init function (overloading the default ODP init performed). odp_cunit_register_global_term() is to be used to register test executable terminason function (overloading the default ODP term). These two functions should be used instead of overloading the default weak symbol. Overloading the weak symbol still works, but is planned for removal. The usage of these register functions enables the init/term functions to be part of the library for the tested module. Signed-off-by: Christophe Milard --- test/validation/common/odp_cunit_common.c | 37 +++++++++++++++++++++++++++++-- test/validation/common/odp_cunit_common.h | 21 +++++++++++++----- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c index 2b83ae6..67938f2 100644 --- a/test/validation/common/odp_cunit_common.c +++ b/test/validation/common/odp_cunit_common.c @@ -11,6 +11,15 @@ /* Globals */ static odph_linux_pthread_t thread_tbl[MAX_WORKERS]; +/* + * global init/term functions which may be registered + * defaults to functions performing odp init/term. + */ +static struct { + int (*global_init_ptr)(void); + int (*global_term_ptr)(void); +} global_init_term = {tests_global_init, tests_global_term}; + /** create test thread */ int odp_cunit_thread_create(void *func_ptr(void *), pthrd_arg *arg) { @@ -62,6 +71,26 @@ ODP_WEAK_SYMBOL int tests_global_term(void) return 0; } +/* + * register tests_global_init and tests_global_term functions. + * If some of these functions are not registered, the defaults functions + * (tests_global_init() and tests_global_term()) defined above are used. + * One should use these register functions when defining these hooks. + * (overloading the weak symbol above is obsolete and will be removed in + * the future). + * Note that passing NULL as function pointer is valid and will simply + * prevent the default (odp init/term) to be done. + */ +void odp_cunit_register_global_init(int (*func_init_ptr)(void)) +{ + global_init_term.global_init_ptr = func_init_ptr; +} + +void odp_cunit_register_global_term(int (*func_term_ptr)(void)) +{ + global_init_term.global_term_ptr = func_term_ptr; +} + int odp_cunit_run(CU_SuiteInfo testsuites[]) { int ret; @@ -69,7 +98,9 @@ int odp_cunit_run(CU_SuiteInfo testsuites[]) printf("\tODP API version: %s\n", odp_version_api_str()); printf("\tODP implementation version: %s\n", odp_version_impl_str()); - if (0 != tests_global_init()) + /* call test executable init hook, if any */ + if (global_init_term.global_init_ptr && + ((*global_init_term.global_init_ptr)() != 0)) return -1; CU_set_error_action(CUEA_ABORT); @@ -83,7 +114,9 @@ int odp_cunit_run(CU_SuiteInfo testsuites[]) CU_cleanup_registry(); - if (0 != tests_global_term()) + /* call test executable terminason hook, if any */ + if (global_init_term.global_term_ptr && + ((*global_init_term.global_term_ptr)() != 0)) 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 3b4d9fb..7d02a01 100644 --- a/test/validation/common/odp_cunit_common.h +++ b/test/validation/common/odp_cunit_common.h @@ -43,13 +43,20 @@ typedef struct { /** create thread fro 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 initialization. + * Global tests initialization/terminason. * - * Initialize global resources needed by all testsuites. Default weak definition - * do nothing. Test application can override it by defining a strong version. - * The function is called by the common main() just after ODP global/local - * initialization. + * Initialize global resources needed by the test executable. Default + * definition does ODP init / term (both global and local). + * Test executables can override it by calling one of the + * register function below (or by defining a strong version, + * but this is depreciated). + * The functions are called at the very beginning + * end very end of the test execution. + * Passing NULL to odp_cunit_register_global_init() and/or + * odp_cunit_register_global_term() is legal and will simply prevent the + * default (ODP init/term) to be done. * * @note: This function is a workaround for Crypto test and other applications * should try not to use it, because it will complicate migration to a @@ -60,4 +67,8 @@ extern int tests_global_init(void); extern int tests_global_term(void); +void odp_cunit_register_global_init(int (*func_init_ptr)(void)); + +void odp_cunit_register_global_term(int (*func_term_ptr)(void)); + #endif /* ODP_CUNICT_COMMON_H */