summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnatoly Burakov <anatoly.burakov@intel.com>2018-05-31 17:14:02 +0100
committerThomas Monjalon <thomas@monjalon.net>2018-10-29 03:32:58 +0100
commit3f9e31d71d631fb44a209722afc5a8216b09403d (patch)
tree4d1fea34c36b0c8e9af9044b4aa1f790d2edf24d /test
parent3bb038388962d7243277eb190dfdbc044087c6b3 (diff)
downloaddpdk-3f9e31d71d631fb44a209722afc5a8216b09403d.zip
dpdk-3f9e31d71d631fb44a209722afc5a8216b09403d.tar.gz
dpdk-3f9e31d71d631fb44a209722afc5a8216b09403d.tar.xz
test: clean up on exit
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 <anatoly.burakov@intel.com> Reviewed-by: Reshma Pattan <reshma.pattan@intel.com> Tested-by: Reshma Pattan <reshma.pattan@intel.com>
Diffstat (limited to 'test')
-rw-r--r--test/test/test.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/test/test/test.c b/test/test/test.c
index 44dfe20..ffa9c36 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;
}