[asterisk-commits] mmichelson: trunk r397593 - /trunk/main/bridge_channel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 23 16:02:28 CDT 2013


Author: mmichelson
Date: Fri Aug 23 16:02:26 2013
New Revision: 397593

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397593
Log:
Add test events necessary for bridge tests to pass in the test suite.

(closes issue AST-1200)
reported by John Bigelow


Modified:
    trunk/main/bridge_channel.c

Modified: trunk/main/bridge_channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/bridge_channel.c?view=diff&rev=397593&r1=397592&r2=397593
==============================================================================
--- trunk/main/bridge_channel.c (original)
+++ trunk/main/bridge_channel.c Fri Aug 23 16:02:26 2013
@@ -54,6 +54,7 @@
 #include "asterisk/features_config.h"
 #include "asterisk/parking.h"
 #include "asterisk/causes.h"
+#include "asterisk/test.h"
 
 /*!
  * \brief Used to queue an action frame onto a bridge channel and write an action frame into a bridge.
@@ -1076,6 +1077,44 @@
 {
 	return bridge_channel_write_action_data(bridge_channel,
 		BRIDGE_CHANNEL_ACTION_DTMF_STREAM, dtmf, strlen(dtmf) + 1);
+}
+
+/*!
+ * \internal
+ * \brief Indicate to the testsuite a feature was successfully detected.
+ *
+ * Currently, this function only will relay built-in features to the testsuite,
+ * but it could be modified to detect applicationmap items should the need arise.
+ *
+ * \param chan The channel that activated the feature
+ * \param dtmf The DTMF sequence entered to activate the feature
+ */
+static void testsuite_notify_feature_success(struct ast_channel *chan, const char *dtmf)
+{
+#ifdef TEST_FRAMEWORK
+	char *feature = "unknown";
+	struct ast_featuremap_config *featuremap = ast_get_chan_featuremap_config(chan);
+
+	if (featuremap) {
+		if (!strcmp(dtmf, featuremap->blindxfer)) {
+			feature = "blindxfer";
+		} else if (!strcmp(dtmf, featuremap->atxfer)) {
+			feature = "atxfer";
+		} else if (!strcmp(dtmf, featuremap->disconnect)) {
+			feature = "disconnect";
+		} else if (!strcmp(dtmf, featuremap->automon)) {
+			feature = "automon";
+		} else if (!strcmp(dtmf, featuremap->automixmon)) {
+			feature = "automixmon";
+		} else if (!strcmp(dtmf, featuremap->parkcall)) {
+			feature = "parkcall";
+		}
+	}
+
+	ast_test_suite_event_notify("FEATURE_DETECTION",
+			"Result: success\r\n"
+			"Feature: %s", feature);
+#endif /* TEST_FRAMEWORK */
 }
 
 /*!
@@ -1170,8 +1209,10 @@
 				hook, bridge_channel, ast_channel_name(bridge_channel->chan));
 			ao2_unlink(features->dtmf_hooks, hook);
 		}
+
+		testsuite_notify_feature_success(bridge_channel->chan, hook->dtmf.code);
+
 		ao2_ref(hook, -1);
-
 		/*
 		 * If we are handing the channel off to an external hook for
 		 * ownership, we are not guaranteed what kind of state it will
@@ -1181,9 +1222,12 @@
 		if (bridge_channel->chan && ast_check_hangup_locked(bridge_channel->chan)) {
 			ast_bridge_channel_kick(bridge_channel, 0);
 		}
-	} else if (features->dtmf_passthrough) {
-		/* Stream any collected DTMF to the other channels. */
-		bridge_channel_write_dtmf_stream(bridge_channel, dtmf);
+	} else {
+		if (features->dtmf_passthrough) {
+			/* Stream any collected DTMF to the other channels. */
+			bridge_channel_write_dtmf_stream(bridge_channel, dtmf);
+		}
+		ast_test_suite_event_notify("FEATURE_DETECTION", "Result: fail");
 	}
 }
 
@@ -1713,6 +1757,13 @@
 		}
 		ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
 		bridge_channel_unsuspend(bridge_channel);
+#ifdef TEST_FRAMEWORK
+	} else if (frame->frametype == AST_FRAME_DTMF_END) {
+		/* Only transmit this event on DTMF end or else every DTMF
+		 * press will result in the event being broadcast twice
+		 */
+		ast_test_suite_event_notify("FEATURE_DETECTION", "Result: fail");
+#endif
 	}
 
 	return frame;




More information about the asterisk-commits mailing list