[svn-commits] mmichelson: branch group/CCSS r236135 - in /team/group/CCSS: ./ build_tools/ ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Dec 22 11:31:57 CST 2009


Author: mmichelson
Date: Tue Dec 22 11:31:55 2009
New Revision: 236135

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=236135
Log:
RESOLVE A CONFLICT. RESET AUTOMERGE. BE A GOOD CITIZEN.


Added:
    team/group/CCSS/include/asterisk/test.h
      - copied unchanged from r236063, trunk/include/asterisk/test.h
    team/group/CCSS/main/test.c
      - copied unchanged from r236063, trunk/main/test.c
Modified:
    team/group/CCSS/   (props changed)
    team/group/CCSS/CHANGES
    team/group/CCSS/build_tools/cflags-devmode.xml
    team/group/CCSS/channels/chan_sip.c
    team/group/CCSS/include/asterisk/_private.h
    team/group/CCSS/main/asterisk.c
    team/group/CCSS/tests/test_heap.c

Propchange: team/group/CCSS/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/group/CCSS/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/group/CCSS/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Dec 22 11:31:55 2009
@@ -1,1 +1,1 @@
-/trunk:1-235953
+/trunk:1-236130

Modified: team/group/CCSS/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/CHANGES?view=diff&rev=236135&r1=236134&r2=236135
==============================================================================
--- team/group/CCSS/CHANGES (original)
+++ team/group/CCSS/CHANGES Tue Dec 22 11:31:55 2009
@@ -361,6 +361,8 @@
 
 Miscellaneous
 -------------
+ * Addition of the Unit Test Framework API for managing registration and execution
+   of unit tests with the purpose of verifying the operation of C functions.
  * SendText is now implemented in chan_gtalk and chan_jingle. It will simply send
    XMPP text messages to the remote JID.
  * Modules.conf has a new option - "require" - that marks a module as critical for 

Modified: team/group/CCSS/build_tools/cflags-devmode.xml
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/build_tools/cflags-devmode.xml?view=diff&rev=236135&r1=236134&r2=236135
==============================================================================
--- team/group/CCSS/build_tools/cflags-devmode.xml (original)
+++ team/group/CCSS/build_tools/cflags-devmode.xml Tue Dec 22 11:31:55 2009
@@ -20,4 +20,7 @@
 		</member>
 		<member name="SKINNY_DEVMODE" displayname="Enable Skinny Dev Mode">
 		</member>
+		<member name="TEST_FRAMEWORK" displayname="Enable Test Framework API">
+		</member>
+
 	</category>

Modified: team/group/CCSS/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/chan_sip.c?view=diff&rev=236135&r1=236134&r2=236135
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Tue Dec 22 11:31:55 2009
@@ -24188,6 +24188,8 @@
 	int debug = sip_debug_test_pvt(p);
 	const char *e;
 	int error = 0;
+	int oldmethod = p->method;
+	int acked = 0;
 
 	/* Get Method and Cseq */
 	cseq = get_header(req, "Cseq");
@@ -24366,7 +24368,7 @@
 		if (seqno == p->pendinginvite) {
 			p->invitestate = INV_TERMINATED;
 			p->pendinginvite = 0;
-			__sip_ack(p, seqno, 1 /* response */, 0);
+			acked = __sip_ack(p, seqno, 1 /* response */, 0);
 			if (find_sdp(req)) {
 				if (process_sdp(p, req, SDP_T38_NONE))
 					return -1;
@@ -24375,9 +24377,13 @@
 		} else if (p->glareinvite == seqno) {
 			/* handle ack for the 491 pending sent for glareinvite */
 			p->glareinvite = 0;
-			__sip_ack(p, seqno, 1, 0);
-		}
-		/* Got an ACK that we did not match. Ignore silently */
+			acked = __sip_ack(p, seqno, 1, 0);
+		}
+		if (!acked) {
+			/* Got an ACK that did not match anything. Ignore
+			 * silently and restore previous method */
+			p->method = oldmethod;
+		}
 		if (!p->lastinvite && ast_strlen_zero(p->randdata)) {
 			pvt_set_needdestroy(p, "unmatched ACK");
 		}

Modified: team/group/CCSS/include/asterisk/_private.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/include/asterisk/_private.h?view=diff&rev=236135&r1=236134&r2=236135
==============================================================================
--- team/group/CCSS/include/asterisk/_private.h (original)
+++ team/group/CCSS/include/asterisk/_private.h Tue Dec 22 11:31:55 2009
@@ -44,7 +44,8 @@
 void ast_stun_init(void);               /*!< Provided by stun.c */
 int ast_cel_engine_init(void);		/*!< Provided by cel.c */
 int ast_cel_engine_reload(void);	/*!< Provided by cel.c */
-int ast_ssl_init(void);                 /*!< Porvided by ssl.c */
+int ast_ssl_init(void);                 /*!< Provided by ssl.c */
+int ast_test_init(void);            /*!< Provided by test.c */
 
 /*!
  * \brief Reload asterisk modules.

Modified: team/group/CCSS/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/asterisk.c?view=diff&rev=236135&r1=236134&r2=236135
==============================================================================
--- team/group/CCSS/main/asterisk.c (original)
+++ team/group/CCSS/main/asterisk.c Tue Dec 22 11:31:55 2009
@@ -141,6 +141,7 @@
 #include "asterisk/xmldoc.h"
 #include "asterisk/poll-compat.h"
 #include "asterisk/ccss.h"
+#include "asterisk/test.h"
 
 #include "../defaults.h"
 
@@ -3548,6 +3549,13 @@
 		exit(1);
 	}
 
+#ifdef TEST_FRAMEWORK
+	if (ast_test_init()) {
+		printf("%s", term_quit());
+		exit(1);
+	}
+#endif
+
 	ast_makesocket();
 	sigemptyset(&sigs);
 	sigaddset(&sigs, SIGHUP);

Modified: team/group/CCSS/tests/test_heap.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/tests/test_heap.c?view=diff&rev=236135&r1=236134&r2=236135
==============================================================================
--- team/group/CCSS/tests/test_heap.c (original)
+++ team/group/CCSS/tests/test_heap.c Tue Dec 22 11:31:55 2009
@@ -32,9 +32,9 @@
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include "asterisk/module.h"
-#include "asterisk/cli.h"
 #include "asterisk/utils.h"
 #include "asterisk/heap.h"
+#include "asterisk/test.h"
 
 struct node {
 	long val;
@@ -55,24 +55,32 @@
 	}
 }
 
-static int test1(int fd)
+AST_TEST_DEFINE(heap_test_1)
 {
 	struct ast_heap *h;
 	struct node *obj;
 	struct node nodes[3] = {
-		{ 1, },
-		{ 2, },
-		{ 3, },
+		{ 1, } ,
+		{ 2, } ,
+		{ 3, } ,
 	};
 
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "heap_test_1";
+		info->category = "main/heap/";
+		info->summary = "push and pop elements";
+		info->description = "Push a few elements onto a heap and make sure that they come back off in the right order.";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
 	if (!(h = ast_heap_create(8, node_cmp, offsetof(struct node, index)))) {
-		return -1;
-	}
-
-	/* Pushing 1 2 3, and then popping 3 elements */
-
-	ast_cli(fd, "Test #1 - Push a few elements onto a heap and make sure that they "
-			"come back off in the right order.\n");
+		return AST_TEST_FAIL;
+	}
+
+	ast_test_status_update(&args->status_update, "pushing nodes\n");
 
 	ast_heap_push(h, &nodes[0]);
 
@@ -82,52 +90,59 @@
 
 	obj = ast_heap_pop(h);
 	if (obj->val != 3) {
-		return -2;
-	}
-
+		return AST_TEST_FAIL;
+	}
+
+	ast_test_status_update(&args->status_update, "popping nodes\n");
 	obj = ast_heap_pop(h);
 	if (obj->val != 2) {
-		return -3;
+		return AST_TEST_FAIL;
 	}
 
 	obj = ast_heap_pop(h);
 	if (obj->val != 1) {
-		return -4;
+		return AST_TEST_FAIL;
 	}
 
 	obj = ast_heap_pop(h);
 	if (obj) {
-		return -5;
+		return AST_TEST_FAIL;
 	}
 
 	h = ast_heap_destroy(h);
 
-	ast_cli(fd, "Test #1 successful.\n");
-
-	return 0;
-}
-
-static int test2(int fd)
+	return AST_TEST_PASS;
+}
+
+AST_TEST_DEFINE(heap_test_2)
 {
 	struct ast_heap *h = NULL;
 	static const unsigned int one_million = 1000000;
 	struct node *nodes = NULL;
 	struct node *node;
 	unsigned int i = one_million;
-	long last = LONG_MAX, cur;
-	int res = 0;
-
-	ast_cli(fd, "Test #2 - Push a million random elements on to a heap, "
-			"verify that the heap has been properly constructed, "
-			"and then ensure that the elements are come back off in the proper order\n");
+	long last = LONG_MAX;
+	long cur;
+	enum ast_test_result_state res = AST_TEST_PASS;
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "heap_test_2";
+		info->category = "main/heap/";
+		info->summary = "load test";
+		info->description = "Push a million random elements on to a heap,verify that the heap has been properly constructed, and then ensure that the elements are come back off in the proper order";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
 
 	if (!(nodes = ast_malloc(one_million * sizeof(*node)))) {
-		res = -1;
+		res = AST_TEST_FAIL;
 		goto return_cleanup;
 	}
 
 	if (!(h = ast_heap_create(20, node_cmp, offsetof(struct node, index)))) {
-		res = -2;
+		res = AST_TEST_FAIL;
 		goto return_cleanup;
 	}
 
@@ -137,7 +152,7 @@
 	}
 
 	if (ast_heap_verify(h)) {
-		res = -3;
+		res = AST_TEST_FAIL;
 		goto return_cleanup;
 	}
 
@@ -145,8 +160,8 @@
 	while ((node = ast_heap_pop(h))) {
 		cur = node->val;
 		if (cur > last) {
-			ast_cli(fd, "i: %u, cur: %ld, last: %ld\n", i, cur, last);
-			res = -4;
+			ast_str_set(&args->ast_test_error_str, 0, "i: %u, cur: %ld, last: %ld\n", i, cur, last);
+			res = AST_TEST_FAIL;
 			goto return_cleanup;
 		}
 		last = cur;
@@ -154,12 +169,10 @@
 	}
 
 	if (i != one_million) {
-		ast_cli(fd, "Stopped popping off after only getting %u nodes\n", i);
-		res = -5;
-		goto return_cleanup;
-	}
-
-	ast_cli(fd, "Test #2 successful.\n");
+		ast_str_set(&args->ast_test_error_str, 0, "Stopped popping off after only getting %u nodes\n", i);
+		res = AST_TEST_FAIL;
+		goto return_cleanup;
+	}
 
 return_cleanup:
 	if (h) {
@@ -172,51 +185,20 @@
 	return res;
 }
 
-static char *handle_cli_heap_test(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	int res;
-
-	switch (cmd) {
-	case CLI_INIT:
-		e->command = "heap test";
-		e->usage = ""
-			"Usage: heap test\n"
-			"";
-		return NULL;
-	case CLI_GENERATE:
-		return NULL;
-	}
-
-	if (a->argc != e->args) {
-		return CLI_SHOWUSAGE;
-	}
-
-	if ((res = test1(a->fd))) {
-		ast_cli(a->fd, "Test 1 failed! (%d)\n", res);
-		return CLI_FAILURE;
-	}
-
-	if ((res = test2(a->fd))) {
-		ast_cli(a->fd, "Test 2 failed! (%d)\n", res);
-		return CLI_FAILURE;
-	}
-
-	return CLI_SUCCESS;
-}
-
-static struct ast_cli_entry cli_heap[] = {
-	AST_CLI_DEFINE(handle_cli_heap_test, "Test the heap implementation"),
-};
-
 static int unload_module(void)
 {
-	ast_cli_unregister_multiple(cli_heap, ARRAY_LEN(cli_heap));
+	AST_TEST_UNREGISTER(heap_test_1);
+	AST_TEST_UNREGISTER(heap_test_2);
 	return 0;
 }
 
 static int load_module(void)
 {
-	ast_cli_register_multiple(cli_heap, ARRAY_LEN(cli_heap));
+
+	AST_TEST_REGISTER(heap_test_1);
+
+	AST_TEST_REGISTER(heap_test_2);
+
 	return AST_MODULE_LOAD_SUCCESS;
 }
 




More information about the svn-commits mailing list