diff mbox series

[v2,2/2] test: support cleanup in bitrate and latency test

Message ID 20200519105258.31426-2-hemant.agrawal@nxp.com
State Accepted
Commit d3f7095baffb5f3cdc3293fd6ae42433aac62b37
Headers show
Series [v2,1/2] lib/metrics: fix to reset the init flag | expand

Commit Message

Hemant Agrawal May 19, 2020, 10:52 a.m. UTC
both bitratestats_autotest latency test initializes
the metrics library. It should be cleaned during exit.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>

---
 app/test/test_bitratestats.c | 14 ++++++++++++++
 app/test/test_latencystats.c |  3 +++
 2 files changed, 17 insertions(+)

-- 
2.17.1

Comments

Stephen Hemminger May 19, 2020, 3:24 p.m. UTC | #1
On Tue, 19 May 2020 16:22:58 +0530
Hemant Agrawal <hemant.agrawal@nxp.com> wrote:

> +/* To test free the resources from bitrate_reg test */

> +static int

> +test_stats_bitrate_free(void)

> +{

> +	int ret = 0;

> +

> +	ret = rte_metrics_deinit();


Coverity will complain about extra initialization like this
diff mbox series

Patch

diff --git a/app/test/test_bitratestats.c b/app/test/test_bitratestats.c
index 3a7d9c037a..39d7f734d4 100644
--- a/app/test/test_bitratestats.c
+++ b/app/test/test_bitratestats.c
@@ -32,6 +32,18 @@  test_stats_bitrate_create(void)
 	return TEST_SUCCESS;
 }
 
+/* To test free the resources from bitrate_reg test */
+static int
+test_stats_bitrate_free(void)
+{
+	int ret = 0;
+
+	ret = rte_metrics_deinit();
+	TEST_ASSERT(ret >= 0, "Test Failed: rte_metrics_deinit failed");
+
+	return TEST_SUCCESS;
+}
+
 /* To test bit rate registration */
 static int
 test_stats_bitrate_reg(void)
@@ -214,6 +226,8 @@  unit_test_suite bitratestats_testsuite  = {
 		 */
 		TEST_CASE_ST(test_bit_packet_forward, NULL,
 				test_stats_bitrate_calc),
+		/* TEST CASE 9: Test to do the cleanup w.r.t create */
+		TEST_CASE(test_stats_bitrate_free),
 		TEST_CASES_END()
 	}
 };
diff --git a/app/test/test_latencystats.c b/app/test/test_latencystats.c
index 968e0bc470..427339904d 100644
--- a/app/test/test_latencystats.c
+++ b/app/test/test_latencystats.c
@@ -60,6 +60,9 @@  static int test_latency_uninit(void)
 	ret = rte_latencystats_uninit();
 	TEST_ASSERT(ret >= 0, "Test Failed: rte_latencystats_uninit failed");
 
+	ret = rte_metrics_deinit();
+	TEST_ASSERT(ret >= 0, "Test Failed: rte_metrics_deinit failed");
+
 	return TEST_SUCCESS;
 }