@@ -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
@@ -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;
+}
@@ -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;
@@ -5,7 +5,6 @@
*/
#include "odp.h"
-#include "CUnit/Basic.h"
#include "odp_cunit_common.h"
#define ALIGE_SIZE (128)
@@ -71,54 +70,12 @@ static void test_odp_shm_sunnyday(void)
odp_cunit_thread_exit(&thrdarg);
}
-static int finalize(void)
-{
- odp_term_local();
- odp_term_global();
- return 0;
-}
-
-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, finalize, 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();
-
- 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 | 47 ++--------------------------- 4 files changed, 46 insertions(+), 47 deletions(-)