Merge pull request #209 from signalwire/test_db

[Unit-tests] Do not initiate sqldb by default unless requested.
This commit is contained in:
Andrey Volk 2020-01-07 21:52:06 +04:00 committed by GitHub
commit cd1a1db336
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -66,7 +66,7 @@ static char *fst_getenv_default(const char *env, char *default_value, switch_boo
/** /**
* initialize FS core from optional configuration dir * 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; switch_status_t status;
const char *err; 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(); switch_core_set_globals();
if (!minimal) { 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_sleep(1 * 1000000);
switch_core_set_variable("sound_prefix", "." SWITCH_PATH_SEPARATOR); switch_core_set_variable("sound_prefix", "." SWITCH_PATH_SEPARATOR);
if (status != SWITCH_STATUS_SUCCESS && err) { 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; \ int fst_timer_started = 0; \
fst_getenv_default("FST_SUPPRESS_UNUSED_STATIC_WARNING", NULL, SWITCH_FALSE); \ fst_getenv_default("FST_SUPPRESS_UNUSED_STATIC_WARNING", NULL, SWITCH_FALSE); \
if (fst_core) { \ 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. * Define the beginning of a freeswitch core test driver. Only one per test application allowed.
* @param confdir directory containing freeswitch.xml configuration * @param confdir directory containing freeswitch.xml configuration
*/ */
#define FST_CORE_BEGIN(confdir) \ #define FST_CORE_EX_BEGIN(confdir, flags) \
FCT_BGN() \ FCT_BGN() \
{ \ { \
int fst_core = 0; \ 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; \ switch_memory_pool_t *fst_pool = NULL; \
int fst_timer_started = 0; \ int fst_timer_started = 0; \
fst_getenv_default("FST_SUPPRESS_UNUSED_STATIC_WARNING", NULL, SWITCH_FALSE); \ 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; \ fst_core = 2; \
} else { \ } else { \
fprintf(stderr, "Failed to load FS core\n"); \ 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() 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 * 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; \ switch_memory_pool_t *fst_pool = NULL; \
int fst_timer_started = 0; \ int fst_timer_started = 0; \
fst_getenv_default("FST_SUPPRESS_UNUSED_STATIC_WARNING", NULL, SWITCH_FALSE); \ 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; \ fst_core = 1; \
} else { \ } else { \
fprintf(stderr, "Failed to load FS core\n"); \ fprintf(stderr, "Failed to load FS core\n"); \

View File

@ -34,7 +34,7 @@
#include <test/switch_test.h> #include <test/switch_test.h>
FST_CORE_BEGIN("./conf") FST_CORE_DB_BEGIN("./conf")
{ {
FST_SUITE_BEGIN(switch_core_db) FST_SUITE_BEGIN(switch_core_db)
{ {