[PATCHv3] validation: odp_timer: cleanup for clean termination

Message ID 1425634857-11435-1-git-send-email-ola.liljedahl@linaro.org
State New
Headers show

Commit Message

Ola Liljedahl March 6, 2015, 9:40 a.m.
Free queue and timeouts, destroy timeout pool before termination.
https://bugs.linaro.org/show_bug.cgi?id=1285

Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org>
---
(This document/code contribution attached is provided under the terms of
agreement LES-LTM-21309)

v2:
Removed reference to Linaro CARDS as this is internal.

v3:
Added check of return value from odp_queue_destroy().

 test/validation/odp_timer.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Maxim Uvarov March 6, 2015, 12:27 p.m. | #1
On 03/06/15 12:40, Ola Liljedahl wrote:
> Free queue and timeouts, destroy timeout pool before termination.
> https://bugs.linaro.org/show_bug.cgi?id=1285
>
> Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org>
> ---
> (This document/code contribution attached is provided under the terms of
> agreement LES-LTM-21309)
>
> v2:
> Removed reference to Linaro CARDS as this is internal.
>
> v3:
> Added check of return value from odp_queue_destroy().
>
>   test/validation/odp_timer.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c
> index 88af61b..4cb2379 100644
> --- a/test/validation/odp_timer.c
> +++ b/test/validation/odp_timer.c
> @@ -336,6 +336,12 @@ static void *worker_entrypoint(void *arg)
>   	if (ev != ODP_EVENT_INVALID)
>   		CU_FAIL("Unexpected event received");
>   
> +	int rc = odp_queue_destroy(queue);

can int rc go on top of the function?
> +	CU_ASSERT(rc == 0);
> +	for (i = 0; i < NTIMERS; i++) {
> +		if (tt[i].ev != ODP_EVENT_INVALID)
> +			odp_timeout_free(odp_timeout_from_event(tt[i].ev));
> +	}
>   	LOG_DBG("Thread %u: exiting\n", thr);
>   	return NULL;
>   }
> @@ -426,6 +432,10 @@ static void test_odp_timer_all(void)
>   	/* Destroy timer pool, all timers must have been freed */
>   	odp_timer_pool_destroy(tp);
>   
> +	/* Destroy timeout pool, all timeouts must have been freed */
> +	int rc = odp_pool_destroy(tbp);
same here.
> +	CU_ASSERT(rc == 0);
> +
>   	CU_PASS("ODP timer test");
>   }
>
Ola Liljedahl March 6, 2015, 4:47 p.m. | #2
On 6 March 2015 at 13:27, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
> On 03/06/15 12:40, Ola Liljedahl wrote:
>>
>> Free queue and timeouts, destroy timeout pool before termination.
>> https://bugs.linaro.org/show_bug.cgi?id=1285
>>
>> Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org>
>> ---
>> (This document/code contribution attached is provided under the terms of
>> agreement LES-LTM-21309)
>>
>> v2:
>> Removed reference to Linaro CARDS as this is internal.
>>
>> v3:
>> Added check of return value from odp_queue_destroy().
>>
>>   test/validation/odp_timer.c | 10 ++++++++++
>>   1 file changed, 10 insertions(+)
>>
>> diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c
>> index 88af61b..4cb2379 100644
>> --- a/test/validation/odp_timer.c
>> +++ b/test/validation/odp_timer.c
>> @@ -336,6 +336,12 @@ static void *worker_entrypoint(void *arg)
>>         if (ev != ODP_EVENT_INVALID)
>>                 CU_FAIL("Unexpected event received");
>>   +     int rc = odp_queue_destroy(queue);
>
>
> can int rc go on top of the function?
Yes but why?

>>
>> +       CU_ASSERT(rc == 0);
>> +       for (i = 0; i < NTIMERS; i++) {
>> +               if (tt[i].ev != ODP_EVENT_INVALID)
>> +
>> odp_timeout_free(odp_timeout_from_event(tt[i].ev));
>> +       }
>>         LOG_DBG("Thread %u: exiting\n", thr);
>>         return NULL;
>>   }
>> @@ -426,6 +432,10 @@ static void test_odp_timer_all(void)
>>         /* Destroy timer pool, all timers must have been freed */
>>         odp_timer_pool_destroy(tp);
>>   +     /* Destroy timeout pool, all timeouts must have been freed */
>> +       int rc = odp_pool_destroy(tbp);
>
> same here.
>>
>> +       CU_ASSERT(rc == 0);
>> +
>>         CU_PASS("ODP timer test");
>>   }
>>
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp

Patch

diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c
index 88af61b..4cb2379 100644
--- a/test/validation/odp_timer.c
+++ b/test/validation/odp_timer.c
@@ -336,6 +336,12 @@  static void *worker_entrypoint(void *arg)
 	if (ev != ODP_EVENT_INVALID)
 		CU_FAIL("Unexpected event received");
 
+	int rc = odp_queue_destroy(queue);
+	CU_ASSERT(rc == 0);
+	for (i = 0; i < NTIMERS; i++) {
+		if (tt[i].ev != ODP_EVENT_INVALID)
+			odp_timeout_free(odp_timeout_from_event(tt[i].ev));
+	}
 	LOG_DBG("Thread %u: exiting\n", thr);
 	return NULL;
 }
@@ -426,6 +432,10 @@  static void test_odp_timer_all(void)
 	/* Destroy timer pool, all timers must have been freed */
 	odp_timer_pool_destroy(tp);
 
+	/* Destroy timeout pool, all timeouts must have been freed */
+	int rc = odp_pool_destroy(tbp);
+	CU_ASSERT(rc == 0);
+
 	CU_PASS("ODP timer test");
 }