[asterisk-commits] rmudgett: branch rmudgett/ao2_red_black r372873 - /team/rmudgett/ao2_red_blac...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Sep 11 13:07:19 CDT 2012
Author: rmudgett
Date: Tue Sep 11 13:07:15 2012
New Revision: 372873
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=372873
Log:
Package container test debug dump code. Add container creation failure messages.
Modified:
team/rmudgett/ao2_red_black/tests/test_astobj2.c
Modified: team/rmudgett/ao2_red_black/tests/test_astobj2.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/ao2_red_black/tests/test_astobj2.c?view=diff&rev=372873&r1=372872&r2=372873
==============================================================================
--- team/rmudgett/ao2_red_black/tests/test_astobj2.c (original)
+++ team/rmudgett/ao2_red_black/tests/test_astobj2.c Tue Sep 11 13:07:15 2012
@@ -37,7 +37,9 @@
#include "asterisk/test.h"
#include "asterisk/astobj2.h"
-/*! \todo BUGBUG Specific rbtree tests not written */
+/* Uncomment the following line to dump the container contents during tests. */
+//#define TEST_CONTAINER_DEBUG_DUMP 1
+
enum test_container_type {
TEST_CONTAINER_LIST,
TEST_CONTAINER_HASH,
@@ -204,6 +206,7 @@
}
}
+#if defined(TEST_CONTAINER_DEBUG_DUMP)
/*!
* \internal
* \brief Print test object key.
@@ -224,6 +227,7 @@
}
prnt(where, "%6d-%d", obj->i, obj->dup_number);
}
+#endif /* defined(TEST_CONTAINER_DEBUG_DUMP) */
/*!
* \internal
@@ -753,8 +757,10 @@
ast_test_status_update(test, "container integrity check failed\n");
res = AST_TEST_FAIL;
}
- ao2_container_dump(c1, 0, "BUGBUG c1", (void *) test, (ao2_prnt_fn *) ast_test_debug, test_prnt_obj);
- ao2_container_stats(c1, 0, "BUGBUG c1", (void *) test, (ao2_prnt_fn *) ast_test_debug);
+#if defined(TEST_CONTAINER_DEBUG_DUMP)
+ ao2_container_dump(c1, 0, "test_1 c1", (void *) test, (ao2_prnt_fn *) ast_test_debug, test_prnt_obj);
+ ao2_container_stats(c1, 0, "test_1 c1", (void *) test, (ao2_prnt_fn *) ast_test_debug);
+#endif /* defined(TEST_CONTAINER_DEBUG_DUMP) */
cleanup:
/* destroy containers */
@@ -1525,6 +1531,7 @@
/* Create container that inserts objects at the end. */
c1 = test_make_nonsorted(type, 0);
if (!c1) {
+ ast_test_status_update(test, "Container c1 creation failed.\n");
res = AST_TEST_FAIL;
goto test_cleanup;
}
@@ -1536,6 +1543,7 @@
/* Create container that inserts objects at the beginning. */
c2 = test_make_nonsorted(type, AO2_CONTAINER_ALLOC_OPT_INSERT_BEGIN);
if (!c2) {
+ ast_test_status_update(test, "Container c2 creation failed.\n");
res = AST_TEST_FAIL;
goto test_cleanup;
}
@@ -1749,6 +1757,7 @@
/* Create container that inserts duplicate objects after matching objects. */
c1 = test_make_sorted(type, AO2_CONTAINER_ALLOC_OPT_DUPS_ALLOW);
if (!c1) {
+ ast_test_status_update(test, "Container c1 creation failed.\n");
res = AST_TEST_FAIL;
goto test_cleanup;
}
@@ -1760,6 +1769,7 @@
/* Create container that inserts duplicate objects before matching objects. */
c2 = test_make_sorted(type, AO2_CONTAINER_ALLOC_OPT_INSERT_BEGIN | AO2_CONTAINER_ALLOC_OPT_DUPS_ALLOW);
if (!c2) {
+ ast_test_status_update(test, "Container c2 creation failed.\n");
res = AST_TEST_FAIL;
goto test_cleanup;
}
@@ -1767,6 +1777,13 @@
res = AST_TEST_FAIL;
goto test_cleanup;
}
+
+#if defined(TEST_CONTAINER_DEBUG_DUMP)
+ ao2_container_dump(c1, 0, "c1(DUPS_ALLOW)", (void *) test, (ao2_prnt_fn *) ast_test_debug, test_prnt_obj);
+ ao2_container_stats(c1, 0, "c1(DUPS_ALLOW)", (void *) test, (ao2_prnt_fn *) ast_test_debug);
+ ao2_container_dump(c2, 0, "c2(DUPS_ALLOW)", (void *) test, (ao2_prnt_fn *) ast_test_debug, test_prnt_obj);
+ ao2_container_stats(c2, 0, "c2(DUPS_ALLOW)", (void *) test, (ao2_prnt_fn *) ast_test_debug);
+#endif /* defined(TEST_CONTAINER_DEBUG_DUMP) */
/* Check container iteration directions */
switch (type) {
@@ -1847,6 +1864,13 @@
goto test_cleanup;
}
+#if defined(TEST_CONTAINER_DEBUG_DUMP)
+ ao2_container_dump(c1, 0, "c1(DUPS_ALLOW) w/ dups", (void *) test, (ao2_prnt_fn *) ast_test_debug, test_prnt_obj);
+ ao2_container_stats(c1, 0, "c1(DUPS_ALLOW) w/ dups", (void *) test, (ao2_prnt_fn *) ast_test_debug);
+ ao2_container_dump(c2, 0, "c2(DUPS_ALLOW) w/ dups", (void *) test, (ao2_prnt_fn *) ast_test_debug, test_prnt_obj);
+ ao2_container_stats(c2, 0, "c2(DUPS_ALLOW) w/ dups", (void *) test, (ao2_prnt_fn *) ast_test_debug);
+#endif /* defined(TEST_CONTAINER_DEBUG_DUMP) */
+
/* Check duplicates in containers that allow duplicates. */
res = test_expected_duplicates(res, c1, OBJ_ORDER_ASCENDING, duplicate_number,
test_dup_allow_forward, ARRAY_LEN(test_dup_allow_forward),
@@ -1863,6 +1887,7 @@
/* Create containers that reject duplicate keyed objects. */
c1 = test_make_sorted(type, AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT);
if (!c1) {
+ ast_test_status_update(test, "Container c1 creation failed.\n");
res = AST_TEST_FAIL;
goto test_cleanup;
}
@@ -1876,6 +1901,7 @@
}
c2 = test_make_sorted(type, AO2_CONTAINER_ALLOC_OPT_INSERT_BEGIN | AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT);
if (!c2) {
+ ast_test_status_update(test, "Container c2 creation failed.\n");
res = AST_TEST_FAIL;
goto test_cleanup;
}
@@ -1904,6 +1930,7 @@
/* Create containers that reject duplicate objects. */
c1 = test_make_sorted(type, AO2_CONTAINER_ALLOC_OPT_DUPS_OBJ_REJECT);
if (!c1) {
+ ast_test_status_update(test, "Container c1 creation failed.\n");
res = AST_TEST_FAIL;
goto test_cleanup;
}
@@ -1917,6 +1944,7 @@
}
c2 = test_make_sorted(type, AO2_CONTAINER_ALLOC_OPT_INSERT_BEGIN | AO2_CONTAINER_ALLOC_OPT_DUPS_OBJ_REJECT);
if (!c2) {
+ ast_test_status_update(test, "Container c2 creation failed.\n");
res = AST_TEST_FAIL;
goto test_cleanup;
}
@@ -1945,6 +1973,7 @@
/* Create container that replaces duplicate keyed objects. */
c1 = test_make_sorted(type, AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE);
if (!c1) {
+ ast_test_status_update(test, "Container c1 creation failed.\n");
res = AST_TEST_FAIL;
goto test_cleanup;
}
@@ -1958,6 +1987,7 @@
}
c2 = test_make_sorted(type, AO2_CONTAINER_ALLOC_OPT_INSERT_BEGIN | AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE);
if (!c2) {
+ ast_test_status_update(test, "Container c2 creation failed.\n");
res = AST_TEST_FAIL;
goto test_cleanup;
}
More information about the asterisk-commits
mailing list