From d4f1af83e87cfc11506e1dad4d59eb9f90327c8a Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Fri, 26 Apr 2019 21:26:37 -0400 Subject: [PATCH] FS-11781 [test] Fix memory leak in test --- src/include/test/switch_test.h | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/include/test/switch_test.h b/src/include/test/switch_test.h index b809e67228..8c9a970217 100644 --- a/src/include/test/switch_test.h +++ b/src/include/test/switch_test.h @@ -387,16 +387,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char /** * Define the test suite setup. This is run before each test or session test. */ -#define FST_SETUP_BEGIN() \ - FCT_SETUP_BGN() \ - if (fst_core) { \ - switch_core_new_memory_pool(&fst_pool); \ - fst_requires(fst_pool != NULL); \ - if (fst_core > 1) { \ - fst_requires(switch_core_timer_init(&fst_timer, "soft", 20, 160, fst_pool) == SWITCH_STATUS_SUCCESS); \ - } \ - fst_time_mark(); \ - } +#define FST_SETUP_BEGIN FCT_SETUP_BGN /** * Define the end of test suite setup. @@ -430,6 +421,14 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char */ #define FST_TEST_BEGIN(name) \ FCT_TEST_BGN(name) \ + if (fst_core) { \ + switch_core_new_memory_pool(&fst_pool); \ + fst_requires(fst_pool != NULL); \ + if (fst_core > 1) { \ + fst_requires(switch_core_timer_init(&fst_timer, "soft", 20, 160, fst_pool) == SWITCH_STATUS_SUCCESS); \ + } \ + fst_time_mark(); \ + } \ if (fst_test_module) { \ fst_requires_module(fst_test_module); \ } @@ -459,6 +458,16 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char #define FST_SESSION_BEGIN_RATE(name, rate) \ FCT_TEST_BGN(name) \ + { \ + if (fst_core) { \ + switch_core_new_memory_pool(&fst_pool); \ + fst_requires(fst_pool != NULL); \ + if (fst_core > 1) { \ + fst_requires(switch_core_timer_init(&fst_timer, "soft", 20, 160, fst_pool) == SWITCH_STATUS_SUCCESS); \ + } \ + fst_time_mark(); \ + } \ + } \ { \ switch_core_session_t *fst_session = NULL; \ switch_event_t *fst_originate_vars = NULL; \