From patchwork Thu Oct 22 09:50:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 55428 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by patches.linaro.org (Postfix) with ESMTPS id 4FE442304B for ; Thu, 22 Oct 2015 09:54:38 +0000 (UTC) Received: by wiclg3 with SMTP id lg3sf31346858wic.3 for ; Thu, 22 Oct 2015 02:54:37 -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: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=PiBhGUmr1c5UAOiLfo679MjAorUneYl6FMyTRYfSoVw=; b=SVAz+lmZcz5e3uMqzsKTpEUxFbBGeUc55GKOFH5GUCctfQ95y8Vhv9CbduUzujKxv8 uLMY77b9TNRzVOSIQJlDDAYjL7biw/5R6UYwo8Zffs7Y4BfyZuplkM24FN8Es2MKfiIu 5k+nZiiLM4ik3JC5gsfNyfZovFoKph+cJFlNrxD0HaEQ7Z681868BMVuGWfi5D0YB/u8 9sID2exNRjKDw6DJSOIhYAvYs3ec7rJ6+iTPl4MPgT5dkpSkNyGcjAbTMZIm/e0hDxuz rPgzenzHe3Xm60xjlh1MSREuBqrq40JXnFF1hERsUW9Wl90sVAOaw1OxfGL9R/YUjLJ1 t7Kw== X-Gm-Message-State: ALoCoQlE3aES0Em4Hwna1JPvfNni6QQSiwSzA5XBACl+pcddORfuFjONRRzjsukpvG7QBFxnPwWl X-Received: by 10.194.71.166 with SMTP id w6mr3437831wju.6.1445507677665; Thu, 22 Oct 2015 02:54:37 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.17.70 with SMTP id g67ls315753lfi.13.gmail; Thu, 22 Oct 2015 02:54:37 -0700 (PDT) X-Received: by 10.112.173.198 with SMTP id bm6mr7800635lbc.43.1445507677503; Thu, 22 Oct 2015 02:54:37 -0700 (PDT) Received: from mail-lf0-x229.google.com (mail-lf0-x229.google.com. [2a00:1450:4010:c07::229]) by mx.google.com with ESMTPS id pr8si2625336lbc.15.2015.10.22.02.54.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2015 02:54:37 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) client-ip=2a00:1450:4010:c07::229; Received: by lffz202 with SMTP id z202so41632790lff.3 for ; Thu, 22 Oct 2015 02:54:37 -0700 (PDT) X-Received: by 10.112.135.9 with SMTP id po9mr8205046lbb.56.1445507677324; Thu, 22 Oct 2015 02:54:37 -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.59.35 with SMTP id w3csp491500lbq; Thu, 22 Oct 2015 02:54:36 -0700 (PDT) X-Received: by 10.140.133.196 with SMTP id 187mr18565650qhf.2.1445507675998; Thu, 22 Oct 2015 02:54:35 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 69si12528055qgt.1.2015.10.22.02.54.35; Thu, 22 Oct 2015 02:54:35 -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 5752062BF2; Thu, 22 Oct 2015 09:54:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW,T_DKIM_INVALID,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id A25A662050; Thu, 22 Oct 2015 09:51:18 +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 3EC8E6203E; Thu, 22 Oct 2015 09:51:12 +0000 (UTC) Received: from mail-lf0-f44.google.com (mail-lf0-f44.google.com [209.85.215.44]) by lists.linaro.org (Postfix) with ESMTPS id 886D16203A for ; Thu, 22 Oct 2015 09:50:25 +0000 (UTC) Received: by lffz202 with SMTP id z202so41518514lff.3 for ; Thu, 22 Oct 2015 02:50:24 -0700 (PDT) X-Received: by 10.112.11.163 with SMTP id r3mr7441457lbb.8.1445507424384; Thu, 22 Oct 2015 02:50:24 -0700 (PDT) Received: from localhost.localdomain (ppp91-76-161-180.pppoe.mtu-net.ru. [91.76.161.180]) by smtp.gmail.com with ESMTPSA id nb1sm2207849lbb.9.2015.10.22.02.50.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Oct 2015 02:50:23 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 22 Oct 2015 12:50:09 +0300 Message-Id: <1445507411-20556-6-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445507411-20556-1-git-send-email-maxim.uvarov@linaro.org> References: <1445507411-20556-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv11 5/7] helper: move ring test to helper 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-Original-Sender: maxim.uvarov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c07::229 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Move ring test to helper and kill not needed api_test directory. Unfortunately odp_ring_test.c had some old dirty code so I had to clean up it to to use cunit and latest helper apis. Signed-off-by: Maxim Uvarov --- configure.ac | 1 - helper/ring.c | 1 + helper/test/Makefile.am | 6 +- .../api_test/odp_ring_test.c => helper/test/ring.c | 100 ++++++++++++--------- test/Makefile.am | 2 +- test/api_test/.gitignore | 2 - test/api_test/Makefile.am | 13 --- test/api_test/odp_common.c | 91 ------------------- test/api_test/odp_common.h | 42 --------- 9 files changed, 63 insertions(+), 195 deletions(-) rename test/api_test/odp_ring_test.c => helper/test/ring.c (86%) delete mode 100644 test/api_test/.gitignore delete mode 100644 test/api_test/Makefile.am delete mode 100644 test/api_test/odp_common.c delete mode 100644 test/api_test/odp_common.h diff --git a/configure.ac b/configure.ac index 5d84f92..fb34e19 100644 --- a/configure.ac +++ b/configure.ac @@ -308,7 +308,6 @@ AC_CONFIG_FILES([Makefile pkgconfig/libodphelper.pc scripts/Makefile test/Makefile - test/api_test/Makefile test/performance/Makefile test/validation/Makefile test/validation/buffer/Makefile diff --git a/helper/ring.c b/helper/ring.c index e113606..2bd8e67 100644 --- a/helper/ring.c +++ b/helper/ring.c @@ -644,3 +644,4 @@ int odph_ring_dequeue_burst(odph_ring_t *r, void **obj_table, unsigned n) else return odph_ring_mc_dequeue_burst(r, obj_table, n); } + diff --git a/helper/test/Makefile.am b/helper/test/Makefile.am index f6a3f83..3e0df0b 100644 --- a/helper/test/Makefile.am +++ b/helper/test/Makefile.am @@ -1,13 +1,15 @@ include $(top_srcdir)/test/Makefile.inc AM_CFLAGS += -I$(srcdir)/common +AM_CFLAGS += -I$(top_srcdir)/test/validation/common AM_LDFLAGS += -static TESTS_ENVIRONMENT += TEST_DIR=${builddir} EXECUTABLES = chksum$(EXEEXT) \ thread$(EXEEXT) \ - process$(EXEEXT) + process$(EXEEXT) \ + ring$(EXEEXT) COMPILE_ONLY = @@ -27,3 +29,5 @@ dist_thread_SOURCES = thread.c thread_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp.la dist_process_SOURCES = process.c process_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp.la +dist_ring_SOURCES = ring.c +ring_LDADD = $(LIB)/libodphelper.la $(LIB)/libodp.la diff --git a/test/api_test/odp_ring_test.c b/helper/test/ring.c similarity index 86% rename from test/api_test/odp_ring_test.c rename to helper/test/ring.c index e8a962a..ca2199d 100644 --- a/test/api_test/odp_ring_test.c +++ b/helper/test/ring.c @@ -37,7 +37,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - /** * @file * @@ -48,14 +47,24 @@ #include #include #include -#include +#include #include #include +#include #define RING_SIZE 4096 #define MAX_BULK 32 -#define RING_TEST_BASIC +enum { + ODP_RING_TEST_BASIC, + ODP_RING_TEST_STRESS, +}; + +/* local struct for ring_thread argument */ +typedef struct { + pthrd_arg thrdarg; + int stress_type; +} ring_arg_t; static int test_ring_basic(odph_ring_t *r) { @@ -64,24 +73,24 @@ static int test_ring_basic(odph_ring_t *r) unsigned i, num_elems; /* alloc dummy object pointers */ - src = malloc(RING_SIZE*2*sizeof(void *)); + src = malloc(RING_SIZE * 2 * sizeof(void *)); if (src == NULL) { LOG_ERR("failed to allocate test ring src memory\n"); goto fail; } - for (i = 0; i < RING_SIZE*2; i++) + for (i = 0; i < RING_SIZE * 2; i++) src[i] = (void *)(unsigned long)i; cur_src = src; /* alloc some room for copied objects */ - dst = malloc(RING_SIZE*2*sizeof(void *)); + dst = malloc(RING_SIZE * 2 * sizeof(void *)); if (dst == NULL) { LOG_ERR("failed to allocate test ring dst memory\n"); goto fail; } - memset(dst, 0, RING_SIZE*2*sizeof(void *)); + memset(dst, 0, RING_SIZE * 2 * sizeof(void *)); cur_dst = dst; printf("Test SP & SC basic functions\n"); @@ -251,7 +260,7 @@ static int producer_fn(void) void **src = NULL; /* alloc dummy object pointers */ - src = malloc(MAX_BULK*2*sizeof(void *)); + src = malloc(MAX_BULK * 2 * sizeof(void *)); if (src == NULL) { LOG_ERR("failed to allocate producer memory.\n"); return -1; @@ -275,7 +284,7 @@ static int consumer_fn(void) void **src = NULL; /* alloc dummy object pointers */ - src = malloc(MAX_BULK*2*sizeof(void *)); + src = malloc(MAX_BULK * 2 * sizeof(void *)); if (src == NULL) { LOG_ERR("failed to allocate consumer memory.\n"); return -1; @@ -298,7 +307,6 @@ static int consumer_fn(void) } while (1); } - /* * Note : make sure that both enqueue and dequeue * operation starts at same time so to avoid data corruption @@ -319,24 +327,22 @@ typedef enum { static void test_ring_stress(stress_type_t type) { int thr; + thr = odp_thread_id(); switch (type) { case one_enq_one_deq: - if (thr == 1) producer_fn(); if (thr == 2) consumer_fn(); break; - case multi_enq_multi_deq: - if (thr%2 == 0) + if (thr % 2 == 0) producer_fn(); else consumer_fn(); break; - case one_deq_rest_enq: case one_enq_rest_deq:/*TBD*/ default: @@ -344,13 +350,6 @@ static void test_ring_stress(stress_type_t type) } } -/* local struct for ring_thread argument */ -typedef struct { - pthrd_arg thrdarg; - int stress_type; -} ring_arg_t; - - static void *test_ring(void *arg) { ring_arg_t *parg = (ring_arg_t *)arg; @@ -368,8 +367,8 @@ static void *test_ring(void *arg) snprintf(ring_name, sizeof(ring_name), "test_ring_%i", thr); r = odph_ring_create(ring_name, RING_SIZE, - 0 /* not used, alignement - taken care inside func : todo */); + 0 /* not used, alignement + taken care inside func : todo */); if (r == NULL) { LOG_ERR("ring create failed\n"); result = -1; @@ -417,36 +416,43 @@ static void *test_ring(void *arg) return parg; } - -int main(int argc __attribute__((__unused__)), - char *argv[] __attribute__((__unused__))) +int main(int argc TEST_UNUSED, char *argv[] TEST_UNUSED) { ring_arg_t rarg; + odph_linux_pthread_t thread_tbl[MAX_WORKERS]; + odp_cpumask_t cpu_mask; + int num_workers; + char ring_name[ODPH_RING_NAMESIZE]; - if (odp_test_global_init() != 0) - return -1; + if (odp_init_global(NULL, NULL)) { + LOG_ERR("Error: ODP global init failed.\n"); + exit(EXIT_FAILURE); + } - odp_print_system_info(); + if (odp_init_local(ODP_THREAD_CONTROL)) { + LOG_ERR("Error: ODP local init failed.\n"); + exit(EXIT_FAILURE); + } odph_ring_tailq_init(); - rarg.thrdarg.numthrds = odp_cpu_count(); + num_workers = odp_cpumask_def_worker(&cpu_mask, MAX_WORKERS); + rarg.thrdarg.numthrds = rarg.thrdarg.numthrds; -#ifdef RING_TEST_BASIC rarg.thrdarg.testcase = ODP_RING_TEST_BASIC; -#else + printf("starting stess test type : %d..\n", rarg.stress_type); + odph_linux_pthread_create(&thread_tbl[0], &cpu_mask, + test_ring, (void *)&rarg); + odph_linux_pthread_join(thread_tbl, num_workers); + rarg.thrdarg.testcase = ODP_RING_TEST_STRESS; rarg.stress_type = one_enq_one_deq; -/* rarg.stress_type = multi_enq_multi_deq;*/ - char ring_name[ODPH_RING_NAMESIZE]; printf("starting stess test type : %d..\n", rarg.stress_type); - /* create a ring */ snprintf(ring_name, sizeof(ring_name), "test_ring_stress"); - r_stress = odph_ring_create(ring_name, RING_SIZE, - 0 /* not used, alignement - taken care inside func : todo */); + 0 /* not used, alignement + taken care inside func : todo */); if (r_stress == NULL) { LOG_ERR("ring create failed\n"); goto fail; @@ -456,15 +462,21 @@ int main(int argc __attribute__((__unused__)), LOG_ERR("ring lookup failed\n"); goto fail; } -#endif - odp_test_thread_create(test_ring, (pthrd_arg *)&rarg); -#ifndef RING_TEST_BASIC + odph_linux_pthread_create(&thread_tbl[0], &cpu_mask, + test_ring, (void *)&rarg); + odph_linux_pthread_join(thread_tbl, num_workers); + fail: -#endif + if (odp_term_local()) { + LOG_ERR("Error: ODP local term failed.\n"); + exit(EXIT_FAILURE); + } - odp_test_thread_exit(&rarg.thrdarg); + if (odp_term_global()) { + LOG_ERR("Error: ODP global term failed.\n"); + exit(EXIT_FAILURE); + } return 0; } - diff --git a/test/Makefile.am b/test/Makefile.am index 2ba8008..4a75364 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = api_test performance miscellaneous +SUBDIRS = performance miscellaneous if cunit_support SUBDIRS += validation diff --git a/test/api_test/.gitignore b/test/api_test/.gitignore deleted file mode 100644 index 950f443..0000000 --- a/test/api_test/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -odp_ring -odp_shm diff --git a/test/api_test/Makefile.am b/test/api_test/Makefile.am deleted file mode 100644 index fcdba48..0000000 --- a/test/api_test/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -include $(top_srcdir)/test/Makefile.inc - -bin_PROGRAMS = odp_ring$(EXEEXT) - -odp_ring_CFLAGS = $(AM_CFLAGS) - -odp_ring_LDFLAGS = $(AM_LDFLAGS) -static - -noinst_HEADERS = \ - $(top_srcdir)/test/api_test/odp_common.h \ - $(top_srcdir)/test/test_debug.h - -dist_odp_ring_SOURCES = odp_ring_test.c odp_common.c diff --git a/test/api_test/odp_common.c b/test/api_test/odp_common.c deleted file mode 100644 index 0dbefa5..0000000 --- a/test/api_test/odp_common.c +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP test application common - */ - -#include -#include -#include -#include -#include - -#define MAX_WORKERS 32 /**< Max worker threads */ - -/* Globals */ -static odph_linux_pthread_t thread_tbl[MAX_WORKERS]; /**< worker threads table*/ -static int num_workers; /**< number of workers */ - -/** - * Print system information - */ -void odp_print_system_info(void) -{ - odp_cpumask_t cpumask; - char str[ODP_CPUMASK_STR_SIZE]; - - memset(str, 1, sizeof(str)); - - odp_cpumask_zero(&cpumask); - - odp_cpumask_from_str(&cpumask, "0x1"); - (void)odp_cpumask_to_str(&cpumask, str, sizeof(str)); - - printf("\n"); - printf("ODP system info\n"); - printf("---------------\n"); - printf("ODP API version: %s\n", odp_version_api_str()); - printf("CPU model: %s\n", odp_sys_cpu_model_str()); - printf("CPU freq (hz): %"PRIu64"\n", odp_sys_cpu_hz()); - printf("Cache line size: %i\n", odp_sys_cache_line_size()); - printf("CPU count: %i\n", odp_cpu_count()); - printf("CPU mask: %s\n", str); - - printf("\n"); -} - -/** test init globals and call odp_init_global() */ -int odp_test_global_init(void) -{ - memset(thread_tbl, 0, sizeof(thread_tbl)); - - if (odp_init_global(NULL, NULL)) { - LOG_ERR("ODP global init failed.\n"); - return -1; - } - - num_workers = odp_cpu_count(); - /* force to max CPU count */ - if (num_workers > MAX_WORKERS) - num_workers = MAX_WORKERS; - - return 0; -} - -/** create test thread */ -int odp_test_thread_create(void *func_ptr(void *), pthrd_arg *arg) -{ - odp_cpumask_t cpumask; - - /* Create and init additional threads */ - odp_cpumask_def_worker(&cpumask, arg->numthrds); - odph_linux_pthread_create(thread_tbl, &cpumask, func_ptr, - (void *)arg); - - return 0; -} - -/** exit from test thread */ -int odp_test_thread_exit(pthrd_arg *arg) -{ - /* Wait for other threads to exit */ - odph_linux_pthread_join(thread_tbl, arg->numthrds); - - return 0; -} diff --git a/test/api_test/odp_common.h b/test/api_test/odp_common.h deleted file mode 100644 index f321b6b..0000000 --- a/test/api_test/odp_common.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP test application common headers - */ - -#ifndef ODP_COMMON_H -#define ODP_COMMON_H - -#define MAX_WORKERS 32 /**< Maximum number of work threads */ - -/** types of tests */ -typedef enum { - ODP_ATOMIC_TEST = 0, - ODP_SHM_TEST, - ODP_RING_TEST_BASIC, - ODP_RING_TEST_STRESS, - ODP_TIMER_PING_TEST, - ODP_MAX_TEST -} odp_test_case_e; - -/** - * Thread argument - */ -typedef struct { - int testcase; /**< specifies which set of API's to exercise */ - int numthrds; /**< no of pthreads to create */ -} pthrd_arg; - -extern void odp_print_system_info(void); -extern int odp_test_global_init(void); -/** create thread fro start_routine function */ -extern int odp_test_thread_create(void *(*start_routine) (void *), pthrd_arg *); -extern int odp_test_thread_exit(pthrd_arg *); - -#endif /* ODP_COMMON_H */