Message ID | 1426586009-21519-2-git-send-email-ciprian.barbu@linaro.org |
---|---|
State | Superseded |
Headers | show |
On 03/17/15 12:53, Ciprian Barbu wrote: > With the implementation of termination APIs it is now necessarry to cleanup all > allocated resources, queues and pool in this case. > Fixes https://bugs.linaro.org/show_bug.cgi?id=1284 > > Signed-off-by: Ciprian Barbu <ciprian.barbu@linaro.org> > --- > test/validation/odp_schedule.c | 56 ++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 54 insertions(+), 2 deletions(-) > > diff --git a/test/validation/odp_schedule.c b/test/validation/odp_schedule.c > index a9369c5..b86f997 100644 > --- a/test/validation/odp_schedule.c > +++ b/test/validation/odp_schedule.c > @@ -624,7 +624,58 @@ static int schd_suite_init(void) > return 0; > } > > -struct CU_TestInfo test_odp_schedule[] = { > +static int destroy_queue(const char *name) > +{ > + odp_queue_t q; > + > + q = odp_queue_lookup(name); > + > + if (q == ODP_QUEUE_INVALID) > + return -1; > + > + return odp_queue_destroy(q); > +} > + > +static int destroy_queues(void) > +{ > + int i, j, prios; > + > + prios = odp_schedule_num_prio(); > + > + for (i = 0; i < prios; i++) { > + for (j = 0; j < QUEUES_PER_PRIO; j++) { > + char name[32]; > + > + snprintf(name, sizeof(name), "sched_%d_%d_n", i, j); > + if (destroy_queue(name)) > + return -1; > + > + snprintf(name, sizeof(name), "sched_%d_%d_a", i, j); > + if (destroy_queue(name)) > + return -1; > + > + snprintf(name, sizeof(name), "sched_%d_%d_o", i, j); > + if (destroy_queue(name)) > + return -1; > + } > + } > + > + return 0; > +} > + > +static int schd_suite_term(void) > +{ > + odp_pool_t pool; > + > + destroy_queues(); Coverity does not like not checking return codes for int functions. It has to be (void)destroy_queues(); > + pool = odp_pool_lookup(MSG_POOL_NAME); > + if (odp_pool_destroy(pool) != 0) > + fprintf(stderr, "error: failed to destroy pool\n"); > + > + return 0; > +} > + > +struct CU_TestInfo schd_tests[] = { > {"schedule_wait_time", test_schedule_wait_time}, > {"schedule_num_prio", test_schedule_num_prio}, > {"schedule_1q_1t_n", test_schedule_1q_1t_n}, > @@ -658,6 +709,7 @@ struct CU_TestInfo test_odp_schedule[] = { > }; > > CU_SuiteInfo odp_testsuites[] = { > - {"Scheduler", schd_suite_init, NULL, NULL, NULL, test_odp_schedule}, > + {"Scheduler", > + schd_suite_init, schd_suite_term, NULL, NULL, schd_tests}, > CU_SUITE_INFO_NULL, > };
Mike, review ok? Maxim. On 03/17/15 12:53, Ciprian Barbu wrote: > With the implementation of termination APIs it is now necessarry to cleanup all > allocated resources, queues and pool in this case. > Fixes https://bugs.linaro.org/show_bug.cgi?id=1284 > > Signed-off-by: Ciprian Barbu <ciprian.barbu@linaro.org> > --- > test/validation/odp_schedule.c | 56 ++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 54 insertions(+), 2 deletions(-) > > diff --git a/test/validation/odp_schedule.c b/test/validation/odp_schedule.c > index a9369c5..b86f997 100644 > --- a/test/validation/odp_schedule.c > +++ b/test/validation/odp_schedule.c > @@ -624,7 +624,58 @@ static int schd_suite_init(void) > return 0; > } > > -struct CU_TestInfo test_odp_schedule[] = { > +static int destroy_queue(const char *name) > +{ > + odp_queue_t q; > + > + q = odp_queue_lookup(name); > + > + if (q == ODP_QUEUE_INVALID) > + return -1; > + > + return odp_queue_destroy(q); > +} > + > +static int destroy_queues(void) > +{ > + int i, j, prios; > + > + prios = odp_schedule_num_prio(); > + > + for (i = 0; i < prios; i++) { > + for (j = 0; j < QUEUES_PER_PRIO; j++) { > + char name[32]; > + > + snprintf(name, sizeof(name), "sched_%d_%d_n", i, j); > + if (destroy_queue(name)) > + return -1; > + > + snprintf(name, sizeof(name), "sched_%d_%d_a", i, j); > + if (destroy_queue(name)) > + return -1; > + > + snprintf(name, sizeof(name), "sched_%d_%d_o", i, j); > + if (destroy_queue(name)) > + return -1; > + } > + } > + > + return 0; > +} > + > +static int schd_suite_term(void) > +{ > + odp_pool_t pool; > + > + destroy_queues(); > + pool = odp_pool_lookup(MSG_POOL_NAME); > + if (odp_pool_destroy(pool) != 0) > + fprintf(stderr, "error: failed to destroy pool\n"); > + > + return 0; > +} > + > +struct CU_TestInfo schd_tests[] = { > {"schedule_wait_time", test_schedule_wait_time}, > {"schedule_num_prio", test_schedule_num_prio}, > {"schedule_1q_1t_n", test_schedule_1q_1t_n}, > @@ -658,6 +709,7 @@ struct CU_TestInfo test_odp_schedule[] = { > }; > > CU_SuiteInfo odp_testsuites[] = { > - {"Scheduler", schd_suite_init, NULL, NULL, NULL, test_odp_schedule}, > + {"Scheduler", > + schd_suite_init, schd_suite_term, NULL, NULL, schd_tests}, > CU_SUITE_INFO_NULL, > };
diff --git a/test/validation/odp_schedule.c b/test/validation/odp_schedule.c index a9369c5..b86f997 100644 --- a/test/validation/odp_schedule.c +++ b/test/validation/odp_schedule.c @@ -624,7 +624,58 @@ static int schd_suite_init(void) return 0; } -struct CU_TestInfo test_odp_schedule[] = { +static int destroy_queue(const char *name) +{ + odp_queue_t q; + + q = odp_queue_lookup(name); + + if (q == ODP_QUEUE_INVALID) + return -1; + + return odp_queue_destroy(q); +} + +static int destroy_queues(void) +{ + int i, j, prios; + + prios = odp_schedule_num_prio(); + + for (i = 0; i < prios; i++) { + for (j = 0; j < QUEUES_PER_PRIO; j++) { + char name[32]; + + snprintf(name, sizeof(name), "sched_%d_%d_n", i, j); + if (destroy_queue(name)) + return -1; + + snprintf(name, sizeof(name), "sched_%d_%d_a", i, j); + if (destroy_queue(name)) + return -1; + + snprintf(name, sizeof(name), "sched_%d_%d_o", i, j); + if (destroy_queue(name)) + return -1; + } + } + + return 0; +} + +static int schd_suite_term(void) +{ + odp_pool_t pool; + + destroy_queues(); + pool = odp_pool_lookup(MSG_POOL_NAME); + if (odp_pool_destroy(pool) != 0) + fprintf(stderr, "error: failed to destroy pool\n"); + + return 0; +} + +struct CU_TestInfo schd_tests[] = { {"schedule_wait_time", test_schedule_wait_time}, {"schedule_num_prio", test_schedule_num_prio}, {"schedule_1q_1t_n", test_schedule_1q_1t_n}, @@ -658,6 +709,7 @@ struct CU_TestInfo test_odp_schedule[] = { }; CU_SuiteInfo odp_testsuites[] = { - {"Scheduler", schd_suite_init, NULL, NULL, NULL, test_odp_schedule}, + {"Scheduler", + schd_suite_init, schd_suite_term, NULL, NULL, schd_tests}, CU_SUITE_INFO_NULL, };
With the implementation of termination APIs it is now necessarry to cleanup all allocated resources, queues and pool in this case. Fixes https://bugs.linaro.org/show_bug.cgi?id=1284 Signed-off-by: Ciprian Barbu <ciprian.barbu@linaro.org> --- test/validation/odp_schedule.c | 56 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-)