bsc-nat: Introduce Osmux test

Depends: openbsc.git Iadc004064a5a237c93009f242cb943ebc4d2d7e6
Change-Id: I35f206aab713ccf0a4e074872e291c349c903b9d
diff --git a/bsc-nat/BSCNAT_Tests.ttcn b/bsc-nat/BSCNAT_Tests.ttcn
index b9b031f..2fab4a3 100644
--- a/bsc-nat/BSCNAT_Tests.ttcn
+++ b/bsc-nat/BSCNAT_Tests.ttcn
@@ -26,6 +26,9 @@
 import from MSC_Simulation all;
 import from BSC_MS_Simulation all;
 
+import from Osmocom_VTY_Functions all;
+import from TELNETasp_PortType all;
+
 const integer NUM_MSC := 1;
 const integer NUM_BSC := 1;
 
@@ -46,6 +49,8 @@
 	var MscState msc[NUM_MSC];
 	var BscState bsc[NUM_BSC];
 
+	port TELNETasp_PT BSCNATVTY;
+
 	var boolean g_initialized := false;
 	var octetstring g_sio := '83'O;
 }
@@ -112,10 +117,31 @@
 	msc_st.sccp_addr_own := valueof(ts_SccpAddr_PC_SSN(opc, local_ssn));
 }
 
-function f_init() runs on test_CT {
+function f_vty_allow_osmux(boolean allow) runs on test_CT {
+	if (allow) {
+		f_vty_config(BSCNATVTY, "mgcp", "osmux on");
+	} else {
+		f_vty_config(BSCNATVTY, "mgcp", "osmux off");
+	}
+}
+
+function f_init_vty(charstring id := "foo") runs on test_CT {
+	if (BSCNATVTY.checkstate("Mapped")) {
+		/* skip initialization if already executed once */
+		return;
+	}
+	map(self:BSCNATVTY, system:BSCNATVTY);
+	f_vty_set_prompts(BSCNATVTY);
+	f_vty_transceive(BSCNATVTY, "enable");
+}
+
+function f_init(boolean use_osmux) runs on test_CT {
 	var integer i;
 	var charstring id;
 
+	f_init_vty("VirtBSCNAT");
+	f_vty_allow_osmux(use_osmux);
+
 	for (i := 0; i < NUM_MSC; i := i+1) {
 		f_init_MscState(msc[i], mp_msc_pc +i, mp_bsc_pc, mp_msc_ssn, mp_bsc_ssn);
 		id := "MSC" & int2str(i);
@@ -125,22 +151,23 @@
 
 	/* Wait for bsc_nat to attach to MSC. Before that all BSC connections will be dropped */
 	f_sleep(5.0);
+
 	for (i := 0; i < NUM_BSC; i := i+1) {
 		f_init_BscState(bsc[i], mp_bsc_pc +i, mp_msc_pc, mp_bsc_ssn, mp_msc_ssn);
 		id := "BSC" & int2str(i);
 		bsc[i].BSC := BSC_CT.create(id);
 		bsc[i].BSC.start(BSC_MS_Simulation.main(mp_nat_ip, mp_nat_port, mp_bsc_ip, mp_bsc_port+i,
 							bsc[i].sccp_pars, bsc[i].sccp_addr_own,
-							bsc[i].sccp_addr_peer, id));
+							bsc[i].sccp_addr_peer, use_osmux, id));
 	}
 
 }
 
-testcase TC_recv_dump() runs on test_CT {
+function f_TC_recv_dump(boolean use_osmux := false) runs on test_CT {
 	var integer i;
 	timer T := 30.0;
 
-	f_init();
+	f_init(use_osmux);
 
 	alt {
 		/* wait for BSC to stop. The idea is that the BSC components terminate first */
@@ -155,8 +182,17 @@
 	}
 }
 
+testcase TC_recv_dump() runs on test_CT {
+	f_TC_recv_dump();
+}
+
+testcase TC_recv_dump_osmux() runs on test_CT {
+	f_TC_recv_dump(true);
+}
+
 control {
 	execute( TC_recv_dump() );
+	execute( TC_recv_dump_osmux() );
 }
 
 }