[svn-commits] dvossel: branch dvossel/fixtheworld_phase1_step1 r298595 - in /team/dvossel/f...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Dec 16 18:17:20 UTC 2010


Author: dvossel
Date: Thu Dec 16 12:17:16 2010
New Revision: 298595

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=298595
Log:
update to Ast Format API unit test

Modified:
    team/dvossel/fixtheworld_phase1_step1/main/format_cap.c
    team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c

Modified: team/dvossel/fixtheworld_phase1_step1/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step1/main/format_cap.c?view=diff&rev=298595&r1=298594&r2=298595
==============================================================================
--- team/dvossel/fixtheworld_phase1_step1/main/format_cap.c (original)
+++ team/dvossel/fixtheworld_phase1_step1/main/format_cap.c Thu Dec 16 12:17:16 2010
@@ -49,7 +49,7 @@
 	int res = ast_format_cmp(format1, format2);
 
 	return ((res == AST_FORMAT_CMP_SAME) ||
-			(res = AST_FORMAT_CMP_SUBSET)) ?
+			(res == AST_FORMAT_CMP_SUBSET)) ?
 				CMP_MATCH | CMP_STOP :
 				0;
 }
@@ -170,6 +170,8 @@
 	 * compatible with cap2. If so copy it to the result */
 	it = ao2_iterator_init(cap1->formats, 0);
 	while ((tmp = ao2_iterator_next(&it))) {
+
+//todohere, This is wrong.  we need to be using ast_format_joint here
 		if (ast_cap_iscompatible(cap2, tmp)) {
 			/* copy joint format */
 			ast_cap_add(result, tmp);

Modified: team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c?view=diff&rev=298595&r1=298594&r2=298595
==============================================================================
--- team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c (original)
+++ team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c Thu Dec 16 12:17:16 2010
@@ -84,7 +84,7 @@
 	struct test_attr *attr_res = (struct test_attr *) result;
 	int joint = -1;
 
-	attr_res->samp_flags = attr1->samp_flags & attr2->samp_flags;
+	attr_res->samp_flags = (attr1->samp_flags & attr2->samp_flags);
 
 	if (attr_res->samp_flags) {
 		joint = 0;
@@ -304,7 +304,7 @@
 	struct ast_format tmpformat = { 0, };
 	struct ast_cap *cap1;
 	struct ast_cap *cap2;
-//	struct ast_cap *cap_joint;
+	struct ast_cap *cap_joint;
 
 	switch (cmd) {
 	case TEST_INIT:
@@ -365,13 +365,71 @@
 		return AST_TEST_FAIL;
 	}
 
-	//todohere start working on stuff here.
 	/* Test compatiblity with format with attributes. */
-
-
+	if (!ast_cap_iscompatible(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_TESTLAW, 1,
+			TEST_ATTR_KEY_STRING, "testing caps hooray",
+			TEST_ATTR_KEY_SAMP_RATE, TEST_ATTR_VAL_SAMP_8KHZ,
+			TEST_ATTR_KEY_SAMP_RATE, TEST_ATTR_VAL_SAMP_16KHZ,
+			AST_FORMATNEW_ATTR_END))) {
+
+		ast_test_status_update(test, "ast cap1 failed to properly detect compatibility test 3.\n");
+		return AST_TEST_FAIL;
+	}
+	if (!ast_cap_iscompatible(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_TESTLAW, 1,
+			TEST_ATTR_KEY_SAMP_RATE, TEST_ATTR_VAL_SAMP_8KHZ,
+			AST_FORMATNEW_ATTR_END))) {
+
+		ast_test_status_update(test, "ast cap1 failed to properly detect compatibility test 4.\n");
+		return AST_TEST_FAIL;
+	}
+	if (ast_cap_iscompatible(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_TESTLAW, 1,
+			TEST_ATTR_KEY_SAMP_RATE, TEST_ATTR_VAL_SAMP_8KHZ,
+			TEST_ATTR_KEY_SAMP_RATE, TEST_ATTR_VAL_SAMP_48KHZ, /* 48khz was not compatible, so this should fail iscompatible check */
+			AST_FORMATNEW_ATTR_END))) {
+
+		ast_test_status_update(test, "ast cap1 failed to properly detect compatibility test 5.\n");
+		return AST_TEST_FAIL;
+	}
+
+	/* Lets start testing the functions that compare ast_cap objects.
+	 * Genreate the cap2 object to contain some similar formats as cap1
+	 * and some different formats as well. */
+	ast_cap_add(cap2, ast_format_set(&tmpformat, AST_FORMATNEW_GSM, 0));
+	ast_cap_add(cap2, ast_format_set(&tmpformat, AST_FORMATNEW_ULAW, 0));
+	ast_cap_add(cap2, ast_format_set(&tmpformat, AST_FORMATNEW_SIREN7, 0));
+	ast_cap_add(cap2, ast_format_set(&tmpformat, AST_FORMATNEW_H261, 0));
+	ast_cap_add(cap2, ast_format_set(&tmpformat, AST_FORMATNEW_T140, 0));
+	ast_cap_add(cap2, ast_format_set(&tmpformat, AST_FORMATNEW_TESTLAW, 1,
+			TEST_ATTR_KEY_STRING, "testing caps hooray",
+			TEST_ATTR_KEY_SAMP_RATE, TEST_ATTR_VAL_SAMP_16KHZ,
+			TEST_ATTR_KEY_SAMP_RATE, TEST_ATTR_VAL_SAMP_48KHZ,
+			AST_FORMATNEW_ATTR_END));
+
+
+	/* find joint formats between cap1 and cap2 */
+	cap_joint = ast_cap_joint(cap1, cap2);
+
+	if (!cap_joint) {
+		ast_test_status_update(test, "failed to create joint capabilities correctly.\n");
+		return AST_TEST_FAIL;
+	}
+	/* determine if cap_joint is what we think it should be */
+	if (!ast_cap_iscompatible(cap_joint, ast_format_set(&tmpformat, AST_FORMATNEW_GSM, 0)) ||
+		!ast_cap_iscompatible(cap_joint, ast_format_set(&tmpformat, AST_FORMATNEW_ULAW, 0)) ||
+		!ast_cap_iscompatible(cap_joint, ast_format_set(&tmpformat, AST_FORMATNEW_T140, 0)) ||
+		!ast_cap_iscompatible(cap_joint, ast_format_set(&tmpformat, AST_FORMATNEW_TESTLAW, 1,
+			TEST_ATTR_KEY_STRING, "testing caps hooray",
+			TEST_ATTR_KEY_SAMP_RATE, TEST_ATTR_VAL_SAMP_8KHZ,
+			AST_FORMATNEW_ATTR_END))) {
+
+//todohere MAKE THIS PASS.
+		ast_test_status_update(test, "ast cap_joint failed to properly detect compatibility test 1.\n");
+		return AST_TEST_FAIL;
+	}
 
 	ast_cap_destroy(cap1);
 	ast_cap_destroy(cap2);
+	ast_cap_destroy(cap_joint);
 
 	/* unregister interface */
 	if (ast_format_attr_unreg_interface(&test_interface)) {




More information about the svn-commits mailing list