test_config: Fix failure and segfault when config_hook is run twice.

On second run the config_hook test was unexpectedly failing to load
test_config.conf because it was still unmodified since the last load.
This is fixed by not passing CONFIG_FLAG_FILEUNCHANGED for the initial
loads, only using it when we are tested that a reload of unmodified
files do not initiate the hook.

ASTERISK-25960

Change-Id: Ifd679509a23ed163e5cc647490bf7df4ae3cd856
15.6
Corey Farrell 8 years ago
parent 415c8e9c8f
commit ddce3ddab5

@ -957,7 +957,8 @@ AST_TEST_DEFINE(config_hook)
{ {
enum ast_test_result_state res = AST_TEST_FAIL; enum ast_test_result_state res = AST_TEST_FAIL;
enum config_hook_flags hook_flags = { 0, }; enum config_hook_flags hook_flags = { 0, };
struct ast_flags config_flags = { CONFIG_FLAG_FILEUNCHANGED }; struct ast_flags config_flags = { 0 };
struct ast_flags reload_flags = { CONFIG_FLAG_FILEUNCHANGED };
struct ast_config *cfg; struct ast_config *cfg;
switch (cmd) { switch (cmd) {
@ -1025,7 +1026,7 @@ AST_TEST_DEFINE(config_hook)
* Hook should not run * Hook should not run
*/ */
hook_run = 0; hook_run = 0;
cfg = ast_config_load(CONFIG_FILE, config_flags); cfg = ast_config_load(CONFIG_FILE, reload_flags);
/* Only destroy this cfg conditionally. Otherwise a crash happens. */ /* Only destroy this cfg conditionally. Otherwise a crash happens. */
if (cfg != CONFIG_STATUS_FILEUNCHANGED) { if (cfg != CONFIG_STATUS_FILEUNCHANGED) {
ast_config_destroy(cfg); ast_config_destroy(cfg);

Loading…
Cancel
Save