summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2018-03-21 19:33:13 +0100
committerHarald Welte <laforge@gnumonks.org>2018-03-21 22:48:18 +0100
commit60aa576a6288b1a71f29b74933143a1cbbda4e55 (patch)
treebbdcd5099b1e4ec75aaf9240285b565d857df149
parent6fa1f73346fedff8055314645063de3251abe2bc (diff)
bsc: Add tests for assigning channels of all 5 codecs
This tests if the BSC is chosing the correct codec during the assignment procedure. Change-Id: Ia67c09fa725eff48ec56779f8674ddcaa08a8793
-rw-r--r--bsc/BSC_Tests.ttcn173
-rw-r--r--bsc/MSC_ConnectionHandler.ttcn6
2 files changed, 177 insertions, 2 deletions
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index 94f38fd..ea67105 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -1569,6 +1569,173 @@ testcase TC_assignment_sign() runs on test_CT {
vc_conn.done;
}
+/***********************************************************************
+ * Codec (list) testing
+ ***********************************************************************/
+
+/* check if the given rsl_mode is compatible with the a_elem */
+private function f_match_codec(BSSMAP_FIELD_CodecElement a_elem, RSL_IE_ChannelMode rsl_mode)
+return boolean {
+ select (a_elem.codecType) {
+ case (GSM_FR) {
+ if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM1))) {
+ return true;
+ }
+ }
+ case (GSM_HR) {
+ if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM1))) {
+ return true;
+ }
+ }
+ case (GSM_EFR) {
+ if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM2))) {
+ return true;
+ }
+ }
+ case (FR_AMR) {
+ if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_F, RSL_CMOD_SP_GSM3))) {
+ return true;
+ }
+ }
+ case (HR_AMR) {
+ if (match(rsl_mode, tr_RSL_ChanMode(RSL_CHRT_TCH_H, RSL_CMOD_SP_GSM3))) {
+ return true;
+ }
+ }
+ case else { }
+ }
+ return false;
+}
+
+/* check if the given rsl_mode is compatible with the a_list */
+private function f_match_codecs(BSSMAP_IE_SpeechCodecList a_list, RSL_IE_ChannelMode rsl_mode)
+return boolean {
+ for (var integer i := 0; i < sizeof(a_list); i := i+1) {
+ if (f_match_codec(a_list.codecElements[i], rsl_mode)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+/* determine BSSMAP_IE_ChannelType from *first* element of BSSMAP_FIELD_CodecElement */
+private function f_BSSMAP_chtype_from_codec(BSSMAP_FIELD_CodecElement a_elem)
+return BSSMAP_IE_ChannelType {
+ /* FIXME: actually look at all elements of BSSMAP_IE_SpeechCodecList */
+ var BSSMAP_IE_ChannelType ret := valueof(ts_BSSMAP_IE_ChannelType);
+ select (a_elem.codecType) {
+ case (GSM_FR) {
+ ret.channelRateAndType := ChRate_TCHF;
+ ret.speechId_DataIndicator := Spdi_TCHF_FR;
+ }
+ case (GSM_HR) {
+ ret.channelRateAndType := ChRate_TCHH;
+ ret.speechId_DataIndicator := Spdi_TCHH_HR;
+ }
+ case (GSM_EFR) {
+ ret.channelRateAndType := ChRate_TCHF;
+ ret.speechId_DataIndicator := Spdi_TCHF_EFR;
+ }
+ case (FR_AMR) {
+ ret.channelRateAndType := ChRate_TCHF;
+ ret.speechId_DataIndicator := Spdi_TCHF_AMR;
+ }
+ case (HR_AMR) {
+ ret.channelRateAndType := ChRate_TCHH;
+ ret.speechId_DataIndicator := Spdi_TCHH_AMR;
+ }
+ case else {
+ setverdict(fail, "Unsupported codec ", a_elem);
+ self.stop;
+ }
+ }
+ return ret;
+}
+
+type record CodecListTest {
+ BSSMAP_IE_SpeechCodecList codec_list,
+ charstring id
+}
+type record of CodecListTest CodecListTests
+
+private function f_TC_assignment_codec(charstring id) runs on MSC_ConnHdlr {
+ var BSSMAP_IE_AoIP_TransportLayerAddress tla := valueof(ts_BSSMAP_IE_AoIP_TLA4('01020304'O, 2342));
+ var PDU_BSSAP ass_cmd := valueof(ts_BSSMAP_AssignmentReq(omit, tla));
+ var template PDU_BSSAP exp_compl := tr_BSSMAP_AssignmentComplete(omit, ?);
+
+ /* puzzle together the ASSIGNMENT REQ for given codec[s] */
+ ass_cmd.pdu.bssmap.assignmentRequest.codecList := g_pars.ass_codec_list;
+ ass_cmd.pdu.bssmap.assignmentRequest.channelType :=
+ f_BSSMAP_chtype_from_codec(g_pars.ass_codec_list.codecElements[0]);
+ exp_compl.pdu.bssmap.assignmentComplete.speechCodec.codecElements[0] :=
+ g_pars.ass_codec_list.codecElements[0];
+ log("expecting ASS COMPL like this: ", exp_compl);
+
+ f_establish_fully(ass_cmd, exp_compl);
+}
+
+testcase TC_assignment_codec_fr() runs on test_CT {
+ var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
+ var MSC_ConnHdlr vc_conn;
+
+ f_init(1, true);
+ f_sleep(1.0);
+
+ pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
+ vc_conn := f_start_handler(refers(f_TC_assignment_codec), testcasename(), pars);
+ vc_conn.done;
+}
+
+testcase TC_assignment_codec_hr() runs on test_CT {
+ var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
+ var MSC_ConnHdlr vc_conn;
+
+ f_init(1, true);
+ f_sleep(1.0);
+
+ pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecHR}));
+ vc_conn := f_start_handler(refers(f_TC_assignment_codec), testcasename(), pars);
+ vc_conn.done;
+}
+
+testcase TC_assignment_codec_efr() runs on test_CT {
+ var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
+ var MSC_ConnHdlr vc_conn;
+
+ f_init(1, true);
+ f_sleep(1.0);
+
+ pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecEFR}));
+ vc_conn := f_start_handler(refers(f_TC_assignment_codec), testcasename(), pars);
+ vc_conn.done;
+}
+
+testcase TC_assignment_codec_amr_f() runs on test_CT {
+ var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
+ var MSC_ConnHdlr vc_conn;
+
+ f_init(1, true);
+ f_sleep(1.0);
+
+ pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_F}));
+ vc_conn := f_start_handler(refers(f_TC_assignment_codec), testcasename(), pars);
+ vc_conn.done;
+}
+
+testcase TC_assignment_codec_amr_h() runs on test_CT {
+ var TestHdlrParams pars := valueof(t_def_TestHdlrPars);
+ var MSC_ConnHdlr vc_conn;
+
+ f_init(1, true);
+ f_sleep(1.0);
+
+ pars.ass_codec_list := valueof(ts_BSSMAP_IE_CodecList({ts_CodecAMR_H}));
+ vc_conn := f_start_handler(refers(f_TC_assignment_codec), testcasename(), pars);
+ vc_conn.done;
+}
+
+
+
/* test if L3 RR CLASSMARK CHANGE is translated to BSSMAP CLASSMARK UPDATE */
private function f_tc_classmark(charstring id) runs on MSC_ConnHdlr {
g_pars := valueof(t_def_TestHdlrPars);
@@ -1956,6 +2123,12 @@ control {
execute( TC_assignment_fr_a5_3() );
execute( TC_assignment_fr_a5_4() );
+ execute( TC_assignment_codec_fr() );
+ execute( TC_assignment_codec_hr() );
+ execute( TC_assignment_codec_efr() );
+ execute( TC_assignment_codec_amr_f() );
+ execute( TC_assignment_codec_amr_h() );
+
/* RLL Establish Indication on inactive DCHAN / SAPI */
execute( TC_rll_est_ind_inact_lchan() );
execute( TC_rll_est_ind_inval_sapi1() );
diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn
index 44def3b..659ac36 100644
--- a/bsc/MSC_ConnectionHandler.ttcn
+++ b/bsc/MSC_ConnectionHandler.ttcn
@@ -348,14 +348,16 @@ type record TestHdlrParams {
OCT1 ra,
GsmFrameNumber fn,
hexstring imsi,
- RslLinkId link_id
+ RslLinkId link_id,
+ BSSMAP_IE_SpeechCodecList ass_codec_list optional
};
template (value) TestHdlrParams t_def_TestHdlrPars := {
ra := '23'O,
fn := 23,
imsi := '001019876543210'H,
- link_id := valueof(ts_RslLinkID_DCCH(0))
+ link_id := valueof(ts_RslLinkID_DCCH(0)),
+ ass_codec_list := omit
}
function f_create_chan_and_exp() runs on MSC_ConnHdlr {