stp: add testcases for M3UA-over-TCP

Change-Id: I1e2a887aa22f317783b3207494fd707d7b426439
Related: docker-playground.git I210b7d62845075dcfe147f2f77603625cc1e64f9
Related: SYS#5424
diff --git a/stp/STP_Tests_M3UA.ttcn b/stp/STP_Tests_M3UA.ttcn
index 96cd268..a0162cb 100644
--- a/stp/STP_Tests_M3UA.ttcn
+++ b/stp/STP_Tests_M3UA.ttcn
@@ -1203,6 +1203,75 @@
 	f_clear_m3ua();
 }
 
+private function f_TC_m3ua_tcp(integer idx_a, integer idx_b) runs on RAW_M3UA_CT {
+	var M3uaConfig cfg_a := mp_m3ua_configs[idx_a];
+	var M3uaConfig cfg_b := mp_m3ua_configs[idx_b];
+	var OCT4 rctx_a := int2oct(cfg_a.routing_ctx, 4);
+	var OCT4 rctx_b := int2oct(cfg_b.routing_ctx, 4);
+	var OCT4 pc_a := int2oct(cfg_a.point_code, 4);
+	var OCT4 pc_b := int2oct(cfg_b.point_code, 4);
+
+	/* establish connection with ASP 'A' */
+	if (idx_a < NR_M3UA) {
+		f_M3UA_asp_up_act(idx_a, rctx := rctx_a);
+	} else {
+		f_M3UA_CLNT_asp_up_act(idx_a, rctx := rctx_a);
+	}
+
+	/* establish connection with ASP 'B' */
+	if (idx_b < NR_M3UA) {
+		f_M3UA_asp_up_act(idx_b, rctx := rctx_b);
+	} else {
+		f_M3UA_CLNT_asp_up_act(idx_b, rctx := rctx_b);
+	}
+
+	/* In the case when ASP[idx_b] is configured as the client (i.e. osmo-stp connects to
+	 * the testsuite; idx_b >= NR_M3UA), in f_M3UA_CLNT_asp_up_act() we're expecting to
+	 * receive ASPACT and then sending ASPACT_ACK to it.  Right after that, we're sending
+	 * some random data via ASP[idx_a], which we then expect to receive via ASP[idx_b].
+	 *
+	 * There is a chance that the random data sent via ASP[idx_a] would reach osmo-stp
+	 * earlier than the ASPUP_ACK we sent for ASP[idx_b].  This is happening most of the
+	 * times when running TC_m3ua_tcp_cli_srv.  Using f_sleep() helps to avoid this. */
+	f_sleep(1.0);
+
+	/* M3UA/A -> M3UA/B */
+	f_test_traffic(idx_a, rctx_a, pc_a,
+		       idx_b, rctx_b, pc_b);
+	/* M3UA/B -> M3UA/A */
+	f_test_traffic(idx_b, rctx_b, pc_b,
+		       idx_a, rctx_a, pc_a);
+
+	f_clear_m3ua();
+}
+
+/* test routing between M3UA/SCTP (client) and M3UA/TCP (client) */
+testcase TC_m3ua_tcp_cli() runs on RAW_M3UA_CT {
+	f_init_m3ua();
+	f_TC_m3ua_tcp(0, 3); /* 'asp-sender' <-> 'asp-sender-tcp' */
+}
+
+/* test routing between M3UA/SCTP (client) and M3UA/TCP (server) */
+testcase TC_m3ua_tcp_cli_srv() runs on RAW_M3UA_CT {
+	f_init_m3ua();
+	f_init_m3ua_srv();
+	f_TC_m3ua_tcp(0, M3UA_SRV(3)); /* 'asp-sender' <-> 'asp-client-tcp' */
+}
+
+/* test routing between M3UA/SCTP (server) and M3UA/TCP (server) */
+testcase TC_m3ua_tcp_srv() runs on RAW_M3UA_CT {
+	f_init_m3ua();
+	f_init_m3ua_srv();
+	f_TC_m3ua_tcp(M3UA_SRV(0), M3UA_SRV(3)); /* 'asp-client' <-> 'asp-client-tcp' */
+}
+
+/* test routing between M3UA/SCTP (server) and M3UA/TCP (client) */
+testcase TC_m3ua_tcp_srv_cli() runs on RAW_M3UA_CT {
+	f_init_m3ua();
+	f_init_m3ua_srv();
+	f_TC_m3ua_tcp(M3UA_SRV(0), 3); /* 'asp-client' <-> 'asp-sender-tcp' */
+}
+
 
 control {
 	/* M3UA Tests */
@@ -1218,6 +1287,11 @@
 	execute( TC_tmt_broadcast() );
 	execute( TC_act_rctx_data_no_rctx() );
 
+	execute( TC_m3ua_tcp_cli() );
+	execute( TC_m3ua_tcp_cli_srv() );
+	execute( TC_m3ua_tcp_srv() );
+	execute( TC_m3ua_tcp_srv_cli() );
+
 	/* M3UA RKM tests */
 	execute( TC_rkm_reg_static_notpermitted() );
 	execute( TC_rkm_reg_static_permitted() );