BTS_Tests.ttcn: add TC_pcu_ext_rach_content() for 11-bit RACH

According to 3GPP TS 04.60, section 11.2.5a, the extended (11-bit)
Access Burst on RACH/PRACH is used by the MS to indicate its EGPRS
capability. One of the alternative synch. sequences (see 3GPP TS
05.02, TS1 and TS2) shall be used.

Add a test case to verify extended (11-bit) RACH decoding.

Depends: (OsmocomBB) I36fd20cd5502ce33c52f644ee4c22abb83350df8
Change-Id: I8fe156aeac9de3dc1e71a4950821d4942ba9a253
Related: OS#1854
diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index e617323..711947a 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -989,6 +989,12 @@
 	return ra;
 }
 
+/* generate a random 11-bit RA (packet-switched only) */
+private function f_rnd_ra11_ps() return BIT11 {
+	var integer ra11 := f_rnd_int(bit2int('11111111111'B));
+	return int2bit(ra11, 11);
+}
+
 /* Send 1000 RACH requests and check their RA+FN on the RSL side */
 testcase TC_rach_content() runs on test_CT {
 	f_init(testcasename());
@@ -2969,6 +2975,64 @@
 	setverdict(pass);
 }
 
+/* Send extended (11-bit, TS1 & TS2) RACH bursts from the Um side,
+ * expect them to show up on PCU socket (with proper BURST_TYPE_*). */
+testcase TC_pcu_ext_rach_content() runs on test_CT {
+	var template PCUIF_Message pcu_rach_ind;
+	var GsmFrameNumber fn_last := 0;
+	var L1ctlRachSynchSeq synch_seq;
+	var PCUIF_BurstType pcu_bt;
+	var GsmFrameNumber fn;
+	var BIT11 ra11;
+
+	f_init_pcu_test();
+	f_init_l1ctl();
+	f_l1_tune(L1CTL);
+
+	for (var integer i := 0; i < 1000; i := i+1) {
+		/* We need to test both TS1 & TS2 */
+		if (i rem 2 == 0) {
+			synch_seq := RACH_SYNCH_SEQ_TS1;
+			pcu_bt := BURST_TYPE_1;
+		} else {
+			synch_seq := RACH_SYNCH_SEQ_TS2;
+			pcu_bt := BURST_TYPE_2;
+		}
+
+		ra11 := f_rnd_ra11_ps();
+		fn := f_L1CTL_EXT_RACH(L1CTL, bit2int(ra11), synch_seq);
+		if (fn == fn_last) {
+			Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+						"Two RACH in same FN?!?");
+		}
+		fn_last := fn;
+
+		/* Compose the expected message */
+		pcu_rach_ind := tr_PCUIF_RACH_IND(
+			bts_nr := 0,
+			ra := bit2int(ra11),
+			is_11bit := 1,
+			burst_type := pcu_bt,
+			fn := fn);
+
+		timer T := 2.0;
+		T.start;
+		alt {
+		[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, pcu_rach_ind)) {
+			T.stop;
+			}
+		[] PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_RACH_IND)) {
+			Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected RACH IND");
+			}
+		[] PCU.receive { repeat; }
+		[] T.timeout {
+			Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Timeout waiting for RACH IND");
+			}
+		}
+	}
+	setverdict(pass);
+}
+
 private function f_pad_oct(octetstring str, integer len, OCT1 pad) return octetstring {
 	var integer strlen := lengthof(str);
 	for (var integer i := 0; i < len-strlen; i := i+1) {
@@ -4311,6 +4375,7 @@
 		execute( TC_pcu_data_req_agch() );
 		execute( TC_pcu_data_req_imm_ass_pch() );
 		execute( TC_pcu_rach_content() );
+		execute( TC_pcu_ext_rach_content() );
 		execute( TC_pcu_paging_from_rsl() );
 	} else {
 		log("PCU socket path not available, skipping PCU tests");