From patchwork Tue Aug 5 21:29:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 34967 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 891D820523 for ; Tue, 5 Aug 2014 21:30:40 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id l13sf6696015iga.6 for ; Tue, 05 Aug 2014 14:30:40 -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: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:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=xfZdd0dltc0OjopA0nvhdqpI3jqLIfdC+mma2/TSl/U=; b=OxWnRfsWYTdP9tlEkI1lCxBLho6Mco/NQgIVBsdNAF2xhhFYNGcllZF54OT5Uk9w4g tt0oZqnST8Uz0NOTfsXQgE/K6j++89Ko6E7clxPvMxTfibdQP7i/YbARKutJ6gtfbNuO p0Ykv/ol8Anzb4kLnWR55poblTVEnqP4953pHu9lF3JGr+bO4tDBf/PUWXagsH/AYiez HWEt1RD2C87J47pa44VSn4H6VbRCzUmp0XZ4OFzVUI3bRGo+ge+pSOMBwNbuPtfr0V2n r+urH/oOtQfjqueh1X7pXLbt1NPlwhyS0j+FKSCDQqlQYMPQ7qXwM/RZ1r7jVku2DxZ6 GYDA== X-Gm-Message-State: ALoCoQk7jYlg8XOsg+Mo//QppqV7lZ8nzAdaS4p2ObD9YmyfpXQ52iRhBlNjIKG2v8Mm2R5O8t3m X-Received: by 10.182.68.17 with SMTP id r17mr3220477obt.26.1407274240026; Tue, 05 Aug 2014 14:30:40 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.92.140 with SMTP id b12ls529713qge.88.gmail; Tue, 05 Aug 2014 14:30:39 -0700 (PDT) X-Received: by 10.52.243.135 with SMTP id wy7mr4158553vdc.82.1407274239909; Tue, 05 Aug 2014 14:30:39 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id u2si2081466vdx.74.2014.08.05.14.30.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 05 Aug 2014 14:30:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hy4so2643632vcb.8 for ; Tue, 05 Aug 2014 14:30:39 -0700 (PDT) X-Received: by 10.52.129.165 with SMTP id nx5mr5774685vdb.25.1407274239818; Tue, 05 Aug 2014 14:30:39 -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.221.37.5 with SMTP id tc5csp422370vcb; Tue, 5 Aug 2014 14:30:39 -0700 (PDT) X-Received: by 10.229.191.2 with SMTP id dk2mr10143661qcb.8.1407274238895; Tue, 05 Aug 2014 14:30:38 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id 6si5195288qgp.85.2014.08.05.14.30.38 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 05 Aug 2014 14:30:38 -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-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XEmJZ-0000W1-UG; Tue, 05 Aug 2014 21:30:37 +0000 Received: from mail-qg0-f45.google.com ([209.85.192.45]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XEmJG-0000UM-4P for lng-odp@lists.linaro.org; Tue, 05 Aug 2014 21:30:18 +0000 Received: by mail-qg0-f45.google.com with SMTP id f51so1759484qge.18 for ; Tue, 05 Aug 2014 14:30:13 -0700 (PDT) X-Received: by 10.140.97.131 with SMTP id m3mr9533850qge.80.1407274212972; Tue, 05 Aug 2014 14:30:12 -0700 (PDT) Received: from fedora1.holmesfamily.ws (c-98-221-136-245.hsd1.nj.comcast.net. [98.221.136.245]) by mx.google.com with ESMTPSA id h7sm3781428qai.20.2014.08.05.14.30.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Aug 2014 14:30:12 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Tue, 5 Aug 2014 17:29:57 -0400 Message-Id: <1407274197-44498-5-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1407274197-44498-1-git-send-email-mike.holmes@linaro.org> References: <1407274197-44498-1-git-send-email-mike.holmes@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 5/5] test/api_test: Add odp_buffer 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: mike.holmes@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.220.177 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 Signed-off-by: Mike Holmes --- test/api_test/Makefile.am | 4 +- test/api_test/minunit.h | 4 + test/api_test/odp_buffer.c | 365 ++++++++++++++++++++++++++++++++++++++++++++ test/api_test/odp_buffer.sh | 12 ++ 4 files changed, 384 insertions(+), 1 deletion(-) create mode 100644 test/api_test/minunit.h create mode 100644 test/api_test/odp_buffer.c create mode 100755 test/api_test/odp_buffer.sh diff --git a/test/api_test/Makefile.am b/test/api_test/Makefile.am index 5104454..6fbf982 100644 --- a/test/api_test/Makefile.am +++ b/test/api_test/Makefile.am @@ -1,12 +1,14 @@ include $(top_srcdir)/test/Makefile.inc -bin_PROGRAMS = odp_atomic odp_shm odp_ring odp_timer_ping +bin_PROGRAMS = odp_atomic odp_shm odp_ring odp_timer_ping odp_buffer odp_atomic_LDFLAGS = $(AM_LDFLAGS) -static odp_shm_LDFLAGS = $(AM_LDFLAGS) -static odp_ring_LDFLAGS = $(AM_LDFLAGS) -static odp_timer_ping_LDFLAGS = $(AM_LDFLAGS) -static +odp_buffer_LDFLAGS = $(AM_LDFLAGS) -static dist_odp_atomic_SOURCES = odp_atomic_test.c odp_common.c dist_odp_shm_SOURCES = odp_shm_test.c odp_common.c dist_odp_ring_SOURCES = odp_ring_test.c odp_common.c dist_odp_timer_ping_SOURCES = odp_timer_ping.c odp_common.c +dist_odp_buffer_SOURCES = odp_buffer.c diff --git a/test/api_test/minunit.h b/test/api_test/minunit.h new file mode 100644 index 0000000..d256ec1 --- /dev/null +++ b/test/api_test/minunit.h @@ -0,0 +1,4 @@ +/* file: minunit.h */ +#define mu_run_test(test) do { const char *message = test(); tests_run++; \ +if (message) return message; } while (0) +extern int tests_run; diff --git a/test/api_test/odp_buffer.c b/test/api_test/odp_buffer.c new file mode 100644 index 0000000..57dcd3c --- /dev/null +++ b/test/api_test/odp_buffer.c @@ -0,0 +1,365 @@ +#include +#include "minunit.h" +#include "odp.h" + + +int tests_run = 0; + +typedef struct { + int msg_id; + int seq; +} test_message_t; + +#define DEFAULT_MSG_POOL_SIZE (4*1024*1024) + +static const char* test_odp_buffer_addr(void) { + void* startaddress; + odp_buffer_pool_t msg_pool; + odp_buffer_t mybuffer; + void* pool_base; + printf("->%s:\n",__FUNCTION__); + odp_init_global(); + + pool_base = odp_shm_reserve("msg_pool", + DEFAULT_MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE); + + msg_pool = odp_buffer_pool_create("msg_pool", pool_base, DEFAULT_MSG_POOL_SIZE, + sizeof(test_message_t), + ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW); + mybuffer = odp_buffer_alloc(msg_pool); + + startaddress = odp_buffer_addr(mybuffer); + + printf("<-\n"); + printf("%s: Result:",__FUNCTION__); + if (startaddress == NULL) + { + printf("fail\n"); + printf("error, start address == NULL\n"); + } + else + printf("pass\n"); + + return NULL; +} + +static const char* test_odp_buffer_size(void) { + size_t size; + odp_buffer_pool_t msg_pool; + odp_buffer_t mybuffer; + void* pool_base; + + printf("->%s:\n",__FUNCTION__); + odp_init_global(); + + pool_base = odp_shm_reserve("msg_pool", + DEFAULT_MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE); + + msg_pool = odp_buffer_pool_create("msg_pool", pool_base, DEFAULT_MSG_POOL_SIZE, + sizeof(test_message_t), + ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW); + mybuffer = odp_buffer_alloc(msg_pool); + + size = odp_buffer_size(mybuffer); + + printf("<-\n"); + printf("%s: Measurement: %lu Result:",__FUNCTION__, size); + + if (size != sizeof(test_message_t)) + { + printf("fail\n"); + } + else + printf("pass\n"); + + return NULL; +} + +static const char* test_odp_buffer_type1 (void) { + int type; + int type_in = ODP_BUFFER_TYPE_ANY; + odp_buffer_pool_t msg_pool; + odp_buffer_t mybuffer; + void* pool_base; + + printf("->%s:\n",__FUNCTION__); + + odp_init_global(); + + pool_base = odp_shm_reserve("msg_pool", + DEFAULT_MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE); + + msg_pool = odp_buffer_pool_create("msg_pool", pool_base, DEFAULT_MSG_POOL_SIZE, + sizeof(test_message_t), + ODP_CACHE_LINE_SIZE, type_in); + mybuffer = odp_buffer_alloc(msg_pool); + + type = odp_buffer_type(mybuffer); + + printf ("buffer type: %d\n",type); + + printf("<-\n"); + printf("%s: Result:",__FUNCTION__); + + if (type == type_in) + printf("pass\n"); + else + printf("fail\n"); + + return NULL; +} + +static const char* test_odp_buffer_type2 (void) { + int type; + int type_in = ODP_BUFFER_TYPE_RAW; + odp_buffer_pool_t msg_pool; + odp_buffer_t mybuffer; + void* pool_base; + + printf("->%s:\n",__FUNCTION__); + + odp_init_global(); + + pool_base = odp_shm_reserve("msg_pool", + DEFAULT_MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE); + + msg_pool = odp_buffer_pool_create("msg_pool", pool_base, DEFAULT_MSG_POOL_SIZE, + sizeof(test_message_t), + ODP_CACHE_LINE_SIZE, type_in); + mybuffer = odp_buffer_alloc(msg_pool); + + type = odp_buffer_type(mybuffer); + + printf ("buffer type: %d\n",type); + + printf("<-\n"); + printf("%s: Result:",__FUNCTION__); + + if (type == type_in) + printf("pass\n"); + else + printf("fail\n"); + + return NULL; +} + +static const char* test_odp_buffer_type3 (void) { + int type; + int type_in = ODP_BUFFER_TYPE_PACKET; + odp_buffer_pool_t msg_pool; + odp_buffer_t mybuffer; + void* pool_base; + + printf("->%s:\n",__FUNCTION__); + + odp_init_global(); + + pool_base = odp_shm_reserve("msg_pool", + DEFAULT_MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE); + + msg_pool = odp_buffer_pool_create("msg_pool", pool_base, DEFAULT_MSG_POOL_SIZE, + sizeof(test_message_t), + ODP_CACHE_LINE_SIZE, type_in); + mybuffer = odp_buffer_alloc(msg_pool); + + type = odp_buffer_type(mybuffer); + + printf ("buffer type: %d\n",type); + + printf("<-\n"); + printf("%s: Result:",__FUNCTION__); + + if (type == type_in) + printf("pass\n"); + else + printf("fail\n"); + + return NULL; +} + +static const char* test_odp_buffer_type4 (void) { + int type; + int type_in = ODP_BUFFER_TYPE_TIMEOUT; + odp_buffer_pool_t msg_pool; + odp_buffer_t mybuffer; + void* pool_base; + + printf("->%s:\n",__FUNCTION__); + + odp_init_global(); + + pool_base = odp_shm_reserve("msg_pool", + DEFAULT_MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE); + + msg_pool = odp_buffer_pool_create("msg_pool", pool_base, DEFAULT_MSG_POOL_SIZE, + sizeof(test_message_t), + ODP_CACHE_LINE_SIZE, type_in); + mybuffer = odp_buffer_alloc(msg_pool); + + type = odp_buffer_type(mybuffer); + + printf ("buffer type: %d\n",type); + + printf("<-\n"); + printf("%s: Result:",__FUNCTION__); + + if (type == type_in) + printf("pass\n"); + else + printf("fail\n"); + + return NULL; +} + + +static const char* test_odp_buffer_type5 (void) { + int type; + int type_in = ODP_BUFFER_TYPE_INVALID; + odp_buffer_pool_t msg_pool; + odp_buffer_t mybuffer; + void* pool_base; + + printf("->%s:\n",__FUNCTION__); + + odp_init_global(); + + pool_base = odp_shm_reserve("msg_pool", + DEFAULT_MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE); + + msg_pool = odp_buffer_pool_create("msg_pool", pool_base, DEFAULT_MSG_POOL_SIZE, + sizeof(test_message_t), + ODP_CACHE_LINE_SIZE, type_in); + mybuffer = odp_buffer_alloc(msg_pool); + + type = odp_buffer_type(mybuffer); + + printf ("buffer type: %d\n",type); + + printf("<-\n"); + printf("%s: Result:",__FUNCTION__); + + if (type == type_in) + printf("pass\n"); + else + printf("fail\n"); + + return NULL; +} + + +static const char* test_odp_is_scatter (void) { + int is_scatter; + odp_buffer_pool_t msg_pool; + odp_buffer_t mybuffer; + void* pool_base; + printf("->%s:\n",__FUNCTION__); + odp_init_global(); + + pool_base = odp_shm_reserve("msg_pool", + DEFAULT_MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE); + + msg_pool = odp_buffer_pool_create("msg_pool", pool_base, DEFAULT_MSG_POOL_SIZE, + sizeof(test_message_t), + ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW); + mybuffer = odp_buffer_alloc(msg_pool); + + is_scatter = odp_buffer_size(mybuffer); + + printf("<-\n"); + printf("%s: Result:",__FUNCTION__); + + if ((is_scatter <0) || (is_scatter >1)) + { + printf("fail \n"); + printf("is_scatter: %d \n",is_scatter); + } + else + printf("pass\n"); + + return NULL; +} + +static const char* test_odp_is_valid (void) { + int is_valid; + odp_buffer_pool_t msg_pool; + odp_buffer_t mybuffer; + void* pool_base; + printf("->%s:\n",__FUNCTION__); + odp_init_global(); + + pool_base = odp_shm_reserve("msg_pool", + DEFAULT_MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE); + + msg_pool = odp_buffer_pool_create("msg_pool", pool_base, DEFAULT_MSG_POOL_SIZE, + sizeof(test_message_t), + ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW); + mybuffer = odp_buffer_alloc(msg_pool); + + is_valid = odp_buffer_is_valid(mybuffer); + if ((is_valid <0) || (is_valid >1)) + { + printf("fail \n"); + printf("is_valid: %d \n",is_valid); + } + else + printf("pass\n"); + + printf("<-\n"); + printf("%s: Result:",__FUNCTION__); + + printf("pass\n"); + + return NULL; +} + +static const char* test_odp_buffer_print (void) { + odp_buffer_pool_t msg_pool; + odp_buffer_t mybuffer; + void* pool_base; + printf("->%s:\n",__FUNCTION__); + odp_init_global(); + + pool_base = odp_shm_reserve("msg_pool", + DEFAULT_MSG_POOL_SIZE, ODP_CACHE_LINE_SIZE); + + msg_pool = odp_buffer_pool_create("msg_pool", pool_base, DEFAULT_MSG_POOL_SIZE, + sizeof(test_message_t), + ODP_CACHE_LINE_SIZE, ODP_BUFFER_TYPE_RAW); + mybuffer = odp_buffer_alloc(msg_pool); + + odp_buffer_print(mybuffer); + + printf("<-\n"); + printf("%s: Result:",__FUNCTION__); + + printf("pass\n"); + + return NULL; +} + +static const char * all_tests(void) { + mu_run_test(test_odp_buffer_addr); + mu_run_test(test_odp_buffer_size); + mu_run_test(test_odp_buffer_type1); + mu_run_test(test_odp_buffer_type2); + mu_run_test(test_odp_buffer_type3); + mu_run_test(test_odp_buffer_type4); + mu_run_test(test_odp_buffer_type5); + mu_run_test(test_odp_is_scatter); + mu_run_test(test_odp_is_valid); + mu_run_test(test_odp_buffer_print); + return NULL; + } + +int main(void) { + const char *result = all_tests(); + if (result != 0) { + printf("%s\n", result); + } + else { + printf("ALL TESTS passED\n"); + } + printf("Tests run: %d\n", tests_run); + + return result != 0; + } diff --git a/test/api_test/odp_buffer.sh b/test/api_test/odp_buffer.sh new file mode 100755 index 0000000..5dc4537 --- /dev/null +++ b/test/api_test/odp_buffer.sh @@ -0,0 +1,12 @@ +#!/bin/bash +EXECUTABLE=$(basename $0 .sh) +RESULT_FILE=$1 + +if [[ ! -x "$TEST_PATH$EXECUTABLE" ]] +then + echo "$EXECUTABLE" Result:fail >> $RESULT_FILE +fi + +FULL_CASE="$TEST_PATH$EXECUTABLE" +echo "Calling $FULL_CASE from $0" +$FULL_CASE >> $RESULT_FILE