From patchwork Fri Oct 3 18:50:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 38347 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 03050201F1 for ; Fri, 3 Oct 2014 18:51:21 +0000 (UTC) Received: by mail-la0-f70.google.com with SMTP id ge10sf1055656lab.5 for ; Fri, 03 Oct 2014 11:51:20 -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=Wg7PwfW4tjQLW8872VsIs/8ed4sTEH8EiLN5HEDjHD4=; b=jOfgtlfH3jKCBUUjbzhzZx4oZgcZaV1OlUELoSbPOvdvn8/vsj4je0R5dFib94KHoz 5JIUlkO34hph9KRhFJzAFLIiUSIUoop7s57LcNenVgdhtknFVrdJSekg9MS7pdtveGOu 7YGaSMo2Dug7WX0i+dez3T4BbpIl8LdjDgc+r7FAPirEe9tYoLWN8Jmoq9a/rMYLD7Cm ypEnwFEHRRmNviTU9GlSpd9QOJjGnM4MvLmRDfvdPuJllXGT28YP/WLTi/zj9TEQZc1a xDrMl96hf6Px2knqVuIK0PlV3L2lvterW0ZQ2j2I4/R28mpY0VkaxyzNiX5QS1JIxgKT Uslw== X-Gm-Message-State: ALoCoQkGv6czYxUw/PRlbICJUc7MjEXZLMsA0VVkrK5bUZwCSfDZkbIZiOVLtypLekxBOQf5qVwM X-Received: by 10.180.79.202 with SMTP id l10mr66402wix.3.1412362280545; Fri, 03 Oct 2014 11:51:20 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.164 with SMTP id r4ls56544laj.57.gmail; Fri, 03 Oct 2014 11:51:20 -0700 (PDT) X-Received: by 10.152.18.130 with SMTP id w2mr7804266lad.89.1412362280381; Fri, 03 Oct 2014 11:51:20 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) by mx.google.com with ESMTPS id f8si12444335lbc.136.2014.10.03.11.51.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 03 Oct 2014 11:51:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id l4so1473452lbv.26 for ; Fri, 03 Oct 2014 11:51:19 -0700 (PDT) X-Received: by 10.112.4.33 with SMTP id h1mr7311441lbh.67.1412362279925; Fri, 03 Oct 2014 11:51:19 -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 of9csp281073lbb; Fri, 3 Oct 2014 11:51:19 -0700 (PDT) X-Received: by 10.224.121.80 with SMTP id g16mr10371481qar.64.1412362278578; Fri, 03 Oct 2014 11:51:18 -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 k3si13697439qay.112.2014.10.03.11.51.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 03 Oct 2014 11:51:18 -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 1Xa7wh-0000zM-UB; Fri, 03 Oct 2014 18:51:15 +0000 Received: from mail-qc0-f171.google.com ([209.85.216.171]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xa7wc-0000zE-MP for lng-odp@lists.linaro.org; Fri, 03 Oct 2014 18:51:10 +0000 Received: by mail-qc0-f171.google.com with SMTP id i17so1486615qcy.2 for ; Fri, 03 Oct 2014 11:51:05 -0700 (PDT) X-Received: by 10.140.97.53 with SMTP id l50mr7890948qge.97.1412362265454; Fri, 03 Oct 2014 11:51:05 -0700 (PDT) Received: from fedora1.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id p3sm5866929qaa.31.2014.10.03.11.51.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Oct 2014 11:51:04 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Fri, 3 Oct 2014 14:50:56 -0400 Message-Id: <1412362256-35358-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH v3] 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.181 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 --- v3: Add configure.ac trap for cunit headers .gitignore | 1 + DEPENDENCIES | 23 ++++++++++++++++++++ configure.ac | 23 ++++++++++++++++++++ test/Makefile.am | 2 +- test/cunit/Makefile.am | 11 ++++++++++ test/cunit/odp_init_test.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 112 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..a840e5e 100644 --- a/configure.ac +++ b/configure.ac @@ -60,6 +60,28 @@ 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 ],[ ]) + +AS_IF([test x$cunit_support = xyes ], [ + AC_CHECK_HEADERS([CUnit/Basic.h], [], + [AC_MSG_FAILURE(["can't find cunit headers"])]) +]) +AC_SUBST(CUNIT_PATH) +AM_CONDITIONAL([ODP_CUNIT_ENABLED], [test x$cunit_support = xyes ]) + ########################################################################## # Enable/disable ODP_DEBUG_PRINT ########################################################################## @@ -138,6 +160,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(); +}