RLCMAC_EncDec.cc: Fix egprs data block encode alignment

Selftests I'm using in the pcu testsuite to verify encoding are attached
too.

Change-Id: Id0e21248853eb5fac89e863822804cfbecf3c865
diff --git a/pcu/PCU_Tests.ttcn b/pcu/PCU_Tests.ttcn
index 3562925..c69101b 100644
--- a/pcu/PCU_Tests.ttcn
+++ b/pcu/PCU_Tests.ttcn
@@ -187,7 +187,7 @@
 	}
 }
 
-private function f_init_raw(charstring id, template (value) PCUIF_info_ind info_ind := ts_PCUIF_INFO_default)
+function f_init_raw(charstring id, template (value) PCUIF_info_ind info_ind := ts_PCUIF_INFO_default)
 runs on RAW_PCU_Test_CT {
 	var RAW_PCUIF_CT vc_PCUIF;
 	var RAW_PCU_BTS_CT vc_BTS;
@@ -394,7 +394,7 @@
 }
 
 /* Enqueue DATA.ind (both TDMA frame and block numbers to be patched) */
-private function f_pcuif_tx_data_ind(octetstring data, int16_t lqual_cb := 0, uint32_t fn := 0)
+function f_pcuif_tx_data_ind(octetstring data, int16_t lqual_cb := 0, uint32_t fn := 0)
 runs on RAW_PCU_Test_CT {
 	var template RAW_PCU_EventParam ev_param := {tdma_fn := ? };
 	BTS.send(ts_PCUIF_DATA_IND(bts_nr := 0, trx_nr := 0, ts_nr := 7, block_nr := 0,
diff --git a/pcu/PCU_selftest.ttcn b/pcu/PCU_selftest.ttcn
index 3cdb4f4..15cdd80 100644
--- a/pcu/PCU_selftest.ttcn
+++ b/pcu/PCU_selftest.ttcn
@@ -17,12 +17,15 @@
 import from NS_Emulation all;
 import from GPRS_Context all;
 import from Osmocom_Gb_Types all;
+import from Osmocom_Types all;
 import from LLC_Types all;
 import from LLC_Templates all;
 import from L3_Templates all;
 import from GSM_RR_Types all;
-import from RLCMAC_Types all;
 import from RLCMAC_CSN1_Types all;
+import from RLCMAC_Types all;
+import from RLCMAC_Templates all;
+import from PCU_Tests all;
 
 type component dummy_CT extends BSSGP_Client_CT {
 	var NS_CT ns_component;
@@ -249,6 +252,53 @@
 	f_rlcmac_ul_decenc(c_ul_dl_ack_nack);
 }
 
+testcase TC_selftest_rlcmac_egprs() runs on RAW_PCU_Test_CT
+{
+	var octetstring data;
+	var CodingSchemeArray schemes := {
+		//MCS_0,
+		MCS_1,
+		MCS_2,
+		MCS_3,
+		MCS_4,
+		MCS_5,
+		MCS_6,
+		MCS_7,
+		MCS_8,
+		MCS_9
+		};
+
+	/* Initialize the PCU interface abstraction */
+	f_init_raw(testcasename());
+
+	log("Started Uplink test");
+	for (var integer i := 0; i < sizeof(schemes); i := i+1) {
+		log("Testing Coding Schema ", schemes[i]);
+		var template (value) RlcmacUlBlock ul_data := t_RLCMAC_UL_EGPRS_DATA(
+			schemes[i],
+			tfi := 4,
+			cv := 1, /* num UL blocks to be sent (to be overridden in loop) */
+			bsn1 := 2, /* TODO: what should be here? */
+			blocks := { /* To be generated in loop */ });
+
+		ul_data.data_egprs.tlli := '00100101'O;
+		ul_data.data_egprs.blocks := { valueof(t_RLCMAC_LLCBLOCK_EGPRS('AABBCCDDEEFF00112233'O)) };
+
+		/* Encode the payload of DATA.ind */
+		log("Encoding ", valueof(ul_data));
+		data := enc_RlcmacUlBlock(valueof(ul_data));
+		data := f_pad_oct(data, f_rlcmac_cs_mcs2block_len(schemes[i]), '00'O);
+
+		/* Send to PCU so that we get gsmtap traces to verify with wireshark */
+		f_pcuif_tx_data_ind(data, 0, 0);
+
+		log("Decoding ", schemes[i]);
+		ul_data := dec_RlcmacUlBlock(data);
+		log("Decoded: ", ul_data);
+	}
+	log("Done Uplink test");
+}
+
 ///////////////////
 // RR selftest
 ///////////////////