diff mbox

[PATCHv4] validation: odp_timer: cleanup for clean termination

Message ID 1425900483-4619-1-git-send-email-ola.liljedahl@linaro.org
State Accepted
Commit 111a1b50b4de2f8838f4bd33042e8e738a6ecac1
Headers show

Commit Message

Ola Liljedahl March 9, 2015, 11:28 a.m. UTC
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().

v4:
Declare 'rc' variable at start of function.

 test/validation/odp_timer.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

Bill Fischofer March 9, 2015, 4:59 p.m. UTC | #1
On Mon, Mar 9, 2015 at 6:28 AM, Ola Liljedahl <ola.liljedahl@linaro.org>
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>
>

Reviewed-by: Bill Fischofer <bill.fischofer@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().
>
> v4:
> Declare 'rc' variable at start of function.
>
>  test/validation/odp_timer.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c
> index 88af61b..b625b80 100644
> --- a/test/validation/odp_timer.c
> +++ b/test/validation/odp_timer.c
> @@ -188,6 +188,7 @@ static void *worker_entrypoint(void *arg)
>         int thr = odp_thread_id();
>         uint32_t i;
>         unsigned seed = thr;
> +       int rc;
>         (void)arg;
>
>         odp_queue_t queue = odp_queue_create("timer_queue",
> @@ -251,7 +252,7 @@ static void *worker_entrypoint(void *arg)
>                 if (tt[i].ev == ODP_EVENT_INVALID &&
>                     (rand_r(&seed) % 2 == 0)) {
>                         /* Timer active, cancel it */
> -                       int rc = odp_timer_cancel(tt[i].tim, &tt[i].ev);
> +                       rc = odp_timer_cancel(tt[i].tim, &tt[i].ev);
>                         if (rc != 0)
>                                 /* Cancel failed, timer already expired */
>                                 ntoolate++;
> @@ -336,6 +337,12 @@ static void *worker_entrypoint(void *arg)
>         if (ev != ODP_EVENT_INVALID)
>                 CU_FAIL("Unexpected event received");
>
> +       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;
>  }
> @@ -343,6 +350,7 @@ static void *worker_entrypoint(void *arg)
>  /* @private Timer test case entrypoint */
>  static void test_odp_timer_all(void)
>  {
> +       int rc;
>         odp_pool_param_t params;
>         odp_timer_pool_param_t tparam;
>         /* Reserve at least one core for running other processes so the
> timer
> @@ -426,6 +434,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 */
> +       rc = odp_pool_destroy(tbp);
> +       CU_ASSERT(rc == 0);
> +
>         CU_PASS("ODP timer test");
>  }
>
> --
> 1.9.1
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Maxim Uvarov March 10, 2015, 9:56 a.m. UTC | #2
Merged,
Maxim.

On 03/09/15 14:28, 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().
>
> v4:
> Declare 'rc' variable at start of function.
>
>   test/validation/odp_timer.c | 14 +++++++++++++-
>   1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c
> index 88af61b..b625b80 100644
> --- a/test/validation/odp_timer.c
> +++ b/test/validation/odp_timer.c
> @@ -188,6 +188,7 @@ static void *worker_entrypoint(void *arg)
>   	int thr = odp_thread_id();
>   	uint32_t i;
>   	unsigned seed = thr;
> +	int rc;
>   	(void)arg;
>   
>   	odp_queue_t queue = odp_queue_create("timer_queue",
> @@ -251,7 +252,7 @@ static void *worker_entrypoint(void *arg)
>   		if (tt[i].ev == ODP_EVENT_INVALID &&
>   		    (rand_r(&seed) % 2 == 0)) {
>   			/* Timer active, cancel it */
> -			int rc = odp_timer_cancel(tt[i].tim, &tt[i].ev);
> +			rc = odp_timer_cancel(tt[i].tim, &tt[i].ev);
>   			if (rc != 0)
>   				/* Cancel failed, timer already expired */
>   				ntoolate++;
> @@ -336,6 +337,12 @@ static void *worker_entrypoint(void *arg)
>   	if (ev != ODP_EVENT_INVALID)
>   		CU_FAIL("Unexpected event received");
>   
> +	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;
>   }
> @@ -343,6 +350,7 @@ static void *worker_entrypoint(void *arg)
>   /* @private Timer test case entrypoint */
>   static void test_odp_timer_all(void)
>   {
> +	int rc;
>   	odp_pool_param_t params;
>   	odp_timer_pool_param_t tparam;
>   	/* Reserve at least one core for running other processes so the timer
> @@ -426,6 +434,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 */
> +	rc = odp_pool_destroy(tbp);
> +	CU_ASSERT(rc == 0);
> +
>   	CU_PASS("ODP timer test");
>   }
>
diff mbox

Patch

diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c
index 88af61b..b625b80 100644
--- a/test/validation/odp_timer.c
+++ b/test/validation/odp_timer.c
@@ -188,6 +188,7 @@  static void *worker_entrypoint(void *arg)
 	int thr = odp_thread_id();
 	uint32_t i;
 	unsigned seed = thr;
+	int rc;
 	(void)arg;
 
 	odp_queue_t queue = odp_queue_create("timer_queue",
@@ -251,7 +252,7 @@  static void *worker_entrypoint(void *arg)
 		if (tt[i].ev == ODP_EVENT_INVALID &&
 		    (rand_r(&seed) % 2 == 0)) {
 			/* Timer active, cancel it */
-			int rc = odp_timer_cancel(tt[i].tim, &tt[i].ev);
+			rc = odp_timer_cancel(tt[i].tim, &tt[i].ev);
 			if (rc != 0)
 				/* Cancel failed, timer already expired */
 				ntoolate++;
@@ -336,6 +337,12 @@  static void *worker_entrypoint(void *arg)
 	if (ev != ODP_EVENT_INVALID)
 		CU_FAIL("Unexpected event received");
 
+	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;
 }
@@ -343,6 +350,7 @@  static void *worker_entrypoint(void *arg)
 /* @private Timer test case entrypoint */
 static void test_odp_timer_all(void)
 {
+	int rc;
 	odp_pool_param_t params;
 	odp_timer_pool_param_t tparam;
 	/* Reserve at least one core for running other processes so the timer
@@ -426,6 +434,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 */
+	rc = odp_pool_destroy(tbp);
+	CU_ASSERT(rc == 0);
+
 	CU_PASS("ODP timer test");
 }