Message ID | 1432810692-25231-2-git-send-email-christophe.milard@linaro.org |
---|---|
State | New |
Headers | show |
On Thu, May 28, 2015 at 12:58:07PM +0200, Christophe Milard wrote: > In odp_cunit_common.c, a macro, called MODULE_HAS_OWN_MAIN is used to tell > whether to define a main or not. > If MODULE_HAS_OWN_MAIN is defined, odp_cunit_common.c does not > define any main, but offers odp_cunit_run(CU_SuiteInfo testsuites[]) > to run the tests. > Two libs are then built, one with MODULE_HAS_OWN_MAIN defined > (to be used in the future, by tests which define their own main) > and one with MODULE_HAS_OWN_MAIN undefined, used by all tests at > this stage. > > Signed-off-by: Christophe Milard <christophe.milard@linaro.org> Reviewed-by: Stuart Haslam <stuart.haslam@linaro.org> > --- > configure.ac | 1 + > test/validation/Makefile.am | 44 ++++++++++++++++++------------- > test/validation/common/.gitignore | 2 ++ > test/validation/common/Makefile.am | 10 +++++++ > test/validation/common/odp_cunit_common.c | 18 +++++++------ > test/validation/common/odp_cunit_common.h | 3 +++ > 6 files changed, 51 insertions(+), 27 deletions(-) > create mode 100644 test/validation/common/.gitignore > create mode 100644 test/validation/common/Makefile.am > > diff --git a/configure.ac b/configure.ac > index 59e9057..f8a7e72 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -300,6 +300,7 @@ AC_CONFIG_FILES([Makefile > test/api_test/Makefile > test/performance/Makefile > test/validation/Makefile > + test/validation/common/Makefile > test/miscellaneous/Makefile > ]) > > diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am > index 577063b..965f603 100644 > --- a/test/validation/Makefile.am > +++ b/test/validation/Makefile.am > @@ -3,6 +3,11 @@ include $(top_srcdir)/test/Makefile.inc > AM_CFLAGS += -I$(srcdir)/common > AM_LDFLAGS += -static > > +#warning: in the following line, the libs using the symbols should come before > +#the libs using them! > +LDADD = $(top_builddir)/test/validation/common/libcunit_common_as_main.a \ > + $(LIB)/libodp.la > + > TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform} TEST_DIR=${builddir} > > EXECUTABLES = odp_buffer \ > @@ -39,30 +44,31 @@ bin_PROGRAMS = $(EXECUTABLES) $(COMPILE_ONLY) > ODP_CU_COMMON=common/odp_cunit_common.c > > odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer > -dist_odp_buffer_SOURCES = odp_buffer.c $(ODP_CU_COMMON) > +dist_odp_buffer_SOURCES = odp_buffer.c > odp_classification_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/classification > dist_odp_classification_SOURCES = classification/odp_classification_tests.c \ > classification/odp_classification_basic.c \ > - odp_classification.c $(ODP_CU_COMMON) > + odp_classification.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 $(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_scheduler_SOURCES = odp_scheduler.c $(ODP_CU_COMMON) > -dist_odp_shared_memory_SOURCES = odp_shared_memory.c $(ODP_CU_COMMON) > -dist_odp_synchronizers_SOURCES = odp_synchronizers.c $(ODP_CU_COMMON) > -dist_odp_time_SOURCES = odp_time.c $(ODP_CU_COMMON) > -dist_odp_timer_SOURCES = odp_timer.c $(ODP_CU_COMMON) > -dist_odp_pktio_SOURCES = odp_pktio.c $(ODP_CU_COMMON) > -dist_odp_packet_SOURCES = odp_packet.c $(ODP_CU_COMMON) > -dist_odp_pool_SOURCES = odp_pool.c $(ODP_CU_COMMON) > -dist_odp_cpumask_SOURCES = odp_cpumask.c $(ODP_CU_COMMON) > -dist_odp_thread_SOURCES = odp_thread.c $(ODP_CU_COMMON) > + odp_crypto.c > +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_queue_SOURCES = odp_queue.c > +dist_odp_random_SOURCES = odp_random.c > +dist_odp_scheduler_SOURCES = odp_scheduler.c > +dist_odp_shared_memory_SOURCES = odp_shared_memory.c > +dist_odp_synchronizers_SOURCES = odp_synchronizers.c > +dist_odp_time_SOURCES = odp_time.c > +dist_odp_timer_SOURCES = odp_timer.c > +dist_odp_pktio_SOURCES = odp_pktio.c > +dist_odp_packet_SOURCES = odp_packet.c > +dist_odp_pool_SOURCES = odp_pool.c > +dist_odp_cpumask_SOURCES = odp_cpumask.c > +dist_odp_thread_SOURCES = odp_thread.c > odp_ver_abt_log_dbg_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/ver_abt_log_dbg > dist_odp_ver_abt_log_dbg_SOURCES = ver_abt_log_dbg/odp_system.c \ > ver_abt_log_dbg/odp_errno.c \ > - ver_abt_log_dbg/odp_ver_abt_log_dbg.c $(ODP_CU_COMMON) > + ver_abt_log_dbg/odp_ver_abt_log_dbg.c > +SUBDIRS = common > diff --git a/test/validation/common/.gitignore b/test/validation/common/.gitignore > new file mode 100644 > index 0000000..e8aa876 > --- /dev/null > +++ b/test/validation/common/.gitignore > @@ -0,0 +1,2 @@ > +libcunit_common.a > +libcunit_common_as_main.a > diff --git a/test/validation/common/Makefile.am b/test/validation/common/Makefile.am > new file mode 100644 > index 0000000..bd2f214 > --- /dev/null > +++ b/test/validation/common/Makefile.am > @@ -0,0 +1,10 @@ > +AUTOMAKE_OPTIONS = foreign > +include $(top_srcdir)/test/Makefile.inc > + > +#libcunit_common_as_main.a is meant to be removed when all tests define > +#their own main > +noinst_LIBRARIES = libcunit_common.a libcunit_common_as_main.a > +libcunit_common_a_CFLAGS = $(AM_CFLAGS) -DMODULE_HAS_OWN_MAIN > +libcunit_common_a_SOURCES = odp_cunit_common.c > +libcunit_common_as_main_a_CFLAGS = $(AM_CFLAGS) > +libcunit_common_as_main_a_SOURCES = odp_cunit_common.c > diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c > index eac2d81..2b83ae6 100644 > --- a/test/validation/common/odp_cunit_common.c > +++ b/test/validation/common/odp_cunit_common.c > @@ -4,12 +4,6 @@ > * SPDX-License-Identifier: BSD-3-Clause > */ > > -/** > - * @file > - * > - * ODP test application common > - */ > - > #include <string.h> > #include <odp.h> > #include <odp_cunit_common.h> > @@ -68,7 +62,7 @@ ODP_WEAK_SYMBOL int tests_global_term(void) > return 0; > } > > -int main(void) > +int odp_cunit_run(CU_SuiteInfo testsuites[]) > { > int ret; > > @@ -81,7 +75,7 @@ int main(void) > CU_set_error_action(CUEA_ABORT); > > CU_initialize_registry(); > - CU_register_suites(odp_testsuites); > + CU_register_suites(testsuites); > CU_basic_set_mode(CU_BRM_VERBOSE); > CU_basic_run_tests(); > > @@ -94,3 +88,11 @@ int main(void) > > return (ret) ? -1 : 0; > } > + > +/* this is left for old style main declartion. will be removed soon */ > +#ifndef MODULE_HAS_OWN_MAIN > +int main(void) > +{ > + return odp_cunit_run(odp_testsuites); > +} > +#endif > diff --git a/test/validation/common/odp_cunit_common.h b/test/validation/common/odp_cunit_common.h > index 127020d..3b4d9fb 100644 > --- a/test/validation/common/odp_cunit_common.h > +++ b/test/validation/common/odp_cunit_common.h > @@ -24,6 +24,9 @@ > */ > extern CU_SuiteInfo odp_testsuites[]; > > +/* the function, called by module main(), to run the testsuites: */ > +int odp_cunit_run(CU_SuiteInfo testsuites[]); > + > typedef struct { > uint32_t foo; > uint32_t bar; > -- > 1.9.1 >
diff --git a/configure.ac b/configure.ac index 59e9057..f8a7e72 100644 --- a/configure.ac +++ b/configure.ac @@ -300,6 +300,7 @@ AC_CONFIG_FILES([Makefile test/api_test/Makefile test/performance/Makefile test/validation/Makefile + test/validation/common/Makefile test/miscellaneous/Makefile ]) diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am index 577063b..965f603 100644 --- a/test/validation/Makefile.am +++ b/test/validation/Makefile.am @@ -3,6 +3,11 @@ include $(top_srcdir)/test/Makefile.inc AM_CFLAGS += -I$(srcdir)/common AM_LDFLAGS += -static +#warning: in the following line, the libs using the symbols should come before +#the libs using them! +LDADD = $(top_builddir)/test/validation/common/libcunit_common_as_main.a \ + $(LIB)/libodp.la + TESTS_ENVIRONMENT = ODP_PLATFORM=${with_platform} TEST_DIR=${builddir} EXECUTABLES = odp_buffer \ @@ -39,30 +44,31 @@ bin_PROGRAMS = $(EXECUTABLES) $(COMPILE_ONLY) ODP_CU_COMMON=common/odp_cunit_common.c odp_buffer_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/buffer -dist_odp_buffer_SOURCES = odp_buffer.c $(ODP_CU_COMMON) +dist_odp_buffer_SOURCES = odp_buffer.c odp_classification_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/classification dist_odp_classification_SOURCES = classification/odp_classification_tests.c \ classification/odp_classification_basic.c \ - odp_classification.c $(ODP_CU_COMMON) + odp_classification.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 $(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_scheduler_SOURCES = odp_scheduler.c $(ODP_CU_COMMON) -dist_odp_shared_memory_SOURCES = odp_shared_memory.c $(ODP_CU_COMMON) -dist_odp_synchronizers_SOURCES = odp_synchronizers.c $(ODP_CU_COMMON) -dist_odp_time_SOURCES = odp_time.c $(ODP_CU_COMMON) -dist_odp_timer_SOURCES = odp_timer.c $(ODP_CU_COMMON) -dist_odp_pktio_SOURCES = odp_pktio.c $(ODP_CU_COMMON) -dist_odp_packet_SOURCES = odp_packet.c $(ODP_CU_COMMON) -dist_odp_pool_SOURCES = odp_pool.c $(ODP_CU_COMMON) -dist_odp_cpumask_SOURCES = odp_cpumask.c $(ODP_CU_COMMON) -dist_odp_thread_SOURCES = odp_thread.c $(ODP_CU_COMMON) + odp_crypto.c +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_queue_SOURCES = odp_queue.c +dist_odp_random_SOURCES = odp_random.c +dist_odp_scheduler_SOURCES = odp_scheduler.c +dist_odp_shared_memory_SOURCES = odp_shared_memory.c +dist_odp_synchronizers_SOURCES = odp_synchronizers.c +dist_odp_time_SOURCES = odp_time.c +dist_odp_timer_SOURCES = odp_timer.c +dist_odp_pktio_SOURCES = odp_pktio.c +dist_odp_packet_SOURCES = odp_packet.c +dist_odp_pool_SOURCES = odp_pool.c +dist_odp_cpumask_SOURCES = odp_cpumask.c +dist_odp_thread_SOURCES = odp_thread.c odp_ver_abt_log_dbg_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/ver_abt_log_dbg dist_odp_ver_abt_log_dbg_SOURCES = ver_abt_log_dbg/odp_system.c \ ver_abt_log_dbg/odp_errno.c \ - ver_abt_log_dbg/odp_ver_abt_log_dbg.c $(ODP_CU_COMMON) + ver_abt_log_dbg/odp_ver_abt_log_dbg.c +SUBDIRS = common diff --git a/test/validation/common/.gitignore b/test/validation/common/.gitignore new file mode 100644 index 0000000..e8aa876 --- /dev/null +++ b/test/validation/common/.gitignore @@ -0,0 +1,2 @@ +libcunit_common.a +libcunit_common_as_main.a diff --git a/test/validation/common/Makefile.am b/test/validation/common/Makefile.am new file mode 100644 index 0000000..bd2f214 --- /dev/null +++ b/test/validation/common/Makefile.am @@ -0,0 +1,10 @@ +AUTOMAKE_OPTIONS = foreign +include $(top_srcdir)/test/Makefile.inc + +#libcunit_common_as_main.a is meant to be removed when all tests define +#their own main +noinst_LIBRARIES = libcunit_common.a libcunit_common_as_main.a +libcunit_common_a_CFLAGS = $(AM_CFLAGS) -DMODULE_HAS_OWN_MAIN +libcunit_common_a_SOURCES = odp_cunit_common.c +libcunit_common_as_main_a_CFLAGS = $(AM_CFLAGS) +libcunit_common_as_main_a_SOURCES = odp_cunit_common.c diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c index eac2d81..2b83ae6 100644 --- a/test/validation/common/odp_cunit_common.c +++ b/test/validation/common/odp_cunit_common.c @@ -4,12 +4,6 @@ * SPDX-License-Identifier: BSD-3-Clause */ -/** - * @file - * - * ODP test application common - */ - #include <string.h> #include <odp.h> #include <odp_cunit_common.h> @@ -68,7 +62,7 @@ ODP_WEAK_SYMBOL int tests_global_term(void) return 0; } -int main(void) +int odp_cunit_run(CU_SuiteInfo testsuites[]) { int ret; @@ -81,7 +75,7 @@ int main(void) CU_set_error_action(CUEA_ABORT); CU_initialize_registry(); - CU_register_suites(odp_testsuites); + CU_register_suites(testsuites); CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); @@ -94,3 +88,11 @@ int main(void) return (ret) ? -1 : 0; } + +/* this is left for old style main declartion. will be removed soon */ +#ifndef MODULE_HAS_OWN_MAIN +int main(void) +{ + return odp_cunit_run(odp_testsuites); +} +#endif diff --git a/test/validation/common/odp_cunit_common.h b/test/validation/common/odp_cunit_common.h index 127020d..3b4d9fb 100644 --- a/test/validation/common/odp_cunit_common.h +++ b/test/validation/common/odp_cunit_common.h @@ -24,6 +24,9 @@ */ extern CU_SuiteInfo odp_testsuites[]; +/* the function, called by module main(), to run the testsuites: */ +int odp_cunit_run(CU_SuiteInfo testsuites[]); + typedef struct { uint32_t foo; uint32_t bar;
In odp_cunit_common.c, a macro, called MODULE_HAS_OWN_MAIN is used to tell whether to define a main or not. If MODULE_HAS_OWN_MAIN is defined, odp_cunit_common.c does not define any main, but offers odp_cunit_run(CU_SuiteInfo testsuites[]) to run the tests. Two libs are then built, one with MODULE_HAS_OWN_MAIN defined (to be used in the future, by tests which define their own main) and one with MODULE_HAS_OWN_MAIN undefined, used by all tests at this stage. Signed-off-by: Christophe Milard <christophe.milard@linaro.org> --- configure.ac | 1 + test/validation/Makefile.am | 44 ++++++++++++++++++------------- test/validation/common/.gitignore | 2 ++ test/validation/common/Makefile.am | 10 +++++++ test/validation/common/odp_cunit_common.c | 18 +++++++------ test/validation/common/odp_cunit_common.h | 3 +++ 6 files changed, 51 insertions(+), 27 deletions(-) create mode 100644 test/validation/common/.gitignore create mode 100644 test/validation/common/Makefile.am