bsc: as_Media_mgw: fail on DLCX

as_Media_mgw() is used to establish a voice stream. If a DLCX happens as
part of that, that should be flagged as a problem.

In fact the Mode Modify test with current osmo-bsc does exhibit a DLCX
right upon the Assignment Complete message, which is a bug fixed in
I5ab10ee7fd9c5d7608e8a06893881d990943feed.

This patch now correctly flags this as a failure.

In the two tests
TC_ho_in_fail_no_detect, TC_ho_in_fail_no_detect2
the expected failure causes expected DLCX, so exempt those.

Related: SYS#5916
Change-Id: I0633f60f09d58802f6be0238ef41a632d93a4327
diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn
index db2e9ef..06f9ebe 100644
--- a/bsc/MSC_ConnectionHandler.ttcn
+++ b/bsc/MSC_ConnectionHandler.ttcn
@@ -373,7 +373,7 @@
 /* altstep for handling of MGCP media related commands. Activated by as_Media() to test
  * MGW level media handling */
 
-altstep as_Media_mgw(boolean norepeat := false) runs on MSC_ConnHdlr {
+altstep as_Media_mgw(boolean norepeat := false, boolean fail_on_dlcx := true) runs on MSC_ConnHdlr {
 	var MgcpCommand mgcp_cmd;
 	var template MgcpResponse mgcp_resp;
 	var MGCP_RecvFrom mrf;
@@ -383,6 +383,9 @@
 	var template MgcpMessage msg_mdcx := {
 		command := tr_MDCX
 	}
+	var template MgcpMessage msg_dlcx := {
+		command := tr_DLCX
+	}
 	var template MgcpMessage msg_resp;
 
 	[g_pars.aoip] MGCP.receive(tr_CRCX) -> value mgcp_cmd {
@@ -422,13 +425,21 @@
 			repeat;
 		}
 	}
+
+	[fail_on_dlcx and g_pars.aoip] MGCP.receive(tr_DLCX) {
+		setverdict(fail, "Unexpected DLCX received");
+	}
+
+	[fail_on_dlcx and not g_pars.aoip] MGCP_MULTI.receive(tr_MGCP_RecvFrom_any(msg_dlcx)) {
+		setverdict(fail, "Unexpected DLCX received");
+	}
 }
 
 /* Altsteps for handling of media related commands. Can be activated by a given
  * test case if it expects to see media related handling (i.e. voice calls) */
-altstep as_Media() runs on MSC_ConnHdlr {
+altstep as_Media(boolean fail_on_dlcx := true) runs on MSC_ConnHdlr {
 	[] as_Media_ipacc();
-	[] as_Media_mgw();
+	[] as_Media_mgw(fail_on_dlcx := fail_on_dlcx);
 }
 
 type port Coord_PT message