[asterisk-commits] twilson: trunk r356397 - in /trunk/tests: test_substitution.c test_utils.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 22 19:53:21 CST 2012


Author: twilson
Date: Wed Feb 22 19:53:17 2012
New Revision: 356397

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=356397
Log:
Fix some tests that didn't get opaquification changes

Review: https://reviewboard.asterisk.org/r/1766/

Modified:
    trunk/tests/test_substitution.c
    trunk/tests/test_utils.c

Modified: trunk/tests/test_substitution.c
URL: http://svnview.digium.com/svn/asterisk/trunk/tests/test_substitution.c?view=diff&rev=356397&r1=356396&r2=356397
==============================================================================
--- trunk/tests/test_substitution.c (original)
+++ trunk/tests/test_substitution.c Wed Feb 22 19:53:17 2012
@@ -56,6 +56,29 @@
 	ast_test_status_update(test, "Testing '%s' . . . . . %s\n", expression, okay ? "passed" : "FAILED");
 	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_test_status_update(test, "%s != %s and/or %d != %d != %d\n", ast_str_buffer(str), workspace, value1, value2, i);
+			okay = 0;
+		}
+	}
+
+	ast_free(str);
+
+	return okay ? AST_TEST_PASS : AST_TEST_FAIL;
+}
+
+static enum ast_test_result_state test_chan_integer_accessor(struct ast_test *test,
+		struct ast_channel *c, void (*setter)(struct ast_channel *, int),const char *expression)
+{
+	int i, okay = 1, value1 = -1, value2 = -1;
+	char workspace[4096];
+	struct ast_str *str = ast_str_create(16);
+
+	ast_test_status_update(test, "Testing '%s' . . . . . %s\n", expression, okay ? "passed" : "FAILED");
+	for (i = 0; i < 256; i++) {
+		setter(c, 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) {
@@ -232,8 +255,8 @@
 	TEST(test_chan_integer(test, c, &c->caller.ani2, "${CALLINGANI2}"));
 	TEST(test_chan_integer(test, c, &c->caller.id.number.plan, "${CALLINGTON}"));
 	TEST(test_chan_integer(test, c, &c->dialed.transit_network_select, "${CALLINGTNS}"));
-	TEST(test_chan_integer(test, c, &c->hangupcause, "${HANGUPCAUSE}"));
-	TEST(test_chan_integer(test, c, &c->priority, "${PRIORITY}"));
+	TEST(test_chan_integer_accessor(test, c, ast_channel_hangupcause_set, "${HANGUPCAUSE}"));
+	TEST(test_chan_integer_accessor(test, c, ast_channel_priority_set, "${PRIORITY}"));
 	TEST(test_chan_string(test, c, ast_channel_context_set, ast_channel_context, "${CONTEXT}"));
 	TEST(test_chan_string(test, c, ast_channel_exten_set, ast_channel_exten, "${EXTEN}"));
 	TEST(test_chan_variable(test, c, "CHANNEL(language)"));

Modified: trunk/tests/test_utils.c
URL: http://svnview.digium.com/svn/asterisk/trunk/tests/test_utils.c?view=diff&rev=356397&r1=356396&r2=356397
==============================================================================
--- trunk/tests/test_utils.c (original)
+++ trunk/tests/test_utils.c Wed Feb 22 19:53:17 2012
@@ -341,7 +341,8 @@
 
 AST_TEST_DEFINE(adsi_loaded_test)
 {
-	struct ast_channel c = { .adsicpe = AST_ADSI_AVAILABLE, };
+	struct ast_channel *c;
+	int res;
 	switch (cmd) {
 	case TEST_INIT:
 		info->name = "adsi_loaded_test";
@@ -353,7 +354,13 @@
 		break;
 	}
 
-	return ast_adsi_available(&c) ? AST_TEST_PASS : AST_TEST_FAIL;
+	if (!(c = ast_dummy_channel_alloc())) {
+		return AST_TEST_FAIL;
+	}
+	ast_channel_adsicpe_set(c, AST_ADSI_AVAILABLE);
+	res = ast_adsi_available(c) ? AST_TEST_PASS : AST_TEST_FAIL;
+	c = ast_channel_unref(c);
+	return res;
 }
 
 static int handle_noop(struct ast_channel *chan, AGI *agi, int arg, const char * const argv[])




More information about the asterisk-commits mailing list