Free queue and timeouts, destroy timeout pool before termination.
https://bugs.linaro.org/show_bug.cgi?id=1285

Signed-off-by: Ola Liljedahl <[email protected]>
---
(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
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to