patches for DPDK stable branches
 help / color / mirror / Atom feed
From: luca.boccassi@gmail.com
To: Anatoly Burakov <anatoly.burakov@intel.com>
Cc: Phil Yang <phil.yang@arm.com>,
	Radoslaw Biernacki <radoslaw.biernacki@linaro.org>,
	dpdk stable <stable@dpdk.org>
Subject: [dpdk-stable] patch 'test/memzone: handle previously allocated memzones' has been queued to LTS release 16.11.5
Date: Wed,  7 Feb 2018 16:46:54 +0000	[thread overview]
Message-ID: <20180207164705.29052-23-luca.boccassi@gmail.com> (raw)
In-Reply-To: <20180207164705.29052-1-luca.boccassi@gmail.com>

Hi,

FYI, your patch has been queued to LTS release 16.11.5

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 02/09/18. So please
shout if anyone has objections.

Thanks.

Luca Boccassi

---
>From 822a7dc7e259404ce515ed8b167aee5e6dfd7fb6 Mon Sep 17 00:00:00 2001
From: Anatoly Burakov <anatoly.burakov@intel.com>
Date: Thu, 1 Feb 2018 10:14:50 +0000
Subject: [PATCH] test/memzone: handle previously allocated memzones

[ upstream commit 5c45e0fdeddfc773fab63e12d086c4f2052cda40 ]

Currently, memzone autotest expects there to be no memzones
present by the time the test is run. Some hardware drivers
will allocate memzones for internal use during initialization,
resulting in tests failing due to unexpected memzones being
allocated before the test was run.

Fix this by making sure all memzones allocated by this test
have a common prefix, and making callback increment a counter
on encountering memzones with this prefix. Also, separately
increment another counter that will count total number of
memzones left after test, and compares it to previously stored
number of memzones, to ensure that we didn't accidentally
allocated/freed any memzones we weren't supposed to. This
also doubles as a test for correct operation of memzone_walk().

Fixes: 71330483a193 ("test/memzone: fix memory leak")

Signed-off-by: Phil Yang <phil.yang@arm.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Reviewed-by: Radoslaw Biernacki <radoslaw.biernacki@linaro.org>
---
 app/test/test_memzone.c | 225 ++++++++++++++++++++++++++++++------------------
 1 file changed, 140 insertions(+), 85 deletions(-)

diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c
index 91d8e6a87..53be29f0e 100644
--- a/app/test/test_memzone.c
+++ b/app/test/test_memzone.c
@@ -33,6 +33,7 @@
 
 #include <stdio.h>
 #include <stdint.h>
+#include <string.h>
 #include <inttypes.h>
 #include <sys/queue.h>
 
@@ -76,6 +77,8 @@
  * - Check flags for specific huge page size reservation
  */
 
+#define TEST_MEMZONE_NAME(suffix) "MZ_TEST_" suffix
+
 /* Test if memory overlaps: return 1 if true, or 0 if false. */
 static int
 is_memory_overlap(phys_addr_t ptr1, size_t len1, phys_addr_t ptr2, size_t len2)
@@ -92,14 +95,14 @@ test_memzone_invalid_alignment(void)
 {
 	const struct rte_memzone * mz;
 
-	mz = rte_memzone_lookup("invalid_alignment");
+	mz = rte_memzone_lookup(TEST_MEMZONE_NAME("invalid_alignment"));
 	if (mz != NULL) {
 		printf("Zone with invalid alignment has been reserved\n");
 		return -1;
 	}
 
-	mz = rte_memzone_reserve_aligned("invalid_alignment", 100,
-			SOCKET_ID_ANY, 0, 100);
+	mz = rte_memzone_reserve_aligned(TEST_MEMZONE_NAME("invalid_alignment"),
+					 100, SOCKET_ID_ANY, 0, 100);
 	if (mz != NULL) {
 		printf("Zone with invalid alignment has been reserved\n");
 		return -1;
@@ -112,14 +115,16 @@ test_memzone_reserving_zone_size_bigger_than_the_maximum(void)
 {
 	const struct rte_memzone * mz;
 
-	mz = rte_memzone_lookup("zone_size_bigger_than_the_maximum");
+	mz = rte_memzone_lookup(
+			TEST_MEMZONE_NAME("zone_size_bigger_than_the_maximum"));
 	if (mz != NULL) {
 		printf("zone_size_bigger_than_the_maximum has been reserved\n");
 		return -1;
 	}
 
-	mz = rte_memzone_reserve("zone_size_bigger_than_the_maximum", (size_t)-1,
-			SOCKET_ID_ANY, 0);
+	mz = rte_memzone_reserve(
+			TEST_MEMZONE_NAME("zone_size_bigger_than_the_maximum"),
+			(size_t)-1, SOCKET_ID_ANY, 0);
 	if (mz != NULL) {
 		printf("It is impossible to reserve such big a memzone\n");
 		return -1;
@@ -166,8 +171,8 @@ test_memzone_reserve_flags(void)
 	 * available page size (i.e 1GB ) when 2MB pages are unavailable.
 	 */
 	if (hugepage_2MB_avail) {
-		mz = rte_memzone_reserve("flag_zone_2M", size, SOCKET_ID_ANY,
-				RTE_MEMZONE_2MB);
+		mz = rte_memzone_reserve(TEST_MEMZONE_NAME("flag_zone_2M"),
+				size, SOCKET_ID_ANY, RTE_MEMZONE_2MB);
 		if (mz == NULL) {
 			printf("MEMZONE FLAG 2MB\n");
 			return -1;
@@ -181,7 +186,8 @@ test_memzone_reserve_flags(void)
 			return -1;
 		}
 
-		mz = rte_memzone_reserve("flag_zone_2M_HINT", size, SOCKET_ID_ANY,
+		mz = rte_memzone_reserve(TEST_MEMZONE_NAME("flag_zone_2M_HINT"),
+				size, SOCKET_ID_ANY,
 				RTE_MEMZONE_2MB|RTE_MEMZONE_SIZE_HINT_ONLY);
 		if (mz == NULL) {
 			printf("MEMZONE FLAG 2MB\n");
@@ -200,7 +206,9 @@ test_memzone_reserve_flags(void)
 		 * HINT flag is indicated
 		 */
 		if (!hugepage_1GB_avail) {
-			mz = rte_memzone_reserve("flag_zone_1G_HINT", size, SOCKET_ID_ANY,
+			mz = rte_memzone_reserve(
+					TEST_MEMZONE_NAME("flag_zone_1G_HINT"),
+					size, SOCKET_ID_ANY,
 					RTE_MEMZONE_1GB|RTE_MEMZONE_SIZE_HINT_ONLY);
 			if (mz == NULL) {
 				printf("MEMZONE FLAG 1GB & HINT\n");
@@ -215,8 +223,9 @@ test_memzone_reserve_flags(void)
 				return -1;
 			}
 
-			mz = rte_memzone_reserve("flag_zone_1G", size, SOCKET_ID_ANY,
-					RTE_MEMZONE_1GB);
+			mz = rte_memzone_reserve(
+					TEST_MEMZONE_NAME("flag_zone_1G"), size,
+					SOCKET_ID_ANY, RTE_MEMZONE_1GB);
 			if (mz != NULL) {
 				printf("MEMZONE FLAG 1GB\n");
 				return -1;
@@ -226,8 +235,8 @@ test_memzone_reserve_flags(void)
 
 	/*As with 2MB tests above for 1GB huge page requests*/
 	if (hugepage_1GB_avail) {
-		mz = rte_memzone_reserve("flag_zone_1G", size, SOCKET_ID_ANY,
-				RTE_MEMZONE_1GB);
+		mz = rte_memzone_reserve(TEST_MEMZONE_NAME("flag_zone_1G"),
+				size, SOCKET_ID_ANY, RTE_MEMZONE_1GB);
 		if (mz == NULL) {
 			printf("MEMZONE FLAG 1GB\n");
 			return -1;
@@ -241,7 +250,8 @@ test_memzone_reserve_flags(void)
 			return -1;
 		}
 
-		mz = rte_memzone_reserve("flag_zone_1G_HINT", size, SOCKET_ID_ANY,
+		mz = rte_memzone_reserve(TEST_MEMZONE_NAME("flag_zone_1G_HINT"),
+				size, SOCKET_ID_ANY,
 				RTE_MEMZONE_1GB|RTE_MEMZONE_SIZE_HINT_ONLY);
 		if (mz == NULL) {
 			printf("MEMZONE FLAG 1GB\n");
@@ -260,7 +270,9 @@ test_memzone_reserve_flags(void)
 		 * HINT flag is indicated
 		 */
 		if (!hugepage_2MB_avail) {
-			mz = rte_memzone_reserve("flag_zone_2M_HINT", size, SOCKET_ID_ANY,
+			mz = rte_memzone_reserve(
+					TEST_MEMZONE_NAME("flag_zone_2M_HINT"),
+					size, SOCKET_ID_ANY,
 					RTE_MEMZONE_2MB|RTE_MEMZONE_SIZE_HINT_ONLY);
 			if (mz == NULL){
 				printf("MEMZONE FLAG 2MB & HINT\n");
@@ -274,8 +286,9 @@ test_memzone_reserve_flags(void)
 				printf("Fail memzone free\n");
 				return -1;
 			}
-			mz = rte_memzone_reserve("flag_zone_2M", size, SOCKET_ID_ANY,
-					RTE_MEMZONE_2MB);
+			mz = rte_memzone_reserve(
+					TEST_MEMZONE_NAME("flag_zone_2M"), size,
+					SOCKET_ID_ANY, RTE_MEMZONE_2MB);
 			if (mz != NULL) {
 				printf("MEMZONE FLAG 2MB\n");
 				return -1;
@@ -283,8 +296,10 @@ test_memzone_reserve_flags(void)
 		}
 
 		if (hugepage_2MB_avail && hugepage_1GB_avail) {
-			mz = rte_memzone_reserve("flag_zone_2M_HINT", size, SOCKET_ID_ANY,
-								RTE_MEMZONE_2MB|RTE_MEMZONE_1GB);
+			mz = rte_memzone_reserve(
+					TEST_MEMZONE_NAME("flag_zone_2M_HINT"),
+					size, SOCKET_ID_ANY,
+					RTE_MEMZONE_2MB|RTE_MEMZONE_1GB);
 			if (mz == NULL) {
 				printf("BOTH SIZES SET\n");
 				return -1;
@@ -308,8 +323,8 @@ test_memzone_reserve_flags(void)
 	 * page size (i.e 16GB ) when 16MB pages are unavailable.
 	 */
 	if (hugepage_16MB_avail) {
-		mz = rte_memzone_reserve("flag_zone_16M", size, SOCKET_ID_ANY,
-				RTE_MEMZONE_16MB);
+		mz = rte_memzone_reserve(TEST_MEMZONE_NAME("flag_zone_16M"),
+				size, SOCKET_ID_ANY, RTE_MEMZONE_16MB);
 		if (mz == NULL) {
 			printf("MEMZONE FLAG 16MB\n");
 			return -1;
@@ -323,8 +338,10 @@ test_memzone_reserve_flags(void)
 			return -1;
 		}
 
-		mz = rte_memzone_reserve("flag_zone_16M_HINT", size,
-		SOCKET_ID_ANY, RTE_MEMZONE_16MB|RTE_MEMZONE_SIZE_HINT_ONLY);
+		mz = rte_memzone_reserve(
+				TEST_MEMZONE_NAME("flag_zone_16M_HINT"), size,
+				SOCKET_ID_ANY,
+				RTE_MEMZONE_16MB|RTE_MEMZONE_SIZE_HINT_ONLY);
 		if (mz == NULL) {
 			printf("MEMZONE FLAG 2MB\n");
 			return -1;
@@ -342,9 +359,11 @@ test_memzone_reserve_flags(void)
 		 * unless HINT flag is indicated
 		 */
 		if (!hugepage_16GB_avail) {
-			mz = rte_memzone_reserve("flag_zone_16G_HINT", size,
-				SOCKET_ID_ANY,
-				RTE_MEMZONE_16GB|RTE_MEMZONE_SIZE_HINT_ONLY);
+			mz = rte_memzone_reserve(
+					TEST_MEMZONE_NAME("flag_zone_16G_HINT"),
+					size, SOCKET_ID_ANY,
+					RTE_MEMZONE_16GB |
+					RTE_MEMZONE_SIZE_HINT_ONLY);
 			if (mz == NULL) {
 				printf("MEMZONE FLAG 16GB & HINT\n");
 				return -1;
@@ -358,8 +377,10 @@ test_memzone_reserve_flags(void)
 				return -1;
 			}
 
-			mz = rte_memzone_reserve("flag_zone_16G", size,
-				SOCKET_ID_ANY, RTE_MEMZONE_16GB);
+			mz = rte_memzone_reserve(
+					TEST_MEMZONE_NAME("flag_zone_16G"),
+					size,
+					SOCKET_ID_ANY, RTE_MEMZONE_16GB);
 			if (mz != NULL) {
 				printf("MEMZONE FLAG 16GB\n");
 				return -1;
@@ -368,8 +389,8 @@ test_memzone_reserve_flags(void)
 	}
 	/*As with 16MB tests above for 16GB huge page requests*/
 	if (hugepage_16GB_avail) {
-		mz = rte_memzone_reserve("flag_zone_16G", size, SOCKET_ID_ANY,
-				RTE_MEMZONE_16GB);
+		mz = rte_memzone_reserve(TEST_MEMZONE_NAME("flag_zone_16G"),
+				size, SOCKET_ID_ANY, RTE_MEMZONE_16GB);
 		if (mz == NULL) {
 			printf("MEMZONE FLAG 16GB\n");
 			return -1;
@@ -383,8 +404,10 @@ test_memzone_reserve_flags(void)
 			return -1;
 		}
 
-		mz = rte_memzone_reserve("flag_zone_16G_HINT", size,
-		SOCKET_ID_ANY, RTE_MEMZONE_16GB|RTE_MEMZONE_SIZE_HINT_ONLY);
+		mz = rte_memzone_reserve(
+				TEST_MEMZONE_NAME("flag_zone_16G_HINT"), size,
+				SOCKET_ID_ANY,
+				RTE_MEMZONE_16GB|RTE_MEMZONE_SIZE_HINT_ONLY);
 		if (mz == NULL) {
 			printf("MEMZONE FLAG 16GB\n");
 			return -1;
@@ -402,9 +425,11 @@ test_memzone_reserve_flags(void)
 		 * unless HINT flag is indicated
 		 */
 		if (!hugepage_16MB_avail) {
-			mz = rte_memzone_reserve("flag_zone_16M_HINT", size,
-				SOCKET_ID_ANY,
-				RTE_MEMZONE_16MB|RTE_MEMZONE_SIZE_HINT_ONLY);
+			mz = rte_memzone_reserve(
+					TEST_MEMZONE_NAME("flag_zone_16M_HINT"),
+					size, SOCKET_ID_ANY,
+					RTE_MEMZONE_16MB |
+					RTE_MEMZONE_SIZE_HINT_ONLY);
 			if (mz == NULL) {
 				printf("MEMZONE FLAG 16MB & HINT\n");
 				return -1;
@@ -417,8 +442,9 @@ test_memzone_reserve_flags(void)
 				printf("Fail memzone free\n");
 				return -1;
 			}
-			mz = rte_memzone_reserve("flag_zone_16M", size,
-				SOCKET_ID_ANY, RTE_MEMZONE_16MB);
+			mz = rte_memzone_reserve(
+					TEST_MEMZONE_NAME("flag_zone_16M"),
+					size, SOCKET_ID_ANY, RTE_MEMZONE_16MB);
 			if (mz != NULL) {
 				printf("MEMZONE FLAG 16MB\n");
 				return -1;
@@ -426,9 +452,10 @@ test_memzone_reserve_flags(void)
 		}
 
 		if (hugepage_16MB_avail && hugepage_16GB_avail) {
-			mz = rte_memzone_reserve("flag_zone_16M_HINT", size,
-				SOCKET_ID_ANY,
-				RTE_MEMZONE_16MB|RTE_MEMZONE_16GB);
+			mz = rte_memzone_reserve(
+					TEST_MEMZONE_NAME("flag_zone_16M_HINT"),
+					size, SOCKET_ID_ANY,
+					RTE_MEMZONE_16MB|RTE_MEMZONE_16GB);
 			if (mz == NULL) {
 				printf("BOTH SIZES SET\n");
 				return -1;
@@ -484,7 +511,8 @@ test_memzone_reserve_max(void)
 		return 0;
 	}
 
-	mz = rte_memzone_reserve("max_zone", 0, SOCKET_ID_ANY, 0);
+	mz = rte_memzone_reserve(TEST_MEMZONE_NAME("max_zone"), 0,
+			SOCKET_ID_ANY, 0);
 	if (mz == NULL){
 		printf("Failed to reserve a big chunk of memory - %s\n",
 				rte_strerror(rte_errno));
@@ -526,8 +554,8 @@ test_memzone_reserve_max_aligned(void)
 		return 0;
 	}
 
-	mz = rte_memzone_reserve_aligned("max_zone_aligned", 0,
-			SOCKET_ID_ANY, 0, align);
+	mz = rte_memzone_reserve_aligned(TEST_MEMZONE_NAME("max_zone_aligned"),
+			0, SOCKET_ID_ANY, 0, align);
 	if (mz == NULL){
 		printf("Failed to reserve a big chunk of memory - %s\n",
 				rte_strerror(rte_errno));
@@ -564,24 +592,29 @@ test_memzone_aligned(void)
 	const struct rte_memzone *memzone_aligned_1024;
 
 	/* memzone that should automatically be adjusted to align on 64 bytes */
-	memzone_aligned_32 = rte_memzone_reserve_aligned("aligned_32", 100,
-				SOCKET_ID_ANY, 0, 32);
+	memzone_aligned_32 = rte_memzone_reserve_aligned(
+			TEST_MEMZONE_NAME("aligned_32"), 100, SOCKET_ID_ANY, 0,
+			32);
 
 	/* memzone that is supposed to be aligned on a 128 byte boundary */
-	memzone_aligned_128 = rte_memzone_reserve_aligned("aligned_128", 100,
-				SOCKET_ID_ANY, 0, 128);
+	memzone_aligned_128 = rte_memzone_reserve_aligned(
+			TEST_MEMZONE_NAME("aligned_128"), 100, SOCKET_ID_ANY, 0,
+			128);
 
 	/* memzone that is supposed to be aligned on a 256 byte boundary */
-	memzone_aligned_256 = rte_memzone_reserve_aligned("aligned_256", 100,
-				SOCKET_ID_ANY, 0, 256);
+	memzone_aligned_256 = rte_memzone_reserve_aligned(
+			TEST_MEMZONE_NAME("aligned_256"), 100, SOCKET_ID_ANY, 0,
+			256);
 
 	/* memzone that is supposed to be aligned on a 512 byte boundary */
-	memzone_aligned_512 = rte_memzone_reserve_aligned("aligned_512", 100,
-				SOCKET_ID_ANY, 0, 512);
+	memzone_aligned_512 = rte_memzone_reserve_aligned(
+			TEST_MEMZONE_NAME("aligned_512"), 100, SOCKET_ID_ANY, 0,
+			512);
 
 	/* memzone that is supposed to be aligned on a 1024 byte boundary */
-	memzone_aligned_1024 = rte_memzone_reserve_aligned("aligned_1024", 100,
-				SOCKET_ID_ANY, 0, 1024);
+	memzone_aligned_1024 = rte_memzone_reserve_aligned(
+			TEST_MEMZONE_NAME("aligned_1024"), 100, SOCKET_ID_ANY,
+			0, 1024);
 
 	printf("check alignments and lengths\n");
 	if (memzone_aligned_32 == NULL) {
@@ -750,37 +783,46 @@ static int
 test_memzone_bounded(void)
 {
 	const struct rte_memzone *memzone_err;
-	const char *name;
 	int rc;
 
 	/* should fail as boundary is not power of two */
-	name = "bounded_error_31";
-	if ((memzone_err = rte_memzone_reserve_bounded(name,
-			100, SOCKET_ID_ANY, 0, 32, UINT32_MAX)) != NULL) {
+	memzone_err = rte_memzone_reserve_bounded(
+			TEST_MEMZONE_NAME("bounded_error_31"), 100,
+			SOCKET_ID_ANY, 0, 32, UINT32_MAX);
+	if (memzone_err != NULL) {
 		printf("%s(%s)created a memzone with invalid boundary "
 			"conditions\n", __func__, memzone_err->name);
 		return -1;
 	}
 
 	/* should fail as len is greater then boundary */
-	name = "bounded_error_32";
-	if ((memzone_err = rte_memzone_reserve_bounded(name,
-			100, SOCKET_ID_ANY, 0, 32, 32)) != NULL) {
+	memzone_err = rte_memzone_reserve_bounded(
+			TEST_MEMZONE_NAME("bounded_error_32"), 100,
+			SOCKET_ID_ANY, 0, 32, 32);
+	if (memzone_err != NULL) {
 		printf("%s(%s)created a memzone with invalid boundary "
 			"conditions\n", __func__, memzone_err->name);
 		return -1;
 	}
 
-	if ((rc = check_memzone_bounded("bounded_128", 100, 128, 128)) != 0)
+	rc = check_memzone_bounded(TEST_MEMZONE_NAME("bounded_128"), 100, 128,
+			128);
+	if (rc != 0)
 		return rc;
 
-	if ((rc = check_memzone_bounded("bounded_256", 100, 256, 128)) != 0)
+	rc = check_memzone_bounded(TEST_MEMZONE_NAME("bounded_256"), 100, 256,
+			128);
+	if (rc != 0)
 		return rc;
 
-	if ((rc = check_memzone_bounded("bounded_1K", 100, 64, 1024)) != 0)
+	rc = check_memzone_bounded(TEST_MEMZONE_NAME("bounded_1K"), 100, 64,
+			1024);
+	if (rc != 0)
 		return rc;
 
-	if ((rc = check_memzone_bounded("bounded_1K_MAX", 0, 64, 1024)) != 0)
+	rc = check_memzone_bounded(TEST_MEMZONE_NAME("bounded_1K_MAX"), 0, 64,
+			1024);
+	if (rc != 0)
 		return rc;
 
 	return 0;
@@ -793,25 +835,28 @@ test_memzone_free(void)
 	int i;
 	char name[20];
 
-	mz[0] = rte_memzone_reserve("tempzone0", 2000, SOCKET_ID_ANY, 0);
-	mz[1] = rte_memzone_reserve("tempzone1", 4000, SOCKET_ID_ANY, 0);
+	mz[0] = rte_memzone_reserve(TEST_MEMZONE_NAME("tempzone0"), 2000,
+			SOCKET_ID_ANY, 0);
+	mz[1] = rte_memzone_reserve(TEST_MEMZONE_NAME("tempzone1"), 4000,
+			SOCKET_ID_ANY, 0);
 
 	if (mz[0] > mz[1])
 		return -1;
-	if (!rte_memzone_lookup("tempzone0"))
+	if (!rte_memzone_lookup(TEST_MEMZONE_NAME("tempzone0")))
 		return -1;
-	if (!rte_memzone_lookup("tempzone1"))
+	if (!rte_memzone_lookup(TEST_MEMZONE_NAME("tempzone1")))
 		return -1;
 
 	if (rte_memzone_free(mz[0])) {
 		printf("Fail memzone free - tempzone0\n");
 		return -1;
 	}
-	if (rte_memzone_lookup("tempzone0")) {
+	if (rte_memzone_lookup(TEST_MEMZONE_NAME("tempzone0"))) {
 		printf("Found previously free memzone - tempzone0\n");
 		return -1;
 	}
-	mz[2] = rte_memzone_reserve("tempzone2", 2000, SOCKET_ID_ANY, 0);
+	mz[2] = rte_memzone_reserve(TEST_MEMZONE_NAME("tempzone2"), 2000,
+			SOCKET_ID_ANY, 0);
 
 	if (mz[2] > mz[1]) {
 		printf("tempzone2 should have gotten the free entry from tempzone0\n");
@@ -821,7 +866,7 @@ test_memzone_free(void)
 		printf("Fail memzone free - tempzone2\n");
 		return -1;
 	}
-	if (rte_memzone_lookup("tempzone2")) {
+	if (rte_memzone_lookup(TEST_MEMZONE_NAME("tempzone2"))) {
 		printf("Found previously free memzone - tempzone2\n");
 		return -1;
 	}
@@ -829,14 +874,15 @@ test_memzone_free(void)
 		printf("Fail memzone free - tempzone1\n");
 		return -1;
 	}
-	if (rte_memzone_lookup("tempzone1")) {
+	if (rte_memzone_lookup(TEST_MEMZONE_NAME("tempzone1"))) {
 		printf("Found previously free memzone - tempzone1\n");
 		return -1;
 	}
 
 	i = 0;
 	do {
-		snprintf(name, sizeof(name), "tempzone%u", i);
+		snprintf(name, sizeof(name), TEST_MEMZONE_NAME("tempzone%u"),
+				i);
 		mz[i] = rte_memzone_reserve(name, 1, SOCKET_ID_ANY, 0);
 	} while (mz[i++] != NULL);
 
@@ -844,7 +890,8 @@ test_memzone_free(void)
 		printf("Fail memzone free - tempzone0\n");
 		return -1;
 	}
-	mz[0] = rte_memzone_reserve("tempzone0new", 0, SOCKET_ID_ANY, 0);
+	mz[0] = rte_memzone_reserve(TEST_MEMZONE_NAME("tempzone0new"), 0,
+			SOCKET_ID_ANY, 0);
 
 	if (mz[0] == NULL) {
 		printf("Fail to create memzone - tempzone0new - when MAX memzones were "
@@ -871,16 +918,16 @@ test_memzone_basic(void)
 	const struct rte_memzone *memzone4;
 	const struct rte_memzone *mz;
 
-	memzone1 = rte_memzone_reserve("testzone1", 100,
+	memzone1 = rte_memzone_reserve(TEST_MEMZONE_NAME("testzone1"), 100,
 				SOCKET_ID_ANY, 0);
 
-	memzone2 = rte_memzone_reserve("testzone2", 1000,
+	memzone2 = rte_memzone_reserve(TEST_MEMZONE_NAME("testzone2"), 1000,
 				0, 0);
 
-	memzone3 = rte_memzone_reserve("testzone3", 1000,
+	memzone3 = rte_memzone_reserve(TEST_MEMZONE_NAME("testzone3"), 1000,
 				1, 0);
 
-	memzone4 = rte_memzone_reserve("testzone4", 1024,
+	memzone4 = rte_memzone_reserve(TEST_MEMZONE_NAME("testzone4"), 1024,
 				SOCKET_ID_ANY, 0);
 
 	/* memzone3 may be NULL if we don't have NUMA */
@@ -932,12 +979,12 @@ test_memzone_basic(void)
 		return -1;
 
 	printf("test zone lookup\n");
-	mz = rte_memzone_lookup("testzone1");
+	mz = rte_memzone_lookup(TEST_MEMZONE_NAME("testzone1"));
 	if (mz != memzone1)
 		return -1;
 
 	printf("test duplcate zone name\n");
-	mz = rte_memzone_reserve("testzone1", 100,
+	mz = rte_memzone_reserve(TEST_MEMZONE_NAME("testzone1"), 100,
 			SOCKET_ID_ANY, 0);
 	if (mz != NULL)
 		return -1;
@@ -962,16 +1009,22 @@ test_memzone_basic(void)
 	return 0;
 }
 
-static int memzone_calk_called;
-static void memzone_walk_clb(const struct rte_memzone *mz __rte_unused,
+static int test_memzones_left;
+static int memzone_walk_cnt;
+static void memzone_walk_clb(const struct rte_memzone *mz,
 			     void *arg __rte_unused)
 {
-	memzone_calk_called = 1;
+	memzone_walk_cnt++;
+	if (!strncmp(TEST_MEMZONE_NAME(""), mz->name, RTE_MEMZONE_NAMESIZE))
+		test_memzones_left++;
 }
 
 static int
 test_memzone(void)
 {
+	/* take note of how many memzones were allocated before running */
+	int memzone_cnt = rte_eal_get_configuration()->mem_config->memzone_cnt;
+
 	printf("test basic memzone API\n");
 	if (test_memzone_basic() < 0)
 		return -1;
@@ -1009,8 +1062,10 @@ test_memzone(void)
 		return -1;
 
 	printf("check memzone cleanup\n");
+	memzone_walk_cnt = 0;
+	test_memzones_left = 0;
 	rte_memzone_walk(memzone_walk_clb, NULL);
-	if (memzone_calk_called) {
+	if (memzone_walk_cnt != memzone_cnt || test_memzones_left > 0) {
 		printf("there are some memzones left after test\n");
 		rte_memzone_dump(stdout);
 		return -1;
-- 
2.14.2

  parent reply	other threads:[~2018-02-07 16:47 UTC|newest]

Thread overview: 111+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-26 13:12 [dpdk-stable] patch 'kni: fix build with kernel 4.15' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'eal: update assertion macro' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'contigmem: fix build on FreeBSD 12' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'mem: fix mmap error check on huge page attach' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'app/testpmd: fix crash of txonly with multiple segments' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'mbuf: cleanup function to get last segment' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'bus/pci: fix interrupt handler type' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'memzone: fix leak on allocation error' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'malloc: protect stats with lock' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'malloc: fix end for bounded elements' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'vfio: fix enabled check on error' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'pmdinfogen: fix cross compilation for ARM big endian' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'lpm: fix ARM big endian build' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'net/i40e: " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'net/ixgbe: " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'examples/l3fwd-power: fix Rx without interrupt' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'examples/l3fwd-power: fix frequency detection' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'net/nfp: fix MTU settings' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'net/nfp: fix jumbo " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'net/nfp: fix CRC strip check behaviour' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'net/thunderx: fix multi segment Tx function return' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'net/szedata2: fix check of mmap return value' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'net/bonding: fix activated slave in 8023ad mode' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'net/qede: fix to reject config with no Rx queue' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'ethdev: fix missing imissed counter in xstats' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'ethdev: fix typo in functions comment' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'net/i40e: fix VLAN offload setting' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'net/fm10k: fix logical port delete' " luca.boccassi
2018-01-26 13:12 ` [dpdk-stable] patch 'net/igb: fix Tx queue number assignment' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'vhost: fix dequeue zero copy with virtio1' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/virtio: fix incorrect cast' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/virtio: fix vector Rx flushing' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'examples/vhost: fix sending ARP packet to self' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/ixgbe: fix the failure of number of Tx queue check' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/i40e/base: fix NVM lock' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/i40e/base: fix link LED blink' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/i40e/base: fix compile issue for GCC 6.3' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/ixgbe/base: add media type of fixed fiber' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/i40e: fix VSI MAC filter on primary address change' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/bnxt: parse checksum offload flags' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/bonding: fix setting slave MAC addresses' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'ethdev: fix link autonegotiation value' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/pcap: fix the NUMA id display in logs' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/ixgbe: fix max queue number for VF' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/i40e: fix VF reset stats crash' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/ixgbe: fix mailbox interrupt handler' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/e1000: " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/mlx5: fix deadlock of link status alarm' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'vhost: fix error code check when creating thread' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'examples/vhost: fix startup check' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'pdump: fix error check when creating/canceling thread' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'app/procinfo: add compilation option in config' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'test: register test as failed if setup failed' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'test/table: fix uninitialized parameter' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'test/memzone: fix wrong test' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'test/memzone: fix NULL freeing' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'test/memzone: fix freeing test' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'test/crypto: fix missing include' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'examples/ipsec-secgw: fix corner case for SPI value' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/i40e: fix flag for MAC address write' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'vhost: fix mbuf free' " luca.boccassi
2018-01-26 13:13 ` [dpdk-stable] patch 'net/i40e: fix flow director Rx resource defect' " luca.boccassi
2018-02-07 16:46   ` [dpdk-stable] patch 'keepalive: fix state alignment' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'eal/x86: use lock-prefixed instructions for SMP barrier' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'mbuf: fix NULL freeing when debug enabled' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'crypto/qat: fix null auth algo overwrite' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'net/enic: fix crash due to static max number of queues' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'net/mlx5: fix missing RSS capability' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'net/ena: do not set Tx L4 offloads in Rx path' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'net/virtio: fix Rx and Tx handler selection for ARM32' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'net/virtio: fix queue flushing with vector Rx enabled' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'net/virtio: fix memory leak when reinitializing device' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'net/virtio: fix typo in function name' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'net/i40e: fix VF Rx interrupt enabling' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'net/ixgbe: " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'net/e1000: " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'net/bnxt: fix size of Tx ring in HW' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'net/qede/base: fix VF LRO tunnel configuration' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'eal/ppc: remove the braces in memory barrier macros' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'mk: support renamed Makefile in external project' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'net/ixgbe: fix reset error handling' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'test/pmd_perf: declare variables as static' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'examples/bond: check mbuf allocation' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'mk: fix external build' " luca.boccassi
2018-02-07 16:46     ` luca.boccassi [this message]
2018-02-07 16:46     ` [dpdk-stable] patch 'usertools/devbind: remove unused function' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'net/bonding: check error of MAC address setting' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'net/qede: fix few log messages' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'app/testpmd: fix port index in RSS forward config' " luca.boccassi
2018-02-07 16:46     ` [dpdk-stable] patch 'app/testpmd: fix port topology " luca.boccassi
2018-02-07 16:47     ` [dpdk-stable] patch 'examples/ip_pipeline: fix timer period unit' " luca.boccassi
2018-02-07 16:47     ` [dpdk-stable] patch 'test/reorder: fix memory leak' " luca.boccassi
2018-02-07 16:47     ` [dpdk-stable] patch 'test/ring_perf: " luca.boccassi
2018-02-07 16:47     ` [dpdk-stable] patch 'test/table: " luca.boccassi
2018-02-07 16:47     ` [dpdk-stable] patch 'test/timer_perf: " luca.boccassi
2018-02-07 16:47     ` [dpdk-stable] patch 'net/i40e: fix Rx interrupt' " luca.boccassi
2018-02-09 10:40     ` [dpdk-stable] patch 'net/bnxt: fix Rx checksum flags' " Luca Boccassi
2018-02-09 10:40       ` [dpdk-stable] patch 'net/bnxt: fix link speed setting with autoneg off' " Luca Boccassi
2018-02-11 12:49         ` [dpdk-stable] patch 'eal/ppc: support sPAPR IOMMU for vfio-pci' " Luca Boccassi
2018-02-11 12:49           ` [dpdk-stable] patch 'igb_uio: switch to new irq function for MSI-X' " Luca Boccassi
2018-02-15 12:03             ` [dpdk-stable] patch 'ethdev: fix data alignment' " Luca Boccassi
2018-02-15 12:03               ` [dpdk-stable] patch 'net/virtio: fix mbuf data offset for simple Rx' " Luca Boccassi
2018-02-15 12:03               ` [dpdk-stable] patch 'net/virtio: fix resuming port with Rx vector path' " Luca Boccassi
2018-02-15 12:03               ` [dpdk-stable] patch 'net/vhost: fix log messages on create/destroy' " Luca Boccassi
2018-02-15 12:03               ` [dpdk-stable] patch 'net/virtio-user: fix start with kernel vhost' " Luca Boccassi
2018-02-15 12:03               ` [dpdk-stable] patch 'examples/exception_path: align stats on cache line' " Luca Boccassi
2018-02-15 12:03               ` [dpdk-stable] patch 'doc: fix outdated link to IPsec white paper' " Luca Boccassi
2018-02-11 12:49           ` [dpdk-stable] patch 'igb_uio: fix IRQ disable on recent kernels' " Luca Boccassi
2018-02-11 12:49           ` [dpdk-stable] patch 'igb_uio: fix MSI-X IRQ assignment with new IRQ function' " Luca Boccassi
2018-02-09 10:40       ` [dpdk-stable] patch 'net/i40e: check multi-driver option parsing' " Luca Boccassi
2018-02-09 10:40       ` [dpdk-stable] patch 'app/testpmd: fix flow director filter' " Luca Boccassi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180207164705.29052-23-luca.boccassi@gmail.com \
    --to=luca.boccassi@gmail.com \
    --cc=anatoly.burakov@intel.com \
    --cc=phil.yang@arm.com \
    --cc=radoslaw.biernacki@linaro.org \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).