Message ID | 1412273803-16965-1-git-send-email-mike.holmes@linaro.org |
---|---|
State | Rejected |
Headers | show |
Mike, please add to configure.ac check for cunit headers. I think we need to fail in ./configure if cunit is not installed but requested. odp_init_test.c:8:25: fatal error: CUnit/Basic.h: No such file or directory Thanks, Maxim. On 10/02/2014 10:16 PM, Mike Holmes wrote: > Signed-off-by: Mike Holmes <mike.holmes@linaro.org> > --- > v2: > Improved description in DEPENDENCIES > Made configure example user independent > Aligned #defines > > .gitignore | 1 + > DEPENDENCIES | 23 ++++++++++++++++++++ > configure.ac | 21 ++++++++++++++++++ > test/Makefile.am | 2 +- > test/cunit/Makefile.am | 11 ++++++++++ > test/cunit/odp_init_test.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ > 6 files changed, 110 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..26f48c8 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -60,6 +60,26 @@ 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 > +],[ 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 > ########################################################################## > @@ -138,6 +158,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(); > +}
On 10/03/2014 05:03 PM, Maxim Uvarov wrote: > Mike, please add to configure.ac check for cunit headers. I think we > need to fail in ./configure if cunit is not installed but requested. > > odp_init_test.c:8:25: fatal error: CUnit/Basic.h: No such file or > directory > > Thanks, > Maxim. > Also it might be worth to add status of cunit to the end of configure output. Maxim. > On 10/02/2014 10:16 PM, Mike Holmes wrote: >> Signed-off-by: Mike Holmes <mike.holmes@linaro.org> >> --- >> v2: >> Improved description in DEPENDENCIES >> Made configure example user independent >> Aligned #defines >> >> .gitignore | 1 + >> DEPENDENCIES | 23 ++++++++++++++++++++ >> configure.ac | 21 ++++++++++++++++++ >> test/Makefile.am | 2 +- >> test/cunit/Makefile.am | 11 ++++++++++ >> test/cunit/odp_init_test.c | 53 >> ++++++++++++++++++++++++++++++++++++++++++++++ >> 6 files changed, 110 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..26f48c8 100644 >> --- a/configure.ac >> +++ b/configure.ac >> @@ -60,6 +60,26 @@ 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 >> +],[ 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 >> ########################################################################## >> @@ -138,6 +158,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(); >> +} >
I can add a test but the docs do say you need to add a path + $ 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 On 3 October 2014 09:03, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: > Mike, please add to configure.ac check for cunit headers. I think we need > to fail in ./configure if cunit is not installed but requested. > > odp_init_test.c:8:25: fatal error: CUnit/Basic.h: No such file or directory > > Thanks, > Maxim. > > > On 10/02/2014 10:16 PM, Mike Holmes wrote: > >> Signed-off-by: Mike Holmes <mike.holmes@linaro.org> >> --- >> v2: >> Improved description in DEPENDENCIES >> Made configure example user independent >> Aligned #defines >> >> .gitignore | 1 + >> DEPENDENCIES | 23 ++++++++++++++++++++ >> configure.ac | 21 ++++++++++++++++++ >> test/Makefile.am | 2 +- >> test/cunit/Makefile.am | 11 ++++++++++ >> test/cunit/odp_init_test.c | 53 ++++++++++++++++++++++++++++++ >> ++++++++++++++++ >> 6 files changed, 110 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..26f48c8 100644 >> --- a/configure.ac >> +++ b/configure.ac >> @@ -60,6 +60,26 @@ 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 >> +],[ 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 >> ############################################################ >> ############## >> @@ -138,6 +158,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(); >> +} >> > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp >
On 10/03/2014 05:09 PM, Mike Holmes wrote: > I can add a test > but the docs do say you need to add a path > > + $ 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 > My point we need to follow as positive branch (cunit is installed) as negative branch (cunit is not installed). And in case if it's not installed ./configure should say about that. Not make. > On 3 October 2014 09:03, Maxim Uvarov <maxim.uvarov@linaro.org > <mailto:maxim.uvarov@linaro.org>> wrote: > > Mike, please add to configure.ac <http://configure.ac> check for > cunit headers. I think we need to fail in ./configure if cunit is > not installed but requested. > > odp_init_test.c:8:25: fatal error: CUnit/Basic.h: No such file or > directory > > Thanks, > Maxim. > > > On 10/02/2014 10:16 PM, Mike Holmes wrote: > > Signed-off-by: Mike Holmes <mike.holmes@linaro.org > <mailto:mike.holmes@linaro.org>> > --- > v2: > Improved description in DEPENDENCIES > Made configure example user independent > Aligned #defines > > .gitignore | 1 + > DEPENDENCIES | 23 ++++++++++++++++++++ > configure.ac <http://configure.ac> | 21 > ++++++++++++++++++ > test/Makefile.am | 2 +- > test/cunit/Makefile.am | 11 ++++++++++ > test/cunit/odp_init_test.c | 53 > ++++++++++++++++++++++++++++++++++++++++++++++ > 6 files changed, 110 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 <http://configure.ac> b/configure.ac > <http://configure.ac> > index 46eaec1..26f48c8 100644 > --- a/configure.ac <http://configure.ac> > +++ b/configure.ac <http://configure.ac> > @@ -60,6 +60,26 @@ 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 > +],[ 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 > > ########################################################################## > @@ -138,6 +158,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(); > +} > > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org> > http://lists.linaro.org/mailman/listinfo/lng-odp > > > > > -- > *Mike Holmes* > Linaro Sr Technical Manager > LNG - ODP
On 3 October 2014 09:12, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: > On 10/03/2014 05:09 PM, Mike Holmes wrote: > >> I can add a test >> but the docs do say you need to add a path >> >> + $ 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 >> >> > My point we need to follow as positive branch (cunit is installed) as > negative branch (cunit is not installed). > And in case if it's not installed ./configure should say about that. Not > make. > yep, no problem, might be worth checking some of the other configure items then, since I copied them and they have the same issue > > On 3 October 2014 09:03, Maxim Uvarov <maxim.uvarov@linaro.org <mailto: >> maxim.uvarov@linaro.org>> wrote: >> >> Mike, please add to configure.ac <http://configure.ac> check for >> cunit headers. I think we need to fail in ./configure if cunit is >> not installed but requested. >> >> odp_init_test.c:8:25: fatal error: CUnit/Basic.h: No such file or >> directory >> >> Thanks, >> Maxim. >> >> >> On 10/02/2014 10:16 PM, Mike Holmes wrote: >> >> Signed-off-by: Mike Holmes <mike.holmes@linaro.org >> <mailto:mike.holmes@linaro.org>> >> --- >> v2: >> Improved description in DEPENDENCIES >> Made configure example user independent >> Aligned #defines >> >> .gitignore | 1 + >> DEPENDENCIES | 23 ++++++++++++++++++++ >> configure.ac <http://configure.ac> | 21 >> >> ++++++++++++++++++ >> test/Makefile.am | 2 +- >> test/cunit/Makefile.am | 11 ++++++++++ >> test/cunit/odp_init_test.c | 53 >> ++++++++++++++++++++++++++++++++++++++++++++++ >> 6 files changed, 110 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 <http://configure.ac> b/configure.ac >> <http://configure.ac> >> index 46eaec1..26f48c8 100644 >> --- a/configure.ac <http://configure.ac> >> +++ b/configure.ac <http://configure.ac> >> >> @@ -60,6 +60,26 @@ 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 >> +],[ 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 >> ############################## >> ############################################ >> @@ -138,6 +158,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(); >> +} >> >> >> >> _______________________________________________ >> lng-odp mailing list >> lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org> >> http://lists.linaro.org/mailman/listinfo/lng-odp >> >> >> >> >> -- >> *Mike Holmes* >> Linaro Sr Technical Manager >> 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..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..26f48c8 100644 --- a/configure.ac +++ b/configure.ac @@ -60,6 +60,26 @@ 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 +],[ 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 ########################################################################## @@ -138,6 +158,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> --- v2: Improved description in DEPENDENCIES Made configure example user independent Aligned #defines .gitignore | 1 + DEPENDENCIES | 23 ++++++++++++++++++++ configure.ac | 21 ++++++++++++++++++ test/Makefile.am | 2 +- test/cunit/Makefile.am | 11 ++++++++++ test/cunit/odp_init_test.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 test/cunit/Makefile.am create mode 100644 test/cunit/odp_init_test.c