[asterisk-commits] rmudgett: branch 12 r406707 - in /branches/12/tests: test_cdr.c test_cel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 27 18:11:19 CST 2014


Author: rmudgett
Date: Mon Jan 27 18:11:16 2014
New Revision: 406707

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=406707
Log:
test_cdr.c, test_cel.c: Correctly destroy created bridges.

* Fixed the test_cel_attended_transfer_bridges_link unit test to also
account for the local channel link being destroyed now that the bridges
are actually destroyed.

* Made CDR unit test use its own version of do_sleep() from the CEL unit
tests.

Modified:
    branches/12/tests/test_cdr.c
    branches/12/tests/test_cel.c

Modified: branches/12/tests/test_cdr.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/tests/test_cdr.c?view=diff&rev=406707&r1=406706&r2=406707
==============================================================================
--- branches/12/tests/test_cdr.c (original)
+++ branches/12/tests/test_cdr.c Mon Jan 27 18:11:16 2014
@@ -360,6 +360,20 @@
 	ast_channel_release(chan);
 }
 
+static void safe_bridge_destroy(struct ast_bridge *bridge)
+{
+	if (!bridge) {
+		return;
+	}
+	ast_bridge_destroy(bridge, 0);
+}
+
+static void do_sleep(struct timespec *to_sleep)
+{
+	while ((nanosleep(to_sleep, to_sleep) == -1) && (errno == EINTR)) {
+	}
+}
+
 AST_TEST_DEFINE(test_cdr_channel_creation)
 {
 	RAII_VAR(struct ast_channel *, chan, NULL, safe_channel_release);
@@ -506,7 +520,7 @@
 {
 	RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	RAII_VAR(struct ast_cdr_config *, config, ao2_alloc(sizeof(*config), NULL),
 			ao2_cleanup);
 	struct timespec to_sleep = {1, 0};
@@ -564,7 +578,7 @@
 
 	bridge = ast_bridge_basic_new();
 	ast_test_validate(test, bridge != NULL);
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
 
@@ -582,11 +596,11 @@
 
 	ast_channel_state_set(chan_bob, AST_STATE_UP);
 
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
 
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_bridge_depart(chan_bob);
 	ast_bridge_depart(chan_alice);
@@ -653,7 +667,7 @@
 AST_TEST_DEFINE(test_cdr_single_bridge)
 {
 	RAII_VAR(struct ast_channel *, chan, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	RAII_VAR(struct ast_cdr_config *, config, ao2_alloc(sizeof(*config), NULL),
 			ao2_cleanup);
 	struct timespec to_sleep = {1, 0};
@@ -697,10 +711,10 @@
 	bridge = ast_bridge_basic_new();
 	ast_test_validate(test, bridge != NULL);
 
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
 
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_bridge_depart(chan);
 
@@ -714,8 +728,7 @@
 AST_TEST_DEFINE(test_cdr_single_bridge_continue)
 {
 	RAII_VAR(struct ast_channel *, chan, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge_one, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_bridge *, bridge_two, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	RAII_VAR(struct ast_cdr_config *, config, ao2_alloc(sizeof(*config), NULL),
 			ao2_cleanup);
 	struct timespec to_sleep = {1, 0};
@@ -771,13 +784,13 @@
 	EMULATE_APP_DATA(chan, 2, "Bridge", "");
 	ast_channel_unlock(chan);
 
-	bridge_one = ast_bridge_basic_new();
-	ast_test_validate(test, bridge_one != NULL);
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
-
-	ast_test_validate(test, !ast_bridge_impart(bridge_one, chan, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
-
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	bridge = ast_bridge_basic_new();
+	ast_test_validate(test, bridge != NULL);
+	do_sleep(&to_sleep);
+
+	ast_test_validate(test, !ast_bridge_impart(bridge, chan, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
+
+	do_sleep(&to_sleep);
 
 	ast_bridge_depart(chan);
 
@@ -795,7 +808,7 @@
 {
 	RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	RAII_VAR(struct ast_cdr_config *, config, ao2_alloc(sizeof(*config), NULL),
 			ao2_cleanup);
 	struct timespec to_sleep = {1, 0};
@@ -861,7 +874,7 @@
 	ast_test_validate(test, bridge != NULL);
 
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_channel_lock(chan_bob);
 	EMULATE_APP_DATA(chan_bob, 1, "Answer", "");
@@ -870,7 +883,7 @@
 	ast_channel_unlock(chan_bob);
 
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_bridge_depart(chan_alice);
 	ast_bridge_depart(chan_bob);
@@ -887,7 +900,7 @@
 {
 	RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	RAII_VAR(struct ast_cdr_config *, config, ao2_alloc(sizeof(*config), NULL),
 			ao2_cleanup);
 	struct timespec to_sleep = {1, 0};
@@ -957,13 +970,13 @@
 	ast_setstate(chan_bob, AST_STATE_UP);
 	EMULATE_APP_DATA(chan_bob, 2, "Bridge", "");
 	ast_channel_unlock(chan_bob);
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_bridge_depart(chan_alice);
 	ast_bridge_depart(chan_bob);
@@ -981,7 +994,7 @@
 	RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	RAII_VAR(struct ast_cdr_config *, config, ao2_alloc(sizeof(*config), NULL),
 			ao2_cleanup);
 	struct timespec to_sleep = {1, 0};
@@ -1078,7 +1091,7 @@
 
 	bridge = ast_bridge_basic_new();
 	ast_test_validate(test, bridge != NULL);
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
 
@@ -1087,11 +1100,11 @@
 	ast_setstate(chan_bob, AST_STATE_UP);
 	EMULATE_APP_DATA(chan_bob, 2, "Bridge", "");
 	ast_channel_unlock(chan_bob);
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
 
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_channel_lock(chan_charlie);
 	EMULATE_APP_DATA(chan_charlie, 1, "Answer", "");
@@ -1100,7 +1113,7 @@
 	ast_channel_unlock(chan_charlie);
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_charlie, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
 
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_bridge_depart(chan_alice);
 	ast_bridge_depart(chan_bob);
@@ -1650,7 +1663,7 @@
 {
 	RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_callee, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	RAII_VAR(struct ast_cdr_config *, config, ao2_alloc(sizeof(*config), NULL),
 			ao2_cleanup);
 	struct timespec to_sleep = {1, 0};
@@ -1705,12 +1718,12 @@
 
 	bridge = ast_bridge_basic_new();
 	ast_test_validate(test, bridge != NULL);
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_caller, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_callee, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
 
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_bridge_depart(chan_caller);
 	ast_bridge_depart(chan_callee);
@@ -1726,7 +1739,7 @@
 {
 	RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_callee, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	RAII_VAR(struct ast_cdr_config *, config, ao2_alloc(sizeof(*config), NULL),
 			ao2_cleanup);
 	struct timespec to_sleep = {1, 0};
@@ -1781,11 +1794,11 @@
 
 	bridge = ast_bridge_basic_new();
 	ast_test_validate(test, bridge != NULL);
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_callee, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_caller, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 	ast_bridge_depart(chan_caller);
 	ast_bridge_depart(chan_callee);
 
@@ -1802,7 +1815,7 @@
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_david, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	RAII_VAR(struct ast_cdr_config *, config, ao2_alloc(sizeof(*config), NULL),
 			ao2_cleanup);
 	struct timespec to_sleep = {1, 0};
@@ -1960,15 +1973,15 @@
 	bridge = ast_bridge_basic_new();
 	ast_test_validate(test, bridge != NULL);
 
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_charlie, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_david, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 	ast_test_validate(test, !ast_bridge_depart(chan_alice));
 	ast_test_validate(test, !ast_bridge_depart(chan_bob));
 	ast_test_validate(test, !ast_bridge_depart(chan_charlie));
@@ -1988,7 +2001,7 @@
 {
 	RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	RAII_VAR(struct ast_cdr_config *, config, ao2_alloc(sizeof(*config), NULL),
 			ao2_cleanup);
 	struct timespec to_sleep = {1, 0};
@@ -2056,11 +2069,11 @@
 		"test_cdr", "test_cdr_park");
 	ast_test_validate(test, bridge != NULL);
 
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_alice, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 	ast_test_validate(test, !ast_bridge_impart(bridge, chan_bob, NULL, NULL, AST_BRIDGE_IMPART_CHAN_DEPARTABLE));
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 	ast_bridge_depart(chan_alice);
 	ast_bridge_depart(chan_bob);
 
@@ -2166,7 +2179,7 @@
 	ast_channel_unlock(chan);
 
 	/* Wait one second so we get a duration. */
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	ast_cdr_setuserfield(ast_channel_name(chan), "foobar");
 	ast_test_validate(test, ast_cdr_setvar(ast_channel_name(chan), "test_variable", "record_1") == 0);
@@ -2316,7 +2329,7 @@
 
 	CREATE_ALICE_CHANNEL(chan, &caller, &expected);
 
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	/* Disable the CDR */
 	ast_test_validate(test, ast_cdr_set_property(ast_channel_name(chan), AST_CDR_FLAG_DISABLE) == 0);
@@ -2418,7 +2431,7 @@
 	ast_copy_string(fork_expected_two.uniqueid, ast_channel_uniqueid(chan), sizeof(fork_expected_two.uniqueid));
 	ast_copy_string(fork_expected_two.linkedid, ast_channel_linkedid(chan), sizeof(fork_expected_two.linkedid));
 
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 
 	/* Test blowing away variables */
 	ast_test_validate(test, ast_cdr_setvar(ast_channel_name(chan), "test_variable", "record_1") == 0);
@@ -2438,7 +2451,7 @@
 	ast_channel_lock(chan);
 	ast_setstate(chan, AST_STATE_UP);
 	ast_channel_unlock(chan);
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	do_sleep(&to_sleep);
 	ast_test_validate(test, ast_cdr_setvar(ast_channel_name(chan), "test_variable", "record_2") == 0);
 	ast_test_validate(test, ast_cdr_getvar(ast_channel_name(chan), "test_variable", varbuffer, sizeof(varbuffer)) == 0);
 	ast_test_validate(test, strcmp(varbuffer, "record_2") == 0);

Modified: branches/12/tests/test_cel.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/tests/test_cel.c?view=diff&rev=406707&r1=406706&r2=406707
==============================================================================
--- branches/12/tests/test_cel.c (original)
+++ branches/12/tests/test_cel.c Mon Jan 27 18:11:16 2014
@@ -87,7 +87,8 @@
 
 static void do_sleep(void)
 {
-	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR));
+	while ((nanosleep(&to_sleep, &to_sleep) == -1) && (errno == EINTR)) {
+	}
 }
 
 #define APPEND_EVENT(chan, ev_type, userevent, extra) do { \
@@ -357,6 +358,14 @@
 	ast_channel_release(chan);
 }
 
+static void safe_bridge_destroy(struct ast_bridge *bridge)
+{
+	if (!bridge) {
+		return;
+	}
+	ast_bridge_destroy(bridge, 0);
+}
+
 AST_TEST_DEFINE(test_cel_channel_creation)
 {
 	RAII_VAR(struct ast_channel *, chan, NULL, safe_channel_release);
@@ -472,7 +481,7 @@
 AST_TEST_DEFINE(test_cel_single_bridge)
 {
 	RAII_VAR(struct ast_channel *, chan, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 
 	struct ast_party_caller caller = ALICE_CALLERID;
 
@@ -511,7 +520,7 @@
 AST_TEST_DEFINE(test_cel_single_bridge_continue)
 {
 	RAII_VAR(struct ast_channel *, chan, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	struct ast_party_caller caller = ALICE_CALLERID;
 
 	switch (cmd) {
@@ -553,7 +562,7 @@
 {
 	RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	struct ast_party_caller caller_alice = ALICE_CALLERID;
 	struct ast_party_caller caller_bob = BOB_CALLERID;
 
@@ -601,7 +610,7 @@
 {
 	RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	struct ast_party_caller caller_alice = ALICE_CALLERID;
 	struct ast_party_caller caller_bob = BOB_CALLERID;
 
@@ -654,7 +663,7 @@
 	RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	struct ast_party_caller caller_alice = ALICE_CALLERID;
 	struct ast_party_caller caller_bob = BOB_CALLERID;
 	struct ast_party_caller caller_charlie = CHARLIE_CALLERID;
@@ -1003,7 +1012,7 @@
 {
 	RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_callee, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	struct ast_party_caller caller = ALICE_CALLERID;
 
 	switch (cmd) {
@@ -1050,7 +1059,7 @@
 {
 	RAII_VAR(struct ast_channel *, chan_caller, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_callee, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	struct ast_party_caller caller = ALICE_CALLERID;
 
 	switch (cmd) {
@@ -1099,7 +1108,7 @@
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_david, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	struct ast_party_caller alice_caller = ALICE_CALLERID;
 	struct ast_party_caller charlie_caller = CHARLIE_CALLERID;
 
@@ -1173,7 +1182,7 @@
 {
 	RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge, NULL, safe_bridge_destroy);
 	struct ast_party_caller alice_caller = ALICE_CALLERID;
 	struct ast_party_caller bob_caller = BOB_CALLERID;
 	struct ast_bridge_channel_pair pair;
@@ -1224,8 +1233,8 @@
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_david, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge1, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_bridge *, bridge2, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge1, NULL, safe_bridge_destroy);
+	RAII_VAR(struct ast_bridge *, bridge2, NULL, safe_bridge_destroy);
 	struct ast_party_caller alice_caller = ALICE_CALLERID;
 	struct ast_party_caller bob_caller = BOB_CALLERID;
 	struct ast_party_caller charlie_caller = CHARLIE_CALLERID;
@@ -1301,8 +1310,8 @@
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_david, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge1, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_bridge *, bridge2, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge1, NULL, safe_bridge_destroy);
+	RAII_VAR(struct ast_bridge *, bridge2, NULL, safe_bridge_destroy);
 	struct ast_party_caller alice_caller = ALICE_CALLERID;
 	struct ast_party_caller bob_caller = BOB_CALLERID;
 	struct ast_party_caller charlie_caller = CHARLIE_CALLERID;
@@ -1382,8 +1391,8 @@
 	RAII_VAR(struct ast_channel *, chan_bob, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_charlie, NULL, safe_channel_release);
 	RAII_VAR(struct ast_channel *, chan_david, NULL, safe_channel_release);
-	RAII_VAR(struct ast_bridge *, bridge1, NULL, ao2_cleanup);
-	RAII_VAR(struct ast_bridge *, bridge2, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_bridge *, bridge1, NULL, safe_bridge_destroy);
+	RAII_VAR(struct ast_bridge *, bridge2, NULL, safe_bridge_destroy);
 	struct ast_party_caller alice_caller = ALICE_CALLERID;
 	struct ast_party_caller bob_caller = BOB_CALLERID;
 	struct ast_party_caller charlie_caller = CHARLIE_CALLERID;
@@ -1439,7 +1448,7 @@
 
 	/* The following events can not be matched directly since nothing is known
 	 * about the linking local channel.
-	 * local channel ;1 and ;2 creation and ;2 answer */
+	 * ;1 and ;2 CHAN_START and ;2 ANSWER */
 	APPEND_DUMMY_EVENT();
 	APPEND_DUMMY_EVENT();
 	APPEND_DUMMY_EVENT();
@@ -1469,6 +1478,15 @@
 	HANGUP_CHANNEL(chan_david, AST_CAUSE_NORMAL, "");
 	do_sleep();
 	HANGUP_CHANNEL(chan_charlie, AST_CAUSE_NORMAL, "");
+	do_sleep();
+
+	/* ;1 and ;2 BRIDGE_EXIT, HANGUP, and CHAN_END */
+	APPEND_DUMMY_EVENT();
+	APPEND_DUMMY_EVENT();
+	APPEND_DUMMY_EVENT();
+	APPEND_DUMMY_EVENT();
+	APPEND_DUMMY_EVENT();
+	APPEND_DUMMY_EVENT();
 
 	return AST_TEST_PASS;
 }




More information about the asterisk-commits mailing list