bts: low-level RSL ERROR REPORT Testing

Change-Id: If1cc6c672d5a0cf8eb8ef23b96eb1e80ceef30f1
diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index 2d0b81d..ed37428 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -949,6 +949,56 @@
 	/* negative test: ensure ERROR REPORT on unsupported types */
 }
 
+private function f_exp_err_rep(template RSL_Cause cause) runs on test_CT {
+	timer T := 5.0;
+	T.start;
+	alt {
+	[] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(cause))) {
+		setverdict(pass);
+		}
+	[] RSL_CCHAN.receive(tr_RSL_UD(tr_RSL_ERROR_REPORT(?))) {
+		setverdict(fail, "Wrong cause in RSL ERR REP");
+		}
+	[] RSL_CCHAN.receive {
+		repeat;
+		}
+	[] T.timeout {
+		setverdict(fail, "Timeout waiting for RSL ERR REP");
+		}
+	}
+}
+
+/* Provoke a protocol error (message too short) and match on ERROR REPORT */
+testcase TC_rsl_protocol_error() runs on test_CT {
+	f_init(testcasename());
+	var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
+	rsl.ies := omit;
+	RSL_CCHAN.send(ts_RSL_UD(rsl));
+
+	f_exp_err_rep(RSL_ERR_PROTO);
+}
+
+/* Provoke a mandatory IE error and match on ERROR REPORT */
+testcase TC_rsl_mand_ie_error() runs on test_CT {
+	f_init(testcasename());
+
+	var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
+	rsl.ies := { rsl.ies[0] };
+	RSL_CCHAN.send(ts_RSL_UD(rsl));
+
+	f_exp_err_rep(RSL_ERR_MAND_IE_ERROR);
+}
+
+/* Provoke an IE content error and match on ERROR REPORT */
+testcase TC_rsl_ie_content_error() runs on test_CT {
+	f_init(testcasename());
+	var RSL_Message rsl := valueof(ts_RSL_BCCH_INFO(RSL_SYSTEM_INFO_1, ''O));
+	rsl.ies[1].body.sysinfo_type := RSL_SYSTEM_INFO_5;
+	RSL_CCHAN.send(ts_RSL_UD(rsl));
+
+	f_exp_err_rep(RSL_ERR_IE_CONTENT);
+}
+
 
 /* TODO Areas:
 
@@ -979,8 +1029,6 @@
 ** type error
 ** sequence error
 ** IE duplicated?
-** IE missing
-** IE length error
 
 */
 
@@ -999,6 +1047,9 @@
 	execute( TC_paging_tmsi_80percent() );
 	execute( TC_paging_imsi_200percent() );
 	execute( TC_paging_tmsi_200percent() );
+	execute( TC_rsl_protocol_error() );
+	execute( TC_rsl_mand_ie_error() );
+	execute( TC_rsl_ie_content_error() );
 }