diff mbox

[PATCHv2] cunit: add odp_init sunnyday unit test

Message ID 1416507511-3186-1-git-send-email-madhusudan.venugopal@linaro.org
State New
Headers show

Commit Message

Madhusudan Venugopal Nov. 20, 2014, 6:18 p.m. UTC
Signed-off-by: Madhusudan Venugopal <madhusudan.venugopal@linaro.org>
---
Merged odp_init and odp_init_local tests
 test/validation/odp_init.c | 144 +++++++++++++++++++++++++++++++++++++++------
 1 file changed, 126 insertions(+), 18 deletions(-)

Comments

Maxim Uvarov Nov. 20, 2014, 10:21 p.m. UTC | #1
Now I think it's good.

Reviewed-by: Maxim Uvarov <maxim.uvarov@linaro.org>

Maxim.

On 11/20/2014 09:18 PM, Madhusudan Venugopal wrote:
> Signed-off-by: Madhusudan Venugopal <madhusudan.venugopal@linaro.org>
> ---
> Merged odp_init and odp_init_local tests
>   test/validation/odp_init.c | 144 +++++++++++++++++++++++++++++++++++++++------
>   1 file changed, 126 insertions(+), 18 deletions(-)
>
> diff --git a/test/validation/odp_init.c b/test/validation/odp_init.c
> index 88e6235..b4db1e1 100644
> --- a/test/validation/odp_init.c
> +++ b/test/validation/odp_init.c
> @@ -6,49 +6,157 @@
>   
>   #include "odp.h"
>   #include "CUnit/Basic.h"
> +#include <odph_linux.h>
>   
> -#define DEFAULT_MSG_POOL_SIZE	(4*1024*1024)
> -#define DEFAULT_MSG_SIZE	(8)
> +void *odp_init_test(void *arg);
> +static void odp_init_local_singlethread_sunnyday(void);
> +static void odp_init_local_thread_per_core_sunnyday(void);
> +static int init(void);
> +static void test_odp_init_global(void);
>   
> -static void test_odp_init_global(void)
> +#define MAX_WORKERS           32
> +#define FIRST_CORE            0
> +#define SINGLE_THREAD         1
> +
> +/* Test to check if the thread is able to initialize using
> + * odp_init_local() and can terminate using odp_term_local().
> + * odp_init_local() will return 0 if successful intialization.
> + * odp_term_local() will return 0 if successful termination.
> + */
> +
> +void *odp_init_test(void *arg)
> +{
> +	int status;
> +
> +	status = odp_init_local();
> +	CU_ASSERT(!status);
> +
> +	status = odp_term_local();
> +	CU_ASSERT(!status);
> +
> +	return arg;
> +}
> +
> +int init(void)
> +{
> +	printf("\t ODP version: %s\n", odp_version_api_str());
> +	return 0;
> +}
> +
> +/* Test for initialization and termination of single odp thread */
> +
> +
> +void odp_init_local_singlethread_sunnyday(void)
>   {
>   	int status;
> +	odph_linux_pthread_t thread;
> +
>   	status = odp_init_global(NULL, NULL);
> -	CU_ASSERT(status == 0);
> +	CU_ASSERT(!status);
> +
> +	status = odp_init_local();
> +	CU_ASSERT(!status);
> +
> +	odph_linux_pthread_create(&thread, SINGLE_THREAD, FIRST_CORE,
> +				  odp_init_test, NULL);
> +	odph_linux_pthread_join(&thread, 1);
> +
> +	status = odp_term_local();
> +	CU_ASSERT(!status);
>   
>   	status = odp_term_global();
> -	CU_ASSERT(status == 0);
> +	CU_ASSERT(!status);
>   }
>   
> -static int init(void)
> +/* Test for initialization and termination of multiple odp threads
> + * One odp thread per core.
> + */
> +
> +void odp_init_local_thread_per_core_sunnyday(void)
>   {
> -	printf("\tODP version: %s\n", odp_version_api_str());
> -	return 0;
> +	odph_linux_pthread_t thread_tbl[MAX_WORKERS];
> +	int num_workers;
> +	int status, first_core;
> +	first_core = 1;
> +
> +	status = odp_init_global(NULL, NULL);
> +	CU_ASSERT(!status);
> +	status = odp_init_local();
> +	CU_ASSERT(!status);
> +
> +	num_workers = odp_sys_core_count();
> +	if (1 == num_workers)
> +		first_core = 0;
> +
> +	if (MAX_WORKERS < num_workers)
> +		num_workers = MAX_WORKERS;
> +
> +	odph_linux_pthread_create(thread_tbl, num_workers, first_core,
> +				  odp_init_test, NULL);
> +
> +	/* if the number of cores  in the system is 1, we have to use  core 0.
> +	 * However if the number of cores is more than 1, we can leave core 0
> +	 * for linux system and this how we expect odp systems to be used.
> +	 */
> +
> +	odph_linux_pthread_join(thread_tbl, num_workers);
> +
> +	status = odp_term_local();
> +	CU_ASSERT(!status);
> +
> +	status = odp_term_global();
> +	CU_ASSERT(!status);
>   }
>   
> -static int finalise(void)
> +/* Test to check if ODP is able to initialize globally using odp_init_global()
> + * and terminate globally using odp_term_global() successfully.
> + * odp_init_global() returns 0 if successful
> + * odp_term_global() returns 0 if successful
> + */
> +
> +static void test_odp_init_global(void)
>   {
> -	return 0;
> +	int status;
> +
> +	status = odp_init_global(NULL, NULL);
> +	CU_ASSERT(!status);
> +
> +	status = odp_term_global();
> +	CU_ASSERT(!status);
>   }
>   
>   int main(void)
>   {
> -	CU_pSuite ptr_suite = NULL;
> -	/* initialize the CUnit test registry */
> +	CU_pSuite p_suite;
> +	CU_pTest ret;
> +
>   	if (CUE_SUCCESS != CU_initialize_registry())
>   		return CU_get_error();
> -	/* add a suite to the registry */
> -	ptr_suite = CU_add_suite(__FILE__, init, finalise);
> -	if (NULL == ptr_suite) {
> +
> +	p_suite = CU_add_suite(__FILE__, init, NULL);
> +	if (!p_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)) {
> +
> +	ret = CU_ADD_TEST(p_suite, test_odp_init_global);
> +	if (!ret) {
>   		CU_cleanup_registry();
>   		return CU_get_error();
>   	}
> -	/* Run all tests using the CUnit Basic interface */
> +
> +	ret = CU_ADD_TEST(p_suite, odp_init_local_singlethread_sunnyday);
> +	if (!ret) {
> +		CU_cleanup_registry();
> +		return CU_get_error();
> +	}
> +
> +	ret = CU_ADD_TEST(p_suite, odp_init_local_thread_per_core_sunnyday);
> +	if (!ret) {
> +		CU_cleanup_registry();
> +		return CU_get_error();
> +	}
> +
>   	CU_basic_set_mode(CU_BRM_VERBOSE);
>   	CU_basic_run_tests();
>   	CU_cleanup_registry();
Mike Holmes Nov. 20, 2014, 11:25 p.m. UTC | #2
On 20 November 2014 17:21, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> Now I think it's good.
>
> Reviewed-by: Maxim Uvarov <maxim.uvarov@linaro.org>


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


>
>
> Maxim.
>
>
> On 11/20/2014 09:18 PM, Madhusudan Venugopal wrote:
>
>> Signed-off-by: Madhusudan Venugopal <madhusudan.venugopal@linaro.org>
>> ---
>> Merged odp_init and odp_init_local tests
>>   test/validation/odp_init.c | 144 ++++++++++++++++++++++++++++++
>> +++++++++------
>>   1 file changed, 126 insertions(+), 18 deletions(-)
>>
>> diff --git a/test/validation/odp_init.c b/test/validation/odp_init.c
>> index 88e6235..b4db1e1 100644
>> --- a/test/validation/odp_init.c
>> +++ b/test/validation/odp_init.c
>> @@ -6,49 +6,157 @@
>>     #include "odp.h"
>>   #include "CUnit/Basic.h"
>> +#include <odph_linux.h>
>>   -#define DEFAULT_MSG_POOL_SIZE        (4*1024*1024)
>> -#define DEFAULT_MSG_SIZE       (8)
>> +void *odp_init_test(void *arg);
>> +static void odp_init_local_singlethread_sunnyday(void);
>> +static void odp_init_local_thread_per_core_sunnyday(void);
>> +static int init(void);
>> +static void test_odp_init_global(void);
>>   -static void test_odp_init_global(void)
>> +#define MAX_WORKERS           32
>> +#define FIRST_CORE            0
>> +#define SINGLE_THREAD         1
>> +
>> +/* Test to check if the thread is able to initialize using
>> + * odp_init_local() and can terminate using odp_term_local().
>> + * odp_init_local() will return 0 if successful intialization.
>> + * odp_term_local() will return 0 if successful termination.
>> + */
>> +
>> +void *odp_init_test(void *arg)
>> +{
>> +       int status;
>> +
>> +       status = odp_init_local();
>> +       CU_ASSERT(!status);
>> +
>> +       status = odp_term_local();
>> +       CU_ASSERT(!status);
>> +
>> +       return arg;
>> +}
>> +
>> +int init(void)
>> +{
>> +       printf("\t ODP version: %s\n", odp_version_api_str());
>> +       return 0;
>> +}
>> +
>> +/* Test for initialization and termination of single odp thread */
>> +
>> +
>> +void odp_init_local_singlethread_sunnyday(void)
>>   {
>>         int status;
>> +       odph_linux_pthread_t thread;
>> +
>>         status = odp_init_global(NULL, NULL);
>> -       CU_ASSERT(status == 0);
>> +       CU_ASSERT(!status);
>> +
>> +       status = odp_init_local();
>> +       CU_ASSERT(!status);
>> +
>> +       odph_linux_pthread_create(&thread, SINGLE_THREAD, FIRST_CORE,
>> +                                 odp_init_test, NULL);
>> +       odph_linux_pthread_join(&thread, 1);
>> +
>> +       status = odp_term_local();
>> +       CU_ASSERT(!status);
>>         status = odp_term_global();
>> -       CU_ASSERT(status == 0);
>> +       CU_ASSERT(!status);
>>   }
>>   -static int init(void)
>> +/* Test for initialization and termination of multiple odp threads
>> + * One odp thread per core.
>> + */
>> +
>> +void odp_init_local_thread_per_core_sunnyday(void)
>>   {
>> -       printf("\tODP version: %s\n", odp_version_api_str());
>> -       return 0;
>> +       odph_linux_pthread_t thread_tbl[MAX_WORKERS];
>> +       int num_workers;
>> +       int status, first_core;
>> +       first_core = 1;
>> +
>> +       status = odp_init_global(NULL, NULL);
>> +       CU_ASSERT(!status);
>> +       status = odp_init_local();
>> +       CU_ASSERT(!status);
>> +
>> +       num_workers = odp_sys_core_count();
>> +       if (1 == num_workers)
>> +               first_core = 0;
>> +
>> +       if (MAX_WORKERS < num_workers)
>> +               num_workers = MAX_WORKERS;
>> +
>> +       odph_linux_pthread_create(thread_tbl, num_workers, first_core,
>> +                                 odp_init_test, NULL);
>> +
>> +       /* if the number of cores  in the system is 1, we have to use
>> core 0.
>> +        * However if the number of cores is more than 1, we can leave
>> core 0
>> +        * for linux system and this how we expect odp systems to be used.
>> +        */
>> +
>> +       odph_linux_pthread_join(thread_tbl, num_workers);
>> +
>> +       status = odp_term_local();
>> +       CU_ASSERT(!status);
>> +
>> +       status = odp_term_global();
>> +       CU_ASSERT(!status);
>>   }
>>   -static int finalise(void)
>> +/* Test to check if ODP is able to initialize globally using
>> odp_init_global()
>> + * and terminate globally using odp_term_global() successfully.
>> + * odp_init_global() returns 0 if successful
>> + * odp_term_global() returns 0 if successful
>> + */
>> +
>> +static void test_odp_init_global(void)
>>   {
>> -       return 0;
>> +       int status;
>> +
>> +       status = odp_init_global(NULL, NULL);
>> +       CU_ASSERT(!status);
>> +
>> +       status = odp_term_global();
>> +       CU_ASSERT(!status);
>>   }
>>     int main(void)
>>   {
>> -       CU_pSuite ptr_suite = NULL;
>> -       /* initialize the CUnit test registry */
>> +       CU_pSuite p_suite;
>> +       CU_pTest ret;
>> +
>>         if (CUE_SUCCESS != CU_initialize_registry())
>>                 return CU_get_error();
>> -       /* add a suite to the registry */
>> -       ptr_suite = CU_add_suite(__FILE__, init, finalise);
>> -       if (NULL == ptr_suite) {
>> +
>> +       p_suite = CU_add_suite(__FILE__, init, NULL);
>> +       if (!p_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)) {
>> +
>> +       ret = CU_ADD_TEST(p_suite, test_odp_init_global);
>> +       if (!ret) {
>>                 CU_cleanup_registry();
>>                 return CU_get_error();
>>         }
>> -       /* Run all tests using the CUnit Basic interface */
>> +
>> +       ret = CU_ADD_TEST(p_suite, odp_init_local_singlethread_sunnyday);
>> +       if (!ret) {
>> +               CU_cleanup_registry();
>> +               return CU_get_error();
>> +       }
>> +
>> +       ret = CU_ADD_TEST(p_suite, odp_init_local_thread_per_
>> core_sunnyday);
>> +       if (!ret) {
>> +               CU_cleanup_registry();
>> +               return CU_get_error();
>> +       }
>> +
>>         CU_basic_set_mode(CU_BRM_VERBOSE);
>>         CU_basic_run_tests();
>>         CU_cleanup_registry();
>>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Taras Kondratiuk Nov. 21, 2014, 11:40 a.m. UTC | #3
On 11/20/2014 08:18 PM, Madhusudan Venugopal wrote:
>   int main(void)
>   {
> -	CU_pSuite ptr_suite = NULL;
> -	/* initialize the CUnit test registry */
> +	CU_pSuite p_suite;
> +	CU_pTest ret;
> +
>   	if (CUE_SUCCESS != CU_initialize_registry())
>   		return CU_get_error();
> -	/* add a suite to the registry */
> -	ptr_suite = CU_add_suite(__FILE__, init, finalise);
> -	if (NULL == ptr_suite) {
> +
> +	p_suite = CU_add_suite(__FILE__, init, NULL);
> +	if (!p_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)) {
> +
> +	ret = CU_ADD_TEST(p_suite, test_odp_init_global);
> +	if (!ret) {
>   		CU_cleanup_registry();
>   		return CU_get_error();
>   	}
> -	/* Run all tests using the CUnit Basic interface */
> +
> +	ret = CU_ADD_TEST(p_suite, odp_init_local_singlethread_sunnyday);
> +	if (!ret) {
> +		CU_cleanup_registry();
> +		return CU_get_error();
> +	}
> +
> +	ret = CU_ADD_TEST(p_suite, odp_init_local_thread_per_core_sunnyday);
> +	if (!ret) {
> +		CU_cleanup_registry();
> +		return CU_get_error();
> +	}

If there are more than a two tests, then CU_register_suites() API looks
cleaner than adding tests one by one.
Maxim Uvarov Nov. 21, 2014, 11:46 a.m. UTC | #4
On 11/21/2014 02:40 PM, Taras Kondratiuk wrote:
> On 11/20/2014 08:18 PM, Madhusudan Venugopal wrote:
>>   int main(void)
>>   {
>> -    CU_pSuite ptr_suite = NULL;
>> -    /* initialize the CUnit test registry */
>> +    CU_pSuite p_suite;
>> +    CU_pTest ret;
>> +
>>       if (CUE_SUCCESS != CU_initialize_registry())
>>           return CU_get_error();
>> -    /* add a suite to the registry */
>> -    ptr_suite = CU_add_suite(__FILE__, init, finalise);
>> -    if (NULL == ptr_suite) {
>> +
>> +    p_suite = CU_add_suite(__FILE__, init, NULL);
>> +    if (!p_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)) {
>> +
>> +    ret = CU_ADD_TEST(p_suite, test_odp_init_global);
>> +    if (!ret) {
>>           CU_cleanup_registry();
>>           return CU_get_error();
>>       }
>> -    /* Run all tests using the CUnit Basic interface */
>> +
>> +    ret = CU_ADD_TEST(p_suite, odp_init_local_singlethread_sunnyday);
>> +    if (!ret) {
>> +        CU_cleanup_registry();
>> +        return CU_get_error();
>> +    }
>> +
>> +    ret = CU_ADD_TEST(p_suite, 
>> odp_init_local_thread_per_core_sunnyday);
>> +    if (!ret) {
>> +        CU_cleanup_registry();
>> +        return CU_get_error();
>> +    }
>
> If there are more than a two tests, then CU_register_suites() API looks
> cleaner than adding tests one by one.
>

Agree. Please use CU_register_suites().

Maxim.

> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
Mike Holmes Nov. 21, 2014, 4:02 p.m. UTC | #5
On 21 November 2014 06:46, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> On 11/21/2014 02:40 PM, Taras Kondratiuk wrote:
>
>> On 11/20/2014 08:18 PM, Madhusudan Venugopal wrote:
>>
>>>   int main(void)
>>>   {
>>> -    CU_pSuite ptr_suite = NULL;
>>> -    /* initialize the CUnit test registry */
>>> +    CU_pSuite p_suite;
>>> +    CU_pTest ret;
>>> +
>>>       if (CUE_SUCCESS != CU_initialize_registry())
>>>           return CU_get_error();
>>> -    /* add a suite to the registry */
>>> -    ptr_suite = CU_add_suite(__FILE__, init, finalise);
>>> -    if (NULL == ptr_suite) {
>>> +
>>> +    p_suite = CU_add_suite(__FILE__, init, NULL);
>>> +    if (!p_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)) {
>>> +
>>> +    ret = CU_ADD_TEST(p_suite, test_odp_init_global);
>>> +    if (!ret) {
>>>           CU_cleanup_registry();
>>>           return CU_get_error();
>>>       }
>>> -    /* Run all tests using the CUnit Basic interface */
>>> +
>>> +    ret = CU_ADD_TEST(p_suite, odp_init_local_singlethread_sunnyday);
>>> +    if (!ret) {
>>> +        CU_cleanup_registry();
>>> +        return CU_get_error();
>>> +    }
>>> +
>>> +    ret = CU_ADD_TEST(p_suite, odp_init_local_thread_per_
>>> core_sunnyday);
>>> +    if (!ret) {
>>> +        CU_cleanup_registry();
>>> +        return CU_get_error();
>>> +    }
>>>
>>
>> If there are more than a two tests, then CU_register_suites() API looks
>> cleaner than adding tests one by one.
>>
>>
> Agree. Please use CU_register_suites().



Agree, lets make this the standard.


>
>
> Maxim.
>
>
>  _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> http://lists.linaro.org/mailman/listinfo/lng-odp
>>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Anders Roxell Nov. 21, 2014, 4:32 p.m. UTC | #6
On 21 November 2014 17:02, Mike Holmes <mike.holmes@linaro.org> wrote:
>
>
> On 21 November 2014 06:46, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
>>
>> On 11/21/2014 02:40 PM, Taras Kondratiuk wrote:
>>>
>>> On 11/20/2014 08:18 PM, Madhusudan Venugopal wrote:
>>>>
>>>>   int main(void)
>>>>   {
>>>> -    CU_pSuite ptr_suite = NULL;
>>>> -    /* initialize the CUnit test registry */
>>>> +    CU_pSuite p_suite;
>>>> +    CU_pTest ret;
>>>> +
>>>>       if (CUE_SUCCESS != CU_initialize_registry())
>>>>           return CU_get_error();
>>>> -    /* add a suite to the registry */
>>>> -    ptr_suite = CU_add_suite(__FILE__, init, finalise);
>>>> -    if (NULL == ptr_suite) {
>>>> +
>>>> +    p_suite = CU_add_suite(__FILE__, init, NULL);
>>>> +    if (!p_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)) {
>>>> +
>>>> +    ret = CU_ADD_TEST(p_suite, test_odp_init_global);
>>>> +    if (!ret) {
>>>>           CU_cleanup_registry();
>>>>           return CU_get_error();
>>>>       }
>>>> -    /* Run all tests using the CUnit Basic interface */
>>>> +
>>>> +    ret = CU_ADD_TEST(p_suite, odp_init_local_singlethread_sunnyday);
>>>> +    if (!ret) {
>>>> +        CU_cleanup_registry();
>>>> +        return CU_get_error();
>>>> +    }
>>>> +
>>>> +    ret = CU_ADD_TEST(p_suite,
>>>> odp_init_local_thread_per_core_sunnyday);
>>>> +    if (!ret) {
>>>> +        CU_cleanup_registry();
>>>> +        return CU_get_error();
>>>> +    }
>>>
>>>
>>> If there are more than a two tests, then CU_register_suites() API looks
>>> cleaner than adding tests one by one.
>>>
>>
>> Agree. Please use CU_register_suites().
>
>
>
> Agree, lets make this the standard.

+1
diff mbox

Patch

diff --git a/test/validation/odp_init.c b/test/validation/odp_init.c
index 88e6235..b4db1e1 100644
--- a/test/validation/odp_init.c
+++ b/test/validation/odp_init.c
@@ -6,49 +6,157 @@ 
 
 #include "odp.h"
 #include "CUnit/Basic.h"
+#include <odph_linux.h>
 
-#define DEFAULT_MSG_POOL_SIZE	(4*1024*1024)
-#define DEFAULT_MSG_SIZE	(8)
+void *odp_init_test(void *arg);
+static void odp_init_local_singlethread_sunnyday(void);
+static void odp_init_local_thread_per_core_sunnyday(void);
+static int init(void);
+static void test_odp_init_global(void);
 
-static void test_odp_init_global(void)
+#define MAX_WORKERS           32
+#define FIRST_CORE            0
+#define SINGLE_THREAD         1
+
+/* Test to check if the thread is able to initialize using
+ * odp_init_local() and can terminate using odp_term_local().
+ * odp_init_local() will return 0 if successful intialization.
+ * odp_term_local() will return 0 if successful termination.
+ */
+
+void *odp_init_test(void *arg)
+{
+	int status;
+
+	status = odp_init_local();
+	CU_ASSERT(!status);
+
+	status = odp_term_local();
+	CU_ASSERT(!status);
+
+	return arg;
+}
+
+int init(void)
+{
+	printf("\t ODP version: %s\n", odp_version_api_str());
+	return 0;
+}
+
+/* Test for initialization and termination of single odp thread */
+
+
+void odp_init_local_singlethread_sunnyday(void)
 {
 	int status;
+	odph_linux_pthread_t thread;
+
 	status = odp_init_global(NULL, NULL);
-	CU_ASSERT(status == 0);
+	CU_ASSERT(!status);
+
+	status = odp_init_local();
+	CU_ASSERT(!status);
+
+	odph_linux_pthread_create(&thread, SINGLE_THREAD, FIRST_CORE,
+				  odp_init_test, NULL);
+	odph_linux_pthread_join(&thread, 1);
+
+	status = odp_term_local();
+	CU_ASSERT(!status);
 
 	status = odp_term_global();
-	CU_ASSERT(status == 0);
+	CU_ASSERT(!status);
 }
 
-static int init(void)
+/* Test for initialization and termination of multiple odp threads
+ * One odp thread per core.
+ */
+
+void odp_init_local_thread_per_core_sunnyday(void)
 {
-	printf("\tODP version: %s\n", odp_version_api_str());
-	return 0;
+	odph_linux_pthread_t thread_tbl[MAX_WORKERS];
+	int num_workers;
+	int status, first_core;
+	first_core = 1;
+
+	status = odp_init_global(NULL, NULL);
+	CU_ASSERT(!status);
+	status = odp_init_local();
+	CU_ASSERT(!status);
+
+	num_workers = odp_sys_core_count();
+	if (1 == num_workers)
+		first_core = 0;
+
+	if (MAX_WORKERS < num_workers)
+		num_workers = MAX_WORKERS;
+
+	odph_linux_pthread_create(thread_tbl, num_workers, first_core,
+				  odp_init_test, NULL);
+
+	/* if the number of cores  in the system is 1, we have to use  core 0.
+	 * However if the number of cores is more than 1, we can leave core 0
+	 * for linux system and this how we expect odp systems to be used.
+	 */
+
+	odph_linux_pthread_join(thread_tbl, num_workers);
+
+	status = odp_term_local();
+	CU_ASSERT(!status);
+
+	status = odp_term_global();
+	CU_ASSERT(!status);
 }
 
-static int finalise(void)
+/* Test to check if ODP is able to initialize globally using odp_init_global()
+ * and terminate globally using odp_term_global() successfully.
+ * odp_init_global() returns 0 if successful
+ * odp_term_global() returns 0 if successful
+ */
+
+static void test_odp_init_global(void)
 {
-	return 0;
+	int status;
+
+	status = odp_init_global(NULL, NULL);
+	CU_ASSERT(!status);
+
+	status = odp_term_global();
+	CU_ASSERT(!status);
 }
 
 int main(void)
 {
-	CU_pSuite ptr_suite = NULL;
-	/* initialize the CUnit test registry */
+	CU_pSuite p_suite;
+	CU_pTest ret;
+
 	if (CUE_SUCCESS != CU_initialize_registry())
 		return CU_get_error();
-	/* add a suite to the registry */
-	ptr_suite = CU_add_suite(__FILE__, init, finalise);
-	if (NULL == ptr_suite) {
+
+	p_suite = CU_add_suite(__FILE__, init, NULL);
+	if (!p_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)) {
+
+	ret = CU_ADD_TEST(p_suite, test_odp_init_global);
+	if (!ret) {
 		CU_cleanup_registry();
 		return CU_get_error();
 	}
-	/* Run all tests using the CUnit Basic interface */
+
+	ret = CU_ADD_TEST(p_suite, odp_init_local_singlethread_sunnyday);
+	if (!ret) {
+		CU_cleanup_registry();
+		return CU_get_error();
+	}
+
+	ret = CU_ADD_TEST(p_suite, odp_init_local_thread_per_core_sunnyday);
+	if (!ret) {
+		CU_cleanup_registry();
+		return CU_get_error();
+	}
+
 	CU_basic_set_mode(CU_BRM_VERBOSE);
 	CU_basic_run_tests();
 	CU_cleanup_registry();