[asterisk-commits] dvossel: branch dvossel/sip_uri_encode_decode r242970 - in /team/dvossel/sip_...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 25 15:51:19 CST 2010


Author: dvossel
Date: Mon Jan 25 15:51:15 2010
New Revision: 242970

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=242970
Log:
automerge

Modified:
    team/dvossel/sip_uri_encode_decode/   (props changed)
    team/dvossel/sip_uri_encode_decode/addons/ooh323c/src/ooCalls.c
    team/dvossel/sip_uri_encode_decode/addons/ooh323c/src/oochannels.c
    team/dvossel/sip_uri_encode_decode/addons/ooh323c/src/ooh323.c
    team/dvossel/sip_uri_encode_decode/build_tools/cflags.xml
    team/dvossel/sip_uri_encode_decode/build_tools/menuselect-deps.in
    team/dvossel/sip_uri_encode_decode/configure
    team/dvossel/sip_uri_encode_decode/configure.ac
    team/dvossel/sip_uri_encode_decode/tests/test_ast_format_str_reduce.c
    team/dvossel/sip_uri_encode_decode/tests/test_heap.c
    team/dvossel/sip_uri_encode_decode/tests/test_sched.c
    team/dvossel/sip_uri_encode_decode/tests/test_skel.c
    team/dvossel/sip_uri_encode_decode/tests/test_substitution.c

Propchange: team/dvossel/sip_uri_encode_decode/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/dvossel/sip_uri_encode_decode/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jan 25 15:51:15 2010
@@ -1,1 +1,1 @@
-/trunk:1-242922
+/trunk:1-242969

Modified: team/dvossel/sip_uri_encode_decode/addons/ooh323c/src/ooCalls.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_uri_encode_decode/addons/ooh323c/src/ooCalls.c?view=diff&rev=242970&r1=242969&r2=242970
==============================================================================
--- team/dvossel/sip_uri_encode_decode/addons/ooh323c/src/ooCalls.c (original)
+++ team/dvossel/sip_uri_encode_decode/addons/ooh323c/src/ooCalls.c Mon Jan 25 15:51:15 2010
@@ -371,10 +371,11 @@
 	}
    }
 
-   pctxt = call->msgctxt;
-   freeContext(pctxt);
-   free(pctxt);
-   call->msgctxt = NULL;
+   if ((pctxt = call->msgctxt) != NULL) {
+   	freeContext(pctxt);
+   	free(pctxt);
+   	call->msgctxt = NULL;
+   }
 /* May !!!! Fix it !! */
    /* free(pctxt); */
 

Modified: team/dvossel/sip_uri_encode_decode/addons/ooh323c/src/oochannels.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_uri_encode_decode/addons/ooh323c/src/oochannels.c?view=diff&rev=242970&r1=242969&r2=242970
==============================================================================
--- team/dvossel/sip_uri_encode_decode/addons/ooh323c/src/oochannels.c (original)
+++ team/dvossel/sip_uri_encode_decode/addons/ooh323c/src/oochannels.c Mon Jan 25 15:51:15 2010
@@ -748,8 +748,9 @@
 	    ast_mutex_lock(&call->Lock);
             ooEndCall(call);
 	    ast_mutex_unlock(&call->Lock);
-	    ooStopMonitorCallChannels(call);
      }
+     if(call->callState >= OO_CALL_CLEARED)
+		ooStopMonitorCallChannels(call);
    }
 
    return OO_OK;

Modified: team/dvossel/sip_uri_encode_decode/addons/ooh323c/src/ooh323.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_uri_encode_decode/addons/ooh323c/src/ooh323.c?view=diff&rev=242970&r1=242969&r2=242970
==============================================================================
--- team/dvossel/sip_uri_encode_decode/addons/ooh323c/src/ooh323.c (original)
+++ team/dvossel/sip_uri_encode_decode/addons/ooh323c/src/ooh323.c Mon Jan 25 15:51:15 2010
@@ -1594,6 +1594,8 @@
          	ooSendCallProceeding(call);/* Send call proceeding message*/
          	ret = ooH323CallAdmitted (call);
 	  }
+
+	 call->callState = OO_CALL_CONNECTING;
 
 	 } /* end ret == OO_OK */
          break;

Modified: team/dvossel/sip_uri_encode_decode/build_tools/cflags.xml
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_uri_encode_decode/build_tools/cflags.xml?view=diff&rev=242970&r1=242969&r2=242970
==============================================================================
--- team/dvossel/sip_uri_encode_decode/build_tools/cflags.xml (original)
+++ team/dvossel/sip_uri_encode_decode/build_tools/cflags.xml Mon Jan 25 15:51:15 2010
@@ -9,6 +9,11 @@
 			<defaultenabled>yes</defaultenabled>
 		</member>
 		<member name="DEBUG_FD_LEAKS" displayname="Enable File Descriptor Leak Detection">
+		</member>
+		<member name="REBUILD_PARSERS" displayname="Rebuild AEL and expression parsers from bison/flex source files">
+			<depend>bison</depend>
+			<depend>flex</depend>
+			<defaultenabled>no</defaultenabled>
 		</member>
 		<member name="LOW_MEMORY" displayname="Optimize for Low Memory Usage">
 		</member>

Modified: team/dvossel/sip_uri_encode_decode/build_tools/menuselect-deps.in
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_uri_encode_decode/build_tools/menuselect-deps.in?view=diff&rev=242970&r1=242969&r2=242970
==============================================================================
--- team/dvossel/sip_uri_encode_decode/build_tools/menuselect-deps.in (original)
+++ team/dvossel/sip_uri_encode_decode/build_tools/menuselect-deps.in Mon Jan 25 15:51:15 2010
@@ -1,8 +1,10 @@
 ALSA=@PBX_ALSA@
 BLUETOOTH=@PBX_BLUETOOTH@
 CRYPTO=@PBX_CRYPTO@
+BISON=@PBX_BISON@
 CURL=@PBX_CURL@
 DAHDI=@PBX_DAHDI@
+FLEX=@PBX_FLEX@
 FREETDS=@PBX_FREETDS@
 GENERIC_ODBC=@PBX_GENERIC_ODBC@
 GMIME=@PBX_GMIME@

Modified: team/dvossel/sip_uri_encode_decode/configure.ac
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_uri_encode_decode/configure.ac?view=diff&rev=242970&r1=242969&r2=242970
==============================================================================
--- team/dvossel/sip_uri_encode_decode/configure.ac (original)
+++ team/dvossel/sip_uri_encode_decode/configure.ac Mon Jan 25 15:51:15 2010
@@ -241,7 +241,17 @@
 	])
 if test "x${ac_cv_path_BISON2}" = "x" ; then
 	BISON=:
-fi
+	PBX_BISON=0
+else
+	PBX_BISON=1
+fi
+AC_SUBST(PBX_BISON)
+if test "x${FLEX}" = "x:" ; then
+	PBX_FLEX=0
+else
+	PBX_FLEX=1
+fi
+AC_SUBST(PBX_FLEX)
 
 AC_CHECK_TOOL([SOXMIX], [soxmix], [:])
 if test "${SOXMIX}" != ":" ; then

Modified: team/dvossel/sip_uri_encode_decode/tests/test_ast_format_str_reduce.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_uri_encode_decode/tests/test_ast_format_str_reduce.c?view=diff&rev=242970&r1=242969&r2=242970
==============================================================================
--- team/dvossel/sip_uri_encode_decode/tests/test_ast_format_str_reduce.c (original)
+++ team/dvossel/sip_uri_encode_decode/tests/test_ast_format_str_reduce.c Mon Jan 25 15:51:15 2010
@@ -24,7 +24,7 @@
  */
 
 /*** MODULEINFO
-	<defaultenabled>no</defaultenabled>
+	<depend>TEST_FRAMEWORK</depend>
  ***/
 
 #include "asterisk.h"

Modified: team/dvossel/sip_uri_encode_decode/tests/test_heap.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_uri_encode_decode/tests/test_heap.c?view=diff&rev=242970&r1=242969&r2=242970
==============================================================================
--- team/dvossel/sip_uri_encode_decode/tests/test_heap.c (original)
+++ team/dvossel/sip_uri_encode_decode/tests/test_heap.c Mon Jan 25 15:51:15 2010
@@ -24,7 +24,7 @@
  */
 
 /*** MODULEINFO
-	<defaultenabled>no</defaultenabled>
+	<depend>TEST_FRAMEWORK</depend>
  ***/
 
 #include "asterisk.h"

Modified: team/dvossel/sip_uri_encode_decode/tests/test_sched.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_uri_encode_decode/tests/test_sched.c?view=diff&rev=242970&r1=242969&r2=242970
==============================================================================
--- team/dvossel/sip_uri_encode_decode/tests/test_sched.c (original)
+++ team/dvossel/sip_uri_encode_decode/tests/test_sched.c Mon Jan 25 15:51:15 2010
@@ -24,7 +24,7 @@
  */
 
 /*** MODULEINFO
-	<defaultenabled>no</defaultenabled>
+	<depend>TEST_FRAMEWORK</depend>
  ***/
 
 #include "asterisk.h"

Modified: team/dvossel/sip_uri_encode_decode/tests/test_skel.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_uri_encode_decode/tests/test_skel.c?view=diff&rev=242970&r1=242969&r2=242970
==============================================================================
--- team/dvossel/sip_uri_encode_decode/tests/test_skel.c (original)
+++ team/dvossel/sip_uri_encode_decode/tests/test_skel.c Mon Jan 25 15:51:15 2010
@@ -27,7 +27,7 @@
  */
 
 /*** MODULEINFO
-	<defaultenabled>no</defaultenabled>
+	<depend>TEST_FRAMEWORK</depend>
  ***/
 
 #include "asterisk.h"

Modified: team/dvossel/sip_uri_encode_decode/tests/test_substitution.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_uri_encode_decode/tests/test_substitution.c?view=diff&rev=242970&r1=242969&r2=242970
==============================================================================
--- team/dvossel/sip_uri_encode_decode/tests/test_substitution.c (original)
+++ team/dvossel/sip_uri_encode_decode/tests/test_substitution.c Mon Jan 25 15:51:15 2010
@@ -26,7 +26,7 @@
  */
 
 /*** MODULEINFO
-	<defaultenabled>no</defaultenabled>
+	<depend>TEST_FRAMEWORK</depend>
  ***/
 
 #include "asterisk.h"
@@ -42,57 +42,66 @@
 #include "asterisk/strings.h"
 #include "asterisk/stringfields.h"
 #include "asterisk/threadstorage.h"
-#include "asterisk/cli.h"
-
-AST_THREADSTORAGE(buf_buf);
-AST_THREADSTORAGE(var_buf);
-
-static void test_chan_integer(int fd, struct ast_channel *c, int *ifield, const char *expression)
+#include "asterisk/test.h"
+
+static enum ast_test_result_state test_chan_integer(void *status, struct ast_str **err,
+		struct ast_channel *c, int *ifield, const char *expression)
 {
 	int i, okay = 1, value1 = -1, value2 = -1;
 	char workspace[4096];
-	struct ast_str *str = ast_str_thread_get(&buf_buf, 16);
+	struct ast_str *str = ast_str_create(16);
 
 	for (i = 0; i < 256; i++) {
 		*ifield = i;
 		ast_str_substitute_variables(&str, 0, c, expression);
 		pbx_substitute_variables_helper(c, expression, workspace, sizeof(workspace));
 		if (sscanf(workspace, "%d", &value1) != 1 || value1 != i || sscanf(ast_str_buffer(str), "%d", &value2) != 1 || value2 != i) {
-			ast_cli(fd, "%s != %s and/or %d != %d != %d\n", ast_str_buffer(str), workspace, value1, value2, i);
+			ast_str_set(err, 0, "%s != %s and/or %d != %d != %d\n", ast_str_buffer(str), workspace, value1, value2, i);
 			okay = 0;
 			break;
 		}
 	}
-	ast_cli(fd, "Testing '%s' . . . . . %s\n", expression, okay ? "passed" : "FAILED");
-}
-
-static void test_chan_string(int fd, struct ast_channel *c, char *cfield, size_t cfieldsize, const char *expression)
+	ast_test_status_update(status, "Testing '%s' . . . . . %s\n", expression, okay ? "passed" : "FAILED");
+
+	ast_free(str);
+
+	return okay ? AST_TEST_PASS : AST_TEST_FAIL;
+}
+
+static enum ast_test_result_state test_chan_string(void *status, struct ast_str **err,
+		struct ast_channel *c, char *cfield, size_t cfieldsize,
+		const char *expression)
 {
 	const char *values[] = { "one", "three", "reallylongdinosaursoundingthingwithwordsinit" };
 	int i, okay = 1;
 	char workspace[4096];
-	struct ast_str *str = ast_str_thread_get(&buf_buf, 16);
+	struct ast_str *str = ast_str_create(16);
 
 	for (i = 0; i < ARRAY_LEN(values); i++) {
 		ast_copy_string(cfield, values[i], cfieldsize);
 		ast_str_substitute_variables(&str, 0, c, expression);
 		pbx_substitute_variables_helper(c, expression, workspace, sizeof(workspace));
 		if (strcmp(cfield, ast_str_buffer(str)) != 0 || strcmp(cfield, workspace) != 0) {
-			ast_cli(fd, "%s != %s != %s\n", cfield, ast_str_buffer(str), workspace);
+			ast_str_set(err, 0, "%s != %s != %s\n", cfield, ast_str_buffer(str), workspace);
 			okay = 0;
 			break;
 		}
 	}
-	ast_cli(fd, "Testing '%s' . . . . . %s\n", expression, okay ? "passed" : "FAILED");
-}
-
-static void test_chan_variable(int fd, struct ast_channel *c, const char *varname)
+	ast_test_status_update(status, "Testing '%s' . . . . . %s\n", expression, okay ? "passed" : "FAILED");
+
+	ast_free(str);
+
+	return okay ? AST_TEST_PASS : AST_TEST_FAIL;
+}
+
+static enum ast_test_result_state test_chan_variable(void *status, struct ast_str **err,
+		struct ast_channel *c, const char *varname)
 {
 	const char *values[] = { "one", "three", "reallylongdinosaursoundingthingwithwordsinit" };
 	int i, okay = 1;
 	char workspace[4096];
-	struct ast_str *str = ast_str_thread_get(&buf_buf, 16);
-	struct ast_str *var = ast_str_thread_get(&var_buf, 16);
+	struct ast_str *str = ast_str_create(16);
+	struct ast_str *var = ast_str_create(16);
 
 	ast_str_set(&var, 0, "${%s}", varname);
 	for (i = 0; i < ARRAY_LEN(values); i++) {
@@ -100,118 +109,167 @@
 		ast_str_substitute_variables(&str, 0, c, ast_str_buffer(var));
 		pbx_substitute_variables_helper(c, ast_str_buffer(var), workspace, sizeof(workspace));
 		if (strcmp(values[i], ast_str_buffer(str)) != 0 || strcmp(values[i], workspace) != 0) {
-			ast_cli(fd, "%s != %s != %s\n", values[i], ast_str_buffer(str), workspace);
+			ast_str_set(err, 0, "%s != %s != %s\n", values[i], ast_str_buffer(str), workspace);
 			okay = 0;
 			break;
 		}
 	}
-	ast_cli(fd, "Testing '%s' . . . . . %s\n", ast_str_buffer(var), okay ? "passed" : "FAILED");
-}
-
-static void test_chan_function(int fd, struct ast_channel *c, const char *expression)
+	ast_test_status_update(status, "Testing '%s' . . . . . %s\n", ast_str_buffer(var), okay ? "passed" : "FAILED");
+
+	ast_free(str);
+	ast_free(var);
+
+	return okay ? AST_TEST_PASS : AST_TEST_FAIL;
+}
+
+static enum ast_test_result_state test_chan_function(void *status, struct ast_str **err,
+		struct ast_channel *c, const char *expression)
 {
 	int okay = 1;
 	char workspace[4096];
-	struct ast_str *str = ast_str_thread_get(&buf_buf, 16);
+	struct ast_str *str = ast_str_create(16);
 
 	ast_str_substitute_variables(&str, 0, c, expression);
 	pbx_substitute_variables_helper(c, expression, workspace, sizeof(workspace));
 	if (strcmp(workspace, ast_str_buffer(str)) != 0) {
-		ast_cli(fd, "%s != %s\n", ast_str_buffer(str), workspace);
+		ast_str_set(err, 0, "test_chan_function, expr: '%s' ... %s != %s\n",
+				expression, ast_str_buffer(str), workspace);
 		okay = 0;
 	}
-	ast_cli(fd, "Testing '%s' . . . . . %s\n", expression, okay ? "passed" : "FAILED");
-}
-
-static void test_2way_function(int fd, struct ast_channel *c, const char *encode1, const char *encode2, const char *decode1, const char *decode2)
-{
-	struct ast_str *str = ast_str_thread_get(&buf_buf, 16), *expression = ast_str_alloca(120);
+	ast_test_status_update(status, "Testing '%s' . . . . . %s\n", expression, okay ? "passed" : "FAILED");
+
+	ast_free(str);
+
+	return okay ? AST_TEST_PASS : AST_TEST_FAIL;
+}
+
+static enum ast_test_result_state test_2way_function(void *status, struct ast_str **err,
+		struct ast_channel *c, const char *encode1, const char *encode2,
+		const char *decode1, const char *decode2)
+{
+	struct ast_str *str = ast_str_create(16), *expression = ast_str_alloca(120);
+	int okay;
 
 	ast_str_set(&expression, 0, "%s%s%s", encode1, "foobarbaz", encode2);
 	ast_str_substitute_variables(&str, 0, c, ast_str_buffer(expression));
 	ast_str_set(&expression, 0, "%s%s%s", decode1, ast_str_buffer(str), decode2);
 	ast_str_substitute_variables(&str, 0, c, ast_str_buffer(expression));
-	ast_cli(fd, "Testing '%s%s' and '%s%s' . . . . . %s\n", encode1, encode2, decode1, decode2, !strcmp(ast_str_buffer(str), "foobarbaz") ? "passed" : "FAILED");
-	if (strcmp(ast_str_buffer(str), "foobarbaz")) {
-		ast_cli(fd, "  '%s' != 'foobarbaz'\n", ast_str_buffer(str));
-	}
-}
-
-static void test_expected_result(int fd, struct ast_channel *c, const char *expression, const char *result)
-{
-	struct ast_str *str = ast_str_thread_get(&buf_buf, 16);
+
+	okay = !strcmp(ast_str_buffer(str), "foobarbaz");
+
+	ast_test_status_update(status, "Testing '%s%s' and '%s%s' . . . . . %s\n", 
+			encode1, encode2, decode1, decode2, 
+			okay ? "passed" : "FAILED");
+
+	if (!okay) {
+		ast_str_set(err, 0, "  '%s' != 'foobarbaz'\n", ast_str_buffer(str));
+	}
+
+	ast_free(str);
+
+	return okay ? AST_TEST_PASS : AST_TEST_FAIL;
+}
+
+static enum ast_test_result_state test_expected_result(void *status, struct ast_str **err,
+		struct ast_channel *c, const char *expression, const char *result)
+{
+	struct ast_str *str = ast_str_create(16);
+	int okay;
+
 	ast_str_substitute_variables(&str, 0, c, expression);
-	ast_cli(fd, "Testing '%s' ('%s') == '%s' . . . . . %s\n", ast_str_buffer(str), expression, result, !strcmp(ast_str_buffer(str), result) ? "passed" : "FAILED");
-}
-
-static char *handle_cli_test_substitution(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+	okay = !strcmp(ast_str_buffer(str), result);
+
+	ast_test_status_update(status, "Testing '%s' ('%s') == '%s' . . . . . %s\n",
+			ast_str_buffer(str), expression, result,
+			okay ? "passed" : "FAILED");
+
+	if (!okay) {
+		ast_test_status_update(status, "test_expected_result: '%s' != '%s'\n",
+				ast_str_buffer(str), result);
+	}
+
+	ast_free(str);
+
+	return okay ? AST_TEST_PASS : AST_TEST_FAIL;
+}
+
+AST_TEST_DEFINE(test_substitution)
 {
 	struct ast_channel *c;
 	int i;
+	enum ast_test_result_state res = AST_TEST_PASS;
 
 	switch (cmd) {
-	case CLI_INIT:
-		e->command = "test substitution";
-		e->usage = ""
-			"Usage: test substitution\n"
-			"   Test variable and function substitution.\n";
-		return NULL;
-	case CLI_GENERATE:
-		return NULL;
-	}
-
-	if (a->argc != e->args) {
-		return CLI_SHOWUSAGE;
-	}
-
-	ast_cli(a->fd, "Testing variable substitution ...\n");
+	case TEST_INIT:
+		info->name = "test_substitution";
+		info->category = "main/pbx/";
+		info->summary = "Test variable and function substitution";
+		info->description =
+			"This test executes a variety of variable and function substitutions "
+			"and ensures that the expected results are received.";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	ast_test_status_update(&args->status_update, "Testing variable substitution ...\n");
+
 	c = ast_dummy_channel_alloc();
 
-	test_chan_integer(a->fd, c, &c->cid.cid_pres, "${CALLINGPRES}");
-	test_chan_integer(a->fd, c, &c->cid.cid_ani2, "${CALLINGANI2}");
-	test_chan_integer(a->fd, c, &c->cid.cid_ton, "${CALLINGTON}");
-	test_chan_integer(a->fd, c, &c->cid.cid_tns, "${CALLINGTNS}");
-	test_chan_integer(a->fd, c, &c->hangupcause, "${HANGUPCAUSE}");
-	test_chan_integer(a->fd, c, &c->priority, "${PRIORITY}");
-	test_chan_string(a->fd, c, c->context, sizeof(c->context), "${CONTEXT}");
-	test_chan_string(a->fd, c, c->exten, sizeof(c->exten), "${EXTEN}");
-	test_chan_variable(a->fd, c, "CHANNEL(language)");
-	test_chan_variable(a->fd, c, "CHANNEL(musicclass)");
-	test_chan_variable(a->fd, c, "CHANNEL(parkinglot)");
-	test_chan_variable(a->fd, c, "CALLERID(name)");
-	test_chan_variable(a->fd, c, "CURLOPT(proxyuserpwd)");
-	test_chan_variable(a->fd, c, "CDR(foo)");
-	test_chan_variable(a->fd, c, "ENV(foo)");
-	test_chan_variable(a->fd, c, "GLOBAL(foo)");
-	test_chan_variable(a->fd, c, "GROUP()");
-	test_2way_function(a->fd, c, "${AES_ENCRYPT(abcdefghijklmnop,", ")}", "${AES_DECRYPT(abcdefghijklmnop,", ")}");
-	test_2way_function(a->fd, c, "${BASE64_ENCODE(", ")}", "${BASE64_DECODE(", ")}");
-	pbx_builtin_setvar_helper(c, "foo", "123");
-	pbx_builtin_setvar_helper(c, "bar", "foo");
-	pbx_builtin_setvar_helper(c, "baz", "fo");
-	test_expected_result(a->fd, c, "${foo}${foo}", "123123");
-	test_expected_result(a->fd, c, "A${foo}A${foo}A", "A123A123A");
-	test_expected_result(a->fd, c, "A${${bar}}A", "A123A");
-	test_expected_result(a->fd, c, "A${${baz}o}A", "A123A");
-	test_expected_result(a->fd, c, "A${${baz}o:1}A", "A23A");
-	test_expected_result(a->fd, c, "A${${baz}o:1:1}A", "A2A");
-	test_expected_result(a->fd, c, "A${${baz}o:1:-1}A", "A2A");
-	test_expected_result(a->fd, c, "A${${baz}o:-1:1}A", "A3A");
-	test_expected_result(a->fd, c, "A${${baz}o:-2:1}A", "A2A");
-	test_expected_result(a->fd, c, "A${${baz}o:-2:-1}A", "A2A");
+	do {
+#define TEST(t) if ((res = t) == AST_TEST_FAIL) { break; }
+	TEST(test_chan_integer(&args->status_update, &args->ast_test_error_str, c, &c->cid.cid_pres, "${CALLINGPRES}"));
+	TEST(test_chan_integer(&args->status_update, &args->ast_test_error_str, c, &c->cid.cid_ani2, "${CALLINGANI2}"));
+	TEST(test_chan_integer(&args->status_update, &args->ast_test_error_str, c, &c->cid.cid_ton, "${CALLINGTON}"));
+	TEST(test_chan_integer(&args->status_update, &args->ast_test_error_str, c, &c->cid.cid_tns, "${CALLINGTNS}"));
+	TEST(test_chan_integer(&args->status_update, &args->ast_test_error_str, c, &c->hangupcause, "${HANGUPCAUSE}"));
+	TEST(test_chan_integer(&args->status_update, &args->ast_test_error_str, c, &c->priority, "${PRIORITY}"));
+	TEST(test_chan_string(&args->status_update, &args->ast_test_error_str, c, c->context, sizeof(c->context), "${CONTEXT}"));
+	TEST(test_chan_string(&args->status_update, &args->ast_test_error_str, c, c->exten, sizeof(c->exten), "${EXTEN}"));
+	TEST(test_chan_variable(&args->status_update, &args->ast_test_error_str, c, "CHANNEL(language)"));
+	TEST(test_chan_variable(&args->status_update, &args->ast_test_error_str, c, "CHANNEL(musicclass)"));
+	TEST(test_chan_variable(&args->status_update, &args->ast_test_error_str, c, "CHANNEL(parkinglot)"));
+	TEST(test_chan_variable(&args->status_update, &args->ast_test_error_str, c, "CALLERID(name)"));
+	TEST(test_chan_variable(&args->status_update, &args->ast_test_error_str, c, "CURLOPT(proxyuserpwd)"));
+	TEST(test_chan_variable(&args->status_update, &args->ast_test_error_str, c, "CDR(foo)"));
+	TEST(test_chan_variable(&args->status_update, &args->ast_test_error_str, c, "ENV(foo)"));
+	TEST(test_chan_variable(&args->status_update, &args->ast_test_error_str, c, "GLOBAL(foo)"));
+	TEST(test_chan_variable(&args->status_update, &args->ast_test_error_str, c, "GROUP()"));
+	TEST(test_2way_function(&args->status_update, &args->ast_test_error_str, c, "${AES_ENCRYPT(abcdefghijklmnop,", ")}", "${AES_DECRYPT(abcdefghijklmnop,", ")}"));
+	TEST(test_2way_function(&args->status_update, &args->ast_test_error_str, c, "${BASE64_ENCODE(", ")}", "${BASE64_DECODE(", ")}"));
+	pbx_builtin_setvar_helper(c, "foo&args->ast_test_error_str, ", "123");
+	pbx_builtin_setvar_helper(c, "bar&args->ast_test_error_str, ", "foo");
+	pbx_builtin_setvar_helper(c, "baz&args->ast_test_error_str, ", "fo");
+	TEST(test_expected_result(&args->status_update, &args->ast_test_error_str, c, "${foo}${foo}", "123123"));
+	TEST(test_expected_result(&args->status_update, &args->ast_test_error_str, c, "A${foo}A${foo}A", "A123A123A"));
+	TEST(test_expected_result(&args->status_update, &args->ast_test_error_str, c, "A${${bar}}A", "A123A"));
+	TEST(test_expected_result(&args->status_update, &args->ast_test_error_str, c, "A${${baz}o}A", "A123A"));
+	TEST(test_expected_result(&args->status_update, &args->ast_test_error_str, c, "A${${baz}o:1}A", "A23A"));
+	TEST(test_expected_result(&args->status_update, &args->ast_test_error_str, c, "A${${baz}o:1:1}A", "A2A"));
+	TEST(test_expected_result(&args->status_update, &args->ast_test_error_str, c, "A${${baz}o:1:-1}A", "A2A"));
+	TEST(test_expected_result(&args->status_update, &args->ast_test_error_str, c, "A${${baz}o:-1:1}A", "A3A"));
+	TEST(test_expected_result(&args->status_update, &args->ast_test_error_str, c, "A${${baz}o:-2:1}A", "A2A"));
+	TEST(test_expected_result(&args->status_update, &args->ast_test_error_str, c, "A${${baz}o:-2:-1}A", "A2A"));
+#undef TEST
+	} while (0);
 
 	/* For testing dialplan functions */
-	for (i = 0; ; i++) {
+	for (i = 0; res != AST_TEST_PASS; i++) {
 		char *cmd = ast_cli_generator("core show function", "", i);
 		if (cmd == NULL) {
 			break;
 		}
-		if (strcmp(cmd, "CHANNEL") && strcmp(cmd, "CALLERID") && strcmp(cmd, "CURLOPT") && strncmp(cmd, "AES", 3) && strncmp(cmd, "BASE64", 6) && strcmp(cmd, "CDR") && strcmp(cmd, "ENV") && strcmp(cmd, "GLOBAL") && strcmp(cmd, "GROUP") && strcmp(cmd, "CUT") && strcmp(cmd, "LISTFILTER") && strcmp(cmd, "PP_EACH_EXTENSION") && strcmp(cmd, "SET")) {
+		if (strcmp(cmd, "CHANNEL") && strcmp(cmd, "CALLERID") && strcmp(cmd, "CURLOPT") &&
+				strncmp(cmd, "AES", 3) && strncmp(cmd, "BASE64", 6) &&
+				strcmp(cmd, "CDR") && strcmp(cmd, "ENV") && strcmp(cmd, "GLOBAL") &&
+				strcmp(cmd, "GROUP") && strcmp(cmd, "CUT") && strcmp(cmd, "LISTFILTER") &&
+				strcmp(cmd, "PP_EACH_EXTENSION") && strcmp(cmd, "SET")) {
 			struct ast_custom_function *acf = ast_custom_function_find(cmd);
 			if (acf->read && acf->read2) {
 				char expression[80];
 				snprintf(expression, sizeof(expression), "${%s(foo)}", cmd);
-				test_chan_function(a->fd, c, expression);
+				res = test_chan_function(&args->status_update,
+						&args->ast_test_error_str,c, expression);
 			}
 		}
 		ast_free(cmd);
@@ -219,22 +277,18 @@
 
 	ast_channel_release(c);
 
-	return CLI_SUCCESS;
-}
-
-static struct ast_cli_entry cli_substitution[] = {
-	AST_CLI_DEFINE(handle_cli_test_substitution, "Test variable substitution"),
-};
+	return res;
+}
 
 static int unload_module(void)
 {
-	ast_cli_unregister_multiple(cli_substitution, ARRAY_LEN(cli_substitution));
+	AST_TEST_UNREGISTER(test_substitution);
 	return 0;
 }
 
 static int load_module(void)
 {
-	ast_cli_register_multiple(cli_substitution, ARRAY_LEN(cli_substitution));
+	AST_TEST_REGISTER(test_substitution);
 	return AST_MODULE_LOAD_SUCCESS;
 }
 




More information about the asterisk-commits mailing list