From patchwork Mon Sep 29 18:54:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 38110 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 283F0201F1 for ; Mon, 29 Sep 2014 18:55:15 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id mc6sf5769953lab.11 for ; Mon, 29 Sep 2014 11:55:13 -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=mfmqn01qK0P2ikqlR8iybIHgNbEHFlzedweFPJjjhF0=; b=Q1IHRIk9xvVy3znMkbby9Et6Pg0MBAtBqJIT48Elxo6I6oKmTsl3Phnm5kQlwaBrb+ 0q76eRcHMa1pKO0VdHQ+alowDdylx9Rl7svKc3bB1mawstF262wCPanQIx7t8e3utlbY 0nQH50DTUq5/WOplcq9dnYyvrHUjVPicb5v1NxeFQstX3LmUxvb9qugQqVHpJH1oGxQa Lebm7CGlei3X9u7HJgi7sDNdIbM+4vERYP/VzIspNNPuXhW5xwYbTlYVanyXkYJmj7so jZM9fxfSBllvzdHns80l8YaBBmPL3DkOFjaRrl/ZPB7BzbVm8Bkrcur9YHcTJ/tS+UWG YywQ== X-Gm-Message-State: ALoCoQnqX4uGmMfwaC1MfLeIAeQmKnIiMmLj1MApM3R5o/y65xLvAby5ytfSZuDt6EW3RfTnb1Bh X-Received: by 10.181.8.226 with SMTP id dn2mr9226wid.4.1412016913890; Mon, 29 Sep 2014 11:55:13 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.73 with SMTP id q9ls573962laq.27.gmail; Mon, 29 Sep 2014 11:55:13 -0700 (PDT) X-Received: by 10.112.198.228 with SMTP id jf4mr39229862lbc.35.1412016913734; Mon, 29 Sep 2014 11:55:13 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com [209.85.215.42]) by mx.google.com with ESMTPS id rw5si5850362lbb.11.2014.09.29.11.55.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 29 Sep 2014 11:55:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by mail-la0-f42.google.com with SMTP id mk6so2421753lab.1 for ; Mon, 29 Sep 2014 11:55:13 -0700 (PDT) X-Received: by 10.153.6.36 with SMTP id cr4mr7124459lad.40.1412016913627; Mon, 29 Sep 2014 11:55:13 -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 of9csp227854lbb; Mon, 29 Sep 2014 11:55:13 -0700 (PDT) X-Received: by 10.229.100.68 with SMTP id x4mr4934804qcn.29.1412016912514; Mon, 29 Sep 2014 11:55:12 -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 y4si6589541qar.30.2014.09.29.11.55.11 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 29 Sep 2014 11:55:12 -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 1XYg6I-00082W-GI; Mon, 29 Sep 2014 18:55:10 +0000 Received: from mail-qc0-f170.google.com ([209.85.216.170]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XYg6D-00081m-J8 for lng-odp@lists.linaro.org; Mon, 29 Sep 2014 18:55:05 +0000 Received: by mail-qc0-f170.google.com with SMTP id m20so1855247qcx.15 for ; Mon, 29 Sep 2014 11:55:00 -0700 (PDT) X-Received: by 10.224.44.2 with SMTP id y2mr11924428qae.30.1412016900163; Mon, 29 Sep 2014 11:55:00 -0700 (PDT) Received: from fedora1.holmesfamily.ws ([98.221.136.245]) by mx.google.com with ESMTPSA id 107sm11874563qgi.19.2014.09.29.11.54.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Sep 2014 11:54:59 -0700 (PDT) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Mon, 29 Sep 2014 14:54:48 -0400 Message-Id: <1412016888-10185-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH] 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.215.42 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 --- This is the simplest possible case with a rudimentary test for global_init. With this in place we can build up the test cases in a common way and the implementation of the infrastructure around unit tests can be built in parallel. .gitignore | 1 + DEPENDENCIES | 15 +++++++++++++ configure.ac | 22 +++++++++++++++++++ test/Makefile.am | 2 +- test/cunit/Makefile.am | 11 ++++++++++ test/cunit/odp_init_test.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 103 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..5dfcca7 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -75,3 +75,18 @@ Prerequisites for building the OpenDataPlane (ODP) API $ ./configure --host=aarch64-linux-gnu \ --with-openssl-path=/home/user/src/install-openssl-aarch64 $ make + + Packages needed to build API tests + +4.1 Native compile + + # Debian/Ubuntu + $ apt-get install libcunit1-dev + +4.2 Cross compile + + $ 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/anders/src/install-cunit +dditional clean of the patch after cleaning src files diff --git a/configure.ac b/configure.ac index 102486d..b6f1187 100644 --- a/configure.ac +++ b/configure.ac @@ -82,6 +82,27 @@ ODP_CFLAGS="$ODP_CFLAGS -DODP_HAVE_NETMAP=1" AM_CONDITIONAL([ODP_NETMAP_ENABLED], [test x$netmap_support = xyes ]) ########################################################################## +# 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 ########################################################################## ODP_DEBUG=1 @@ -162,6 +183,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..be0673f --- /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(); +}