summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2014-08-11 17:38:31 +0000
committerMark Michelson <mmichelson@digium.com>2014-08-11 17:38:31 +0000
commit1b500d2fa1eb4b158a663e2f20bf2ffa3523a707 (patch)
tree18d1e77478ece48031de2b7f08a3524a48e383aa /res
parentc43c22fe89a1aaf57b562e48d0d8f4fdbd3d7686 (diff)
Fix crashing unit tests with regards to RLS.
The unit tests require a sorcery.conf file that has been set up to store resource lists in memory rather than retrieving from configuration. With a setup that is not conducive to running the tests, a fault in sorcery currently causes Asterisk to crash when attempting to run any of the tests. To get around the crash, this adds a function that verifies the current environment and marks the tests as "not run" if the setup is not correct. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@420779 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res')
-rw-r--r--res/res_pjsip_pubsub.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c
index c9e8834c6..f9b64f85f 100644
--- a/res/res_pjsip_pubsub.c
+++ b/res/res_pjsip_pubsub.c
@@ -3527,6 +3527,31 @@ static void test_resource_tree_destroy(struct resource_tree *tree)
ast_free(tree);
}
+static int ineligible_configuration(void)
+{
+ struct ast_config *config;
+ struct ast_flags flags = {0,};
+ const char *value;
+
+ config = ast_config_load("sorcery.conf", flags);
+ if (!config) {
+ return 1;
+ }
+
+ value = ast_variable_retrieve(config, "res_pjsip_pubsub", "resource_list");
+ if (ast_strlen_zero(value)) {
+ ast_config_destroy(config);
+ return 1;
+ }
+
+ if (strcasecmp(value, "memory") && strcasecmp(value, "astdb")) {
+ ast_config_destroy(config);
+ return 1;
+ }
+
+ return 0;
+}
+
AST_TEST_DEFINE(resource_tree)
{
RAII_VAR(struct resource_list *, list, NULL, cleanup_resource_list);
@@ -3550,6 +3575,12 @@ AST_TEST_DEFINE(resource_tree)
break;
}
+ if (ineligible_configuration()) {
+ ast_test_status_update(test, "Ineligible configuration for this test. Please add a "
+ "'res_pjsip_pubsub' section to sorcery.conf, and set 'resource_list=memory'\n");
+ return AST_TEST_NOT_RUN;
+ }
+
list = create_resource_list(test, "foo", "test", resources, ARRAY_LEN(resources));
if (!list) {
return AST_TEST_FAIL;
@@ -3609,6 +3640,12 @@ AST_TEST_DEFINE(complex_resource_tree)
break;
}
+ if (ineligible_configuration()) {
+ ast_test_status_update(test, "Ineligible configuration for this test. Please add a "
+ "'res_pjsip_pubsub' section to sorcery.conf, and set 'resource_list=memory'\n");
+ return AST_TEST_NOT_RUN;
+ }
+
list_1 = create_resource_list(test, "foo", "test", resources_1, ARRAY_LEN(resources_1));
if (!list_1) {
return AST_TEST_FAIL;
@@ -3669,6 +3706,12 @@ AST_TEST_DEFINE(bad_resource)
break;
}
+ if (ineligible_configuration()) {
+ ast_test_status_update(test, "Ineligible configuration for this test. Please add a "
+ "'res_pjsip_pubsub' section to sorcery.conf, and set 'resource_list=memory'\n");
+ return AST_TEST_NOT_RUN;
+ }
+
list = create_resource_list(test, "foo", "test", resources, ARRAY_LEN(resources));
if (!list) {
return AST_TEST_FAIL;
@@ -3728,6 +3771,12 @@ AST_TEST_DEFINE(bad_branch)
break;
}
+ if (ineligible_configuration()) {
+ ast_test_status_update(test, "Ineligible configuration for this test. Please add a "
+ "'res_pjsip_pubsub' section to sorcery.conf, and set 'resource_list=memory'\n");
+ return AST_TEST_NOT_RUN;
+ }
+
list_1 = create_resource_list(test, "foo", "test", resources_1, ARRAY_LEN(resources_1));
if (!list_1) {
return AST_TEST_FAIL;
@@ -3794,6 +3843,12 @@ AST_TEST_DEFINE(duplicate_resource)
break;
}
+ if (ineligible_configuration()) {
+ ast_test_status_update(test, "Ineligible configuration for this test. Please add a "
+ "'res_pjsip_pubsub' section to sorcery.conf, and set 'resource_list=memory'\n");
+ return AST_TEST_NOT_RUN;
+ }
+
list_1 = create_resource_list(test, "foo", "test", resources_1, ARRAY_LEN(resources_1));
if (!list_1) {
return AST_TEST_FAIL;
@@ -3861,6 +3916,12 @@ AST_TEST_DEFINE(loop)
break;
}
+ if (ineligible_configuration()) {
+ ast_test_status_update(test, "Ineligible configuration for this test. Please add a "
+ "'res_pjsip_pubsub' section to sorcery.conf, and set 'resource_list=memory'\n");
+ return AST_TEST_NOT_RUN;
+ }
+
list_1 = create_resource_list(test, "herp", "test", resources_1, ARRAY_LEN(resources_1));
if (!list_1) {
return AST_TEST_FAIL;
@@ -3903,6 +3964,12 @@ AST_TEST_DEFINE(bad_event)
break;
}
+ if (ineligible_configuration()) {
+ ast_test_status_update(test, "Ineligible configuration for this test. Please add a "
+ "'res_pjsip_pubsub' section to sorcery.conf, and set 'resource_list=memory'\n");
+ return AST_TEST_NOT_RUN;
+ }
+
list = create_resource_list(test, "foo", "tsetse", resources, ARRAY_LEN(resources));
if (!list) {
return AST_TEST_FAIL;