diff mbox

validation: queue: destroy created ODP resources

Message ID 1424860252-17970-1-git-send-email-taras.kondratiuk@linaro.org
State Accepted
Commit 3a0a84edc8f54ac296843b7de2d770936cc69322
Headers show

Commit Message

Taras Kondratiuk Feb. 25, 2015, 10:30 a.m. UTC
Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
---
 test/validation/odp_queue.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Maxim Uvarov Feb. 25, 2015, 1:31 p.m. UTC | #1
Taras, I think it's no need to make pool global var. There is pool 
lookup and
Bill already did patch for that:
[PATCH] validation: queue: clean up test toenable clean termination

Maxim.


On 02/25/2015 01:30 PM, Taras Kondratiuk wrote:
> Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
> ---
>   test/validation/odp_queue.c | 11 +++++++++--
>   1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/test/validation/odp_queue.c b/test/validation/odp_queue.c
> index 91a32dc..5d47399 100644
> --- a/test/validation/odp_queue.c
> +++ b/test/validation/odp_queue.c
> @@ -12,10 +12,10 @@
>   #define CONFIG_MAX_ITERATION    (100)
>   
>   static int queue_contest = 0xff;
> +static odp_pool_t pool;
>   
>   static int init_queue_suite(void)
>   {
> -	odp_pool_t pool;
>   	odp_pool_param_t params;
>   
>   	params.buf.size  = 0;
> @@ -32,6 +32,11 @@ static int init_queue_suite(void)
>   	return 0;
>   }
>   
> +static int init_queue_finalize(void)
> +{
> +	return odp_pool_destroy(pool);
> +}
> +
>   static void test_odp_queue_sunnyday(void)
>   {
>   	odp_queue_t queue_creat_id, queue_id;
> @@ -103,6 +108,7 @@ static void test_odp_queue_sunnyday(void)
>   		odp_buffer_free(enbuf);
>   	}
>   
> +	CU_ASSERT(odp_queue_destroy(queue_id) == 0);
>   	return;
>   }
>   
> @@ -112,6 +118,7 @@ CU_TestInfo test_odp_queue[] = {
>   };
>   
>   CU_SuiteInfo odp_testsuites[] = {
> -	{"Queue", init_queue_suite, NULL, NULL, NULL, test_odp_queue},
> +	{"Queue", init_queue_suite, init_queue_finalize,
> +			NULL, NULL, test_odp_queue},
>   	CU_SUITE_INFO_NULL,
>   };
Taras Kondratiuk Feb. 25, 2015, 2:41 p.m. UTC | #2
On 02/25/2015 03:31 PM, Maxim Uvarov wrote:
> Taras, I think it's no need to make pool global var. There is pool 
> lookup and
> Bill already did patch for that:
> [PATCH] validation: queue: clean up test toenable clean termination

Hmm. I've missed that patch, but anyway it is not correct. Test should
not destroy resource created by testsuite init function, because it can
be used by other tests.

What are you concern regarding global variable for a pool? Why to do a
lookup if you can just save a handle?
Maxim Uvarov Feb. 25, 2015, 3:33 p.m. UTC | #3
On 02/25/2015 05:41 PM, Taras Kondratiuk wrote:
> On 02/25/2015 03:31 PM, Maxim Uvarov wrote:
>> Taras, I think it's no need to make pool global var. There is pool
>> lookup and
>> Bill already did patch for that:
>> [PATCH] validation: queue: clean up test toenable clean termination
> Hmm. I've missed that patch, but anyway it is not correct. Test should
> not destroy resource created by testsuite init function, because it can
> be used by other tests.
>
> What are you concern regarding global variable for a pool? Why to do a
> lookup if you can just save a handle?
>
It's props and cons. Tests are not performance critical and we do lookup 
in other tests like pkio without global pool.

Maxim.
Maxim Uvarov Feb. 25, 2015, 4:55 p.m. UTC | #4
On 02/25/2015 05:41 PM, Taras Kondratiuk wrote:
> On 02/25/2015 03:31 PM, Maxim Uvarov wrote:
>> Taras, I think it's no need to make pool global var. There is pool
>> lookup and
>> Bill already did patch for that:
>> [PATCH] validation: queue: clean up test toenable clean termination
> Hmm. I've missed that patch, but anyway it is not correct. Test should
> not destroy resource created by testsuite init function, because it can
> be used by other tests.

Yes, in case to not free what was in init function that is the key here.
Lets go with global var. I tested patch works good.

Maxim.

>
> What are you concern regarding global variable for a pool? Why to do a
> lookup if you can just save a handle?
>
diff mbox

Patch

diff --git a/test/validation/odp_queue.c b/test/validation/odp_queue.c
index 91a32dc..5d47399 100644
--- a/test/validation/odp_queue.c
+++ b/test/validation/odp_queue.c
@@ -12,10 +12,10 @@ 
 #define CONFIG_MAX_ITERATION    (100)
 
 static int queue_contest = 0xff;
+static odp_pool_t pool;
 
 static int init_queue_suite(void)
 {
-	odp_pool_t pool;
 	odp_pool_param_t params;
 
 	params.buf.size  = 0;
@@ -32,6 +32,11 @@  static int init_queue_suite(void)
 	return 0;
 }
 
+static int init_queue_finalize(void)
+{
+	return odp_pool_destroy(pool);
+}
+
 static void test_odp_queue_sunnyday(void)
 {
 	odp_queue_t queue_creat_id, queue_id;
@@ -103,6 +108,7 @@  static void test_odp_queue_sunnyday(void)
 		odp_buffer_free(enbuf);
 	}
 
+	CU_ASSERT(odp_queue_destroy(queue_id) == 0);
 	return;
 }
 
@@ -112,6 +118,7 @@  CU_TestInfo test_odp_queue[] = {
 };
 
 CU_SuiteInfo odp_testsuites[] = {
-	{"Queue", init_queue_suite, NULL, NULL, NULL, test_odp_queue},
+	{"Queue", init_queue_suite, init_queue_finalize,
+			NULL, NULL, test_odp_queue},
 	CU_SUITE_INFO_NULL,
 };