DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: radoslaw.biernacki@linaro.org, stable@dpdk.org
Subject: [dpdk-dev] [PATCH 2/2] test/memzone: handle previously allocated memzones
Date: Fri, 26 Jan 2018 17:40:35 +0000	[thread overview]
Message-ID: <cfcd9b2f78f4c2988d7824f69737500bd984947b.1516988093.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <ec8bf2436653ce9dbbe9e83a364ca44c41bd2a8a.1516988093.git.anatoly.burakov@intel.com>
In-Reply-To: <ec8bf2436653ce9dbbe9e83a364ca44c41bd2a8a.1516988093.git.anatoly.burakov@intel.com>

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 callback increment a counter instead. This
also doubles as a test for correct operation of memzone_walk().

Fixes: 71330483a193 ("test/memzone: fix memory leak")
Cc: radoslaw.biernacki@linaro.org
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 test/test/test_memzone.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/test/test/test_memzone.c b/test/test/test_memzone.c
index 00d340f..5428b35 100644
--- a/test/test/test_memzone.c
+++ b/test/test/test_memzone.c
@@ -953,16 +953,19 @@ test_memzone_basic(void)
 	return 0;
 }
 
-static int memzone_walk_called;
+static int memzone_walk_cnt;
 static void memzone_walk_clb(const struct rte_memzone *mz __rte_unused,
 			     void *arg __rte_unused)
 {
-	memzone_walk_called = 1;
+	memzone_walk_cnt++;
 }
 
 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;
@@ -1000,8 +1003,9 @@ test_memzone(void)
 		return -1;
 
 	printf("check memzone cleanup\n");
+	memzone_walk_cnt = 0;
 	rte_memzone_walk(memzone_walk_clb, NULL);
-	if (memzone_walk_called) {
+	if (memzone_walk_cnt != memzone_cnt) {
 		printf("there are some memzones left after test\n");
 		rte_memzone_dump(stdout);
 		return -1;
-- 
2.7.4

  reply	other threads:[~2018-01-26 17:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-26 17:40 [dpdk-dev] [PATCH 1/2] test/memzone: add test for memzone count in eal mem config Anatoly Burakov
2018-01-26 17:40 ` Anatoly Burakov [this message]
2018-01-27 14:46   ` [dpdk-dev] [PATCH 2/2] test/memzone: handle previously allocated memzones Radoslaw Biernacki
2018-01-31  7:51   ` Phil Yang
2018-01-31 10:05     ` Burakov, Anatoly
2018-01-31 10:08       ` Phil Yang
2018-01-27 14:53 ` [dpdk-dev] [PATCH 1/2] test/memzone: add test for memzone count in eal mem config Radoslaw Biernacki
2018-01-29  9:40   ` Burakov, Anatoly
2018-01-31 15:29 ` [dpdk-dev] [PATCH v2 " Anatoly Burakov
2018-02-01  0:12   ` Thomas Monjalon
2018-02-01 10:05     ` Burakov, Anatoly
2018-02-01 10:02   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
2018-02-01 10:14     ` [dpdk-dev] [PATCH v4 " Anatoly Burakov
2018-02-06  0:49       ` Thomas Monjalon
2018-02-01 10:14     ` [dpdk-dev] [PATCH v4 2/2] test/memzone: handle previously allocated memzones Anatoly Burakov
2018-02-01 10:02   ` [dpdk-dev] [PATCH v3 " Anatoly Burakov
2018-01-31 15:29 ` [dpdk-dev] [PATCH v2 " Anatoly Burakov

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=cfcd9b2f78f4c2988d7824f69737500bd984947b.1516988093.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --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).