[svn-commits] mmichelson: branch mmichelson/rls-subscribe r417703 - /team/mmichelson/rls-su...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jun 30 20:25:20 CDT 2014


Author: mmichelson
Date: Mon Jun 30 20:25:18 2014
New Revision: 417703

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=417703
Log:
Get one more unit test out of the way.

This one ensures that a branch of a tree with no good resources
gets pruned. Nice!


Modified:
    team/mmichelson/rls-subscribe/res/res_pjsip_pubsub.c

Modified: team/mmichelson/rls-subscribe/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/rls-subscribe/res/res_pjsip_pubsub.c?view=diff&rev=417703&r1=417702&r2=417703
==============================================================================
--- team/mmichelson/rls-subscribe/res/res_pjsip_pubsub.c (original)
+++ team/mmichelson/rls-subscribe/res/res_pjsip_pubsub.c Mon Jun 30 20:25:18 2014
@@ -2834,6 +2834,68 @@
 	return AST_TEST_PASS;
 
 }
+
+AST_TEST_DEFINE(bad_branch)
+{
+	RAII_VAR(struct resource_list *, list_1, NULL, cleanup_resource_list);
+	RAII_VAR(struct resource_list *, list_2, NULL, cleanup_resource_list);
+	RAII_VAR(struct resource_tree *, tree, NULL, resource_tree_destroy);
+	const char *resources_1[] = {
+		"huey",
+		"dewey",
+		"louie",
+		"gross",
+	};
+	const char *resources_2[] = {
+		"coconut",
+		"cilantro",
+		"olive",
+		"cheese",
+	};
+	int resp;
+
+	switch (cmd) {
+	case TEST_INIT:
+		info->name = "bad_branch";
+		info->category = "/res/res_pjsip_pubsub/";
+		info->summary = "Ensure bad branches are pruned from the tree";
+		info->description =
+			"Create a resource list that makes a tree with an entire branch of bad resources.\n"
+			"Ensure the bad branch is pruned from the tree.";
+		return AST_TEST_NOT_RUN;
+	case TEST_EXECUTE:
+		break;
+	}
+
+	list_1 = create_resource_list(test, "foo", resources_1, ARRAY_LEN(resources_1));
+	if (!list_1) {
+		return AST_TEST_FAIL;
+	}
+	list_2 = create_resource_list(test, "gross", resources_2, ARRAY_LEN(resources_2));
+	if (!list_2) {
+		return AST_TEST_FAIL;
+	}
+
+	tree = ast_calloc(1, sizeof(*tree));
+	resp = build_resource_tree(NULL, &test_handler, "foo", tree);
+	if (resp != 200) {
+		ast_test_status_update(test, "Unexpected response %d when building resource tree\n", resp);
+		return AST_TEST_FAIL;
+	}
+
+	if (!tree->root) {
+		ast_test_status_update(test, "Resource tree has no root\n");
+		return AST_TEST_FAIL;
+	}
+
+	if (check_node(test, tree->root, resources_1, ARRAY_LEN(resources_1) - 1)) {
+		return AST_TEST_FAIL;
+	}
+
+	return AST_TEST_PASS;
+
+}
+
 #endif
 
 static int load_module(void)
@@ -2913,6 +2975,7 @@
 	AST_TEST_REGISTER(resource_tree);
 	AST_TEST_REGISTER(complex_resource_tree);
 	AST_TEST_REGISTER(bad_resource);
+	AST_TEST_REGISTER(bad_branch);
 
 	return AST_MODULE_LOAD_SUCCESS;
 }
@@ -2930,6 +2993,7 @@
 	AST_TEST_UNREGISTER(resource_tree);
 	AST_TEST_UNREGISTER(complex_resource_tree);
 	AST_TEST_UNREGISTER(bad_resource);
+	AST_TEST_UNREGISTER(bad_branch);
 
 	return 0;
 }




More information about the svn-commits mailing list