Message ID | 1417453530-18743-2-git-send-email-taras.kondratiuk@linaro.org |
---|---|
State | New |
Headers | show |
On 1 December 2014 at 12:05, Taras Kondratiuk <taras.kondratiuk@linaro.org> wrote: > Most of test application will have the same main function. > Move main() from odp_shm to a common place where it can be reused by > other test applications. > Unifying main() will also simplify transition to a combined single test > application in future. > > Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org> > --- > test/validation/Makefile.am | 4 +-- > test/validation/common/odp_cunit_common.c | 33 +++++++++++++++++++++++ > test/validation/common/odp_cunit_common.h | 9 +++++++ > test/validation/odp_shm.c | 42 > ++--------------------------- > 4 files changed, 46 insertions(+), 42 deletions(-) > > diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am > index 4bee2ab..8b55bad 100644 > --- a/test/validation/Makefile.am > +++ b/test/validation/Makefile.am > @@ -1,6 +1,6 @@ > include $(top_srcdir)/test/Makefile.inc > > -AM_CFLAGS += -I$(CUNIT_PATH)/include > +AM_CFLAGS += -I$(CUNIT_PATH)/include -I$(srcdir)/common > AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit > > if ODP_CUNIT_ENABLED > @@ -11,7 +11,7 @@ odp_init_LDFLAGS = $(AM_LDFLAGS) > odp_queue_LDFLAGS = $(AM_LDFLAGS) > odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto > odp_crypto_LDFLAGS = $(AM_LDFLAGS) > -odp_shm_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/common > +odp_shm_CFLAGS = $(AM_CFLAGS) > odp_shm_LDFLAGS = $(AM_LDFLAGS) > endif > > diff --git a/test/validation/common/odp_cunit_common.c > b/test/validation/common/odp_cunit_common.c > index 885b981..c87e103 100644 > --- a/test/validation/common/odp_cunit_common.c > +++ b/test/validation/common/odp_cunit_common.c > @@ -35,3 +35,36 @@ int odp_cunit_thread_exit(pthrd_arg *arg) > > 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()); > I don't think this will work long term. I think that we need to view a test_suite as an odp application, and any number of suites could be run in any order. We dont want to focus on the batch mode main() because when we migrate to a library there will not be a main when calling tests interactively if so desired. I expect we will have a wrapper batch mode main() that will call all the suites however so that "make check" still has something to call. I think a suite_init should perform the global init and suite_finalize should do a odp_finalize. To that end with a suite being generally smallest unit of testing that can be run, it should also print up what it is being run on - the prints above. I don't see a lot of use for test_init because I don't think we want to be doing odp_global_init per test although you could argue every test should be as independent as possible. I know there is an argument that HW vs SW implementations change how completely calling odp global finalize really creates a clean environment for the next test, but to my mind if suites = odp_apps they should work, OPNFV will require clean teardown without reboot. With a good argument to keep odp calls in main I could be swayed but right now I think it needs to be in the init and finalize function for a suite. Mike > + > + if (0 != odp_init_global(NULL, NULL)) { > + printf("odp_init_global fail.\n"); > + return -1; > See above > + } > + if (0 != odp_init_local()) { > + printf("odp_init_local fail.\n"); > + return -1; > + } > + > See above > + CU_set_error_action(CUEA_ABORT); > + > + CU_initialize_registry(); > + CU_register_suites(odp_testsuites); > + CU_basic_set_mode(CU_BRM_VERBOSE); > + CU_basic_run_tests(); > + > + ret = CU_get_number_of_failure_records(); > + > + CU_cleanup_registry(); > + > + odp_term_local(); > See above > + odp_term_global(); > See above > + > + return ret; > +} > diff --git a/test/validation/common/odp_cunit_common.h > b/test/validation/common/odp_cunit_common.h > index 71a3350..1f30788 100644 > --- a/test/validation/common/odp_cunit_common.h > +++ b/test/validation/common/odp_cunit_common.h > @@ -13,8 +13,17 @@ > #ifndef ODP_CUNICT_COMMON_H > #define ODP_CUNICT_COMMON_H > > +#include "CUnit/Basic.h" > + > #define MAX_WORKERS 32 /**< Maximum number of work threads */ > > +/** > + * Array of testsuites provided by a test application. Array must be > terminated > + * by CU_SUITE_INFO_NULL and must be suitable to be used by > + * CU_register_suites(). > + */ > +extern CU_SuiteInfo odp_testsuites[]; > + > typedef struct { > uint32_t foo; > uint32_t bar; > diff --git a/test/validation/odp_shm.c b/test/validation/odp_shm.c > index bcd46c7..8a991b1 100644 > --- a/test/validation/odp_shm.c > +++ b/test/validation/odp_shm.c > @@ -5,7 +5,6 @@ > */ > > #include "odp.h" > -#include "CUnit/Basic.h" > #include "odp_cunit_common.h" > > #define ALIGE_SIZE (128) > @@ -71,50 +70,13 @@ static void test_odp_shm_sunnyday(void) > odp_cunit_thread_exit(&thrdarg); > } > > -static int init(void) > -{ > - printf("\tODP API version: %s\n", odp_version_api_str()); > - printf("\tODP implementation version: %s\n", > odp_version_impl_str()); > - return 0; > -} > - > CU_TestInfo test_odp_shm[] = { > {"test_odp_shm_creat", test_odp_shm_sunnyday}, > CU_TEST_INFO_NULL, > }; > > -CU_SuiteInfo suites[] = { > - {"odp_system", init, NULL, NULL, NULL, test_odp_shm}, > +CU_SuiteInfo odp_testsuites[] = { > + {"Shared Memory", NULL, NULL, NULL, NULL, test_odp_shm}, > CU_SUITE_INFO_NULL, > }; > > - > -int main(void) > -{ > - int ret; > - > - if (0 != odp_init_global(NULL, NULL)) { > - printf("odp_init_global fail.\n"); > - return -1; > - } > - if (0 != odp_init_local()) { > - printf("odp_init_local fail.\n"); > - return -1; > - } > - > - CU_set_error_action(CUEA_ABORT); > - > - CU_initialize_registry(); > - CU_register_suites(suites); > - CU_basic_set_mode(CU_BRM_VERBOSE); > - CU_basic_run_tests(); > - > - ret = CU_get_number_of_failure_records(); > - > - CU_cleanup_registry(); > - > - odp_term_local(); > - odp_term_global(); > - > - return ret; > -} > -- > 1.7.9.5 > >
On 12/01/2014 08:52 PM, Mike Holmes wrote: > > > On 1 December 2014 at 12:05, Taras Kondratiuk > <taras.kondratiuk@linaro.org <mailto:taras.kondratiuk@linaro.org>> wrote: > + > +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()); > > > I don't think this will work long term. > > I think that we need to view a test_suite as an odp application, and any > number of suites could be run in any order. > We dont want to focus on the batch mode main() because when we migrate > to a library there will not be a main when calling tests interactively > if so desired. I expect we will have a wrapper batch mode main() that > will call all the suites however so that "make check" still has > something to call. I can't agree on the next points: 1. "test suite is an ODP application". It is *not*, because they are executed as a part of a single application. According to a current specification odp_global_init() is called only *once* per application. If you really want to allow several global_init(), then this use case should be mentioned in the specification. But you should understand, that this may significantly complicate implementation. For example linux-generic don't have odp_term_global() and it works fine because OS takes care about resources. If we allow several odp_global_init() calls, then implementation have to carefully clear resources by itself. 2. "when we migrate to a library there will not be a main()". There will be main() which select either batch or interactive mode. > > I think a suite_init should perform the global init and suite_finalize > should do a odp_finalize. To that end with a suite being generally > smallest unit of testing that can be run, it should also print up what > it is being run on - the prints above. I don't see a lot of use for > test_init because I don't think we want to be doing odp_global_init per > test although you could argue every test should be as independent as > possible. Those printfs prints API and implementation versions which are attributes of library, but not a testsuite. That's why they should be print only once per test application start, but not on every testsuite execution. > > I know there is an argument that HW vs SW implementations change how > completely calling odp global finalize really creates a clean > environment for the next test, but to my mind if suites = odp_apps they > should work, OPNFV will require clean teardown without reboot. That's the point where we disagree "suites = odp app". I expect a lot of issues with vendor's SDKs, because this is not a normal usecase for them to reinitialize environment in the same process. They may rely for example on zero'ed static variables which will have some values on a second init. I'd like to get comments from Bala and Alex here. > > With a good argument to keep odp calls in main I could be swayed but > right now I think it needs to be in the init and finalize function for a > suite. Please see above why they can't be there.
On 12/01/2014 09:52 PM, Mike Holmes wrote: > > > On 1 December 2014 at 12:05, Taras Kondratiuk > <taras.kondratiuk@linaro.org <mailto:taras.kondratiuk@linaro.org>> wrote: > > Most of test application will have the same main function. > Move main() from odp_shm to a common place where it can be reused by > other test applications. > Unifying main() will also simplify transition to a combined single > test > application in future. > > Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org > <mailto:taras.kondratiuk@linaro.org>> > --- > test/validation/Makefile.am | 4 +-- > test/validation/common/odp_cunit_common.c | 33 > +++++++++++++++++++++++ > test/validation/common/odp_cunit_common.h | 9 +++++++ > test/validation/odp_shm.c | 42 > ++--------------------------- > 4 files changed, 46 insertions(+), 42 deletions(-) > > diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am > index 4bee2ab..8b55bad 100644 > --- a/test/validation/Makefile.am > +++ b/test/validation/Makefile.am > @@ -1,6 +1,6 @@ > include $(top_srcdir)/test/Makefile.inc > > -AM_CFLAGS += -I$(CUNIT_PATH)/include > +AM_CFLAGS += -I$(CUNIT_PATH)/include -I$(srcdir)/common > AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit > > if ODP_CUNIT_ENABLED > @@ -11,7 +11,7 @@ odp_init_LDFLAGS = $(AM_LDFLAGS) > odp_queue_LDFLAGS = $(AM_LDFLAGS) > odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto > odp_crypto_LDFLAGS = $(AM_LDFLAGS) > -odp_shm_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/common > +odp_shm_CFLAGS = $(AM_CFLAGS) > odp_shm_LDFLAGS = $(AM_LDFLAGS) > endif > > diff --git a/test/validation/common/odp_cunit_common.c > b/test/validation/common/odp_cunit_common.c > index 885b981..c87e103 100644 > --- a/test/validation/common/odp_cunit_common.c > +++ b/test/validation/common/odp_cunit_common.c > @@ -35,3 +35,36 @@ int odp_cunit_thread_exit(pthrd_arg *arg) > > 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()); > > > I don't think this will work long term. > > I think that we need to view a test_suite as an odp application, and > any number of suites could be run in any order. > We dont want to focus on the batch mode main() because when we migrate > to a library there will not be a main when calling tests interactively > if so desired. I expect we will have a wrapper batch mode main() that > will call all the suites however so that "make check" still has > something to call. > > I think a suite_init should perform the global init and suite_finalize > should do a odp_finalize. To that end with a suite being generally > smallest unit of testing that can be run, it should also print up > what it is being run on - the prints above. I don't see a lot of use > for test_init because I don't think we want to be doing > odp_global_init per test although you could argue every test should be > as independent as possible. > > I know there is an argument that HW vs SW implementations change how > completely calling odp global finalize really creates a clean > environment for the next test, but to my mind if suites = odp_apps > they should work, OPNFV will require clean teardown without reboot. > > With a good argument to keep odp calls in main I could be swayed but > right now I think it needs to be in the init and finalize function for > a suite. > > Mike For version 1.0 it might be reasonable to stay with common init. Not sure if everybody can implement odp_term_global() functions at nearest time. And if we start calling odp_init_global()/odp_term_global() for each suite or test it will slowdown other implementers, due to this might be not so easy to implement on other SoCs. Even if it's requirement for OPNFV it should not be requirement for odp 1.0. And we can switch to that some time later. Maxim. > + > + if (0 != odp_init_global(NULL, NULL)) { > + printf("odp_init_global fail.\n"); > + return -1; > > See above > > + } > + if (0 != odp_init_local()) { > + printf("odp_init_local fail.\n"); > + return -1; > + } > + > > > See above > > + CU_set_error_action(CUEA_ABORT); > + > + CU_initialize_registry(); > + CU_register_suites(odp_testsuites); > + CU_basic_set_mode(CU_BRM_VERBOSE); > + CU_basic_run_tests(); > + > + ret = CU_get_number_of_failure_records(); > + > + CU_cleanup_registry(); > + > + odp_term_local(); > > > See above > > + odp_term_global(); > > > See above > > + > + return ret; > +} > diff --git a/test/validation/common/odp_cunit_common.h > b/test/validation/common/odp_cunit_common.h > index 71a3350..1f30788 100644 > --- a/test/validation/common/odp_cunit_common.h > +++ b/test/validation/common/odp_cunit_common.h > @@ -13,8 +13,17 @@ > #ifndef ODP_CUNICT_COMMON_H > #define ODP_CUNICT_COMMON_H > > +#include "CUnit/Basic.h" > + > #define MAX_WORKERS 32 /**< Maximum number of work threads */ > > +/** > + * Array of testsuites provided by a test application. Array must > be terminated > + * by CU_SUITE_INFO_NULL and must be suitable to be used by > + * CU_register_suites(). > + */ > +extern CU_SuiteInfo odp_testsuites[]; > + > typedef struct { > uint32_t foo; > uint32_t bar; > diff --git a/test/validation/odp_shm.c b/test/validation/odp_shm.c > index bcd46c7..8a991b1 100644 > --- a/test/validation/odp_shm.c > +++ b/test/validation/odp_shm.c > @@ -5,7 +5,6 @@ > */ > > #include "odp.h" > -#include "CUnit/Basic.h" > #include "odp_cunit_common.h" > > #define ALIGE_SIZE (128) > @@ -71,50 +70,13 @@ static void test_odp_shm_sunnyday(void) > odp_cunit_thread_exit(&thrdarg); > } > > -static int init(void) > -{ > - printf("\tODP API version: %s\n", odp_version_api_str()); > - printf("\tODP implementation version: %s\n", > odp_version_impl_str()); > - return 0; > -} > - > CU_TestInfo test_odp_shm[] = { > {"test_odp_shm_creat", test_odp_shm_sunnyday}, > CU_TEST_INFO_NULL, > }; > > -CU_SuiteInfo suites[] = { > - {"odp_system", init, NULL, NULL, NULL, test_odp_shm}, > +CU_SuiteInfo odp_testsuites[] = { > + {"Shared Memory", NULL, NULL, NULL, NULL, test_odp_shm}, > CU_SUITE_INFO_NULL, > }; > > - > -int main(void) > -{ > - int ret; > - > - if (0 != odp_init_global(NULL, NULL)) { > - printf("odp_init_global fail.\n"); > - return -1; > - } > - if (0 != odp_init_local()) { > - printf("odp_init_local fail.\n"); > - return -1; > - } > - > - CU_set_error_action(CUEA_ABORT); > - > - CU_initialize_registry(); > - CU_register_suites(suites); > - CU_basic_set_mode(CU_BRM_VERBOSE); > - CU_basic_run_tests(); > - > - ret = CU_get_number_of_failure_records(); > - > - CU_cleanup_registry(); > - > - odp_term_local(); > - odp_term_global(); > - > - return ret; > -} > -- > 1.7.9.5 > > > > > -- > *Mike Holmes* > Linaro Sr Technical Manager > LNG - ODP > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp
We discussed this along with Petris additional ideas on modifying termination. This patch is ok in concept, but I did not do an actual code review myself yet. The rationale is that we have a broad range of SDKs that respond differently to the concept of restarting in the same process, so for 1.0 we have to consider a process as the application, we cannot reuse a process to start a new application and so we cannot use the suites as applications. To support clean up the thread termination will now return an odp_bool_t which is true if it is the last ODP execution object, at that point the thread can check that return code and call global terminate. On 2 December 2014 at 07:10, Maxim Uvarov <maxim.uvarov@linaro.org> wrote: > On 12/01/2014 09:52 PM, Mike Holmes wrote: > >> >> >> On 1 December 2014 at 12:05, Taras Kondratiuk < >> taras.kondratiuk@linaro.org <mailto:taras.kondratiuk@linaro.org>> wrote: >> >> Most of test application will have the same main function. >> Move main() from odp_shm to a common place where it can be reused by >> other test applications. >> Unifying main() will also simplify transition to a combined single >> test >> application in future. >> >> Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org >> <mailto:taras.kondratiuk@linaro.org>> >> >> --- >> test/validation/Makefile.am | 4 +-- >> test/validation/common/odp_cunit_common.c | 33 >> +++++++++++++++++++++++ >> test/validation/common/odp_cunit_common.h | 9 +++++++ >> test/validation/odp_shm.c | 42 >> ++--------------------------- >> 4 files changed, 46 insertions(+), 42 deletions(-) >> >> diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am >> index 4bee2ab..8b55bad 100644 >> --- a/test/validation/Makefile.am >> +++ b/test/validation/Makefile.am >> @@ -1,6 +1,6 @@ >> include $(top_srcdir)/test/Makefile.inc >> >> -AM_CFLAGS += -I$(CUNIT_PATH)/include >> +AM_CFLAGS += -I$(CUNIT_PATH)/include -I$(srcdir)/common >> AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit >> >> if ODP_CUNIT_ENABLED >> @@ -11,7 +11,7 @@ odp_init_LDFLAGS = $(AM_LDFLAGS) >> odp_queue_LDFLAGS = $(AM_LDFLAGS) >> odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto >> odp_crypto_LDFLAGS = $(AM_LDFLAGS) >> -odp_shm_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/common >> +odp_shm_CFLAGS = $(AM_CFLAGS) >> odp_shm_LDFLAGS = $(AM_LDFLAGS) >> endif >> >> diff --git a/test/validation/common/odp_cunit_common.c >> b/test/validation/common/odp_cunit_common.c >> index 885b981..c87e103 100644 >> --- a/test/validation/common/odp_cunit_common.c >> +++ b/test/validation/common/odp_cunit_common.c >> @@ -35,3 +35,36 @@ int odp_cunit_thread_exit(pthrd_arg *arg) >> >> 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()); >> >> >> I don't think this will work long term. >> >> I think that we need to view a test_suite as an odp application, and any >> number of suites could be run in any order. >> We dont want to focus on the batch mode main() because when we migrate to >> a library there will not be a main when calling tests interactively if so >> desired. I expect we will have a wrapper batch mode main() that will call >> all the suites however so that "make check" still has something to call. >> >> I think a suite_init should perform the global init and suite_finalize >> should do a odp_finalize. To that end with a suite being generally smallest >> unit of testing that can be run, it should also print up what it is being >> run on - the prints above. I don't see a lot of use for test_init because I >> don't think we want to be doing odp_global_init per test although you could >> argue every test should be as independent as possible. >> >> I know there is an argument that HW vs SW implementations change how >> completely calling odp global finalize really creates a clean environment >> for the next test, but to my mind if suites = odp_apps they should work, >> OPNFV will require clean teardown without reboot. >> >> With a good argument to keep odp calls in main I could be swayed but >> right now I think it needs to be in the init and finalize function for a >> suite. >> >> Mike >> > > For version 1.0 it might be reasonable to stay with common init. Not sure > if everybody can implement odp_term_global() functions at nearest time. And > if we start calling odp_init_global()/odp_term_global() for each suite or > test it will slowdown other implementers, due to this might be not so easy > to implement on other SoCs. Even if it's requirement for OPNFV it should > not be requirement for odp 1.0. And we can switch to that some time later. > > Maxim. > > > + >> + if (0 != odp_init_global(NULL, NULL)) { >> + printf("odp_init_global fail.\n"); >> + return -1; >> >> See above >> >> + } >> + if (0 != odp_init_local()) { >> + printf("odp_init_local fail.\n"); >> + return -1; >> + } >> + >> >> >> See above >> >> + CU_set_error_action(CUEA_ABORT); >> + >> + CU_initialize_registry(); >> + CU_register_suites(odp_testsuites); >> + CU_basic_set_mode(CU_BRM_VERBOSE); >> + CU_basic_run_tests(); >> + >> + ret = CU_get_number_of_failure_records(); >> + >> + CU_cleanup_registry(); >> + >> + odp_term_local(); >> >> >> See above >> >> + odp_term_global(); >> >> >> See above >> >> + >> + return ret; >> +} >> diff --git a/test/validation/common/odp_cunit_common.h >> b/test/validation/common/odp_cunit_common.h >> index 71a3350..1f30788 100644 >> --- a/test/validation/common/odp_cunit_common.h >> +++ b/test/validation/common/odp_cunit_common.h >> @@ -13,8 +13,17 @@ >> #ifndef ODP_CUNICT_COMMON_H >> #define ODP_CUNICT_COMMON_H >> >> +#include "CUnit/Basic.h" >> + >> #define MAX_WORKERS 32 /**< Maximum number of work threads */ >> >> +/** >> + * Array of testsuites provided by a test application. Array must >> be terminated >> + * by CU_SUITE_INFO_NULL and must be suitable to be used by >> + * CU_register_suites(). >> + */ >> +extern CU_SuiteInfo odp_testsuites[]; >> + >> typedef struct { >> uint32_t foo; >> uint32_t bar; >> diff --git a/test/validation/odp_shm.c b/test/validation/odp_shm.c >> index bcd46c7..8a991b1 100644 >> --- a/test/validation/odp_shm.c >> +++ b/test/validation/odp_shm.c >> @@ -5,7 +5,6 @@ >> */ >> >> #include "odp.h" >> -#include "CUnit/Basic.h" >> #include "odp_cunit_common.h" >> >> #define ALIGE_SIZE (128) >> @@ -71,50 +70,13 @@ static void test_odp_shm_sunnyday(void) >> odp_cunit_thread_exit(&thrdarg); >> } >> >> -static int init(void) >> -{ >> - printf("\tODP API version: %s\n", odp_version_api_str()); >> - printf("\tODP implementation version: %s\n", >> odp_version_impl_str()); >> - return 0; >> -} >> - >> CU_TestInfo test_odp_shm[] = { >> {"test_odp_shm_creat", test_odp_shm_sunnyday}, >> CU_TEST_INFO_NULL, >> }; >> >> -CU_SuiteInfo suites[] = { >> - {"odp_system", init, NULL, NULL, NULL, test_odp_shm}, >> +CU_SuiteInfo odp_testsuites[] = { >> + {"Shared Memory", NULL, NULL, NULL, NULL, test_odp_shm}, >> CU_SUITE_INFO_NULL, >> }; >> >> - >> -int main(void) >> -{ >> - int ret; >> - >> - if (0 != odp_init_global(NULL, NULL)) { >> - printf("odp_init_global fail.\n"); >> - return -1; >> - } >> - if (0 != odp_init_local()) { >> - printf("odp_init_local fail.\n"); >> - return -1; >> - } >> - >> - CU_set_error_action(CUEA_ABORT); >> - >> - CU_initialize_registry(); >> - CU_register_suites(suites); >> - CU_basic_set_mode(CU_BRM_VERBOSE); >> - CU_basic_run_tests(); >> - >> - ret = CU_get_number_of_failure_records(); >> - >> - CU_cleanup_registry(); >> - >> - odp_term_local(); >> - odp_term_global(); >> - >> - return ret; >> -} >> -- >> 1.7.9.5 >> >> >> >> >> -- >> *Mike Holmes* >> Linaro Sr Technical Manager >> LNG - ODP >> >> >> _______________________________________________ >> lng-odp mailing list >> lng-odp@lists.linaro.org >> http://lists.linaro.org/mailman/listinfo/lng-odp >> > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp >
On 1 December 2014 at 12:05, Taras Kondratiuk <taras.kondratiuk@linaro.org> wrote: > Most of test application will have the same main function. > Move main() from odp_shm to a common place where it can be reused by > other test applications. > Unifying main() will also simplify transition to a combined single test > application in future. > > Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org> > Reviewed-by: Mike Holmes <mike.holmes@linaro.org> > --- > test/validation/Makefile.am | 4 +-- > test/validation/common/odp_cunit_common.c | 33 +++++++++++++++++++++++ > test/validation/common/odp_cunit_common.h | 9 +++++++ > test/validation/odp_shm.c | 42 > ++--------------------------- > 4 files changed, 46 insertions(+), 42 deletions(-) > > diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am > index 4bee2ab..8b55bad 100644 > --- a/test/validation/Makefile.am > +++ b/test/validation/Makefile.am > @@ -1,6 +1,6 @@ > include $(top_srcdir)/test/Makefile.inc > > -AM_CFLAGS += -I$(CUNIT_PATH)/include > +AM_CFLAGS += -I$(CUNIT_PATH)/include -I$(srcdir)/common > AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit > > if ODP_CUNIT_ENABLED > @@ -11,7 +11,7 @@ odp_init_LDFLAGS = $(AM_LDFLAGS) > odp_queue_LDFLAGS = $(AM_LDFLAGS) > odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto > odp_crypto_LDFLAGS = $(AM_LDFLAGS) > -odp_shm_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/common > +odp_shm_CFLAGS = $(AM_CFLAGS) > odp_shm_LDFLAGS = $(AM_LDFLAGS) > endif > > diff --git a/test/validation/common/odp_cunit_common.c > b/test/validation/common/odp_cunit_common.c > index 885b981..c87e103 100644 > --- a/test/validation/common/odp_cunit_common.c > +++ b/test/validation/common/odp_cunit_common.c > @@ -35,3 +35,36 @@ int odp_cunit_thread_exit(pthrd_arg *arg) > > 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 != odp_init_global(NULL, NULL)) { > + printf("odp_init_global fail.\n"); > + return -1; > + } > + if (0 != odp_init_local()) { > + printf("odp_init_local fail.\n"); > + return -1; > + } > + > + CU_set_error_action(CUEA_ABORT); > + > + CU_initialize_registry(); > + CU_register_suites(odp_testsuites); > + CU_basic_set_mode(CU_BRM_VERBOSE); > + CU_basic_run_tests(); > + > + ret = CU_get_number_of_failure_records(); > + > + CU_cleanup_registry(); > + > + odp_term_local(); > + odp_term_global(); > + > + return ret; > +} > diff --git a/test/validation/common/odp_cunit_common.h > b/test/validation/common/odp_cunit_common.h > index 71a3350..1f30788 100644 > --- a/test/validation/common/odp_cunit_common.h > +++ b/test/validation/common/odp_cunit_common.h > @@ -13,8 +13,17 @@ > #ifndef ODP_CUNICT_COMMON_H > #define ODP_CUNICT_COMMON_H > > +#include "CUnit/Basic.h" > + > #define MAX_WORKERS 32 /**< Maximum number of work threads */ > > +/** > + * Array of testsuites provided by a test application. Array must be > terminated > + * by CU_SUITE_INFO_NULL and must be suitable to be used by > + * CU_register_suites(). > + */ > +extern CU_SuiteInfo odp_testsuites[]; > + > typedef struct { > uint32_t foo; > uint32_t bar; > diff --git a/test/validation/odp_shm.c b/test/validation/odp_shm.c > index bcd46c7..8a991b1 100644 > --- a/test/validation/odp_shm.c > +++ b/test/validation/odp_shm.c > @@ -5,7 +5,6 @@ > */ > > #include "odp.h" > -#include "CUnit/Basic.h" > #include "odp_cunit_common.h" > > #define ALIGE_SIZE (128) > @@ -71,50 +70,13 @@ static void test_odp_shm_sunnyday(void) > odp_cunit_thread_exit(&thrdarg); > } > > -static int init(void) > -{ > - printf("\tODP API version: %s\n", odp_version_api_str()); > - printf("\tODP implementation version: %s\n", > odp_version_impl_str()); > - return 0; > -} > - > CU_TestInfo test_odp_shm[] = { > {"test_odp_shm_creat", test_odp_shm_sunnyday}, > CU_TEST_INFO_NULL, > }; > > -CU_SuiteInfo suites[] = { > - {"odp_system", init, NULL, NULL, NULL, test_odp_shm}, > +CU_SuiteInfo odp_testsuites[] = { > + {"Shared Memory", NULL, NULL, NULL, NULL, test_odp_shm}, > CU_SUITE_INFO_NULL, > }; > > - > -int main(void) > -{ > - int ret; > - > - if (0 != odp_init_global(NULL, NULL)) { > - printf("odp_init_global fail.\n"); > - return -1; > - } > - if (0 != odp_init_local()) { > - printf("odp_init_local fail.\n"); > - return -1; > - } > - > - CU_set_error_action(CUEA_ABORT); > - > - CU_initialize_registry(); > - CU_register_suites(suites); > - CU_basic_set_mode(CU_BRM_VERBOSE); > - CU_basic_run_tests(); > - > - ret = CU_get_number_of_failure_records(); > - > - CU_cleanup_registry(); > - > - odp_term_local(); > - odp_term_global(); > - > - return ret; > -} > -- > 1.7.9.5 > >
diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am index 4bee2ab..8b55bad 100644 --- a/test/validation/Makefile.am +++ b/test/validation/Makefile.am @@ -1,6 +1,6 @@ include $(top_srcdir)/test/Makefile.inc -AM_CFLAGS += -I$(CUNIT_PATH)/include +AM_CFLAGS += -I$(CUNIT_PATH)/include -I$(srcdir)/common AM_LDFLAGS += -L$(CUNIT_PATH)/lib -static -lcunit if ODP_CUNIT_ENABLED @@ -11,7 +11,7 @@ odp_init_LDFLAGS = $(AM_LDFLAGS) odp_queue_LDFLAGS = $(AM_LDFLAGS) odp_crypto_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/crypto odp_crypto_LDFLAGS = $(AM_LDFLAGS) -odp_shm_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/common +odp_shm_CFLAGS = $(AM_CFLAGS) odp_shm_LDFLAGS = $(AM_LDFLAGS) endif diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c index 885b981..c87e103 100644 --- a/test/validation/common/odp_cunit_common.c +++ b/test/validation/common/odp_cunit_common.c @@ -35,3 +35,36 @@ int odp_cunit_thread_exit(pthrd_arg *arg) 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 != odp_init_global(NULL, NULL)) { + printf("odp_init_global fail.\n"); + return -1; + } + if (0 != odp_init_local()) { + printf("odp_init_local fail.\n"); + return -1; + } + + CU_set_error_action(CUEA_ABORT); + + CU_initialize_registry(); + CU_register_suites(odp_testsuites); + CU_basic_set_mode(CU_BRM_VERBOSE); + CU_basic_run_tests(); + + ret = CU_get_number_of_failure_records(); + + CU_cleanup_registry(); + + odp_term_local(); + odp_term_global(); + + return ret; +} diff --git a/test/validation/common/odp_cunit_common.h b/test/validation/common/odp_cunit_common.h index 71a3350..1f30788 100644 --- a/test/validation/common/odp_cunit_common.h +++ b/test/validation/common/odp_cunit_common.h @@ -13,8 +13,17 @@ #ifndef ODP_CUNICT_COMMON_H #define ODP_CUNICT_COMMON_H +#include "CUnit/Basic.h" + #define MAX_WORKERS 32 /**< Maximum number of work threads */ +/** + * Array of testsuites provided by a test application. Array must be terminated + * by CU_SUITE_INFO_NULL and must be suitable to be used by + * CU_register_suites(). + */ +extern CU_SuiteInfo odp_testsuites[]; + typedef struct { uint32_t foo; uint32_t bar; diff --git a/test/validation/odp_shm.c b/test/validation/odp_shm.c index bcd46c7..8a991b1 100644 --- a/test/validation/odp_shm.c +++ b/test/validation/odp_shm.c @@ -5,7 +5,6 @@ */ #include "odp.h" -#include "CUnit/Basic.h" #include "odp_cunit_common.h" #define ALIGE_SIZE (128) @@ -71,50 +70,13 @@ static void test_odp_shm_sunnyday(void) odp_cunit_thread_exit(&thrdarg); } -static int init(void) -{ - printf("\tODP API version: %s\n", odp_version_api_str()); - printf("\tODP implementation version: %s\n", odp_version_impl_str()); - return 0; -} - CU_TestInfo test_odp_shm[] = { {"test_odp_shm_creat", test_odp_shm_sunnyday}, CU_TEST_INFO_NULL, }; -CU_SuiteInfo suites[] = { - {"odp_system", init, NULL, NULL, NULL, test_odp_shm}, +CU_SuiteInfo odp_testsuites[] = { + {"Shared Memory", NULL, NULL, NULL, NULL, test_odp_shm}, CU_SUITE_INFO_NULL, }; - -int main(void) -{ - int ret; - - if (0 != odp_init_global(NULL, NULL)) { - printf("odp_init_global fail.\n"); - return -1; - } - if (0 != odp_init_local()) { - printf("odp_init_local fail.\n"); - return -1; - } - - CU_set_error_action(CUEA_ABORT); - - CU_initialize_registry(); - CU_register_suites(suites); - CU_basic_set_mode(CU_BRM_VERBOSE); - CU_basic_run_tests(); - - ret = CU_get_number_of_failure_records(); - - CU_cleanup_registry(); - - odp_term_local(); - odp_term_global(); - - return ret; -}
Most of test application will have the same main function. Move main() from odp_shm to a common place where it can be reused by other test applications. Unifying main() will also simplify transition to a combined single test application in future. Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org> --- test/validation/Makefile.am | 4 +-- test/validation/common/odp_cunit_common.c | 33 +++++++++++++++++++++++ test/validation/common/odp_cunit_common.h | 9 +++++++ test/validation/odp_shm.c | 42 ++--------------------------- 4 files changed, 46 insertions(+), 42 deletions(-)