From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 2943A1B338; Fri, 26 Jan 2018 18:40:37 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jan 2018 09:40:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,417,1511856000"; d="scan'208";a="13304868" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga008.jf.intel.com with ESMTP; 26 Jan 2018 09:40:36 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id w0QHeZdC015142; Fri, 26 Jan 2018 17:40:35 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id w0QHeZKh021614; Fri, 26 Jan 2018 17:40:35 GMT Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with LOCAL id w0QHeZLK021610; Fri, 26 Jan 2018 17:40:35 GMT From: Anatoly Burakov To: dev@dpdk.org Cc: radoslaw.biernacki@linaro.org, stable@dpdk.org Date: Fri, 26 Jan 2018 17:40:35 +0000 Message-Id: X-Mailer: git-send-email 1.7.0.7 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 2/2] test/memzone: handle previously allocated memzones X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Jan 2018 17:40:39 -0000 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 --- 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