[asterisk-commits] mmichelson: trunk r420780 - in /trunk: ./ res/res_pjsip_pubsub.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 11 12:40:11 CDT 2014


Author: mmichelson
Date: Mon Aug 11 12:40:07 2014
New Revision: 420780

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=420780
Log:
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.
........

Merged revisions 420779 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    trunk/   (props changed)
    trunk/res/res_pjsip_pubsub.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-13-merged (original)
+++ branch-13-merged Mon Aug 11 12:40:07 2014
@@ -1,1 +1,1 @@
-/branches/13:1-420494,420514,420534,420536,420538,420562,420577,420592,420609,420624,420639,420657,420717,420742,420758
+/branches/13:1-420494,420514,420534,420536,420538,420562,420577,420592,420609,420624,420639,420657,420717,420742,420758,420779

Modified: trunk/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip_pubsub.c?view=diff&rev=420780&r1=420779&r2=420780
==============================================================================
--- trunk/res/res_pjsip_pubsub.c (original)
+++ trunk/res/res_pjsip_pubsub.c Mon Aug 11 12:40:07 2014
@@ -3527,6 +3527,31 @@
 	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);
@@ -3548,6 +3573,12 @@
 		return AST_TEST_NOT_RUN;
 	case TEST_EXECUTE:
 		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));
@@ -3609,6 +3640,12 @@
 		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;
@@ -3667,6 +3704,12 @@
 		return AST_TEST_NOT_RUN;
 	case TEST_EXECUTE:
 		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));
@@ -3726,6 +3769,12 @@
 		return AST_TEST_NOT_RUN;
 	case TEST_EXECUTE:
 		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));
@@ -3794,6 +3843,12 @@
 		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 @@
 		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;
@@ -3901,6 +3962,12 @@
 		return AST_TEST_NOT_RUN;
 	case TEST_EXECUTE:
 		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));




More information about the asterisk-commits mailing list