On 12/01/2014 09:52 PM, Mike Holmes wrote:
On 1 December 2014 at 12:05, Taras Kondratiuk
<[email protected] <mailto:[email protected]>> 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 <[email protected]
<mailto:[email protected]>>
---
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
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp
_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp