diff options
author | Mike Holmes <mike.holmes@linaro.org> | 2014-10-03 14:50:56 -0400 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2014-10-08 20:36:58 +0400 |
commit | 80421759e6633ca493c5440c31324ce460f850c9 (patch) | |
tree | 3c1e85e14fa70dd271b73cbd92824725d6cba5fd | |
parent | 7df90a6f64f620daf653c0462a9ddee9ef6f4935 (diff) |
Add cunit test for APIs in odp_init.h
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | DEPENDENCIES | 23 | ||||
-rw-r--r-- | configure.ac | 23 | ||||
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/cunit/Makefile.am | 11 | ||||
-rw-r--r-- | test/cunit/odp_init_test.c | 53 |
6 files changed, 112 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore index 2b9e4f556..6342e34b0 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 3083d09a9..f70a1d4e8 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/<user>/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 46eaec125..a840e5e7f 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 9bd7db171..61b97a2b2 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 000000000..6bd82f674 --- /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 000000000..fe5e6bc7d --- /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(); +} |