From patchwork Fri Oct 31 02:45:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "yan.songming" X-Patchwork-Id: 39858 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5B9A3202FE for ; Fri, 31 Oct 2014 02:46:24 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id k14sf3599006wgh.7 for ; Thu, 30 Oct 2014 19:46:23 -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:date:from:to:references :mime-version:message-id:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type; bh=vMW6kjhJrVLr0Uacx2rPyjE7ArlM/fxIVNMBoEE78fk=; b=HGY3zyq0jQ15jA70jI1dsEoKH88FMN2qbzXxYaaSIP0dq/FD2qII6UBolH27TkHIz5 z2L/fhzKfgYOA3R5gF9UIYttEbxyzYKHX8kV9Rw8hdgIXKxGNtJ1PScvQ3luedw4H9Wn 1pLZ98oQO2k5Km+dRlrPi+uy3U6RubvmFTT8rMO3X45w4Klg0RsifC+vygskS77wHDoH myn2C+calOEaNzHStiokDNMSfiSQ6y/G5dqR7B+0444Yv8SxS9DWWQJSnOSh8E0eqdVb jPt4xbSO6qoG3HmTVC3Fi3NxIyeGcUa1tel6ukkFOyAgyltLt6pVrgP+RY4AbMGnm7IQ PWnw== X-Gm-Message-State: ALoCoQm2xFHgb0LqLAFrzVxINU6gF1uiqUFstFD5gZD46MGpQKVQNo71t17RYQX1+/ux1hOlGU69 X-Received: by 10.194.206.10 with SMTP id lk10mr80082wjc.3.1414723583590; Thu, 30 Oct 2014 19:46:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.100 with SMTP id z4ls412201laz.60.gmail; Thu, 30 Oct 2014 19:46:23 -0700 (PDT) X-Received: by 10.112.162.73 with SMTP id xy9mr147969lbb.94.1414723583244; Thu, 30 Oct 2014 19:46:23 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id s6si14567365laj.90.2014.10.30.19.46.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Oct 2014 19:46:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id gd6so4227892lab.6 for ; Thu, 30 Oct 2014 19:46:23 -0700 (PDT) X-Received: by 10.152.170.131 with SMTP id am3mr22695215lac.15.1414723583118; Thu, 30 Oct 2014 19:46:23 -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.84.229 with SMTP id c5csp139140lbz; Thu, 30 Oct 2014 19:46:22 -0700 (PDT) X-Received: by 10.140.19.205 with SMTP id 71mr31046670qgh.98.1414723581724; Thu, 30 Oct 2014 19:46:21 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id ka5si15092344qcb.45.2014.10.30.19.46.20 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 30 Oct 2014 19:46:21 -0700 (PDT) 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 1Xk2EE-0004yJ-QQ; Fri, 31 Oct 2014 02:46:18 +0000 Received: from mail-pd0-f180.google.com ([209.85.192.180]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xk2E4-0004xG-O2 for lng-odp@lists.linaro.org; Fri, 31 Oct 2014 02:46:08 +0000 Received: by mail-pd0-f180.google.com with SMTP id ft15so6343262pdb.11 for ; Thu, 30 Oct 2014 19:46:03 -0700 (PDT) X-Received: by 10.68.228.102 with SMTP id sh6mr21928643pbc.12.1414723563013; Thu, 30 Oct 2014 19:46:03 -0700 (PDT) Received: from ZTE-20140828BZT ([210.51.195.9]) by mx.google.com with ESMTPSA id jj12sm8347286pbd.78.2014.10.30.19.46.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Oct 2014 19:46:02 -0700 (PDT) Date: Fri, 31 Oct 2014 10:45:58 +0800 From: "yan.songming@linaro.org" To: hongbo.zhang References: <1414687724-31368-1-git-send-email-yan.songming@linaro.org>, X-Priority: 3 X-GUID: A2998DA4-77EB-44C3-9493-2D86681CE58D X-Has-Attach: no X-Mailer: Foxmail 7, 2, 5, 136[cn] Mime-Version: 1.0 Message-ID: <201410311045560819671@linaro.org> X-Topics: patch Cc: lng-odp Subject: Re: [lng-odp] [PATCH] queue test 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: , 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: yan.songming@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.47 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 Hi, OK! Got it. I'll change it. Thanks. yan.songming@linaro.org From: Hongbo Zhang Date: 2014-10-31 10:35 To: yan.songming CC: lng-odp Subject: Re: [lng-odp] [PATCH] queue test Yan, The title is too short. It is better to name the title in such a format: mudule-name: function-description, for example: cunit: add tests for xxxxx It is my experience, just FYI. On 31 October 2014 00:48, yan.songming wrote: From: "yan.songming" --- test/cunit/Makefile.am | 4 +- test/cunit/odp_queue_test.c | 168 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 test/cunit/odp_queue_test.c -- 1.8.3.1 _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp diff --git a/test/cunit/Makefile.am b/test/cunit/Makefile.am index 927a5a5..46f46c9 100644 --- a/test/cunit/Makefile.am +++ b/test/cunit/Makefile.am @@ -6,8 +6,10 @@ AM_LDFLAGS += -L$(CUNIT_PATH)/lib if ODP_CUNIT_ENABLED TESTS = ${bin_PROGRAMS} check_PROGRAMS = ${bin_PROGRAMS} -bin_PROGRAMS = odp_init +bin_PROGRAMS = odp_init odp_queue odp_init_LDFLAGS = $(AM_LDFLAGS) -static -lcunit +odp_queue_LDFLAGS = $(AM_LDFLAGS) -static -lcunit endif +dist_odp_queue_SOURCES = odp_queue_test.c dist_odp_init_SOURCES = odp_init_test.c diff --git a/test/cunit/odp_queue_test.c b/test/cunit/odp_queue_test.c new file mode 100644 index 0000000..816ef22 --- /dev/null +++ b/test/cunit/odp_queue_test.c @@ -0,0 +1,168 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "odp.h" +#include "CUnit/Basic.h" +#include "odp_queue.h" +#include "odp_buffer.h" +#include "odp_shared_memory.h" +#include "odp_buffer_pool.h" + +#define MAX_BUFFER_QUEUE (8) /**< Max enqueu buf num */ +#define MSG_POOL_SIZE (4*1024*1024) /**< Message pool size */ + +static int Queue_Contest = 0xff; + +static int test_odp_buffer_pool_init(void) +{ + odp_buffer_pool_t pool; + void *pool_base; + odp_shm_t shm; + + shm = odp_shm_reserve("msg_pool", + MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE, 0); + + pool_base = odp_shm_addr(shm); + + if (pool_base == NULL) { + ODP_ERR("Shared memory reserve failed.\n"); + return -1; + } + + pool = odp_buffer_pool_create("msg_pool", pool_base, MSG_POOL_SIZE, + 0, + ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW); + + if (pool == ODP_BUFFER_POOL_INVALID) { + ODP_ERR("Pool create failed.\n"); + return -1; + } + return 0; +} + +static void test_odp_queue(void) +{ + odp_queue_t queue_creatid; + odp_queue_t queue_id; + odp_buffer_t Enbuf[MAX_BUFFER_QUEUE]; + odp_buffer_t Debuf[MAX_BUFFER_QUEUE]; + odp_buffer_pool_t msg_pool; + odp_queue_param_t param; + + int i; + odp_buffer_t buf; + void *pRtn = NULL; + + /* test odp_queue_create */ + memset(¶m, 0, sizeof(param)); + param.sched.sync = ODP_SCHED_SYNC_NONE; + + queue_creatid = odp_queue_create("test_queue", ODP_QUEUE_TYPE_POLL, ¶m); + CU_ASSERT(queue_creatid != ODP_QUEUE_INVALID); + + /* test odp_queue_type */ + CU_ASSERT_EQUAL(ODP_QUEUE_TYPE_POLL, odp_queue_type(queue_creatid)); + + /* test odp_queue_type */ + CU_ASSERT_EQUAL(ODP_SCHED_SYNC_NONE, odp_queue_sched_type(queue_creatid)); + + /* test odp_queue_lookup */ + queue_id = odp_queue_lookup("test_queue"); + CU_ASSERT_EQUAL(queue_creatid, queue_id); + + /* test odp_queue_set_context */ + CU_ASSERT(0 == odp_queue_set_context(queue_id, &Queue_Contest)); + + /* test odp_queue_get_context*/ + pRtn = odp_queue_get_context(queue_id); + CU_ASSERT(&Queue_Contest == (int *)pRtn); + + /* inite buffer pool */ + CU_ASSERT_FATAL(0 == test_odp_buffer_pool_init()); + + /* apply for buffer */ + msg_pool = odp_buffer_pool_lookup("msg_pool"); + buf = odp_buffer_alloc(msg_pool); + + /* test odp_queue_deq and odp_queue_deq */ + odp_queue_enq(queue_id, buf); + CU_ASSERT_EQUAL(buf, odp_queue_deq(queue_id)); + odp_buffer_free(buf); + + /* apply for mutili buffer */ + for(i=0; i