From 44ba7eb7534990cda28669c5d20dbd5cb072a571 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Fri, 13 Dec 2019 00:54:03 +0400 Subject: [PATCH] [Unit-tests] Do not initiate sqldb by default unless requested. --- src/include/test/switch_test.h | 15 +++++++++------ tests/unit/switch_core_db.c | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/include/test/switch_test.h b/src/include/test/switch_test.h index 4e7fcfcd8a..215c36ca4d 100644 --- a/src/include/test/switch_test.h +++ b/src/include/test/switch_test.h @@ -66,7 +66,7 @@ static char *fst_getenv_default(const char *env, char *default_value, switch_boo /** * initialize FS core from optional configuration dir */ -static switch_status_t fst_init_core_and_modload(const char *confdir, const char *basedir, int minimal) +static switch_status_t fst_init_core_and_modload(const char *confdir, const char *basedir, int minimal, switch_core_flag_t flags) { switch_status_t status; const char *err; @@ -113,7 +113,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char switch_core_set_globals(); if (!minimal) { - status = switch_core_init_and_modload(SCF_USE_SQL, SWITCH_TRUE, &err); + status = switch_core_init_and_modload(flags, SWITCH_TRUE, &err); switch_sleep(1 * 1000000); switch_core_set_variable("sound_prefix", "." SWITCH_PATH_SEPARATOR); if (status != SWITCH_STATUS_SUCCESS && err) { @@ -256,7 +256,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char int fst_timer_started = 0; \ fst_getenv_default("FST_SUPPRESS_UNUSED_STATIC_WARNING", NULL, SWITCH_FALSE); \ if (fst_core) { \ - fst_init_core_and_modload(NULL, NULL, 0); /* shuts up compiler */ \ + fst_init_core_and_modload(NULL, NULL, 0, 0); /* shuts up compiler */ \ } \ { \ @@ -274,7 +274,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char * Define the beginning of a freeswitch core test driver. Only one per test application allowed. * @param confdir directory containing freeswitch.xml configuration */ -#define FST_CORE_BEGIN(confdir) \ +#define FST_CORE_EX_BEGIN(confdir, flags) \ FCT_BGN() \ { \ int fst_core = 0; \ @@ -283,7 +283,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char switch_memory_pool_t *fst_pool = NULL; \ int fst_timer_started = 0; \ fst_getenv_default("FST_SUPPRESS_UNUSED_STATIC_WARNING", NULL, SWITCH_FALSE); \ - if (fst_init_core_and_modload(confdir, confdir, 0) == SWITCH_STATUS_SUCCESS) { \ + if (fst_init_core_and_modload(confdir, confdir, 0, flags) == SWITCH_STATUS_SUCCESS) { \ fst_core = 2; \ } else { \ fprintf(stderr, "Failed to load FS core\n"); \ @@ -305,6 +305,9 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char } \ FCT_END() +#define FST_CORE_BEGIN(confdir) FST_CORE_EX_BEGIN(confdir, 0) +#define FST_CORE_DB_BEGIN(confdir) FST_CORE_EX_BEGIN(confdir, SCF_USE_SQL) + /** * Minimal FS core load */ @@ -317,7 +320,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char switch_memory_pool_t *fst_pool = NULL; \ int fst_timer_started = 0; \ fst_getenv_default("FST_SUPPRESS_UNUSED_STATIC_WARNING", NULL, SWITCH_FALSE); \ - if (fst_init_core_and_modload(confdir, NULL, 1) == SWITCH_STATUS_SUCCESS) { /* minimal load */ \ + if (fst_init_core_and_modload(confdir, NULL, 1, 0) == SWITCH_STATUS_SUCCESS) { /* minimal load */ \ fst_core = 1; \ } else { \ fprintf(stderr, "Failed to load FS core\n"); \ diff --git a/tests/unit/switch_core_db.c b/tests/unit/switch_core_db.c index 50a004fed5..244ab38398 100644 --- a/tests/unit/switch_core_db.c +++ b/tests/unit/switch_core_db.c @@ -34,7 +34,7 @@ #include -FST_CORE_BEGIN("./conf") +FST_CORE_DB_BEGIN("./conf") { FST_SUITE_BEGIN(switch_core_db) {