]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11439 [core] Update switch_test.h so unprivileged users can execute tests when...
authorChris Rienzo <chris@signalwire.com>
Thu, 4 Oct 2018 20:02:08 +0000 (20:02 +0000)
committerChris Rienzo <chris@signalwire.com>
Thu, 20 Dec 2018 15:16:53 +0000 (10:16 -0500)
src/include/test/switch_test.h

index 85ad2ae91e8cb2f6e569299c0534faf015d811c9..ae80852e429be232974a20c38c0aa45a2ebfd238 100644 (file)
 /**
  * initialize FS core from optional configuration dir
  */
-static void fst_init_core_and_modload(const char *confdir)
+static void fst_init_core_and_modload(const char *confdir, const char *basedir)
 {
        const char *err;
+       // Let FreeSWITCH core pick these
+       //SWITCH_GLOBAL_dirs.base_dir = strdup("/usr/local/freeswitch");
+       //SWITCH_GLOBAL_dirs.mod_dir = strdup("/usr/local/freeswitch/mod");
+       //SWITCH_GLOBAL_dirs.lib_dir = strdup("/usr/local/freeswitch/lib");
+       //SWITCH_GLOBAL_dirs.temp_dir = strdup("/tmp");
+
+       if (zstr(basedir)) {
+               basedir = ".";
+       }
+
+       // Allow test to define the runtime dir
        if (!zstr(confdir)) {
                SWITCH_GLOBAL_dirs.conf_dir = strdup(confdir);
+       } else {
+               SWITCH_GLOBAL_dirs.conf_dir = switch_mprintf("%s%sconf", basedir, SWITCH_PATH_SEPARATOR);
        }
-       SWITCH_GLOBAL_dirs.sounds_dir = strdup("./");
+
+       SWITCH_GLOBAL_dirs.log_dir = switch_mprintf("%s%s", basedir, SWITCH_PATH_SEPARATOR);
+       SWITCH_GLOBAL_dirs.run_dir = switch_mprintf("%s%s", basedir, SWITCH_PATH_SEPARATOR);
+       SWITCH_GLOBAL_dirs.recordings_dir = switch_mprintf("%s%s", basedir, SWITCH_PATH_SEPARATOR);
+       SWITCH_GLOBAL_dirs.sounds_dir = switch_mprintf("%s%s", basedir, SWITCH_PATH_SEPARATOR);
+       SWITCH_GLOBAL_dirs.cache_dir = switch_mprintf("%s%s", basedir, SWITCH_PATH_SEPARATOR);
+       SWITCH_GLOBAL_dirs.db_dir = switch_mprintf("%s%s", basedir, SWITCH_PATH_SEPARATOR);
+       SWITCH_GLOBAL_dirs.script_dir = switch_mprintf("%s%s", basedir, SWITCH_PATH_SEPARATOR);
+       SWITCH_GLOBAL_dirs.htdocs_dir = switch_mprintf("%s%s", basedir, SWITCH_PATH_SEPARATOR);
+       SWITCH_GLOBAL_dirs.grammar_dir = switch_mprintf("%s%s", basedir, SWITCH_PATH_SEPARATOR);
+       SWITCH_GLOBAL_dirs.fonts_dir = switch_mprintf("%s%s", basedir, SWITCH_PATH_SEPARATOR);
+       SWITCH_GLOBAL_dirs.images_dir = switch_mprintf("%s%s", basedir, SWITCH_PATH_SEPARATOR);
+       SWITCH_GLOBAL_dirs.storage_dir = switch_mprintf("%s%s", basedir, SWITCH_PATH_SEPARATOR);
+       SWITCH_GLOBAL_dirs.data_dir = switch_mprintf("%s%s", basedir, SWITCH_PATH_SEPARATOR);
+       SWITCH_GLOBAL_dirs.localstate_dir = switch_mprintf("%s%s", basedir, SWITCH_PATH_SEPARATOR);
+
        switch_core_init_and_modload(0, SWITCH_TRUE, &err);
        switch_sleep(1 * 1000000);
        switch_core_set_variable("sound_prefix", "");
@@ -122,7 +150,7 @@ static void fst_session_park(switch_core_session_t *session)
        { \
                switch_timer_t fst_timer = { 0 }; \
                switch_memory_pool_t *fst_pool = NULL; \
-               fst_init_core_and_modload(confdir);
+               fst_init_core_and_modload(confdir, NULL);
 
 /**
  * Define the end of a freeswitch core test driver.