[svn-commits] dvossel: branch dvossel/fixtheworld_phase1_step1 r298593 - in /team/dvossel/f...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Dec 16 16:04:59 UTC 2010
Author: dvossel
Date: Thu Dec 16 10:04:55 2010
New Revision: 298593
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=298593
Log:
Update to capability API and unit tests
Modified:
team/dvossel/fixtheworld_phase1_step1/main/format.c
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.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step1/main/format.c?view=diff&rev=298593&r1=298592&r2=298593
==============================================================================
--- team/dvossel/fixtheworld_phase1_step1/main/format.c (original)
+++ team/dvossel/fixtheworld_phase1_step1/main/format.c Thu Dec 16 10:04:55 2010
@@ -56,11 +56,9 @@
return wrapper->id;
}
-
void ast_format_copy(struct ast_format *src, struct ast_format *dst)
{
- /* copying is simple, for now */
- *dst = *src;
+ memcpy(dst, src, sizeof(struct ast_format));
}
/* \internal
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=298593&r1=298592&r2=298593
==============================================================================
--- team/dvossel/fixtheworld_phase1_step1/main/format_cap.c (original)
+++ team/dvossel/fixtheworld_phase1_step1/main/format_cap.c Thu Dec 16 10:04:55 2010
@@ -87,7 +87,7 @@
{
struct ast_format *fnew;
- if (!(fnew = ao2_alloc(sizeof(format), NULL))) {
+ if (!(fnew = ao2_alloc(sizeof(struct ast_format), NULL))) {
return;
}
ast_format_copy(format, fnew);
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=298593&r1=298592&r2=298593
==============================================================================
--- team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c (original)
+++ team/dvossel/fixtheworld_phase1_step1/tests/test_format_api.c Thu Dec 16 10:04:55 2010
@@ -37,6 +37,7 @@
#include "asterisk/module.h"
#include "asterisk/test.h"
#include "asterisk/format.h"
+#include "asterisk/format_cap.h"
#include "asterisk/strings.h"
/*! These are the keys for accessing attributes */
@@ -295,10 +296,97 @@
return AST_TEST_PASS;
}
+/*!
+ * \internal
+ */
+AST_TEST_DEFINE(format_test3)
+{
+ struct ast_format tmpformat = { 0, };
+ struct ast_cap *cap1;
+ struct ast_cap *cap2;
+// struct ast_cap *cap_joint;
+
+ switch (cmd) {
+ case TEST_INIT:
+ info->name = "ast_format_test3";
+ info->category = "/main/format/";
+ info->summary = "Test ast_format and ast_cap structures";
+ info->description =
+ "This test exercises the Ast Format Capability API by creating "
+ "capability structures and performing various API calls on them.";
+ return AST_TEST_NOT_RUN;
+ case TEST_EXECUTE:
+ break;
+ }
+
+ cap1 = ast_cap_alloc();
+ cap2 = ast_cap_alloc();
+
+ if (!cap1 || !cap2) {
+ ast_test_status_update(test, "cap alloc failed.\n");
+ return AST_TEST_FAIL;
+ }
+
+ if (ast_format_attr_reg_interface(&test_interface)) {
+ ast_test_status_update(test, "test_interface failed to register.\n");
+ return AST_TEST_FAIL;
+ }
+
+ ast_cap_add(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_GSM, 0));
+ ast_cap_add(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_ULAW, 0));
+ ast_cap_add(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_G722, 0));
+ ast_cap_add(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_ALAW, 0));
+ ast_cap_add(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_H264, 0));
+ ast_cap_add(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_H263, 0));
+ ast_cap_add(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_T140, 0));
+ ast_cap_add(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_JPEG, 0));
+ ast_cap_add(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));
+
+ /* Test is compatible */
+ if (!ast_cap_iscompatible(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_ALAW, 0)) ||
+ !ast_cap_iscompatible(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_ULAW, 0)) ||
+ !ast_cap_iscompatible(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_GSM, 0)) ||
+ !ast_cap_iscompatible(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_H264, 0)) ||
+ !ast_cap_iscompatible(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_JPEG, 0)) ||
+ !ast_cap_iscompatible(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_T140, 0))) {
+ ast_test_status_update(test, "ast cap1 failed to properly detect compatibility test 1.\n");
+ return AST_TEST_FAIL;
+ }
+
+ /* Test things that are not compatible */
+ if (ast_cap_iscompatible(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_SPEEX, 0)) ||
+ ast_cap_iscompatible(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_SPEEX16, 0)) ||
+ ast_cap_iscompatible(cap1, ast_format_set(&tmpformat, AST_FORMATNEW_H261, 0))) {
+ ast_test_status_update(test, "ast cap1 failed to properly detect compatibility test 2.\n");
+ return AST_TEST_FAIL;
+ }
+
+ //todohere start working on stuff here.
+ /* Test compatiblity with format with attributes. */
+
+
+
+ ast_cap_destroy(cap1);
+ ast_cap_destroy(cap2);
+
+ /* unregister interface */
+ if (ast_format_attr_unreg_interface(&test_interface)) {
+ ast_test_status_update(test, "test_interface failed to unregister.\n");
+ return AST_TEST_FAIL;
+ }
+
+ return AST_TEST_PASS;
+}
+
static int unload_module(void)
{
AST_TEST_UNREGISTER(format_test1);
AST_TEST_UNREGISTER(format_test2);
+ AST_TEST_UNREGISTER(format_test3);
return 0;
}
@@ -307,6 +395,7 @@
{
AST_TEST_REGISTER(format_test1);
AST_TEST_REGISTER(format_test2);
+ AST_TEST_REGISTER(format_test3);
return AST_MODULE_LOAD_SUCCESS;
}
More information about the svn-commits
mailing list