diff mbox

[5/5] validation: init: use CU_register_suites() for tests registration

Message ID 1417453530-18743-6-git-send-email-taras.kondratiuk@linaro.org
State Superseded
Headers show

Commit Message

Taras Kondratiuk Dec. 1, 2014, 5:05 p.m. UTC
Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
---
 test/validation/odp_init.c |   47 ++++++++++++++++++++------------------------
 1 file changed, 21 insertions(+), 26 deletions(-)

Comments

Mike Holmes Dec. 2, 2014, 7:15 p.m. UTC | #1
On 1 December 2014 at 12:05, Taras Kondratiuk <taras.kondratiuk@linaro.org>
wrote:

> Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
>

Reviewed-by: Mike Holmes <mike.holmes@linaro.org>


> ---
>  test/validation/odp_init.c |   47
> ++++++++++++++++++++------------------------
>  1 file changed, 21 insertions(+), 26 deletions(-)
>
> diff --git a/test/validation/odp_init.c b/test/validation/odp_init.c
> index aa7439d..477aa12 100644
> --- a/test/validation/odp_init.c
> +++ b/test/validation/odp_init.c
> @@ -20,38 +20,33 @@ static void test_odp_init_global(void)
>         CU_ASSERT(status == 0);
>  }
>
> -static int init_suite(void)
> +CU_TestInfo test_odp_init[] = {
> +       {"test_odp_init_global",  test_odp_init_global},
> +       CU_TEST_INFO_NULL,
> +};
> +
> +CU_SuiteInfo odp_testsuites[] = {
> +       {"Init", NULL, NULL, NULL, NULL, test_odp_init},
> +       CU_SUITE_INFO_NULL,
> +};
> +
> +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());
> -       return 0;
> -}
>
> -static int finalise(void)
> -{
> -       return 0;
> -}
> +       CU_set_error_action(CUEA_ABORT);
>
> -int main(void)
> -{
> -       CU_pSuite ptr_suite = NULL;
> -       /* initialize the CUnit test registry */
> -       if (CUE_SUCCESS != CU_initialize_registry())
> -               return CU_get_error();
> -       /* add a suite to the registry */
> -       ptr_suite = CU_add_suite(__FILE__, init_suite, finalise);
> -       if (NULL == ptr_suite) {
> -               CU_cleanup_registry();
> -               return CU_get_error();
> -       }
> -       /* add the tests to the suite */
> -       if (NULL == CU_ADD_TEST(ptr_suite, test_odp_init_global)) {
> -               CU_cleanup_registry();
> -               return CU_get_error();
> -       }
> -       /* Run all tests using the CUnit Basic interface */
> +       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();
> -       return CU_get_error();
> +
> +       return ret;
>  }
> --
> 1.7.9.5
>
>
diff mbox

Patch

diff --git a/test/validation/odp_init.c b/test/validation/odp_init.c
index aa7439d..477aa12 100644
--- a/test/validation/odp_init.c
+++ b/test/validation/odp_init.c
@@ -20,38 +20,33 @@  static void test_odp_init_global(void)
 	CU_ASSERT(status == 0);
 }
 
-static int init_suite(void)
+CU_TestInfo test_odp_init[] = {
+	{"test_odp_init_global",  test_odp_init_global},
+	CU_TEST_INFO_NULL,
+};
+
+CU_SuiteInfo odp_testsuites[] = {
+	{"Init", NULL, NULL, NULL, NULL, test_odp_init},
+	CU_SUITE_INFO_NULL,
+};
+
+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());
-	return 0;
-}
 
-static int finalise(void)
-{
-	return 0;
-}
+	CU_set_error_action(CUEA_ABORT);
 
-int main(void)
-{
-	CU_pSuite ptr_suite = NULL;
-	/* initialize the CUnit test registry */
-	if (CUE_SUCCESS != CU_initialize_registry())
-		return CU_get_error();
-	/* add a suite to the registry */
-	ptr_suite = CU_add_suite(__FILE__, init_suite, finalise);
-	if (NULL == ptr_suite) {
-		CU_cleanup_registry();
-		return CU_get_error();
-	}
-	/* add the tests to the suite */
-	if (NULL == CU_ADD_TEST(ptr_suite, test_odp_init_global)) {
-		CU_cleanup_registry();
-		return CU_get_error();
-	}
-	/* Run all tests using the CUnit Basic interface */
+	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();
-	return CU_get_error();
+
+	return ret;
 }