bsc CBSP: introduce g_cbsp_msg_id and g_cbsp_ser_no

For each CBSP test, define one global set of CBSP msg id and serno for use by
that test.

Each CBSP test should use a distinct message id and serial nr, to not get mixed
up with previous state. But keeping those numbers manually is a confusing pain,
and as a reader it is hard to follow how these numbers change (if they do).

In f_cbsp_init_server(), require a preset of msg id and serno to be used in
that test, and from then on only use g_cbsp_msg_id and g_cbsp_ser_no instead of
magic numbers. If they change, write it out explicitly, making it easy to
follow what is expected to happen, and also making it easy to copy-paste code
snippets without having to manually adjust magic numbers.

Choice of numbers: pick a simpler scheme where both msg_id and ser_no share a
common "prefix" in the 1000s range, and for a ser_no add 500 to keep distinct
numbers (that avoid confusion when reading the logs):

test     prefix   msg_id   ser_no  next-ser_no
1        1000     1001     1501    1502
2        2000     2001     2501    2502
3        3000     3001     3501    3502
...

E.g. the first test has the prefix of 1000.
msg_id: 1001, ser_no: 1101.

Change-Id: I43ba196974614d1aea2b6055be2fe82059b38974
This commit is contained in:
Neels Hofmeyr 2020-07-31 14:29:43 +02:00 committed by laforge
parent 90a07524d1
commit 4e63a01c6e
1 changed files with 73 additions and 49 deletions

View File

@ -68,6 +68,15 @@ private template (value) OCT2 bssmap_lac(GsmCgiAbstract cgi) := ts_BSSMAP_CI_LAC
private template (value) OCT2 bssmap_ci(GsmCgiAbstract cgi) := ts_BSSMAP_CI_CI(cgi.ci);
type component cbsp_test_CT extends test_CT, CBSP_Adapter_CT {
var uint16_t g_cbsp_msg_id := 0;
var uint16_t g_cbsp_ser_no := 0;
}
private function f_g_cbsp_next_msg_id_ser_no() runs on cbsp_test_CT
{
g_cbsp_msg_id := g_cbsp_msg_id + 1;
g_cbsp_ser_no := g_cbsp_ser_no + 1;
log("g_cbsp_msg_id=", g_cbsp_msg_id, " g_cbsp_ser_no=", g_cbsp_ser_no);
}
private altstep as_IgnRSL(template RSL_Message tr) runs on cbsp_test_CT {
@ -108,7 +117,7 @@ private function f_cbsp_init_client() runs on cbsp_test_CT {
setverdict(pass);
}
private function f_cbsp_init_server(float guard_timeout := 30.0) runs on cbsp_test_CT {
private function f_cbsp_init_server(uint16_t cbsp_msg_id, uint16_t cbsp_ser_no, float guard_timeout := 30.0) runs on cbsp_test_CT {
var ASP_Event asp_evt;
timer T := 10.0;
@ -126,6 +135,10 @@ private function f_cbsp_init_server(float guard_timeout := 30.0) runs on cbsp_te
}
}
f_expect_cbsp_restart();
g_cbsp_msg_id := cbsp_msg_id;
g_cbsp_ser_no := cbsp_ser_no;
log("g_cbsp_msg_id=", g_cbsp_msg_id, " g_cbsp_ser_no=", g_cbsp_ser_no);
}
private function f_expect_cbsp_restart() runs on cbsp_test_CT {
interleave {
@ -353,13 +366,13 @@ testcase TC_cbsp_bsc_server() runs on cbsp_test_CT {
/* Test if BSC (client) is connecting to CBC (server) */
testcase TC_cbsp_bsc_client() runs on cbsp_test_CT {
f_cbsp_init_server();
f_cbsp_init_server(0, 0);
setverdict(pass);
}
/* Test if a BSS-global RESET is executed successfully */
testcase TC_cbsp_reset_bss() runs on cbsp_test_CT {
f_cbsp_init_server();
f_cbsp_init_server(0, 0);
f_cbsp_reset_bss(0);
setverdict(pass);
@ -368,7 +381,7 @@ testcase TC_cbsp_reset_bss() runs on cbsp_test_CT {
testcase TC_cbsp_write() runs on cbsp_test_CT {
var template (value) CBSP_PDU tx;
var CBSP_IEs pages := {f_gen_page()};
f_cbsp_init_server();
f_cbsp_init_server(0, 0);
tx := ts_CBSP_WRITE_CBS(msg_id:=23, new_ser_nr:=42, cell_list:=ts_BSSMAP_CIL_BSS,
channel_ind:=0, category:=CBSP_CATEG_NORMAL,
@ -384,10 +397,10 @@ function f_tc_cbsp_write_bss(integer payload_len := -1, template (present) integ
var CBSP_IEs pages := {f_gen_page(payload_len := payload_len)};
var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
cell_list := ts_BSSMAP_CIL_BSS;
f_cbsp_write(1, 1001, cell_list, content:=pages,
f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
success_list:=tr_BSSMAP_CIL_CGI({?,?,?}), fail_list:={?});
var template RSL_Message tr := f_page2rsl(pages[0], 1, 1001, expect_blocks := expect_blocks);
var template RSL_Message tr := f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no, expect_blocks := expect_blocks);
log("RSL[0,1,2] EXPECTING ", tr_ASP_RSL_UD(tr));
interleave {
[] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr)) { log("Got SMSCB CMD on RSL[0]"); }
@ -395,9 +408,12 @@ function f_tc_cbsp_write_bss(integer payload_len := -1, template (present) integ
[] IPA_RSL[2].receive(tr_ASP_RSL_UD(tr)) { log("Got SMSCB CMD on RSL[2]"); }
}
setverdict(pass);
/* Make the next test run (if any) use different msg_id and ser_no */
f_g_cbsp_next_msg_id_ser_no();
}
testcase TC_cbsp_write_bss() runs on cbsp_test_CT {
f_cbsp_init_server(guard_timeout := 60.0);
f_cbsp_init_server(1001, 1501, guard_timeout := 60.0);
/* In the SMSCB message, there is a head followed by payload,
* and the resulting data is segmented in blocks of 22 octets (<= 4 blocks).
*
@ -427,10 +443,10 @@ testcase TC_cbsp_write_bts_cgi() runs on cbsp_test_CT {
var CBSP_IEs pages := {f_gen_page()};
var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)});
f_cbsp_init_server();
f_cbsp_write(2, 1002, cell_list, content:=pages,
f_cbsp_init_server(2001, 2501);
f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
success_list:=cell_list, fail_list:=omit);
var template RSL_Message tr := f_page2rsl(pages[0], 1, 1001);
var template RSL_Message tr := f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no);
IPA_RSL[0].receive(tr_ASP_RSL_UD(tr));
f_sleep(5.0);
}
@ -440,8 +456,8 @@ testcase TC_cbsp_write_bts_no_cbch() runs on cbsp_test_CT {
var CBSP_IEs pages := {f_gen_page()};
var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts3)});
f_cbsp_init_server();
f_cbsp_write(3, 1003, cell_list, content:=pages,
f_cbsp_init_server(3001, 3501);
f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
success_list:=omit, fail_list:={?});
f_sleep(5.0);
}
@ -451,8 +467,8 @@ testcase TC_cbsp_write_unknown_bts() runs on cbsp_test_CT {
var CBSP_IEs pages := {f_gen_page()};
var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
cell_list := ts_BSSMAP_CIL_CGI({ts_BSSMAP_CI_CGI(mp_cgi_bts0.mcc, mp_cgi_bts1.mnc, 22222, 33333)});
f_cbsp_init_server();
f_cbsp_write(4, 1004, cell_list, content:=pages,
f_cbsp_init_server(4001, 4501);
f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
success_list:=omit, fail_list:={?});
f_sleep(5.0);
}
@ -462,10 +478,10 @@ testcase TC_cbsp_write_lac_ci() runs on cbsp_test_CT {
var CBSP_IEs pages := {f_gen_page()};
var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)});
f_cbsp_init_server();
f_cbsp_write(5, 1005, cell_list, content:=pages,
f_cbsp_init_server(5001, 5501);
f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
success_list:=?, fail_list:=omit);
IPA_RSL[0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], 5, 1005)));
IPA_RSL[0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no)));
f_sleep(5.0);
}
@ -474,10 +490,10 @@ testcase TC_cbsp_write_ci() runs on cbsp_test_CT {
var CBSP_IEs pages := {f_gen_page()};
var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
cell_list := ts_BSSMAP_CIL_CI({bssmap_ci(mp_cgi_bts0)});
f_cbsp_init_server();
f_cbsp_write(6, 1006, cell_list, content:=pages,
f_cbsp_init_server(6001, 6501);
f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
success_list:=?, fail_list:=omit);
IPA_RSL[0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], 6, 1006)));
IPA_RSL[0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no)));
f_sleep(5.0);
}
@ -486,10 +502,10 @@ testcase TC_cbsp_write_lai() runs on cbsp_test_CT {
var CBSP_IEs pages := {f_gen_page()};
var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
cell_list := ts_BSSMAP_CIL_LAI({bssmap_lai(mp_cgi_bts0)});
f_cbsp_init_server();
f_cbsp_write(7, 1007, cell_list, content:=pages,
f_cbsp_init_server(7001, 7501);
f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
success_list:=?, fail_list:=omit);
IPA_RSL[0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], 7, 1007)));
IPA_RSL[0].receive(tr_ASP_RSL_UD(f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no)));
f_sleep(5.0);
}
@ -498,10 +514,10 @@ testcase TC_cbsp_write_lac() runs on cbsp_test_CT {
var CBSP_IEs pages := {f_gen_page()};
var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
cell_list := ts_BSSMAP_CIL_LAC({bssmap_lac(mp_cgi_bts0)});
f_cbsp_init_server();
f_cbsp_write(8, 1008, cell_list, content:=pages,
f_cbsp_init_server(8001, 8501);
f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages,
success_list:=?, fail_list:=omit);
var template RSL_Message tr := f_page2rsl(pages[0], 8, 1008);
var template RSL_Message tr := f_page2rsl(pages[0], g_cbsp_msg_id, g_cbsp_ser_no);
interleave {
[] IPA_RSL[0].receive(tr_ASP_RSL_UD(tr));
[] IPA_RSL[1].receive(tr_ASP_RSL_UD(tr));
@ -514,11 +530,19 @@ testcase TC_cbsp_write_then_replace() runs on cbsp_test_CT {
var CBSP_IEs pages := {f_gen_page()};
var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)});
f_cbsp_init_server();
f_cbsp_write(9, 1009, cell_list, num_bcast_req:=10, content:=pages,
f_cbsp_init_server(9001, 9501);
f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, num_bcast_req:=10, content:=pages,
success_list:=?, fail_list:=omit);
f_cbsp_replace(9, 2009, 1009, cell_list, content:=pages,
/* FIXME: expect CBSP message */
/* Replace: keep the same msg_id, use a new ser_no */
var uint16_t old_ser_no := g_cbsp_ser_no;
g_cbsp_ser_no := g_cbsp_ser_no + 1;
f_cbsp_replace(g_cbsp_msg_id, g_cbsp_ser_no, old_ser_no, cell_list, content:=pages,
success_list:=?, fail_list:=omit);
/* FIXME: expect CBSP message */
}
/* Replace a message that doesn't exist: failure */
@ -526,8 +550,8 @@ testcase TC_cbsp_replace_nonexist() runs on cbsp_test_CT {
var CBSP_IEs pages := {f_gen_page()};
var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)});
f_cbsp_init_server();
f_cbsp_replace(10, 2010, 1010, cell_list, content:=pages,
f_cbsp_init_server(10001, 10501);
f_cbsp_replace(10, 10023, 10042, cell_list, content:=pages,
success_list:=omit, fail_list:=?);
}
@ -537,8 +561,8 @@ testcase TC_cbsp_write_too_many() runs on cbsp_test_CT {
var CBSP_IEs pages := {f_gen_page(), f_gen_page(), f_gen_page()};
var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)});
f_cbsp_init_server();
f_cbsp_write(11, 1011, cell_list, rep_period:=1, content:=pages,
f_cbsp_init_server(11001, 11501);
f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, rep_period:=1, content:=pages,
success_list:=omit, fail_list:=?);
}
@ -547,17 +571,17 @@ testcase TC_cbsp_kill_nonexist() runs on cbsp_test_CT {
var CBSP_IEs pages := {f_gen_page()};
var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)});
f_cbsp_init_server();
f_cbsp_kill(12, 1012, 0, cell_list, success_list:=omit, fail_list:=?);
f_cbsp_init_server(12001, 12501);
f_cbsp_kill(g_cbsp_msg_id, g_cbsp_ser_no, 0, cell_list, success_list:=omit, fail_list:=?);
}
/* Write a message, then kill it */
testcase TC_cbsp_write_then_kill() runs on cbsp_test_CT {
var CBSP_IEs pages := {f_gen_page()};
var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)});
f_cbsp_init_server();
f_cbsp_write(13, 1013, cell_list, content:=pages, success_list:=?, fail_list:=omit);
f_cbsp_kill(13, 1013, 0, cell_list, success_list:=?, fail_list:=omit);
f_cbsp_init_server(13001, 13501);
f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages, success_list:=?, fail_list:=omit);
f_cbsp_kill(g_cbsp_msg_id, g_cbsp_ser_no, 0, cell_list, success_list:=?, fail_list:=omit);
}
/* Write a message, then reset all messages */
@ -565,8 +589,8 @@ testcase TC_cbsp_write_then_reset() runs on cbsp_test_CT {
var CBSP_IEs pages := {f_gen_page()};
var template (value) BSSMAP_FIELD_CellIdentificationList cell_list;
cell_list := ts_BSSMAP_CIL_LAC_CI({bssmap_lac_ci(mp_cgi_bts0)});
f_cbsp_init_server();
f_cbsp_write(14, 1014, cell_list, content:=pages, success_list:=?, fail_list:=omit);
f_cbsp_init_server(14001, 14501);
f_cbsp_write(g_cbsp_msg_id, g_cbsp_ser_no, cell_list, content:=pages, success_list:=?, fail_list:=omit);
f_cbsp_reset_bss(0);
}
@ -585,14 +609,14 @@ testcase TC_cbsp_emerg_write_bts_cgi_dchan() runs on cbsp_test_CT {
var ASP_RSL_Unitdata rx_rsl_ud;
cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)});
f_cbsp_init_server();
f_cbsp_init_server(15001, 15501);
/* first establish a dedicated channel */
var DchanTuple dt := f_est_dchan('23'O, 23, '00010203040506'O);
/* then send ETWS PN */
f_cbsp_write_emerg(15, 1015, cell_list);
var template (present) octetstring tr_apdu := f_gen_etws_pn(1015, 15);
f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list);
var template (present) octetstring tr_apdu := f_gen_etws_pn(g_cbsp_msg_id, g_cbsp_ser_no);
timer T := 5.0;
T.start;
alt {
@ -627,10 +651,10 @@ testcase TC_cbsp_emerg_write_bts_cgi_cchan() runs on cbsp_test_CT {
var ASP_RSL_Unitdata rx_rsl_ud;
cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)});
f_cbsp_init_server();
f_cbsp_init_server(16001, 16501);
f_cbsp_write_emerg(16, 1016, cell_list);
var template (present) octetstring tr_apdu := f_gen_etws_pn(1016, 16);
f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list);
var template (present) octetstring tr_apdu := f_gen_etws_pn(g_cbsp_msg_id, g_cbsp_ser_no);
timer T := 5.0;
T.start;
alt {
@ -656,12 +680,12 @@ testcase TC_cbsp_emerg_write_bts_cgi_cchan_disable() runs on cbsp_test_CT {
var ASP_RSL_Unitdata rx_rsl_ud;
cell_list := ts_BSSMAP_CIL_CGI({bssmap_cgi(mp_cgi_bts0)});
f_cbsp_init_server();
f_cbsp_init_server(17001, 17501);
f_cbsp_write_emerg(16, 1016, cell_list);
f_cbsp_write_emerg(g_cbsp_msg_id, g_cbsp_ser_no, cell_list);
/* first expect the PN to be enabled */
var template (present) octetstring tr_apdu := f_gen_etws_pn(1016, 16);
var template (present) octetstring tr_apdu := f_gen_etws_pn(g_cbsp_msg_id, g_cbsp_ser_no);
timer T := 5.0;
T.start;
alt {