Vadim Yanitskiy has uploaded this change for review. ( 
https://gerrit.osmocom.org/9471


Change subject: WIP: msc/USSD: add multi-transaction testcase
......................................................................

WIP: msc/USSD: add multi-transaction testcase

The idea of this testcase is to establish a dedicated connection,
perform location update, and then send 8 USSD requests on 8
separate transactions at once. A few requests contain known
'*#100#' request code, others are intentionally wrong.

Finally, we expect that each received response shall correspond
to its request and shall be sent back on a proper transaction.

Change-Id: Ifa3cd1aeeb34ccf5864f78b76a88aaa6d5e51839
---
M msc/MSC_Tests.ttcn
1 file changed, 136 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/71/9471/1

diff --git a/msc/MSC_Tests.ttcn b/msc/MSC_Tests.ttcn
index 7b8740c..bb44f83 100644
--- a/msc/MSC_Tests.ttcn
+++ b/msc/MSC_Tests.ttcn
@@ -2216,6 +2216,141 @@
        vc_conn.done;
 }

+private template (value) PDU_DTAP_MO ts_dtap_ussd_init_req(
+       uint3_t tid := 0,
+       charstring code
+) := ts_PDU_DTAP_MO(
+       ts_ML3_MO_SS_REGISTER(
+               tid := tid,
+               ti_flag := c_TIF_ORIG,
+               facility := f_USSD_FACILITY_IE_INVOKE(
+                       invoke_id := 5, /* Phone may not start from 0 or 1 */
+                       op_code := SS_OP_CODE_PROCESS_USS_REQ,
+                       ussd_string := code
+               )
+       )
+)
+private template PDU_DTAP_MT tr_dtap_ussd_result(
+       template uint3_t tid := ?,
+       charstring result
+) := tr_PDU_DTAP_MT(
+       tr_ML3_MT_SS_RELEASE_COMPLETE(
+               tid := tid,
+               ti_flag := c_TIF_REPL,
+               facility := f_USSD_FACILITY_IE_RETURN_RESULT(
+                       invoke_id := 5, /* Phone may not start from 0 or 1 */
+                       op_code := SS_OP_CODE_PROCESS_USS_REQ,
+                       ussd_string := result
+               )
+       )
+)
+private template PDU_DTAP_MT tr_dtap_ussd_error(
+       template uint3_t tid := ?,
+       SS_Err_Code err_code
+) := tr_PDU_DTAP_MT(
+       tr_ML3_MT_SS_RELEASE_COMPLETE(
+               tid := tid,
+               ti_flag := c_TIF_REPL,
+               facility := f_USSD_FACILITY_IE_RETURN_ERROR(
+                       invoke_id := 5, /* Phone may not start from 0 or 1 */
+                       err_code := err_code
+               )
+       )
+)
+
+private function f_tc_lu_and_ussd_multi_tid(charstring id, BSC_ConnHdlrPars 
pars)
+runs on BSC_ConnHdlr {
+       f_init_handler(pars);
+
+       /* Perform location update */
+       f_perform_lu();
+
+       /* Send CM Service Request for SS/USSD */
+       f_establish_fully(EST_TYPE_SS_ACT);
+
+       /**
+       * Send a few requests using separate transcations.
+       * Some of them are with intentionally wrong codes.
+       *
+       * GSM allows a side to initiate up to 8 transactions,
+       * so let's use them all, why not?
+       */
+       BSSAP.send(ts_dtap_ussd_init_req(tid := 0, code := "*#100#"));
+       BSSAP.send(ts_dtap_ussd_init_req(tid := 1, code := "*110*181#"));
+       BSSAP.send(ts_dtap_ussd_init_req(tid := 2, code := "*999*888#"));
+       BSSAP.send(ts_dtap_ussd_init_req(tid := 3, code := "*#100#"));
+       BSSAP.send(ts_dtap_ussd_init_req(tid := 4, code := "*#100#"));
+       BSSAP.send(ts_dtap_ussd_init_req(tid := 5, code := "##113#"));
+       BSSAP.send(ts_dtap_ussd_init_req(tid := 6, code := "#osmocom"));
+       BSSAP.send(ts_dtap_ussd_init_req(tid := 7, code := "*#100#"));
+
+       /**
+        * We expect that each response shall correspond to its
+        * request and shall be sent back on a proper transaction.
+        */
+       var bitstring rsp_tid_mask := '00000000'B;
+       var PDU_DTAP_MT rsp_msg;
+       var bitstring rsp_tid;
+       alt {
+       [] BSSAP.receive(tr_dtap_ussd_result(
+               tid := (0, 3, 4, 7), /* Known request codes => known result */
+               result := "Your extension is " & hex2str(g_pars.msisdn) & "\r"
+       )) -> value rsp_msg {
+               /**
+                * Looks ugly, but for some reason the field assignment
+                * according to "22.2.2 The Receive operation", i.e.
+                * (-> value (rsp_msg, tid := dtap.etc.)) doesn't work.
+                *
+                * "error: Redirecting parts of a value is not supported
+                * in the Load Test Runtime."
+                */
+               rsp_tid := rsp_msg.dtap.tiOrSkip.transactionId.tio;
+               rsp_tid_mask := rsp_tid_mask or4b ('1'B << bit2int(rsp_tid));
+
+               /* Decide, should we repeat? */
+               if (rsp_tid_mask == '11111111'B) {
+                       setverdict(pass);
+               } else {
+                       repeat;
+               }
+       }
+       [] BSSAP.receive(tr_dtap_ussd_error(
+               tid := (1, 2, 5, 6), /* Unknown request codes => error */
+               err_code := SS_ERR_CODE_UNEXPECTED_DATA_VALUE
+       )) -> value rsp_msg {
+               /**
+                * Looks ugly, but for some reason the field assignment
+                * according to "22.2.2 The Receive operation", i.e.
+                * (-> value (rsp_msg, tid := dtap.etc.)) doesn't work.
+                *
+                * "error: Redirecting parts of a value is not supported
+                * in the Load Test Runtime."
+                */
+               rsp_tid := rsp_msg.dtap.tiOrSkip.transactionId.tio;
+               rsp_tid_mask := rsp_tid_mask or4b ('1'B << bit2int(rsp_tid));
+
+               /* Decide, should we repeat? */
+               if (rsp_tid_mask == '11111111'B) {
+                       setverdict(pass);
+               } else {
+                       repeat;
+               }
+       }
+       [] BSSAP.receive {
+               setverdict(fail, "Unknown/unexpected BSSAP received");
+               self.stop;
+               }
+       }
+
+       f_expect_clear();
+}
+testcase TC_lu_and_ussd_multi_tid() runs on MTC_CT {
+       var BSC_ConnHdlr vc_conn;
+       f_init();
+       vc_conn := f_start_handler(refers(f_tc_lu_and_ussd_multi_tid), 48);
+       vc_conn.done;
+}
+
 /* TODO (SMS):
    * different user data lengths
    * SMPP transaction mode with unsuccessful delivery
@@ -2299,6 +2434,7 @@

        execute( TC_lu_and_ussd_single_req() );
        execute( TC_lu_and_ussd_wrong_code() );
+       execute( TC_lu_and_ussd_multi_tid() );

        /* Run this last: at the time of writing this test crashes the MSC */
        execute( TC_lu_imsi_auth_tmsi_encr_3_1_log_msc_debug() );

--
To view, visit https://gerrit.osmocom.org/9471
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifa3cd1aeeb34ccf5864f78b76a88aaa6d5e51839
Gerrit-Change-Number: 9471
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <[email protected]>

Reply via email to