pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/28541 )
Change subject: cbc: Refactor and split f_cbsp_write() ......................................................................
cbc: Refactor and split f_cbsp_write()
Change-Id: I827fad869c6ca5ce80dd39d30c2e3393b2394217 --- M cbc/CBC_Tests.ttcn 1 file changed, 38 insertions(+), 21 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/41/28541/1
diff --git a/cbc/CBC_Tests.ttcn b/cbc/CBC_Tests.ttcn index fe59039..06fda92 100644 --- a/cbc/CBC_Tests.ttcn +++ b/cbc/CBC_Tests.ttcn @@ -204,8 +204,41 @@ }; type record of CBS_MessageContent CBS_MessageContents;
+private function f_cbsp_tx_write_compl(CBS_Message msg, integer idx := 0, + template (omit) BSSMAP_FIELD_CellIdentificationList tx_cell_list := omit, + template (omit) CBSP_IE_NumBcastComplList tx_compl_list := omit) +runs on test_CT { + var template (value) CBSP_PDU tx; + var template (value) BSSMAP_FIELD_CellIdentificationList tx_list; + if (istemplatekind(tx_cell_list, "omit")) { + /* use the "expected list" when confirming the write-replace */ + tx_list := msg.cell_list; + } else { + /* use an user-provided different list of cells */ + tx_list := valueof(tx_cell_list); + } + if (istemplatekind(tx_compl_list, "omit")) { + tx := ts_CBSP_WRITE_CBS_COMPL(msg.msg_id, msg.ser_nr, tx_list, msg.channel_ind); + } else { + tx := ts_CBSP_REPLACE_CBS_COMPL(msg.msg_id, msg.ser_nr, msg.old_ser_nr, + valueof(tx_compl_list), tx_list, + msg.channel_ind); + } + CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], tx)); +} + +private function f_cbsp_tx_write_fail(CBS_Message msg, integer idx := 0, + template (omit) BSSMAP_FIELD_CellIdentificationList tx_cell_list := omit, + template (omit) CBSP_FailureListItems tx_fail_list := omit) +runs on test_CT { + var template (value) CBSP_PDU tx; + tx := ts_CBSP_WRITE_CBS_FAIL(msg.msg_id, msg.ser_nr, valueof(tx_fail_list), + omit, tx_cell_list, msg.channel_ind); + CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], tx)); +} + /* handle a CBSP-WRITE-REPLACE and respond to it with COMPLETE or FAILURE depending on arguments */ -private function f_cbsp_write(CBS_Message msg, integer idx := 0, +private function f_cbsp_handle_write(CBS_Message msg, integer idx := 0, template (omit) BSSMAP_FIELD_CellIdentificationList tx_cell_list := omit, template (omit) CBSP_FailureListItems tx_fail_list := omit, template (omit) CBSP_IE_NumBcastComplList tx_compl_list := omit) @@ -224,26 +257,10 @@ [] CBSP[idx].receive(tr_CBSP_Recv(g_cbsp_conn_id[idx], rx_templ)) -> value rf { var template (value) CBSP_PDU tx; if (istemplatekind(tx_fail_list, "omit")) { - var template (value) BSSMAP_FIELD_CellIdentificationList tx_list; - if (istemplatekind(tx_cell_list, "omit")) { - /* use the "expected list" when confirming the write-replace */ - tx_list := msg.cell_list; - } else { - /* use an user-provided different list of cells */ - tx_list := valueof(tx_cell_list); - } - if (istemplatekind(tx_compl_list, "omit")) { - tx := ts_CBSP_WRITE_CBS_COMPL(msg.msg_id, msg.ser_nr, tx_list, msg.channel_ind); - } else { - tx := ts_CBSP_REPLACE_CBS_COMPL(msg.msg_id, msg.ser_nr, msg.old_ser_nr, - valueof(tx_compl_list), tx_list, - msg.channel_ind); - } + f_cbsp_tx_write_compl(msg, idx, tx_cell_list, tx_compl_list); } else { - tx := ts_CBSP_WRITE_CBS_FAIL(msg.msg_id, msg.ser_nr, valueof(tx_fail_list), - omit, tx_cell_list, msg.channel_ind); + f_cbsp_tx_write_fail(msg, idx, tx_cell_list, tx_fail_list); } - CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], tx)); } [] as_cbsp_keepalive_ack(idx) { repeat; } [] CBSP[idx].receive { @@ -302,7 +319,7 @@ { '00'O, 1 } } }; - f_cbsp_write(msg); + f_cbsp_handle_write(msg); f_sleep(100.0); f_shutdown_helper(); } @@ -378,7 +395,7 @@ runs on test_CT { var EcbeCbcMessage ecbe := f_cbs2ecbe(msg, "TTCN-3"); f_ecbe_tx_post_cbs(ecbe); - f_cbsp_write(msg, 0, cell_list_success); + f_cbsp_handle_write(msg, 0, cell_list_success); f_ecbe_rx_resp(201);
f_sleep(2.0);