diff mbox

[1/3] validation: preparing for main in tests

Message ID 1431341307-9933-2-git-send-email-christophe.milard@linaro.org
State New
Headers show

Commit Message

Christophe Milard May 11, 2015, 10:48 a.m. UTC
A macro, called MODULE_HAS_OWN_MAIN is used to tell
odp_cunit_common.c 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.
MODULE_HAS_OWN_MAIN is meant to be used during the transition period where
old style tests (defining the symbol odp_testsuites and expecting main()
to be created by odp_cunit_common.c) will coexist with new style tests
(defining their own main() and calling odp_cunit_run()).
After the conversion of all tests, MODULE_HAS_OWN_MAIN is meant to be removed.

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>
---
 test/validation/common/odp_cunit_common.c | 20 +++++++++++---------
 test/validation/common/odp_cunit_common.h |  3 +++
 2 files changed, 14 insertions(+), 9 deletions(-)
diff mbox

Patch

diff --git a/test/validation/common/odp_cunit_common.c b/test/validation/common/odp_cunit_common.c
index 2af4410..5870b80 100644
--- a/test/validation/common/odp_cunit_common.c
+++ b/test/validation/common/odp_cunit_common.c
@@ -1,15 +1,9 @@ 
-/* Copyright (c) 2014, Linaro Limited
+/* Copyright (c) 2015, Linaro Limited
  * All rights reserved.
  *
  * SPDX-License-Identifier:     BSD-3-Clause
  */
 
-/**
- * @file
- *
- * ODP test application common
- */
-
 #include <string.h>
 #include <odp.h>
 #include <odp_cunit_common.h>
@@ -49,7 +43,7 @@  __attribute__((__weak__)) int tests_global_term(void)
 	return 0;
 }
 
-int main(void)
+int odp_cunit_run(CU_SuiteInfo testsuites[])
 {
 	int ret;
 
@@ -72,7 +66,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();
 
@@ -95,3 +89,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;