Message ID | 1412362256-35358-1-git-send-email-mike.holmes@linaro.org |
---|---|
State | Accepted |
Commit | 80421759e6633ca493c5440c31324ce460f850c9 |
Headers | show |
ping any other comments ? On 3 October 2014 14:50, Mike Holmes <mike.holmes@linaro.org> wrote: > Signed-off-by: Mike Holmes <mike.holmes@linaro.org> > --- > 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/<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 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(); > +} > -- > 1.9.1 > >
Did some tests, no objections on meeting -> merged! Thanks, Maxim. On 10/03/2014 10:50 PM, Mike Holmes wrote: > Signed-off-by: Mike Holmes <mike.holmes@linaro.org> > --- > 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/<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 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(); > +}
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/<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 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(); +}
Signed-off-by: Mike Holmes <mike.holmes@linaro.org> --- 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