From patchwork Fri Nov 28 16:05:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 41699 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6E023244C2 for ; Fri, 28 Nov 2014 16:06:09 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf4382289lab.3 for ; Fri, 28 Nov 2014 08:06:08 -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:in-reply-to :references: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=gQdM7ioe/Bly/aqxBluFmDCbWBPy3Vo9iw9NWbFe2Uo=; b=BfwramcPnU9yixd25sgJeulIJY5SkClHRUcbRa0oQaIofrf22gXVYMo8FW86ol/u4m e1+/tcl3XbEy1sdeQftbwfHxmzRdQyGesvB1Wf9SHSBrnTH1tVvYp+NWEMjIO5tVBewh q2oyyEklT2u9NaVUpgGuiuFqjFD0pPN5K3VBJp/Vs9eSAo62vksgpgrTmPhVz+UFQOvR UEQ/F+llh99U0QBtlktUu1tCDsdu4cWBdJuKxecrwVoJo1bYVXiXrEvTgX4f10juHG3f Z5/Q+rKd7xHuGQYbiPXh251Tlhe9Dyaa3dgPxHAbkquP+EBJ0I+4tfFNWvj5E/m+ACY0 vjsg== X-Gm-Message-State: ALoCoQlYrdcyt2UaX/5rvhSKoPvxnuMMw4LZGA7kJD1KUSbgf8yzriDsCgj09cQgc+6Nxl2F6Xab X-Received: by 10.180.82.34 with SMTP id f2mr10171015wiy.1.1417190768364; Fri, 28 Nov 2014 08:06:08 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.2 with SMTP id j2ls89089lae.21.gmail; Fri, 28 Nov 2014 08:06:07 -0800 (PST) X-Received: by 10.112.161.161 with SMTP id xt1mr36324661lbb.9.1417190767921; Fri, 28 Nov 2014 08:06:07 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id v9si10338911lbw.113.2014.11.28.08.06.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Nov 2014 08:06:07 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id hs14so5750070lab.22 for ; Fri, 28 Nov 2014 08:06:07 -0800 (PST) X-Received: by 10.152.37.69 with SMTP id w5mr43808649laj.67.1417190767828; Fri, 28 Nov 2014 08:06:07 -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 ew9csp115759lbc; Fri, 28 Nov 2014 08:06:06 -0800 (PST) X-Received: by 10.140.20.175 with SMTP id 44mr61796445qgj.22.1417190765726; Fri, 28 Nov 2014 08:06:05 -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 s104si1708836qge.78.2014.11.28.08.06.04 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 28 Nov 2014 08:06:05 -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 1XuO3Y-0002Ur-6f; Fri, 28 Nov 2014 16:06:04 +0000 Received: from mail-wg0-f54.google.com ([74.125.82.54]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XuO3O-0002UE-70 for lng-odp@lists.linaro.org; Fri, 28 Nov 2014 16:05:54 +0000 Received: by mail-wg0-f54.google.com with SMTP id l2so9230789wgh.27 for ; Fri, 28 Nov 2014 08:05:48 -0800 (PST) X-Received: by 10.180.126.99 with SMTP id mx3mr48069749wib.66.1417190748738; Fri, 28 Nov 2014 08:05:48 -0800 (PST) Received: from uglx0153363.synapse.com ([195.238.92.128]) by mx.google.com with ESMTPSA id r10sm16438043wiy.19.2014.11.28.08.05.47 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Nov 2014 08:05:48 -0800 (PST) From: Taras Kondratiuk To: lng-odp@lists.linaro.org Date: Fri, 28 Nov 2014 18:05:36 +0200 Message-Id: <1417190740-1212-2-git-send-email-taras.kondratiuk@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1417190740-1212-1-git-send-email-taras.kondratiuk@linaro.org> References: <1417190740-1212-1-git-send-email-taras.kondratiuk@linaro.org> Subject: [lng-odp] [RFC 1/5] validation: shm: move main() to a common place 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: taras.kondratiuk@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.49 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 Most of test application will have the same main function. Move main() from odp_shm to a common place where it can be reused by other test applications. Unifying main() will also simplify transition to a combined single test application in future. Signed-off-by: Taras Kondratiuk --- test/validation/Makefile.am | 4 +-- test/validation/common/odp_cunit_common.c | 33 ++++++++++++++++++++ test/validation/common/odp_cunit_common.h | 9 ++++++ test/validation/odp_shm.c | 47 ++--------------------------- 4 files changed, 46 insertions(+), 47 deletions(-) diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am index 4bee2ab..8b55bad 100644 --- a/test/validation/Makefile.am +++ b/test/validation/Makefile.am @@ -1,6 +1,6 @@ include $(top_srcdir)/test/Makefile.inc -AM_CFLAGS += -I$(CUNIT_PATH)/include +AM_CFLAGS += -I$(CUNIT_PATH)/include -I$(srcdir)/common AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit if ODP_CUNIT_ENABLED @@ -11,7 +11,7 @@ odp_init_LDFLAGS = $(AM_LDFLAGS) odp_queue_LDFLAGS = $(AM_LDFLAGS) odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto odp_crypto_LDFLAGS = $(AM_LDFLAGS) -odp_shm_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/common +odp_shm_CFLAGS = $(AM_CFLAGS) odp_shm_LDFLAGS = $(AM_LDFLAGS) endif diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c index 885b981..c87e103 100644 --- a/test/validation/common/odp_cunit_common.c +++ b/test/validation/common/odp_cunit_common.c @@ -35,3 +35,36 @@ int odp_cunit_thread_exit(pthrd_arg *arg) 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 != odp_init_global(NULL, NULL)) { + printf("odp_init_global fail.\n"); + return -1; + } + if (0 != odp_init_local()) { + printf("odp_init_local fail.\n"); + return -1; + } + + 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(); + + odp_term_local(); + odp_term_global(); + + return ret; +} diff --git a/test/validation/common/odp_cunit_common.h b/test/validation/common/odp_cunit_common.h index 5eec376..9ce0df5 100644 --- a/test/validation/common/odp_cunit_common.h +++ b/test/validation/common/odp_cunit_common.h @@ -13,8 +13,17 @@ #ifndef ODP_CUNICT_COMMON_H #define ODP_CUNICT_COMMON_H +#include "CUnit/Basic.h" + #define MAX_WORKERS 32 /**< Maximum number of work threads */ +/** + * Array of testsuites provided by a test application. Array must be terminated + * by CU_SUITE_INFO_NULL and must be suitable to be used by + * CU_register_suites(). + */ +extern CU_SuiteInfo odp_testsuites[]; + typedef struct { uint32_t foo; uint32_t bar; diff --git a/test/validation/odp_shm.c b/test/validation/odp_shm.c index be2b52b..a9fb4be 100644 --- a/test/validation/odp_shm.c +++ b/test/validation/odp_shm.c @@ -5,7 +5,6 @@ */ #include "odp.h" -#include "CUnit/Basic.h" #include "odp_cunit_common.h" #define ALIGE_SIZE (128) @@ -71,54 +70,12 @@ static void test_odp_shm_sunnyday(void) odp_cunit_thread_exit(&thrdarg); } -static int finalize(void) -{ - odp_term_local(); - odp_term_global(); - return 0; -} - -static int init(void) -{ - printf("\tODP API version: %s\n", odp_version_api_str()); - printf("\tODP implementation version: %s\n", odp_version_impl_str()); - return 0; -} - CU_TestInfo test_odp_shm[] = { {"test_odp_shm_creat", test_odp_shm_sunnyday}, CU_TEST_INFO_NULL, }; -CU_SuiteInfo suites[] = { - {"odp_system", init, finalize, NULL, NULL, test_odp_shm}, +CU_SuiteInfo odp_testsuites[] = { + {"Shared Memory", NULL, NULL, NULL, NULL, test_odp_shm}, CU_SUITE_INFO_NULL, }; - - -int main(void) -{ - int ret; - - if (0 != odp_init_global(NULL, NULL)) { - printf("odp_init_global fail.\n"); - return -1; - } - if (0 != odp_init_local()) { - printf("odp_init_local fail.\n"); - return -1; - } - - CU_set_error_action(CUEA_ABORT); - - CU_initialize_registry(); - CU_register_suites(suites); - CU_basic_set_mode(CU_BRM_VERBOSE); - CU_basic_run_tests(); - - ret = CU_get_number_of_failure_records(); - - CU_cleanup_registry(); - - return ret; -}