[dpdk-dev,v4,1/2] test/memzone: add test for memzone count in eal mem config

Message ID eb34fe4a841eb19d62523226160b7687bb122fba.1517480079.git.anatoly.burakov@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Burakov, Anatoly Feb. 1, 2018, 10:14 a.m. UTC
  Ensure that memzone count in eal mem config is incremented and
decremented whenever memzones are allocated and freed.

Reviewed-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.com>

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---

Notes:
    v4: added missing reviewed-by tag

 test/test/test_memzone.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
  

Comments

Thomas Monjalon Feb. 6, 2018, 12:49 a.m. UTC | #1
01/02/2018 11:14, Anatoly Burakov:
> Ensure that memzone count in eal mem config is incremented and
> decremented whenever memzones are allocated and freed.
> 
> Reviewed-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.com>
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

Series applied, thanks
  

Patch

diff --git a/test/test/test_memzone.c b/test/test/test_memzone.c
index f6c9b56..00d340f 100644
--- a/test/test/test_memzone.c
+++ b/test/test/test_memzone.c
@@ -841,6 +841,9 @@  test_memzone_basic(void)
 	const struct rte_memzone *memzone3;
 	const struct rte_memzone *memzone4;
 	const struct rte_memzone *mz;
+	int memzone_cnt_after, memzone_cnt_expected;
+	int memzone_cnt_before =
+			rte_eal_get_configuration()->mem_config->memzone_cnt;
 
 	memzone1 = rte_memzone_reserve("testzone1", 100,
 				SOCKET_ID_ANY, 0);
@@ -858,6 +861,18 @@  test_memzone_basic(void)
 	if (memzone1 == NULL || memzone2 == NULL || memzone4 == NULL)
 		return -1;
 
+	/* check how many memzones we are expecting */
+	memzone_cnt_expected = memzone_cnt_before +
+			(memzone1 != NULL) + (memzone2 != NULL) +
+			(memzone3 != NULL) + (memzone4 != NULL);
+
+	memzone_cnt_after =
+			rte_eal_get_configuration()->mem_config->memzone_cnt;
+
+	if (memzone_cnt_after != memzone_cnt_expected)
+		return -1;
+
+
 	rte_memzone_dump(stdout);
 
 	/* check cache-line alignments */
@@ -930,6 +945,11 @@  test_memzone_basic(void)
 		return -1;
 	}
 
+	memzone_cnt_after =
+			rte_eal_get_configuration()->mem_config->memzone_cnt;
+	if (memzone_cnt_after != memzone_cnt_before)
+		return -1;
+
 	return 0;
 }