Re: [lng-odp] [PATCH 2/2] validation: init tests using common main
On 24 April 2015 at 20:39, Mike Holmes wrote: > > > On 24 April 2015 at 08:54, Christophe Milard > wrote: > >> The 3 init tests (init, abort,log) now links with common/odp_cunit_common, >> as other tests. In main, ODP init is now performed via weak functions >> which are overloaded (to do nothing) by the 3 init tests. >> >> Signed-off-by: Christophe Milard >> --- >> test/validation/Makefile.am | 6 ++--- >> test/validation/common/odp_cunit_common.c | 41 >> +-- >> test/validation/common/odp_cunit_common.h | 20 ++- >> test/validation/init/odp_init.c | 34 ++--- >> test/validation/init/odp_init_abort.c | 35 +++--- >> test/validation/init/odp_init_log.c | 35 +++--- >> 6 files changed, 91 insertions(+), 80 deletions(-) >> >> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am >> index 7ea86c4..ba622c3 100644 >> --- a/test/validation/Makefile.am >> +++ b/test/validation/Makefile.am >> @@ -48,9 +48,9 @@ dist_odp_classification_SOURCES = >> classification/odp_classification_tests.c \ >> odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto >> dist_odp_crypto_SOURCES = crypto/odp_crypto_test_inp.c \ >> odp_crypto.c $(ODP_CU_COMMON) >> -dist_odp_init_SOURCES = init/odp_init.c >> -dist_odp_init_abort_SOURCES = init/odp_init_abort.c >> -dist_odp_init_log_SOURCES = init/odp_init_log.c >> +dist_odp_init_SOURCES = init/odp_init.c $(ODP_CU_COMMON) >> +dist_odp_init_abort_SOURCES = init/odp_init_abort.c $(ODP_CU_COMMON) >> +dist_odp_init_log_SOURCES = init/odp_init_log.c $(ODP_CU_COMMON) >> dist_odp_queue_SOURCES = odp_queue.c $(ODP_CU_COMMON) >> dist_odp_random_SOURCES = odp_random.c $(ODP_CU_COMMON) >> dist_odp_schedule_SOURCES = odp_schedule.c $(ODP_CU_COMMON) >> diff --git a/test/validation/common/odp_cunit_common.c >> b/test/validation/common/odp_cunit_common.c >> index 2af4410..7eca422 100644 >> --- a/test/validation/common/odp_cunit_common.c >> +++ b/test/validation/common/odp_cunit_common.c >> @@ -49,12 +49,8 @@ __attribute__((__weak__)) int tests_global_term(void) >> return 0; >> } >> >> -int main(void) >> +__attribute__((__weak__)) int tests_odp_init(void) >> > > Elsewhere in ODP to avoid compiler lock in we define attributes with > macros, see test/test_debug.h > Consider creating in that file the following. > #define TEST_WEAK_SYMBOL __attribute__((__weak__)) > > >> { >> - int ret; >> - >> - printf("\tODP API version: %s\n", odp_version_api_str()); >> - printf("\tODP implementation version: %s\n", >> odp_version_impl_str()); >> >> if (0 != odp_init_global(NULL, NULL)) { >> fprintf(stderr, "error: odp_init_global() failed.\n"); >> @@ -64,6 +60,32 @@ int main(void) >> fprintf(stderr, "error: odp_init_local() failed.\n"); >> return -1; >> } >> + return 0; >> +} >> + >> +__attribute__((__weak__)) int tests_odp_term(void) >> +{ >> + if (0 != odp_term_local()) { >> + fprintf(stderr, "error: odp_term_local() failed.\n"); >> + return -1; >> + } >> + >> + if (0 != odp_term_global()) { >> + fprintf(stderr, "error: odp_term_global() failed.\n"); >> + return -1; >> + } >> + return 0; >> +} >> + >> +int main(void) >> +{ >> + int ret; >> + >> + printf("\tODP API version: %s\n", odp_version_api_str()); >> + printf("\tODP implementation version: %s\n", >> odp_version_impl_str()); >> + >> + if (0 != tests_odp_init()) >> + return -1; >> > > Inconsistent coding for tests_global_init - all the other init / term > functions test the call and dont assign to a ret value so it might be nice > to make them uniform now > Mike: Both style, i.e using variable ret and not exist in the current code: I am not sure which one you consider as consistent...? Christophe. > >> ret = tests_global_init(); >> if (ret) >> > > It appears as if tests_odp_init and tests_global_init can be merged if > odp_crypto and odp_syncronizers pick up the trivial addition of the the > call to odp_init_global and odp_init_local. In that way a test clearly > takes ownership of all the init process or it does nothing at all - same > comment for terminate. > > >> @@ -83,15 +105,8 @@ int main(void) >> if (0 != tests_global_term()) >> return -1; >> >> - if (0 != odp_term_local()) { >> - fprintf(stderr, "error: odp_term_local() failed.\n"); >> + if (0 != tests_odp_term()) >> return -1; >> - } >> - >> - if (0 != odp_term_global()) { >> - fprintf(stderr, "error: odp_term_global() failed.\n"); >> - return -1; >> - } >> >> return (ret) ? -1 : 0; >> } >> diff --git a/test/validation/common/odp_cunit_common.h >> b/test/validatio
Re: [lng-odp] [PATCH 2/2] validation: init tests using common main
On 24 April 2015 at 08:54, Christophe Milard wrote: > The 3 init tests (init, abort,log) now links with common/odp_cunit_common, > as other tests. In main, ODP init is now performed via weak functions > which are overloaded (to do nothing) by the 3 init tests. > > Signed-off-by: Christophe Milard > --- > test/validation/Makefile.am | 6 ++--- > test/validation/common/odp_cunit_common.c | 41 > +-- > test/validation/common/odp_cunit_common.h | 20 ++- > test/validation/init/odp_init.c | 34 ++--- > test/validation/init/odp_init_abort.c | 35 +++--- > test/validation/init/odp_init_log.c | 35 +++--- > 6 files changed, 91 insertions(+), 80 deletions(-) > > diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am > index 7ea86c4..ba622c3 100644 > --- a/test/validation/Makefile.am > +++ b/test/validation/Makefile.am > @@ -48,9 +48,9 @@ dist_odp_classification_SOURCES = > classification/odp_classification_tests.c \ > odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto > dist_odp_crypto_SOURCES = crypto/odp_crypto_test_inp.c \ > odp_crypto.c $(ODP_CU_COMMON) > -dist_odp_init_SOURCES = init/odp_init.c > -dist_odp_init_abort_SOURCES = init/odp_init_abort.c > -dist_odp_init_log_SOURCES = init/odp_init_log.c > +dist_odp_init_SOURCES = init/odp_init.c $(ODP_CU_COMMON) > +dist_odp_init_abort_SOURCES = init/odp_init_abort.c $(ODP_CU_COMMON) > +dist_odp_init_log_SOURCES = init/odp_init_log.c $(ODP_CU_COMMON) > dist_odp_queue_SOURCES = odp_queue.c $(ODP_CU_COMMON) > dist_odp_random_SOURCES = odp_random.c $(ODP_CU_COMMON) > dist_odp_schedule_SOURCES = odp_schedule.c $(ODP_CU_COMMON) > diff --git a/test/validation/common/odp_cunit_common.c > b/test/validation/common/odp_cunit_common.c > index 2af4410..7eca422 100644 > --- a/test/validation/common/odp_cunit_common.c > +++ b/test/validation/common/odp_cunit_common.c > @@ -49,12 +49,8 @@ __attribute__((__weak__)) int tests_global_term(void) > return 0; > } > > -int main(void) > +__attribute__((__weak__)) int tests_odp_init(void) > Elsewhere in ODP to avoid compiler lock in we define attributes with macros, see test/test_debug.h Consider creating in that file the following. #define TEST_WEAK_SYMBOL __attribute__((__weak__)) > { > - int ret; > - > - printf("\tODP API version: %s\n", odp_version_api_str()); > - printf("\tODP implementation version: %s\n", > odp_version_impl_str()); > > if (0 != odp_init_global(NULL, NULL)) { > fprintf(stderr, "error: odp_init_global() failed.\n"); > @@ -64,6 +60,32 @@ int main(void) > fprintf(stderr, "error: odp_init_local() failed.\n"); > return -1; > } > + return 0; > +} > + > +__attribute__((__weak__)) int tests_odp_term(void) > +{ > + if (0 != odp_term_local()) { > + fprintf(stderr, "error: odp_term_local() failed.\n"); > + return -1; > + } > + > + if (0 != odp_term_global()) { > + fprintf(stderr, "error: odp_term_global() failed.\n"); > + return -1; > + } > + return 0; > +} > + > +int main(void) > +{ > + int ret; > + > + printf("\tODP API version: %s\n", odp_version_api_str()); > + printf("\tODP implementation version: %s\n", > odp_version_impl_str()); > + > + if (0 != tests_odp_init()) > + return -1; > Inconsistent coding for tests_global_init - all the other init / term functions test the call and dont assign to a ret value so it might be nice to make them uniform now. > ret = tests_global_init(); > if (ret) > It appears as if tests_odp_init and tests_global_init can be merged if odp_crypto and odp_syncronizers pick up the trivial addition of the the call to odp_init_global and odp_init_local. In that way a test clearly takes ownership of all the init process or it does nothing at all - same comment for terminate. > @@ -83,15 +105,8 @@ int main(void) > if (0 != tests_global_term()) > return -1; > > - if (0 != odp_term_local()) { > - fprintf(stderr, "error: odp_term_local() failed.\n"); > + if (0 != tests_odp_term()) > return -1; > - } > - > - if (0 != odp_term_global()) { > - fprintf(stderr, "error: odp_term_global() failed.\n"); > - return -1; > - } > > return (ret) ? -1 : 0; > } > diff --git a/test/validation/common/odp_cunit_common.h > b/test/validation/common/odp_cunit_common.h > index 127020d..852d9ba 100644 > --- a/test/validation/common/odp_cunit_common.h > +++ b/test/validation/common/odp_cunit_common.h > @@ -37,9 +37,27 @@ typedef struct { > int numthrds; /**< no of pthreads to create */ > } pthrd_arg; > > -/** create thread fro start_routine function */ > +/** create thread