[asterisk-commits] kmoore: branch kmoore/microfilm r396992 - /team/kmoore/microfilm/tests/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 19 22:25:02 CDT 2013


Author: kmoore
Date: Mon Aug 19 22:25:00 2013
New Revision: 396992

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396992
Log:
Simplify test code

Modified:
    team/kmoore/microfilm/tests/test_cel.c

Modified: team/kmoore/microfilm/tests/test_cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/microfilm/tests/test_cel.c?view=diff&rev=396992&r1=396991&r2=396992
==============================================================================
--- team/kmoore/microfilm/tests/test_cel.c (original)
+++ team/kmoore/microfilm/tests/test_cel.c Mon Aug 19 22:25:00 2013
@@ -128,6 +128,13 @@
 	APPEND_EVENT_SNAPSHOT(channel, AST_CEL_BRIDGE_EXIT, NULL, extra, NULL); \
 	} while (0)
 
+#define CONF_ENTER(channel, bridge) do { \
+	ast_test_validate(test, 0 == ast_bridge_impart(bridge, channel, NULL, NULL, 0)); \
+	do_sleep(); \
+	CONF_ENTER_EVENT(channel, bridge); \
+	mid_test_sync(); \
+	} while (0)
+
 #define CONF_ENTER_EVENT(channel, bridge) do { \
 	RAII_VAR(struct ast_json *, extra, NULL, ast_json_unref); \
 	extra = ast_json_pack("{s: s}", "bridge_id", bridge->uniqueid); \
@@ -399,8 +406,7 @@
 	EMULATE_APP_DATA(chan, 2, "Bridge", "");
 
 	do_sleep();
-	ast_bridge_impart(bridge, chan, NULL, NULL, 0);
-	CONF_ENTER_EVENT(chan, bridge);
+	CONF_ENTER(chan, bridge);
 
 	do_sleep();
 
@@ -438,8 +444,7 @@
 	EMULATE_APP_DATA(chan, 2, "Bridge", "");
 
 	do_sleep();
-	ast_bridge_impart(bridge, chan, NULL, NULL, 0);
-	CONF_ENTER_EVENT(chan, bridge);
+	CONF_ENTER(chan, bridge);
 
 	do_sleep();
 
@@ -484,16 +489,13 @@
 	ANSWER_CHANNEL(chan_alice);
 	EMULATE_APP_DATA(chan_alice, 2, "Bridge", "");
 
-	CONF_ENTER_EVENT(chan_alice, bridge);
-	ast_bridge_impart(bridge, chan_alice, NULL, NULL, 0);
+	CONF_ENTER(chan_alice, bridge);
 	do_sleep();
 
 	ANSWER_CHANNEL(chan_bob);
 	EMULATE_APP_DATA(chan_bob, 2, "Bridge", "");
 
-	ast_bridge_impart(bridge, chan_bob, NULL, NULL, 0);
-	do_sleep();
-	CONF_ENTER_EVENT(chan_bob, bridge);
+	CONF_ENTER(chan_bob, bridge);
 
 	CONF_EXIT(chan_alice, bridge);
 	CONF_EXIT(chan_bob, bridge);
@@ -539,13 +541,9 @@
 	EMULATE_APP_DATA(chan_bob, 2, "Bridge", "");
 	do_sleep();
 
-	CONF_ENTER_EVENT(chan_bob, bridge);
-	ast_bridge_impart(bridge, chan_bob, NULL, NULL, 0);
-	do_sleep();
-
-	ast_bridge_impart(bridge, chan_alice, NULL, NULL, 0);
-	do_sleep();
-	CONF_ENTER_EVENT(chan_alice, bridge);
+	CONF_ENTER(chan_bob, bridge);
+
+	CONF_ENTER(chan_alice, bridge);
 
 	CONF_EXIT(chan_alice, bridge);
 	CONF_EXIT(chan_bob, bridge);
@@ -559,7 +557,7 @@
 /* XXX Validation needs to be reworked on a per-channel basis before
  * test_cel_single_multiparty_bridge and test_cel_dial_answer_multiparty
  * can operate properly. */
-#if 0
+#ifdef RACEY_TESTS
 AST_TEST_DEFINE(test_cel_single_multiparty_bridge)
 {
 	RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
@@ -595,24 +593,18 @@
 
 	do_sleep();
 
-	ast_bridge_impart(bridge, chan_alice, NULL, NULL, 0);
-	do_sleep();
-	CONF_ENTER_EVENT(chan_alice, bridge);
+	CONF_ENTER(chan_alice, bridge);
 
 	ANSWER_CHANNEL(chan_bob);
 	EMULATE_APP_DATA(chan_bob, 2, "Bridge", "");
 	do_sleep();
 
-	ast_bridge_impart(bridge, chan_bob, NULL, NULL, 0);
-	do_sleep();
-	CONF_ENTER_EVENT(chan_bob, bridge);
+	CONF_ENTER(chan_bob, bridge);
 
 	ANSWER_CHANNEL(chan_charlie);
 	EMULATE_APP_DATA(chan_charlie, 2, "Bridge", "");
 	do_sleep();
-	ast_bridge_impart(bridge, chan_charlie, NULL, NULL, 0);
-	do_sleep();
-	CONF_ENTER_EVENT(chan_charlie, bridge);
+	CONF_ENTER(chan_charlie, bridge);
 
 	CONF_EXIT(chan_alice, bridge);
 	CONF_EXIT(chan_bob, bridge);
@@ -950,13 +942,8 @@
 
 	do_sleep();
 
-	ast_bridge_impart(bridge, chan_caller, NULL, NULL, 0);
-	do_sleep();
-	CONF_ENTER_EVENT(chan_caller, bridge);
-
-	ast_bridge_impart(bridge, chan_callee, NULL, NULL, 0);
-	do_sleep();
-	CONF_ENTER_EVENT(chan_callee, bridge);
+	CONF_ENTER(chan_caller, bridge);
+	CONF_ENTER(chan_callee, bridge);
 
 	CONF_EXIT(chan_caller, bridge);
 	CONF_EXIT(chan_callee, bridge);
@@ -1001,13 +988,8 @@
 	ANSWER_NO_APP(chan_callee);
 
 	do_sleep();
-	ast_bridge_impart(bridge, chan_callee, NULL, NULL, 0);
-	do_sleep();
-	CONF_ENTER_EVENT(chan_callee, bridge);
-
-	ast_bridge_impart(bridge, chan_caller, NULL, NULL, 0);
-	do_sleep();
-	CONF_ENTER_EVENT(chan_caller, bridge);
+	CONF_ENTER(chan_callee, bridge);
+	CONF_ENTER(chan_caller, bridge);
 
 	CONF_EXIT(chan_caller, bridge);
 	CONF_EXIT(chan_callee, bridge);
@@ -1018,7 +1000,7 @@
 	return AST_TEST_PASS;
 }
 
-#if 0
+#ifdef RACEY_TESTS
 AST_TEST_DEFINE(test_cel_dial_answer_multiparty)
 {
 	RAII_VAR(struct ast_channel *, chan_alice, NULL, safe_channel_release);
@@ -1076,20 +1058,10 @@
 	do_sleep();
 
 	do_sleep();
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_charlie, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_charlie, bridge);
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_david, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_david, bridge);
-
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_bob, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_bob, bridge);
-
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_alice, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_alice, bridge);
+	CONF_ENTER(chan_charlie, bridge);
+	CONF_ENTER(chan_david, bridge);
+	CONF_ENTER(chan_bob, bridge);
+	CONF_ENTER(chan_alice, bridge);
 
 	CONF_EXIT(chan_alice, bridge);
 	CONF_EXIT(chan_bob, bridge);
@@ -1135,13 +1107,8 @@
 	ANSWER_NO_APP(chan_alice);
 	ANSWER_NO_APP(chan_bob);
 
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_bob, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_bob, bridge);
-
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge, chan_alice, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_alice, bridge);
+	CONF_ENTER(chan_bob, bridge);
+	CONF_ENTER(chan_alice, bridge);
 
 	pair.bridge = bridge;
 	pair.channel = chan_alice;
@@ -1194,13 +1161,8 @@
 	ANSWER_NO_APP(chan_alice);
 	ANSWER_NO_APP(chan_bob);
 
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge1, chan_bob, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_bob, bridge1);
-
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge1, chan_alice, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_alice, bridge1);
+	CONF_ENTER(chan_bob, bridge1);
+	CONF_ENTER(chan_alice, bridge1);
 
 	/* Create second set of bridged parties */
 	bridge2 = ast_bridge_basic_new();
@@ -1211,13 +1173,9 @@
 	ANSWER_NO_APP(chan_david);
 	ANSWER_NO_APP(chan_charlie);
 
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge2, chan_charlie, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_charlie, bridge2);
-
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge2, chan_david, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_david, bridge2);
+	CONF_ENTER(chan_charlie, bridge2);
+
+	CONF_ENTER(chan_david, bridge2);
 	CONF_EXIT_EVENT(chan_bob, bridge1);
 	do_sleep();
 
@@ -1282,13 +1240,8 @@
 	ANSWER_NO_APP(chan_alice);
 	ANSWER_NO_APP(chan_bob);
 
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge1, chan_bob, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_bob, bridge1);
-
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge1, chan_alice, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_alice, bridge1);
+	CONF_ENTER(chan_bob, bridge1);
+	CONF_ENTER(chan_alice, bridge1);
 
 	/* Create second set of bridged parties */
 	bridge2 = ast_bridge_base_new(AST_BRIDGE_CAPABILITY_1TO1MIX | AST_BRIDGE_CAPABILITY_NATIVE | AST_BRIDGE_CAPABILITY_MULTIMIX,
@@ -1300,13 +1253,9 @@
 	ANSWER_NO_APP(chan_david);
 	ANSWER_NO_APP(chan_charlie);
 
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge2, chan_charlie, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_charlie, bridge2);
-
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge2, chan_david, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_david, bridge2);
+	CONF_ENTER(chan_charlie, bridge2);
+
+	CONF_ENTER(chan_david, bridge2);
 
 	/* Perform attended transfer */
 	ast_bridge_transfer_attended(chan_alice, chan_david);
@@ -1372,13 +1321,8 @@
 	ANSWER_NO_APP(chan_alice);
 	ANSWER_NO_APP(chan_bob);
 
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge1, chan_bob, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_bob, bridge1);
-
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge1, chan_alice, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_alice, bridge1);
+	CONF_ENTER(chan_bob, bridge1);
+	CONF_ENTER(chan_alice, bridge1);
 
 	/* Create second set of bridged parties */
 	bridge2 = ast_bridge_base_new(AST_BRIDGE_CAPABILITY_1TO1MIX | AST_BRIDGE_CAPABILITY_NATIVE | AST_BRIDGE_CAPABILITY_MULTIMIX,
@@ -1392,13 +1336,8 @@
 	ANSWER_NO_APP(chan_david);
 	ANSWER_NO_APP(chan_charlie);
 
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge2, chan_charlie, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_charlie, bridge2);
-
-	ast_test_validate(test, 0 == ast_bridge_impart(bridge2, chan_david, NULL, NULL, 0));
-	do_sleep();
-	CONF_ENTER_EVENT(chan_david, bridge2);
+	CONF_ENTER(chan_charlie, bridge2);
+	CONF_ENTER(chan_david, bridge2);
 
 	/* Perform attended transfer */
 
@@ -1902,7 +1841,9 @@
 	AST_TEST_UNREGISTER(test_cel_single_bridge_continue);
 	AST_TEST_UNREGISTER(test_cel_single_twoparty_bridge_a);
 	AST_TEST_UNREGISTER(test_cel_single_twoparty_bridge_b);
-	/*AST_TEST_UNREGISTER(test_cel_single_multiparty_bridge);*/
+#ifdef RACEY_TESTS
+	AST_TEST_UNREGISTER(test_cel_single_multiparty_bridge);
+#endif
 
 	AST_TEST_UNREGISTER(test_cel_dial_unanswered);
 	AST_TEST_UNREGISTER(test_cel_dial_congestion);
@@ -1913,7 +1854,9 @@
 	AST_TEST_UNREGISTER(test_cel_dial_answer_no_bridge);
 	AST_TEST_UNREGISTER(test_cel_dial_answer_twoparty_bridge_a);
 	AST_TEST_UNREGISTER(test_cel_dial_answer_twoparty_bridge_b);
-	/*AST_TEST_UNREGISTER(test_cel_dial_answer_multiparty);*/
+#ifdef RACEY_TESTS
+	AST_TEST_UNREGISTER(test_cel_dial_answer_multiparty);
+#endif
 
 	AST_TEST_UNREGISTER(test_cel_blind_transfer);
 	AST_TEST_UNREGISTER(test_cel_attended_transfer_bridges_swap);
@@ -1974,7 +1917,9 @@
 	AST_TEST_REGISTER(test_cel_single_bridge_continue);
 	AST_TEST_REGISTER(test_cel_single_twoparty_bridge_a);
 	AST_TEST_REGISTER(test_cel_single_twoparty_bridge_b);
-	/*AST_TEST_REGISTER(test_cel_single_multiparty_bridge);*/
+#ifdef RACEY_TESTS
+	AST_TEST_REGISTER(test_cel_single_multiparty_bridge);
+#endif
 
 	AST_TEST_REGISTER(test_cel_dial_unanswered);
 	AST_TEST_REGISTER(test_cel_dial_congestion);
@@ -1985,7 +1930,9 @@
 	AST_TEST_REGISTER(test_cel_dial_answer_no_bridge);
 	AST_TEST_REGISTER(test_cel_dial_answer_twoparty_bridge_a);
 	AST_TEST_REGISTER(test_cel_dial_answer_twoparty_bridge_b);
-	/*AST_TEST_REGISTER(test_cel_dial_answer_multiparty);*/
+#ifdef RACEY_TESTS
+	AST_TEST_REGISTER(test_cel_dial_answer_multiparty);
+#endif
 
 	AST_TEST_REGISTER(test_cel_blind_transfer);
 	AST_TEST_REGISTER(test_cel_attended_transfer_bridges_swap);




More information about the asterisk-commits mailing list