From patchwork Thu Oct 2 18:16:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 38302 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B3405201F1 for ; Thu, 2 Oct 2014 18:17:52 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id b13sf1532162wgh.8 for ; Thu, 02 Oct 2014 11:17:51 -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: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=v/pmcudv3J8ruK9xGRplxmLvq2tSNrBXZqPmKnclgQ0=; b=PS/TwpYi14WMAUVcp78Jo45Sl5oeSKYEXSwR51E5DJyJ+kA4sUyGganU4j/nogLf2k Cr62UaqkRlzrXPOQ/YyZ1FPvayEyT/kV+35I/+6T9J9HCUV/0wMLxJRPE9lqganOoHrC 2OzTOBfljCPiZwJoSxZkiND7gmLTDW9qM+1Ol5oCqFTbxwhRoaZUtMJejibqGB7dy14g LQr3JUoIXHECluZ08zDYmmHPo5+mA2dJv//w7dEi3kWEH1I0vKmE3KR+PV0uWwdAtWXO oO7W4ZHXsFyX6L7k5N5n9tFaSOVA5+ikM3y/N9bCUrwKBzVLTbULNuKt5SeylV9SwsOg Cdow== X-Gm-Message-State: ALoCoQnIBPmjc9ICy4GhSMibxDsX7i7WVe8mBuL4jTXoEl7vVU5BjQaqqdxIGX48jlEj8+bInW8O X-Received: by 10.194.179.196 with SMTP id di4mr105583wjc.0.1412273871941; Thu, 02 Oct 2014 11:17:51 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.170 with SMTP id l10ls277137lah.18.gmail; Thu, 02 Oct 2014 11:17:51 -0700 (PDT) X-Received: by 10.112.198.131 with SMTP id jc3mr592303lbc.42.1412273871772; Thu, 02 Oct 2014 11:17:51 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com [209.85.217.179]) by mx.google.com with ESMTPS id bk7si7808968lbc.71.2014.10.02.11.17.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 02 Oct 2014 11:17:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id l4so2684706lbv.24 for ; Thu, 02 Oct 2014 11:17:51 -0700 (PDT) X-Received: by 10.112.130.226 with SMTP id oh2mr519072lbb.100.1412273871656; Thu, 02 Oct 2014 11:17:51 -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.130.169 with SMTP id of9csp104934lbb; Thu, 2 Oct 2014 11:17:50 -0700 (PDT) X-Received: by 10.140.98.197 with SMTP id o63mr882680qge.78.1412273869715; Thu, 02 Oct 2014 11:17:49 -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 g88si8587691qgg.113.2014.10.02.11.17.48 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 02 Oct 2014 11:17:49 -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 1XZkwk-0003M5-RX; Thu, 02 Oct 2014 18:17:46 +0000 Received: from mail-qc0-f179.google.com ([209.85.216.179]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XZkwf-0003JN-Kx for lng-odp@lists.linaro.org; Thu, 02 Oct 2014 18:17:41 +0000 Received: by mail-qc0-f179.google.com with SMTP id x3so2580289qcv.24 for ; Thu, 02 Oct 2014 11:17:36 -0700 (PDT) X-Received: by 10.140.35.234 with SMTP id n97mr730981qgn.11.1412273856413; Thu, 02 Oct 2014 11:17:36 -0700 (PDT) Received: from fedora1.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id y9sm3814158qaf.15.2014.10.02.11.17.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 02 Oct 2014 11:17:35 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Thu, 2 Oct 2014 14:16:43 -0400 Message-Id: <1412273803-16965-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH v2] Add cunit test for APIs in odp_init.h 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.217.179 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 --- v2: Improved description in DEPENDENCIES Made configure example user independent Aligned #defines .gitignore | 1 + DEPENDENCIES | 23 ++++++++++++++++++++ configure.ac | 21 ++++++++++++++++++ test/Makefile.am | 2 +- test/cunit/Makefile.am | 11 ++++++++++ test/cunit/odp_init_test.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 test/cunit/Makefile.am create mode 100644 test/cunit/odp_init_test.c diff --git a/.gitignore b/.gitignore index 2b9e4f5..6342e34 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,5 @@ odp_timer_test odp_generator odp_l2fwd odp_ipsec +odp_init doxygen-doc diff --git a/DEPENDENCIES b/DEPENDENCIES index 3083d09..f70a1d4 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -75,3 +75,26 @@ Prerequisites for building the OpenDataPlane (ODP) API $ ./configure --host=aarch64-linux-gnu \ --with-openssl-path=/home/user/src/install-openssl-aarch64 $ make + +4.0 Packages needed to build API tests + + Cunit test framework + Cunit prvodes a framework to run the API test suite that proves conformance to the + ODP API. The home page http://cunit.sourceforge.net/doc/introduction.html + +4.1 Native Cunit install + + # Debian/Ubuntu + $ apt-get install libcunit1-dev + +4.2 Cross compile of Cunit + + $ git svn clone http://svn.code.sf.net/p/cunit/code/trunk cunit-code + $ cd cunit-code + $ ./bootstrap + $ ./configure --host=arm-linux-gnueabihf --prefix=/home//src/install-cunit + +4.3 Using Cunit with ODP + $ Add the configuration option to the regular configuration options + ./configure --enable-cunit #if cunit is in the PATH + ./configure --with-cunit-path=DIR #only if you need a path to Cunit libs and headers diff --git a/configure.ac b/configure.ac index 46eaec1..26f48c8 100644 --- a/configure.ac +++ b/configure.ac @@ -60,6 +60,26 @@ AC_SUBST(SDK_INSTALL_PATH) AM_CONDITIONAL([SDK_INSTALL_PATH_], [test "x${SDK_INSTALL_PATH_}" = "x1"]) + +########################################################################## +# Enable/disable Unit tests +########################################################################## +AC_ARG_ENABLE([cunit], + [ --enable-cunit Enable/disable cunit], + [if test x$enableval = xyes; then + cunit_support=yes + fi]) + +AC_ARG_WITH([cunit-path], +AC_HELP_STRING([--with-cunit-path=DIR Path to Cunit libs and headers], + [(or in the default path if not specified).]), +[CUNIT_PATH=$withval cunit_support=yes +],[ AC_MSG_WARN([Cunit not found - continuing without Cunit support]) +]) + +AC_SUBST(CUNIT_PATH) +AM_CONDITIONAL([ODP_CUNIT_ENABLED], [test x$cunit_support = xyes ]) + ########################################################################## # Enable/disable ODP_DEBUG_PRINT ########################################################################## @@ -138,6 +158,7 @@ AC_CONFIG_FILES([Makefile example/timer/Makefile test/Makefile test/api_test/Makefile + test/cunit/Makefile pkgconfig/libodp.pc]) AC_SEARCH_LIBS([timer_create],[rt posix4]) diff --git a/test/Makefile.am b/test/Makefile.am index 9bd7db1..61b97a2 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1 +1 @@ -SUBDIRS = api_test +SUBDIRS = api_test cunit diff --git a/test/cunit/Makefile.am b/test/cunit/Makefile.am new file mode 100644 index 0000000..6bd82f6 --- /dev/null +++ b/test/cunit/Makefile.am @@ -0,0 +1,11 @@ +include $(top_srcdir)/test/Makefile.inc + +AM_CFLAGS += -I$(CUNIT_PATH)/include +AM_LDFLAGS += -L$(CUNIT_PATH)/lib + +if ODP_CUNIT_ENABLED +bin_PROGRAMS = odp_init +odp_init_LDFLAGS = $(AM_LDFLAGS) -static -lcunit +endif + +dist_odp_init_SOURCES = odp_init_test.c diff --git a/test/cunit/odp_init_test.c b/test/cunit/odp_init_test.c new file mode 100644 index 0000000..fe5e6bc --- /dev/null +++ b/test/cunit/odp_init_test.c @@ -0,0 +1,53 @@ +/* Copyright (c) 2014, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "odp.h" +#include "CUnit/Basic.h" + +#define DEFAULT_MSG_POOL_SIZE (4*1024*1024) +#define DEFAULT_MSG_SIZE (8) + +static void test_odp_init_global(void) +{ + int status; + status = odp_init_global(); + CU_ASSERT(status == 0); +} + +static int init(void) +{ + printf("\tODP version: %s\n", odp_version_api_str()); + return 0; +} + +static int finalise(void) +{ + return 0; +} + +int main(void) +{ + CU_pSuite ptr_suite = NULL; + /* initialize the CUnit test registry */ + if (CUE_SUCCESS != CU_initialize_registry()) + return CU_get_error(); + /* add a suite to the registry */ + ptr_suite = CU_add_suite("odp intalization", init, finalise); + if (NULL == ptr_suite) { + CU_cleanup_registry(); + return CU_get_error(); + } + /* add the tests to the suite */ + if (NULL == CU_ADD_TEST(ptr_suite, test_odp_init_global)) { + CU_cleanup_registry(); + return CU_get_error(); + } + /* Run all tests using the CUnit Basic interface */ + CU_basic_set_mode(CU_BRM_VERBOSE); + CU_basic_run_tests(); + CU_cleanup_registry(); + return CU_get_error(); +}