Message ID | 1412016888-10185-1-git-send-email-mike.holmes@linaro.org |
---|---|
State | Rejected |
Headers | show |
On 09/29/2014 10:54 PM, Mike Holmes wrote: > Signed-off-by: Mike Holmes <mike.holmes@linaro.org> > --- > > 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 ++++++++++++++++++++++++++++++++++++++++++++++ Do we really need special directory for cunit tests? I think all test will be in cunit. Including api tests. So might be it good to switch to cunit straight away right now? I.e. move everything to single directory? > 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 Please add here words about cunit. It's not clear what are you building here. Because native compilation is 3.1 and cross is 3.2 So 4.1. has to be "Compilation CUnit tests" > + > + # 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 anders -> user > +dditional clean of the patch after cleaning src files additional > 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) > + align in my email client is strange here. I think if tabs are used it will on the same level. > +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(); > +}
On 30 September 2014 10:26, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: > On 09/29/2014 10:54 PM, Mike Holmes wrote: > >> Signed-off-by: Mike Holmes <mike.holmes@linaro.org> >> --- >> >> 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 ++++++++++++++++++++++++++++++ >> ++++++++++++++++ >> > > Do we really need special directory for cunit tests? I think all test will > be in cunit. Including api tests. > I want to delete test/api_tests ands transition them to the cunit framework before we are finished, this new dir makes that transition process easier I think. At some point tests could be folded up, but as per the testing meeting just now there are two classes of tests - those that need interfaces and those that don't + benchmarking so I think we may continue to need subdirs So might be it good to switch to cunit straight away right now? I.e. move > everything to single directory? I think wait and slide towards the final structure. > > > 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 >> > > Please add here words about cunit. It's not clear what are you building > here. Because native compilation is 3.1 and cross is 3.2 > So 4.1. has to be "Compilation CUnit tests" > >> + >> + # 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 >> > anders -> user > >> +dditional clean of the patch after cleaning src files >> > additional I will address these, thanks for the review. > > 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) >> + >> > align in my email client is strange here. I think if tabs are used it will > on the same level. > > +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(); >> +} >> > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp >
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(); +}
Signed-off-by: Mike Holmes <mike.holmes@linaro.org> --- 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