[asterisk-commits] eliel: branch eliel/data_api_providers_gsoc2010 r260566 - /team/eliel/data_ap...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon May 3 09:39:35 CDT 2010
Author: eliel
Date: Mon May 3 09:39:31 2010
New Revision: 260566
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=260566
Log:
AstData SIP peers provider unit testing.
Modified:
team/eliel/data_api_providers_gsoc2010/channels/chan_sip.c
Modified: team/eliel/data_api_providers_gsoc2010/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/eliel/data_api_providers_gsoc2010/channels/chan_sip.c?view=diff&rev=260566&r1=260565&r2=260566
==============================================================================
--- team/eliel/data_api_providers_gsoc2010/channels/chan_sip.c (original)
+++ team/eliel/data_api_providers_gsoc2010/channels/chan_sip.c Mon May 3 09:39:31 2010
@@ -27054,6 +27054,76 @@
sip_dialplan_function_unregister_tests();
}
+#ifdef TEST_FRAMEWORK
+AST_TEST_DEFINE(test_sip_peers_get)
+{
+ struct sip_peer *peer;
+ struct ast_data *node;
+ struct ast_data_query query = {
+ .path = "/asterisk/channel/chan_sip/peers",
+ .search = "peers/peer/name=test_peer_data_provider"
+ };
+
+ switch (cmd) {
+ case TEST_INIT:
+ info->name = "sip_peers_get_data_test";
+ info->category = "main/data/chan_sip/peers";
+ info->summary = "SIP peers data providers unit test";
+ info->description =
+ "Tests whether the SIP peers data provider implementation works as expected.";
+ return AST_TEST_NOT_RUN;
+ case TEST_EXECUTE:
+ break;
+ }
+
+ /* Create the peer that we will retrieve. */
+ peer = build_peer("test_peer_data_provider", NULL, NULL, 0, 0);
+ if (!peer) {
+ return AST_TEST_FAIL;
+ }
+ peer->type = SIP_TYPE_USER;
+ peer->call_limit = 10;
+ ao2_link(peers, peer);
+ ao2_ref(peer, -1);
+
+ /* retrieve the chan_sip/peers tree and check the created peer. */
+ node = ast_data_get(&query);
+ if (!node) {
+ ao2_unlink(peers, peer);
+ ao2_ref(peer, -1);
+ return AST_TEST_FAIL;
+ }
+
+ /* compare item. */
+ if (strcmp(ast_data_retrieve_string(node, "peer/name"), "test_peer_data_provider")) {
+ ao2_unlink(peers, peer);
+ ao2_ref(peer, -1);
+ return AST_TEST_FAIL;
+ }
+
+ if (strcmp(ast_data_retrieve_string(node, "peer/type"), "user")) {
+ ao2_unlink(peers, peer);
+ ao2_ref(peer, -1);
+ return AST_TEST_FAIL;
+ }
+
+ if (ast_data_retrieve_int(node, "peer/call_limit") != 10) {
+ ao2_unlink(peers, peer);
+ ao2_ref(peer, -1);
+ return AST_TEST_FAIL;
+ }
+
+ /* release resources */
+ ast_data_free(node);
+
+ ao2_unlink(peers, peer);
+ ao2_ref(peer, -1);
+
+ return AST_TEST_PASS;
+}
+
+#endif
+
#define DATA_EXPORT_SIP_PEER(MEMBER) \
MEMBER(sip_peer, name, AST_DATA_STRING) \
MEMBER(sip_peer, secret, AST_DATA_STRING) \
@@ -27228,6 +27298,10 @@
return AST_MODULE_LOAD_FAILURE;
}
+#ifdef TEST_FRAMEWORK
+ AST_TEST_REGISTER(test_sip_peers_get);
+#endif
+
/* Register AstData providers */
ast_data_register_multiple(sip_data_providers, ARRAY_LEN(sip_data_providers));
More information about the asterisk-commits
mailing list