Change-Id: I7096d5bad15c0595cee0a171b7a434c9f2f58ca4
This commit is contained in:
Harald Welte 2021-01-12 19:08:15 +01:00
parent 0e04c53c63
commit 891db667dd
2 changed files with 99 additions and 8 deletions

View File

@ -16,23 +16,51 @@ modulepar {
type component test_CT extends CBSP_Adapter_CT {
};
private function f_init() runs on test_CT {
altstep as_cbsp_reset(integer idx) runs on CBSP_Adapter_CT {
var CBSP_RecvFrom rf;
[] CBSP[idx].receive(tr_CBSP_Recv(g_cbsp_conn_id[idx], tr_CBSP_RESET)) -> value rf {
var CBSP_IE ie;
f_cbsp_find_ie(rf.msg, CBSP_IEI_CELL_LIST, ie);
CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx],
ts_CBSP_RESET_COMPL(ie.body.cell_list.cell_id)));
}
}
/* receive + acknowledge KEEP-ALIVE */
altstep as_cbsp_keepalive_ack(integer idx) runs on CBSP_Adapter_CT {
[] CBSP[idx].receive(tr_CBSP_Recv(g_cbsp_conn_id[idx], tr_CBSP_KEEP_ALIVE)) {
CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], ts_CBSP_KEEP_ALIVE_COMPL));
}
}
/* receive + ignore RESTART */
altstep as_cbsp_restart(integer idx) runs on CBSP_Adapter_CT {
[] CBSP[idx].receive(tr_CBSP_Recv(g_cbsp_conn_id[idx], tr_CBSP_RESTART));
}
private function f_init(boolean raw := false) runs on test_CT {
CBSP_Adapter.f_connect(mp_cbc_host, mp_cbc_port, "", -1);
if (not raw) {
var BSSMAP_FIELD_CellIdentificationList cell_list := {
cIl_allInBSS := ''O
};
activate(as_cbsp_keepalive_ack(0));
activate(as_cbsp_restart(0));
f_cbsp_send(ts_CBSP_RESTART(cell_list, CBSP_BC_MSGT_CBS, CBSP_RI_DATA_LOST));
f_cbsp_send(ts_CBSP_RESTART(cell_list, CBSP_BC_MSGT_EMERG, CBSP_RI_DATA_LOST));
as_cbsp_reset(0);
}
}
testcase TC_foo() runs on test_CT {
f_init();
var BSSMAP_FIELD_CellIdentificationList cell_list := {
cIl_allInBSS := ''O
};
f_cbsp_send(ts_CBSP_RESTART(cell_list, CBSP_BC_MSGT_CBS, CBSP_RI_DATA_LOST));
f_cbsp_send(ts_CBSP_RESTART(cell_list, CBSP_BC_MSGT_EMERG, CBSP_RI_DATA_LOST));
f_sleep(10.0);
}
/* test whether or not we receive a KEEP-ALIVE at all */
testcase TC_rx_keepalive() runs on test_CT {
f_init();
f_init(raw := true);
f_cbsp_exp(tr_CBSP_KEEP_ALIVE(?));
setverdict(pass);
}
@ -41,13 +69,75 @@ testcase TC_rx_keepalive_timeout() runs on test_CT {
var CBSP_PDU rx;
var CBSP_IE ie;
f_init();
f_init(raw := true);
rx := f_cbsp_exp(tr_CBSP_KEEP_ALIVE(?));
f_cbsp_find_ie(rx, CBSP_IEI_KEEP_ALIVE_REP_PERIOD, ie);
setverdict(pass);
}
type record CBS_Message {
uint16_t msg_id,
uint16_t ser_nr,
BSSMAP_FIELD_CellIdentificationList cell_list,
uint8_t channel_ind,
CBSP_Category category,
uint16_t rep_period,
uint16_t num_bcast_req,
uint8_t dcs,
CBS_MessageContents content
};
type record CBS_MessageContent {
octetstring payload,
uint8_t user_len
};
type record of CBS_MessageContent CBS_MessageContents;
private function f_cbsp_write(CBS_Message msg, integer idx := 0) runs on test_CT {
var template CBSP_IEs content_ies := {};
var template (present) CBSP_PDU rx_templ;
var CBSP_RecvFrom rf;
for (var integer i := 0; i < lengthof(msg.content); i := i+1) {
//content_ies[i] := tr_CbspMsgContent(msg.content[i].payload, msg.content[i].user_len);
content_ies[i] := tr_CbspMsgContent(?, ?);
}
rx_templ := tr_CBSP_WRITE_CBS(msg.msg_id, msg.ser_nr, msg.cell_list, msg.channel_ind,
msg.category, msg.rep_period, msg.num_bcast_req, msg.dcs,
content_ies);
alt {
[] CBSP[idx].receive(tr_CBSP_Recv(g_cbsp_conn_id[idx], rx_templ)) -> value rf {
template (value) CBSP_PDU tx := ts_CBSP_WRITE_CBS_COMPL(msg.msg_id, msg.ser_nr, msg.cell_list, msg.channel_ind);
CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], tx));
}
[] CBSP[idx].receive {
setverdict(fail, "Received unexpected CBSP");
}
}
}
private const BSSMAP_FIELD_CellIdentificationList cil_BSS := {
cIl_allInBSS := ''O
};
testcase TC_write_replace() runs on test_CT {
f_init();
var CBS_Message msg := {
msg_id := 42,
ser_nr := 16752,
cell_list := cil_BSS,
channel_ind := 0,
category := CBSP_CATEG_NORMAL,
rep_period := 5,
num_bcast_req := 3,
dcs := 1,
content := {
{ '00'O, 1 }
}
};
f_cbsp_write(msg);
f_sleep(100.0);
}
testcase TC_selftest() runs on test_CT {
const octetstring c_load_q := '0700000d0400080000f110012345671200'O;
const octetstring c_load_q_compl := '0800000f0a000a0000f1100123456700001200'O;

View File

@ -111,6 +111,7 @@ testcase TC_2byte_len() runs on test_CT {
f_init();
TCP.send(ts_AS(g_tcp_conn_id, c_wrepl));
f_sabp_exp(tr_SABP_Write(?, ?));
f_sabp_send(ts_SABP_Reset({ { pLMNidentity := '09F107'O, lac := '0000'O, sac := '0000'O } }));
setverdict(pass);
}