From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 804385F59 for ; Thu, 31 May 2018 18:14:06 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2018 09:14:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,463,1520924400"; d="scan'208";a="52344151" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 31 May 2018 09:14:03 -0700 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 w4VGE3pE000345 for ; Thu, 31 May 2018 17:14:03 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id w4VGE2iN002534 for ; Thu, 31 May 2018 17:14:02 +0100 Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with LOCAL id w4VGE2tw002530 for dev@dpdk.org; Thu, 31 May 2018 17:14:02 +0100 From: Anatoly Burakov To: dev@dpdk.org Date: Thu, 31 May 2018 17:14:02 +0100 Message-Id: <5edc30573ed29b8e83ac33ea0decf7e41a07b766.1527782953.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] test/test: properly clean up on exit 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: Thu, 31 May 2018 16:14:07 -0000 The test application didn't call rte_eal_cleanup() on exit, which caused leftover hugepages and memory leaks when running secondary processes. Fix this by calling rte_eal_cleanup() on exit. Signed-off-by: Anatoly Burakov --- test/test/test.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/test/test/test.c b/test/test/test.c index 44dfe20ef..ffa9c3669 100644 --- a/test/test/test.c +++ b/test/test/test.c @@ -84,22 +84,29 @@ main(int argc, char **argv) int ret; ret = rte_eal_init(argc, argv); - if (ret < 0) - return -1; + if (ret < 0) { + ret = -1; + goto out; + } #ifdef RTE_LIBRTE_TIMER rte_timer_subsystem_init(); #endif - if (commands_init() < 0) - return -1; + if (commands_init() < 0) { + ret = -1; + goto out; + } argv += ret; prgname = argv[0]; - if ((recursive_call = getenv(RECURSIVE_ENV_VAR)) != NULL) - return do_recursive_call(); + recursive_call = getenv(RECURSIVE_ENV_VAR); + if (recursive_call != NULL) { + ret = do_recursive_call(); + goto out; + } #ifdef RTE_LIBEAL_USE_HPET if (rte_eal_hpet_init(1) < 0) @@ -111,7 +118,8 @@ main(int argc, char **argv) #ifdef RTE_LIBRTE_CMDLINE cl = cmdline_stdin_new(main_ctx, "RTE>>"); if (cl == NULL) { - return -1; + ret = -1; + goto out; } char *dpdk_test = getenv("DPDK_TEST"); @@ -120,18 +128,23 @@ main(int argc, char **argv) snprintf(buf, sizeof(buf), "%s\n", dpdk_test); if (cmdline_in(cl, buf, strlen(buf)) < 0) { printf("error on cmdline input\n"); - return -1; + ret = -1; + goto out; } cmdline_stdin_exit(cl); - return last_test_result; + ret = last_test_result; + goto out; } /* if no DPDK_TEST env variable, go interactive */ cmdline_interact(cl); cmdline_stdin_exit(cl); #endif + ret = 0; - return 0; +out: + rte_eal_cleanup(); + return ret; } -- 2.17.0