From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 2A8FF1B37F; Fri, 22 Dec 2017 11:12:16 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Dec 2017 02:12:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,440,1508828400"; d="scan'208";a="3999321" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 22 Dec 2017 02:12:12 -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 vBMACBOR002167; Fri, 22 Dec 2017 10:12:11 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id vBMACBbC008051; Fri, 22 Dec 2017 10:12:11 GMT Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with LOCAL id vBMACBfn008047; Fri, 22 Dec 2017 10:12:11 GMT From: Anatoly Burakov To: dev@dpdk.org Cc: Cristian Dumitrescu , stable@dpdk.org Date: Fri, 22 Dec 2017 10:12:09 +0000 Message-Id: <31d7534c095b9e6a0e36880f30d666778eff00d8.1513867589.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <9d5a3bc7a779b2dddab4256aa3e0631737861f98.1513867589.git.anatoly.burakov@intel.com> References: <9d5a3bc7a779b2dddab4256aa3e0631737861f98.1513867589.git.anatoly.burakov@intel.com> In-Reply-To: <9d5a3bc7a779b2dddab4256aa3e0631737861f98.1513867589.git.anatoly.burakov@intel.com> References: <9d5a3bc7a779b2dddab4256aa3e0631737861f98.1513867589.git.anatoly.burakov@intel.com> Subject: [dpdk-dev] [PATCH 5/6] test: fix memory leak in table autotest 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, 22 Dec 2017 10:12:17 -0000 Always deallocate allocated resources after the test is done. Fixes: 5205954791cb ("app/test: packet framework unit tests") Cc: cristian.dumitrescu@intel.com Cc: stable@dpdk.org Signed-off-by: Anatoly Burakov --- test/test/test_table.c | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/test/test/test_table.c b/test/test/test_table.c index db7d4e6..c5a6e00 100644 --- a/test/test/test_table.c +++ b/test/test/test_table.c @@ -84,6 +84,14 @@ uint64_t pipeline_test_hash(void *key, } static void +app_free_resources(void) { + int i; + for (i = 0; i < N_PORTS; i++) + rte_ring_free(rings_rx[i]); + rte_mempool_free(pool); +} + +static void app_init_mbuf_pools(void) { /* Init the buffer pool */ @@ -142,18 +150,20 @@ app_init_rings(void) static int test_table(void) { - int status, failures; + int status, ret; unsigned i; - failures = 0; + ret = TEST_SUCCESS; app_init_rings(); app_init_mbuf_pools(); printf("\n\n\n\n************Pipeline tests************\n"); - if (test_table_pipeline() < 0) - return -1; + if (test_table_pipeline() < 0) { + ret = TEST_FAILED; + goto end; + } printf("\n\n\n\n************Port tests************\n"); for (i = 0; i < n_port_tests; i++) { @@ -161,8 +171,8 @@ test_table(void) if (status < 0) { printf("\nPort test number %d failed (%d).\n", i, status); - failures++; - return -1; + ret = TEST_FAILED; + goto end; } } @@ -172,8 +182,8 @@ test_table(void) if (status < 0) { printf("\nTable test number %d failed (%d).\n", i, status); - failures++; - return -1; + ret = TEST_FAILED; + goto end; } } @@ -183,21 +193,23 @@ test_table(void) if (status < 0) { printf("\nCombined table test number %d failed with " "reason number %d.\n", i, status); - failures++; - return -1; + ret = TEST_FAILED; + goto end; } } - if (failures) - return -1; - #ifdef RTE_LIBRTE_ACL printf("\n\n\n\n************ACL tests************\n"); - if (test_table_acl() < 0) - return -1; + if (test_table_acl() < 0) { + ret = TEST_FAILED; + goto end; + } #endif - return 0; +end: + app_free_resources(); + + return ret; } REGISTER_TEST_COMMAND(table_autotest, test_table); -- 2.7.4