summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGeorge Joseph <george.joseph@fairview5.com>2014-10-14 20:48:06 +0000
committerGeorge Joseph <george.joseph@fairview5.com>2014-10-14 20:48:06 +0000
commit104fca50019a432886bfe79615b88122547d9f16 (patch)
tree4b88d7e4d5d2b00f45aa841da2a954ccb9e2ada7 /tests
parent87b5006ff06dd4a719dca96199e065437f31475d (diff)
config: Fix SEGV in unit test with MALLOC_DEBUG
With MALLOC_DEBUG the /main/config config_basic_ops test was causing a SEGV while doing an ast_category_delete in an ast_category_browse loop. Apparently this never worked but was also never tested. I removed the test, added 2 notes to config.h indicating that it's not supported and added a few lines of code to ast_category_delete to prevent the SEGV should someone attempt it in the future. Tested-by: George Joseph Review: https://reviewboard.asterisk.org/r/4078/ ........ Merged revisions 425525 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 425526 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@425527 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'tests')
-rw-r--r--tests/test_config.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/tests/test_config.c b/tests/test_config.c
index b1f55c782..be4bee3d2 100644
--- a/tests/test_config.c
+++ b/tests/test_config.c
@@ -395,26 +395,6 @@ AST_TEST_DEFINE(config_basic_ops)
}
}
- /* Now: test0 test1 test3 test4 test2 */
- /* Test in-flight deletion using ast_category_browse */
- /* Delete test1 and continue */
- cat_name = NULL;
- for(i = 0; i < 5; i++) {
- if (i == 2) { /* 2 was already deleted above */
- continue;
- }
- snprintf(temp, sizeof(temp), "test%d", i);
- cat_name = ast_category_browse(cfg, cat_name);
- cat = ast_category_get(cfg, cat_name, NULL);
- if (strcmp(cat_name, temp)) {
- ast_test_status_update(test, "Should have returned %s instead of %s: %d\n", temp, cat_name, i);
- goto out;
- }
- if (i == 1) {
- ast_category_delete(cfg, cat);
- }
- }
-
/* Now: test0 test3 test4 test2 */
/* delete the head item */
cat = ast_category_browse_filtered(cfg, NULL, NULL, NULL);
@@ -429,7 +409,7 @@ AST_TEST_DEFINE(config_basic_ops)
/* make sure head got updated to the new first element */
cat = ast_category_browse_filtered(cfg, NULL, NULL, NULL);
cat_name = ast_category_get_name(cat);
- if (strcmp(cat_name, "test3")) {
+ if (strcmp(cat_name, "test1")) {
ast_test_status_update(test, "Should have returned test3 instead of %s\n", cat_name);
goto out;
}
@@ -448,6 +428,13 @@ AST_TEST_DEFINE(config_basic_ops)
cat = NULL;
cat = ast_category_browse_filtered(cfg, NULL, cat, NULL);
cat_name = ast_category_get_name(cat);
+ if (strcmp(cat_name, "test1")) {
+ ast_test_status_update(test, "Should have returned test1 instead of %s\n", cat_name);
+ goto out;
+ }
+
+ cat = ast_category_browse_filtered(cfg, NULL, cat, NULL);
+ cat_name = ast_category_get_name(cat);
if (strcmp(cat_name, "test3")) {
ast_test_status_update(test, "Should have returned test3 instead of %s\n", cat_name);
goto out;