From patchwork Fri Dec 19 20:56:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 42501 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 ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 422BC26C6B for ; Fri, 19 Dec 2014 20:57:26 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id bs8sf1257359wib.2 for ; Fri, 19 Dec 2014 12:57:25 -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=C6Cy6E/pLRK80N3LCMDVVL4Hz35Z0bJJ9ycN95YkYH0=; b=FaW1lxMzNEaHj/b9Hu6Z5547yzCyJwN+VYcZpXrPb+NSZnHRoPrYk/xgC7VxmvjdWw Mviz2Qrz9SH9TUdWZDSCc13Py3IWNdN3GA0aux/QCH3cQTAHxRwoJYZNPdIxnRIGGiSF i7+jFoy/qSIbsYSqJRD1uIcFh2K67hY2gxHNkNhk+Sd2KTz6IAnXBC4qvStXzmukCfZr 19G5DbaKMysSs1GNnETCbDVKNzGVJ2ToavpMJVOsGsPsuo9/BZIwMF/Lr411U57Bckqb k0Pg5UN8uhZzosP8vx/kYSSGQaLk1DPgRliiRQNhCAhqP3MBJ0gU41APsPSGdhLjxnFK /ANA== X-Gm-Message-State: ALoCoQk5N7rhA33+xnkW1yuarKDdqbm+TeodSQPWzyqAvMWkOCy3va7LAxDQwmPp/LTXpaKZ5Vsd X-Received: by 10.152.37.193 with SMTP id a1mr1370406lak.3.1419022645493; Fri, 19 Dec 2014 12:57:25 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.198.235 with SMTP id jf11ls1368455lac.74.gmail; Fri, 19 Dec 2014 12:57:25 -0800 (PST) X-Received: by 10.112.12.65 with SMTP id w1mr9768107lbb.68.1419022645090; Fri, 19 Dec 2014 12:57:25 -0800 (PST) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id xz9si10999592lbb.126.2014.12.19.12.57.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 19 Dec 2014 12:57:25 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id pv20so1458351lab.41 for ; Fri, 19 Dec 2014 12:57:25 -0800 (PST) X-Received: by 10.152.37.7 with SMTP id u7mr9889479laj.74.1419022644994; Fri, 19 Dec 2014 12:57:24 -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.142.69 with SMTP id ru5csp390540lbb; Fri, 19 Dec 2014 12:57:24 -0800 (PST) X-Received: by 10.224.128.129 with SMTP id k1mr17355415qas.14.1419022643311; Fri, 19 Dec 2014 12:57:23 -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 97si12977619qgf.42.2014.12.19.12.57.21 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 19 Dec 2014 12:57:23 -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 1Y24bv-0000lC-Tg; Fri, 19 Dec 2014 20:57:19 +0000 Received: from mail-lb0-f170.google.com ([209.85.217.170]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y24bi-0000jE-Bj for lng-odp@lists.linaro.org; Fri, 19 Dec 2014 20:57:06 +0000 Received: by mail-lb0-f170.google.com with SMTP id 10so1475909lbg.15 for ; Fri, 19 Dec 2014 12:57:00 -0800 (PST) X-Received: by 10.112.154.70 with SMTP id vm6mr7524770lbb.18.1419022620434; Fri, 19 Dec 2014 12:57:00 -0800 (PST) Received: from localhost.localdomain ([80.77.38.170]) by mx.google.com with ESMTPSA id a1sm3020243lbi.11.2014.12.19.12.56.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Dec 2014 12:56:59 -0800 (PST) From: Taras Kondratiuk To: lng-odp@lists.linaro.org Date: Fri, 19 Dec 2014 22:56:50 +0200 Message-Id: <1419022611-28989-3-git-send-email-taras.kondratiuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1419022611-28989-1-git-send-email-taras.kondratiuk@linaro.org> References: <1419022611-28989-1-git-send-email-taras.kondratiuk@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv3 2/3] validation: buffer: add initial buffer tests 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.54 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 Reviewed-and-tested-by: Bill Fischofer Signed-off-by: Taras Kondratiuk --- test/validation/Makefile.am | 1 + test/validation/buffer/odp_buffer_test.c | 52 +++++++++++++++++++++++++++++++ test/validation/buffer/odp_buffer_tests.h | 4 +++ test/validation/odp_buffer.c | 5 +++ 4 files changed, 62 insertions(+) create mode 100644 test/validation/buffer/odp_buffer_test.c diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am index e7e6fec..7baada4 100644 --- a/test/validation/Makefile.am +++ b/test/validation/Makefile.am @@ -20,4 +20,5 @@ dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \ dist_odp_shm_SOURCES = odp_shm.c common/odp_cunit_common.c dist_odp_schedule_SOURCES = odp_schedule.c common/odp_cunit_common.c dist_odp_buffer_SOURCES = buffer/odp_buffer_pool_test.c \ + buffer/odp_buffer_test.c \ odp_buffer.c common/odp_cunit_common.c diff --git a/test/validation/buffer/odp_buffer_test.c b/test/validation/buffer/odp_buffer_test.c new file mode 100644 index 0000000..219a9ef --- /dev/null +++ b/test/validation/buffer/odp_buffer_test.c @@ -0,0 +1,52 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "odp_buffer_tests.h" + +static odp_buffer_pool_t raw_pool; +static odp_buffer_t raw_buffer = ODP_BUFFER_INVALID; +static const size_t raw_buffer_size = 1500; + +int buffer_testsuite_init(void) +{ + odp_buffer_pool_param_t params = { + .buf_size = raw_buffer_size, + .buf_align = ODP_CACHE_LINE_SIZE, + .num_bufs = 100, + .buf_type = ODP_BUFFER_TYPE_RAW, + }; + + raw_pool = odp_buffer_pool_create("raw_pool", ODP_SHM_INVALID, ¶ms); + if (raw_pool == ODP_BUFFER_POOL_INVALID) + return -1; + raw_buffer = odp_buffer_alloc(raw_pool); + if (raw_buffer == ODP_BUFFER_INVALID) + return -1; + return 0; +} + +int buffer_testsuite_finalize(void) +{ + odp_buffer_free(raw_buffer); + if (odp_buffer_pool_destroy(raw_pool) != 0) + return -1; + return 0; +} + +static void buffer_management_basic(void) +{ + CU_ASSERT(odp_buffer_is_valid(raw_buffer) == 1); + CU_ASSERT(odp_buffer_pool(raw_buffer) != ODP_BUFFER_POOL_INVALID); + CU_ASSERT(odp_buffer_type(raw_buffer) == ODP_BUFFER_TYPE_RAW); + CU_ASSERT(odp_buffer_size(raw_buffer) >= raw_buffer_size); + CU_ASSERT(odp_buffer_addr(raw_buffer) != NULL); + odp_buffer_print(raw_buffer); +} + +CU_TestInfo buffer_tests[] = { + _CU_TEST_INFO(buffer_management_basic), + CU_TEST_INFO_NULL, +}; diff --git a/test/validation/buffer/odp_buffer_tests.h b/test/validation/buffer/odp_buffer_tests.h index 4184fb5..8de9a57 100644 --- a/test/validation/buffer/odp_buffer_tests.h +++ b/test/validation/buffer/odp_buffer_tests.h @@ -15,6 +15,10 @@ #define _CU_TEST_INFO(test_func) {#test_func, test_func} extern CU_TestInfo buffer_pool_tests[]; +extern CU_TestInfo buffer_tests[]; + +extern int buffer_testsuite_init(void); +extern int buffer_testsuite_finalize(void); odp_buffer_pool_t pool_create(int buf_num, int buf_size, int buf_type); diff --git a/test/validation/odp_buffer.c b/test/validation/odp_buffer.c index daa30ca..7503fc9 100644 --- a/test/validation/odp_buffer.c +++ b/test/validation/odp_buffer.c @@ -10,5 +10,10 @@ CU_SuiteInfo odp_testsuites[] = { { .pName = "buffer Pool tests", .pTests = buffer_pool_tests, }, + { .pName = "buffer tests", + .pTests = buffer_tests, + .pInitFunc = buffer_testsuite_init, + .pCleanupFunc = buffer_testsuite_finalize, + }, CU_SUITE_INFO_NULL, };