"Urgent",
};
+/*!
+ * \brief Reload voicemail.conf
+ * \param reload Whether this is a reload as opposed to module load
+ * \param force Forcefully reload the config, even it has not changed
+ * \retval 0 on success, nonzero on failure
+ */
+static int load_config_force(int reload, int force);
+
+/*! \brief Forcibly reload voicemail.conf, even if it has not changed.
+ * This is necessary after running unit tests. */
+#define force_reload_config() load_config_force(1, 1)
+
static int load_config(int reload);
#ifdef TEST_FRAMEWORK
static int load_config_from_memory(int reload, struct ast_config *cfg, struct ast_config *ucfg);
#endif
free_user(vmu);
+ force_reload_config(); /* Restore original config */
return res ? AST_TEST_FAIL : AST_TEST_PASS;
}
#endif
return ast_str_buffer(str);
}
-static int load_config(int reload)
+static int load_config_force(int reload, int force)
{
struct ast_config *cfg, *ucfg;
- struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
+ struct ast_flags config_flags = { reload && !force ? CONFIG_FLAG_FILEUNCHANGED : 0 };
int res;
ast_unload_realtime("voicemail");
return res;
}
+static int load_config(int reload)
+{
+ return load_config_force(reload, 0);
+}
+
#ifdef TEST_FRAMEWORK
static int load_config_from_memory(int reload, struct ast_config *cfg, struct ast_config *ucfg)
{
}
free_user(vmu);
+ force_reload_config(); /* Restore original config */
return res;
}
}
fclose(file);
free_user(vmu);
+ force_reload_config(); /* Restore original config */
return res;
}
#undef CHECK
- /* restore config */
- load_config(1); /* this might say "Failed to load configuration file." */
+ /* Forcibly restore the original config, to reinitialize after test */
+ force_reload_config(); /* this might say "Failed to load configuration file." */
cleanup:
unlink(config_filename);
populate_defaults(vmu);
vmu->email = ast_strdup("vm-info-test@example.net");
+ if (!vmu->email) {
+ ast_test_status_update(test, "Cannot create vmu email\n");
+ chan = ast_channel_unref(chan);
+ return AST_TEST_FAIL;
+ }
ast_copy_string(vmu->fullname, "Test Framework Mailbox", sizeof(vmu->fullname));
ast_copy_string(vmu->pager, "vm-info-pager-test@example.net", sizeof(vmu->pager));
ast_copy_string(vmu->language, "en", sizeof(vmu->language));