diff mbox

[PATCHv4,1/3] validation: schedule: free queues and pool

Message ID 1426678594-29398-2-git-send-email-ciprian.barbu@linaro.org
State Accepted
Commit 31350d643ca70ba74f640743f00a7051f64331cc
Headers show

Commit Message

Ciprian Barbu March 18, 2015, 11:36 a.m. UTC
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>
---
v4:
- check return code of destroy_queues

 test/validation/odp_schedule.c | 58 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 56 insertions(+), 2 deletions(-)

Comments

Mike Holmes March 19, 2015, 5:38 p.m. UTC | #1
On 18 March 2015 at 07:36, Ciprian Barbu <ciprian.barbu@linaro.org> 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>
> ---
> v4:
> - check return code of destroy_queues
>
>  test/validation/odp_schedule.c | 58
> ++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 56 insertions(+), 2 deletions(-)
>
> diff --git a/test/validation/odp_schedule.c
> b/test/validation/odp_schedule.c
> index a9369c5..a9b6283 100644
> --- a/test/validation/odp_schedule.c
> +++ b/test/validation/odp_schedule.c
> @@ -624,7 +624,60 @@ 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;
> +
> +       if (destroy_queues() != 0)
>

above you use the style  if (destroy_queues())


> +               fprintf(stderr, "error: failed to destroy queues\n");
>

 return -1; ?


> +
> +       pool = odp_pool_lookup(MSG_POOL_NAME);
> +       if (odp_pool_destroy(pool) != 0)
>

above you use the style   if (odp_pool_destroy(pool))


> +               fprintf(stderr, "error: failed to destroy pool\n");
>

 return -1; ?


> +
> +       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 +711,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,
>  };
> --
> 1.8.3.2
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>

This does correct a lot of warnings.
diff mbox

Patch

diff --git a/test/validation/odp_schedule.c b/test/validation/odp_schedule.c
index a9369c5..a9b6283 100644
--- a/test/validation/odp_schedule.c
+++ b/test/validation/odp_schedule.c
@@ -624,7 +624,60 @@  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;
+
+	if (destroy_queues() != 0)
+		fprintf(stderr, "error: failed to destroy queues\n");
+
+	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 +711,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,
 };