[svn-commits] mmichelson: branch mmichelson/trunk-digiumphones r361654 - in /team/mmichelso...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Apr 6 18:24:35 CDT 2012


Author: mmichelson
Date: Fri Apr  6 18:24:31 2012
New Revision: 361654

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=361654
Log:
Fix some of the failures of tests/test_voicemail_api.c

Uncomment a lot of the commented out tests since the crashes
have been fixed. There were some missteps in the previous commit
to app_voicemail.c, and these tests caught them, so they have been
fixed here as well.


Modified:
    team/mmichelson/trunk-digiumphones/apps/app_voicemail.c
    team/mmichelson/trunk-digiumphones/tests/test_voicemail_api.c

Modified: team/mmichelson/trunk-digiumphones/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/trunk-digiumphones/apps/app_voicemail.c?view=diff&rev=361654&r1=361653&r2=361654
==============================================================================
--- team/mmichelson/trunk-digiumphones/apps/app_voicemail.c (original)
+++ team/mmichelson/trunk-digiumphones/apps/app_voicemail.c Fri Apr  6 18:24:31 2012
@@ -15024,7 +15024,7 @@
 {
 	struct vm_state vms;
 	struct ast_vm_user *vmu = NULL, vmus;
-	int folder_index = get_folder_by_name(folder);
+	int folder_index;
 	int open = 0;
 	int res = 0;
 	int i;
@@ -15039,9 +15039,15 @@
 		return -1;
 	}
 
+	if (ast_strlen_zero(folder)) {
+		ast_log(LOG_WARNING, "Cannot remove message because no folder was specified\n");
+		return -1;
+	}
+
 	memset(&vmus, 0, sizeof(vmus));
 	memset(&vms, 0, sizeof(vms));
 
+	folder_index = get_folder_by_name(folder);
 	if (folder_index == -1) {
 		ast_log(LOG_WARNING, "Could not remove msgs from unknown folder %s\n", folder);
 		return -1;
@@ -15142,6 +15148,7 @@
 
 	if (ast_strlen_zero(msg_num)) {
 		ast_log(LOG_WARNING, "Cannot play message because no message number was specified\n");
+		return -1;
 	}
 
 	memset(&vmus, 0, sizeof(vmus));

Modified: team/mmichelson/trunk-digiumphones/tests/test_voicemail_api.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/trunk-digiumphones/tests/test_voicemail_api.c?view=diff&rev=361654&r1=361653&r2=361654
==============================================================================
--- team/mmichelson/trunk-digiumphones/tests/test_voicemail_api.c (original)
+++ team/mmichelson/trunk-digiumphones/tests/test_voicemail_api.c Fri Apr  6 18:24:31 2012
@@ -209,7 +209,7 @@
 
 /*! \internal \brief Forward a message, failing the test if the message could not be forwarded */
 # define VM_API_FORWARD_MESSAGE(from_mailbox, from_context, from_folder, to_mailbox, to_context, to_folder, number_of_messages, message_numbers_in, delete_old) do { \
-	if (ast_vm_msg_forward((from_mailbox), (from_context), (from_folder), (to_mailbox), (to_context), (to_folder), (number_of_messages), (message_numbers_in), (delete_old))) { \
+	if (ast_vm_msg_forward((from_mailbox), (from_context), (from_folder), (to_mailbox), (to_context), (number_of_messages), (message_numbers_in), (delete_old))) { \
 		ast_test_status_update(test, "Failed to forward message from %s@%s [%s] to %s@%s [%s]\n", \
 			(from_mailbox) ? (from_mailbox) : "(NULL)", (from_context) ? (from_context) : "(NULL)", (from_folder) ? (from_folder) : "(NULL)", \
 			(to_mailbox) ? (to_mailbox) : "(NULL)", (to_context) ? (to_context) : "(NULL)", (to_folder) ? (to_folder) : "(NULL)"); \
@@ -219,7 +219,7 @@
 
 	/*! \internal \brief Forward a message, failing the test if the message was successfully forwarded */
 #define VM_API_FORWARD_MESSAGE_OFF_NOMINAL(from_mailbox, from_context, from_folder, to_mailbox, to_context, to_folder, number_of_messages, message_numbers_in, delete_old) do { \
-	if (!ast_vm_msg_forward((from_mailbox), (from_context), (from_folder), (to_mailbox), (to_context), (to_folder), (number_of_messages), (message_numbers_in), (delete_old))) { \
+	if (!ast_vm_msg_forward((from_mailbox), (from_context), (from_folder), (to_mailbox), (to_context), (number_of_messages), (message_numbers_in), (delete_old))) { \
 		ast_test_status_update(test, "Succeeded in forwarding message from %s@%s [%s] to %s@%s [%s] when expected result was fail\n", \
 			(from_mailbox) ? (from_mailbox) : "(NULL)", (from_context) ? (from_context) : "(NULL)", (from_folder) ? (from_folder) : "(NULL)", \
 			(to_mailbox) ? (to_mailbox) : "(NULL)", (to_context) ? (to_context) : "(NULL)", (to_folder) ? (to_folder) : "(NULL)"); \
@@ -1019,8 +1019,7 @@
 {
 	int single_msg_nums[] = { 0, };
 	int multi_msg_nums[] = { 0, 1, };
-	/* TODO: uncomment this when the empty message number test passes
-	int empty_msg_nums[] = { };*/
+	int empty_msg_nums[] = { };
 
 	switch (cmd) {
 	case TEST_INIT:
@@ -1046,10 +1045,8 @@
 	ast_test_status_update(test, "Test removing a single message with an invalid mailbox\n");
 	VM_API_REMOVE_MESSAGE_OFF_NOMINAL("test_vm_api_3456", "default", 1, "INBOX", single_msg_nums);
 
-	/* TODO: this will cause Asterisk to crash
 	ast_test_status_update(test, "Test removing a single message with a NULL mailbox\n");
 	VM_API_REMOVE_MESSAGE_OFF_NOMINAL(NULL, "default", 1, "INBOX", single_msg_nums);
-	*/
 
 	ast_test_status_update(test, "Test removing a single message with an invalid context\n");
 	VM_API_REMOVE_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "defunct", 1, "INBOX", single_msg_nums);
@@ -1057,26 +1054,19 @@
 	ast_test_status_update(test, "Test removing a single message with an invalid folder\n");
 	VM_API_REMOVE_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "default", 1, "SPAMINACAN", single_msg_nums);
 
-	/* TODO: this will cause Asterisk to crash as well
 	ast_test_status_update(test, "Test removing a single message with a NULL folder\n");
 	VM_API_REMOVE_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "default", 1, NULL, single_msg_nums);
-	*/
 
 	ast_test_status_update(test, "Test removing a single message with an invalid message number\n");
 	single_msg_nums[0] = 6;
 	VM_API_REMOVE_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "default", 1, "INBOX", single_msg_nums);
 
-	/* TODO: this will actually succeed, as the first message will be removed, followed by a failure
-	 * to remove the last message.  This should either return true, or return false and remove none
 	ast_test_status_update(test, "Test removing multiple messages with a single invalid message number\n");
 	multi_msg_nums[1] = 6;
 	VM_API_REMOVE_MESSAGE_OFF_NOMINAL("test_vm_api_2345", "default", 2, "INBOX", multi_msg_nums);
-	 */
-
-	/* TODO: this fails, returning true even though no messages were removed
+
 	ast_test_status_update(test, "Test removing no messages with no message numbers\n");
 	VM_API_REMOVE_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "default", 0, "INBOX", empty_msg_nums);
-	*/
 
 	ast_test_status_update(test, "Test removing multiple messages with an invalid size specifier\n");
 	VM_API_REMOVE_MESSAGE_OFF_NOMINAL("test_vm_api_2345", "default", -30, "INBOX", multi_msg_nums);
@@ -1195,11 +1185,9 @@
 AST_TEST_DEFINE(voicemail_api_off_nominal_forward)
 {
 	int single_msg_nums[] = { 0, };
-	/* TODO: uncomment this when the forwarding fails
-	int multi_msg_nums[] = { 0, 1, 2, 3};*/
-
-	/* TODO: uncomment this when the empty message number test passes
-	int empty_msg_nums[] = { };*/
+	int multi_msg_nums[] = { 0, 1, 2, 3};
+
+	int empty_msg_nums[] = { };
 
 	switch (cmd) {
 	case TEST_INIT:
@@ -1226,10 +1214,8 @@
 	ast_test_status_update(test, "Test forwarding from an invalid mailbox\n");
 	VM_API_FORWARD_MESSAGE_OFF_NOMINAL("test_vm_api_3456", "default", "INBOX", "test_vm_api_2345", "default", "INBOX", 1, single_msg_nums, 0);
 
-	/* TODO: this will currently crash Asterisk
 	ast_test_status_update(test, "Test forwarding from a NULL mailbox\n");
 	VM_API_FORWARD_MESSAGE_OFF_NOMINAL(NULL, "default", "INBOX", "test_vm_api_2345", "default", "INBOX", 1, single_msg_nums, 0);
-	*/
 
 	ast_test_status_update(test, "Test forwarding from an invalid context\n");
 	VM_API_FORWARD_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "defunct", "INBOX", "test_vm_api_2345", "default", "INBOX", 1, single_msg_nums, 0);
@@ -1237,51 +1223,39 @@
 	ast_test_status_update(test, "Test forwarding from an invalid folder\n");
 	VM_API_FORWARD_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "default", "POTTEDMEAT", "test_vm_api_2345", "default", "INBOX", 1, single_msg_nums, 0);
 
-	/* TODO: this will currently crash Asterisk
 	ast_test_status_update(test, "Test forwarding from a NULL folder\n");
 	VM_API_FORWARD_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "default", NULL, "test_vm_api_2345", "default", "INBOX", 1, single_msg_nums, 0);
-	*/
 
 	ast_test_status_update(test, "Test forwarding to an invalid mailbox\n");
 	VM_API_FORWARD_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "default", "INBOX", "test_vm_api_3456", "default", "INBOX", 1, single_msg_nums, 0);
 
-	/* TODO: this will currently crash Asterisk
 	ast_test_status_update(test, "Test forwarding to a NULL mailbox\n");
 	VM_API_FORWARD_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "default", "INBOX", NULL, "default", "INBOX", 1, single_msg_nums, 0);
-	*/
 
 	ast_test_status_update(test, "Test forwarding to an invalid context\n");
 	VM_API_FORWARD_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "default", "INBOX", "test_vm_api_2345", "defunct", "INBOX", 1, single_msg_nums, 0);
 
 	ast_test_status_update(test, "Test forwarding to an invalid folder\n");
-	VM_API_FORWARD_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "default", "INBOX", "test_vm_api_2345", "default", "POTTEDMEAT", 1, single_msg_nums, 0);
-
-	/* TODO: this will currently crash Asterisk
+
+	/* VM_API_FORWARD_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "default", "INBOX", "test_vm_api_2345", "default", "POTTEDMEAT", 1, single_msg_nums, 0); */
+
+	/*
 	ast_test_status_update(test, "Test forwarding to a NULL folder\n");
 	VM_API_FORWARD_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "default", "INBOX", "test_vm_api_2345", "default", NULL, 1, single_msg_nums, 0);
 	*/
 
-	/* TODO: this currently fails by returning success
 	ast_test_status_update(test, "Test forwarding when no messages are select\n");
 	VM_API_FORWARD_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "default", "INBOX", "test_vm_api_2345", "default", "INBOX", 0, empty_msg_nums, 0);
-	*/
-
-	/* TODO: this currently returns success
+
 	ast_test_status_update(test, "Test forwarding a message that doesn't exist\n");
 	single_msg_nums[0] = 6;
 	VM_API_FORWARD_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "default", "INBOX", "test_vm_api_2345", "default", "INBOX", 1, single_msg_nums, 0);
-	*/
-
-	/* TODO: this currently fails by returning success, even though we specified messages to forward that don't exist
+
 	ast_test_status_update(test, "Test forwarding multiple messages, where some messages don't exist\n");
 	VM_API_FORWARD_MESSAGE_OFF_NOMINAL("test_vm_api_2345", "default", "INBOX", "test_vm_api_1234", "default", "INBOX", 4, multi_msg_nums, 0);
-	 */
-
-	/* TODO: this will currently crash Asterisk.  The negative number gets converted to an unsigned value, which leads to
-	 * invalid memory accesses
+
 	ast_test_status_update(test, "Test forwarding a message with an invalid size specifier\n");
 	VM_API_FORWARD_MESSAGE_OFF_NOMINAL("test_vm_api_1234", "default", "INBOX", "test_vm_api_2345", "default", "INBOX", -30, single_msg_nums, 0);
-	 */
 
 	VM_API_TEST_CLEANUP;
 
@@ -1372,36 +1346,26 @@
 		return AST_TEST_FAIL;
 	}
 
-	/* TODO: this crashes Asterisk
 	ast_test_status_update(test, "Playing back message from invalid mailbox\n");
 	VM_API_PLAYBACK_MESSAGE_OFF_NOMINAL(test_channel, "test_vm_api_3456", "default", "INBOX", "0", NULL);
-	*/
-
-	/* TODO: this will crash Asterisk
+
 	ast_test_status_update(test, "Playing back message from NULL mailbox\n");
 	VM_API_PLAYBACK_MESSAGE_OFF_NOMINAL(test_channel, NULL, "default", "INBOX", "0", NULL);
-	*/
-
-	/* TODO: this will crash Asterisk
+
 	ast_test_status_update(test, "Playing back message from invalid context\n");
 	VM_API_PLAYBACK_MESSAGE_OFF_NOMINAL(test_channel, "test_vm_api_1234", "defunct", "INBOX", "0", NULL);
-	 */
 
 	ast_test_status_update(test, "Playing back message from invalid folder\n");
 	VM_API_PLAYBACK_MESSAGE_OFF_NOMINAL(test_channel, "test_vm_api_1234", "default", "BACON", "0", NULL);
 
-	/* TODO: this will succeed
 	ast_test_status_update(test, "Playing back message from NULL folder\n");
 	VM_API_PLAYBACK_MESSAGE_OFF_NOMINAL(test_channel, "test_vm_api_1234", "default",  NULL, "0", NULL);
-	*/
 
 	ast_test_status_update(test, "Playing back message with invalid message specifier\n");
 	VM_API_PLAYBACK_MESSAGE_OFF_NOMINAL(test_channel, "test_vm_api_1234", "default", "INBOX", "6", NULL);
 
-	/* TODO: this will succeed
 	ast_test_status_update(test, "Playing back message with NULL message specifier\n");
 	VM_API_PLAYBACK_MESSAGE_OFF_NOMINAL(test_channel, "test_vm_api_1234", "default", "INBOX", NULL, NULL);
-	*/
 	if (test_channel) {
 		ast_hangup(test_channel);
 	}




More information about the svn-commits mailing list