diff mbox

[RFC,3/5] validation: queue: reuse common main() function

Message ID 1417190740-1212-4-git-send-email-taras.kondratiuk@linaro.org
State New
Headers show

Commit Message

Taras Kondratiuk Nov. 28, 2014, 4:05 p.m. UTC
Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
---
 test/validation/Makefile.am |    2 +-
 test/validation/odp_queue.c |   53 ++++++++-----------------------------------
 2 files changed, 10 insertions(+), 45 deletions(-)
diff mbox

Patch

diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am
index 8b55bad..1f5eed4 100644
--- a/test/validation/Makefile.am
+++ b/test/validation/Makefile.am
@@ -16,7 +16,7 @@  odp_shm_LDFLAGS = $(AM_LDFLAGS)
 endif
 
 dist_odp_init_SOURCES = odp_init.c
-dist_odp_queue_SOURCES = odp_queue.c
+dist_odp_queue_SOURCES = odp_queue.c common/odp_cunit_common.c
 dist_odp_crypto_SOURCES = crypto/odp_crypto_test_async_inp.c \
 			  crypto/odp_crypto_test_sync_inp.c \
 			  odp_crypto.c
diff --git a/test/validation/odp_queue.c b/test/validation/odp_queue.c
index 09dba0e..50df6d4 100644
--- a/test/validation/odp_queue.c
+++ b/test/validation/odp_queue.c
@@ -5,7 +5,7 @@ 
  */
 
 #include "odp.h"
-#include "CUnit/Basic.h"
+#include "odp_cunit_common.h"
 
 #define MAX_BUFFER_QUEUE        (8)
 #define MSG_POOL_SIZE           (4*1024*1024)
@@ -107,17 +107,6 @@  static void test_odp_queue_sunnyday(void)
 
 static int init_suite(void)
 {
-	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;
-	}
 	if (0 != test_odp_buffer_pool_init()) {
 		printf("test_odp_buffer_pool_init fail.\n");
 		return -1;
@@ -125,36 +114,12 @@  static int init_suite(void)
 	return 0;
 }
 
-static int finalize(void)
-{
-	odp_term_local();
-	odp_term_global();
-	return 0;
-}
-
-int main(void)
-{
-	CU_pSuite ptr_suite = NULL;
-
-	/* initialize the CUnit test registry */
-	if (CUE_SUCCESS != CU_initialize_registry())
-		return CU_get_error();
-
-	/* add the tests to the queue suite */
-	ptr_suite = CU_add_suite(__FILE__, init_suite, finalize);
-	if (NULL == ptr_suite) {
-		CU_cleanup_registry();
-		return CU_get_error();
-	}
-
-	if (NULL == CU_ADD_TEST(ptr_suite, test_odp_queue_sunnyday)) {
-		CU_cleanup_registry();
-		return CU_get_error();
-	}
+CU_TestInfo test_odp_queue[] = {
+	{"queue sunnyday",  test_odp_queue_sunnyday},
+	CU_TEST_INFO_NULL,
+};
 
-	/* Run all tests using the CUnit Basic interface */
-	CU_basic_set_mode(CU_BRM_VERBOSE);
-	CU_basic_run_tests();
-	CU_cleanup_registry();
-	return CU_get_error();
-}
+CU_SuiteInfo odp_testsuites[] = {
+	{"Queue", init_suite, NULL, NULL, NULL, test_odp_queue},
+	CU_SUITE_INFO_NULL,
+};