summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2019-05-06 16:45:52 +0200
committerHarald Welte <laforge@gnumonks.org>2019-06-19 18:19:43 +0200
commited52181d5ffaacabd835b75c2e12e850fdfe5906 (patch)
tree260fdef0534e11d1d72760c652f29c450fd3d29a
parent3f5eb14087938eaa5a62ad1cb613de8fd928dd13 (diff)
WIP: Initial skeleton of CBC tests
-rw-r--r--bsc/BSC_Tests_CBSP.ttcn250
-rw-r--r--cbc/CBC_Tests.ttcn83
-rwxr-xr-xcbc/gen_links.sh38
-rwxr-xr-xcbc/regen_makefile.sh10
4 files changed, 377 insertions, 4 deletions
diff --git a/bsc/BSC_Tests_CBSP.ttcn b/bsc/BSC_Tests_CBSP.ttcn
index 4b6d019..9d02dd7 100644
--- a/bsc/BSC_Tests_CBSP.ttcn
+++ b/bsc/BSC_Tests_CBSP.ttcn
@@ -1,8 +1,13 @@
module BSC_Tests_CBSP {
-import from BSC_Tests all;
-
+import from General_Types all;
+import from Osmocom_Types all;
+import from GSM_Types all;
import from IPL4asp_Types all;
+import from BSSAP_Types all;
+import from BSSMAP_Templates all;
+
+import from BSC_Tests all;
import from CBSP_Types all;
import from CBSP_Templates all;
@@ -13,8 +18,32 @@ modulepar {
charstring mp_cbc_ip := "0.0.0.0";
integer mp_cbc_port := 48049;
integer mp_bsc_cbsp_port := 48050;
+
+ /* BTS 0: 262-42-1-0 with CBCH
+ * BTS 1: 262-42-1-1 with CBCH
+ * BTS 2: 262-42-2-1 with CBCH
+ * BTS 3: 262-42-2-3 without CBCH */
+ GsmCgiAbstract mp_cgi_bts0 := { '262'H, '42'H, 1, 0 };
+ GsmCgiAbstract mp_cgi_bts1 := { '262'H, '42'H, 1, 1 };
+ GsmCgiAbstract mp_cgi_bts2 := { '262'H, '42'H, 2, 1 };
+ GsmCgiAbstract mp_cgi_bts3 := { '262'H, '42'H, 2, 3 };
}
+private type record GsmCgiAbstract {
+ GsmMcc mcc,
+ GsmMnc mnc,
+ GsmLac lac,
+ GsmCellId ci
+};
+private template (value) BSSMAP_FIELD_CellIdentification_CGI bssmap_cgi(GsmCgiAbstract cgi) :=
+ ts_BSSMAP_CI_CGI(cgi.mcc, cgi.mnc, cgi.lac, cgi.ci);
+private template (value) BSSMAP_FIELD_CellIdentification_LAC_CI bssmap_lac_ci(GsmCgiAbstract cgi) :=
+ ts_BSSMAP_CI_LAC_CI(cgi.lac, cgi.ci);
+private template (value) BSSMAP_FIELD_CellIdentification_LAI bssmap_lai(GsmCgiAbstract cgi) :=
+ ts_BSSMAP_CI_LAI(cgi.mcc, cgi.mnc, cgi.lac);
+private template (value) OCT2 bssmap_lac(GsmCgiAbstract cgi) := ts_BSSMAP_CI_LAC(cgi.lac);
+private template (value) OCT2 bssmap_ci(GsmCgiAbstract cgi) := ts_BSSMAP_CI_CI(cgi.ci);
+
type component cbsp_test_CT extends CBSP_Adapter_CT {
timer T_guard := 20.0;
}
@@ -33,6 +62,7 @@ private function f_init() runs on cbsp_test_CT {
private function f_cbsp_init_client() runs on cbsp_test_CT {
f_init();
CBSP_Adapter.f_connect(mp_bsc_ip, mp_bsc_cbsp_port, "", -1);
+ f_cbsp_init_tail();
}
private function f_cbsp_init_server() runs on cbsp_test_CT {
@@ -51,20 +81,232 @@ private function f_cbsp_init_server() runs on cbsp_test_CT {
setverdict(fail, "Timeout waiting for incoming connection to CBSP Port");
}
}
+ f_cbsp_init_tail();
+}
+private function f_cbsp_init_tail() runs on cbsp_test_CT {
+ interleave {
+ [] CBSP[0].receive(tr_CBSP_Recv(?, tr_CBSP_RESTART(?, CBSP_BC_MSGT_CBS, CBSP_RI_DATA_LOST)));
+ //[] CBSP[0].receive(tr_CBSP_Recv(?, tr_CBSP_RESTART(?, CBSP_BC_MSGT_EMERG, CBSP_RI_DATA_LOST)));
+ }
+}
+
+function f_gen_page() return CBSP_IE {
+ var integer len := f_rnd_int(82);
+ var octetstring payload := f_rnd_octstring(len);
+ return valueof(ts_CbspMsgContent(payload, len));
}
+function f_cbsp_reset_bss(integer idx) runs on CBSP_Adapter_CT {
+ var template (value) CBSP_PDU tx;
+ timer T := 3.0;
+ tx := ts_CBSP_RESET(cell_list := ts_BSSMAP_CIL_BSS);
+ CBSP[idx].clear;
+ CBSP[idx].send(ts_CBSP_Send(g_cbsp_conn_id[idx], tx));
+ T.start;
+ alt {
+ [] CBSP[idx].receive(tr_CBSP_Recv(?, tr_CBSP_RESET_COMPL(cell_list := ts_BSSMAP_CIL_BSS)));
+ [] CBSP[idx].receive {
+ setverdict(fail, "received unexpected CBSP");
+ mtc.stop;
+ }
+ [] T.timeout {
+ setverdict(fail, "timeout waiting for RESET COMPLETE");
+ mtc.stop;
+ }
+ }
+}
+/* send a WRITE CBS to the BSC; expect either COMPLETE or FAILURE in response*/
+function f_cbsp_write(uint16_t msg_id, uint16_t ser_no,
+ template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS,
+ template (value) CBSP_Category category := CBSP_CATEG_NORMAL,
+ uint16_t rep_period := 10, uint16_t num_bcast_req := 1,
+ uint8_t dcs := 0, CBSP_IEs content,
+ template BSSMAP_FIELD_CellIdentificationList success_list := ?,
+ template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT {
+ var template (value) CBSP_PDU tx;
+ var template CBSP_PDU rx;
+ var CBSP_IEs pages := {f_gen_page()};
+
+ tx := ts_CBSP_WRITE_CBS(msg_id, ser_no, cell_list, category,
+ rep_period, num_bcast_req, dcs, content);
+ CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx));
+ if (istemplatekind(fail_list, "omit")) {
+ rx := tr_CBSP_WRITE_CBS_COMPL(msg_id, ser_no, success_list);
+ } else {
+ rx := tr_CBSP_WRITE_CBS_FAIL(msg_id, ser_no, fail_list, *, success_list);
+ }
+ alt {
+ [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) {
+ setverdict(pass);
+ }
+ [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) {
+ setverdict(fail, "Received unexpected CBSP");
+ }
+ }
+}
+
+function f_cbsp_kill(uint16_t msg_id, uint16_t ser_no,
+ template (value) BSSMAP_FIELD_CellIdentificationList cell_list := ts_BSSMAP_CIL_BSS,
+ template BSSMAP_FIELD_CellIdentificationList success_list := ?,
+ template CBSP_FailureListItems fail_list := omit) runs on cbsp_test_CT
+{
+ var template (value) CBSP_PDU tx;
+ var template CBSP_PDU rx;
+
+ tx := ts_CBSP_KILL(msg_id, ser_no, cell_list);
+ CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx));
+ if (istemplatekind(fail_list, "omit")) {
+ rx := tr_CBSP_KILL_COMPL(msg_id, ser_no, compl_list:=*, cell_list:=success_list);
+ } else {
+ rx := tr_CBSP_KILL_FAIL(msg_id, ser_no, fail_list, compl_list:=*, cell_list:=success_list);
+ }
+ alt {
+ [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], rx)) {
+ setverdict(pass);
+ }
+ [] CBSP[0].receive(tr_CBSP_Recv(g_cbsp_conn_id[0], ?)) {
+ setverdict(fail, "Received unexpected CBSP");
+ }
+ }
+}
+
+/* Test if BSC (server) accepts connections from CBC (client) */
testcase TC_cbsp_bsc_server() runs on cbsp_test_CT {
f_cbsp_init_client();
- f_init();
+ setverdict(pass);
}
+/* Test if BSC (client) is connecting to CBC (server) */
testcase TC_cbsp_bsc_client() runs on cbsp_test_CT {
f_cbsp_init_server();
- f_init();
+ 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_reset_bss(0);
+ setverdict(pass);
+}
+
+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();
+
+ tx := ts_CBSP_WRITE_CBS(msg_id:=23, new_ser_nr:=42, cell_list:=ts_BSSMAP_CIL_BSS,
+ category:=CBSP_CATEG_NORMAL,
+ rep_period:=10, num_bcast_req:=1, dcs := 0,
+ content:=pages);
+
+ CBSP[0].send(ts_CBSP_Send(g_cbsp_conn_id[0], tx));
+ f_sleep(10.0);
+}
+
+/* Write to entire BSS; three cells succeed; one fails (no CBCH) */
+testcase TC_cbsp_write_bss() 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_BSS;
+ f_cbsp_init_server();
+ f_cbsp_write(1, 1001, cell_list, content:=pages,
+ success_list:=tr_BSSMAP_CIL_CGI({?,?,?}), fail_list:={?});
+}
+
+/* Write to single BTS supporting CBCH: success */
+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,
+ success_list:=cell_list, fail_list:=omit);
+}
+
+/* Write to single BTS not supporting CBCH: failure */
+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,
+ success_list:=omit, fail_list:={?});
+}
+
+/* Write to single non-existant BTS */
+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,
+ success_list:=omit, fail_list:={?});
+}
+
+/* Write to single BTS using LAC+CI */
+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(24, 1024, cell_list, content:=pages,
+ success_list:=?, fail_list:=omit);
+}
+
+/* Write to single BTS using CI */
+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(24, 1024, cell_list, content:=pages,
+ success_list:=?, fail_list:=omit);
+}
+
+/* Write to single BTS using LAI */
+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(24, 1024, cell_list, content:=pages,
+ success_list:=?, fail_list:=omit);
+}
+
+/* Write to two BTS using LAC */
+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(24, 1024, cell_list, content:=pages,
+ success_list:=?, fail_list:=omit);
+}
+
+/* Write a message, then replace it */
+
+/* Replace a message that doesn't exist: failure */
+/* Write more messages than can be scheduled */
+/* Kill message that doesn't exist: failure */
+/* Write a message, then kill it */
+/* Write a message, then reset all messages */
+
control {
+ execute( TC_cbsp_bsc_server() );
+ execute( TC_cbsp_bsc_client() );
+ execute( TC_cbsp_reset_bss() );
+
+ /* test various different types of Cell Identities */
+ execute( TC_cbsp_write_bss() );
+ execute( TC_cbsp_write_bts_cgi() );
+ execute( TC_cbsp_write_bts_no_cbch() );
+ execute( TC_cbsp_write_unknown_bts() );
+ execute( TC_cbsp_write_lac_ci() );
+ execute( TC_cbsp_write_ci() );
+ execute( TC_cbsp_write_lai() );
+ execute( TC_cbsp_write_lac() );
}
diff --git a/cbc/CBC_Tests.ttcn b/cbc/CBC_Tests.ttcn
new file mode 100644
index 0000000..1d5e7ab
--- /dev/null
+++ b/cbc/CBC_Tests.ttcn
@@ -0,0 +1,83 @@
+module CBC_Tests {
+
+import from Osmocom_Types all;
+
+import from BSSAP_Types all;
+import from CBSP_Types all;
+import from CBSP_Templates all;
+import from CBSP_Adapter all;
+import from CBSP_CodecPort all;
+
+modulepar {
+ charstring mp_cbc_host := "127.0.0.1";
+ integer mp_cbc_port := 48049;
+};
+
+type component test_CT extends CBSP_Adapter_CT {
+};
+
+private function f_init() runs on test_CT {
+ CBSP_Adapter.f_connect(mp_cbc_host, mp_cbc_port, "", -1);
+}
+
+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_cbsp_exp(tr_CBSP_KEEP_ALIVE(?));
+ setverdict(pass);
+}
+
+testcase TC_rx_keepalive_timeout() runs on test_CT {
+ var CBSP_PDU rx;
+ var CBSP_IE ie;
+
+ f_init();
+ rx := f_cbsp_exp(tr_CBSP_KEEP_ALIVE(?));
+ f_cbsp_find_ie(rx, CBSP_IEI_KEEP_ALIVE_REP_PERIOD, ie);
+
+ setverdict(pass);
+}
+
+testcase TC_selftest() runs on test_CT {
+ const octetstring c_load_q := '0700000d0400080000f110012345671200'O;
+ const octetstring c_load_q_compl := '0800000f0a000a0000f1100123456700001200'O;
+ const octetstring c_reset := '1000000b0400080000f11001234567'O;
+ const octetstring c_reset_compl := '1100000b0400080000f11001234567'O;
+ const octetstring c_msg_sts_q := '0a0000130e022b0200000400080000f110012345671200'O;
+ const octetstring c_msg_sts_q_fail := '0c0000140e022b0200000900090000f11001234567021200'O;
+ const octetstring c_kill := '040000110e00000200000400080000f11001234567'O;
+ const octetstring c_kill_fail := '060000120e00000200000900090000f1100123456702'O;
+ const octetstring c_write_repl := '010000c70e022b0300300400080000f110012345671200050006000407000613020c400107f4f29c9e769f5de337b90c921d1b8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d168341a8d46a3d100'O;
+ const octetstring c_write_repl_compl := '020000130e022b0300300400080000f110012345671200'O;
+ const octetstring c_write_repl_fail := '030000140e022b0300300900090000f110012345670d1200'O;
+ const octetstring c_msg_s_q := '0a0000130e022b0200900400080000f110012345671200'O;
+ const octetstring c_msg_s_q_compl := '0b0000160e022b02009008000b0000f110012345670008001200'O;
+ const octetstring c_kill_compl := '050000160e022b02008008000b0000f110012345670006001200'O;
+
+ log(dec_CBSP_PDU(c_load_q));
+ log(dec_CBSP_PDU(c_load_q_compl));
+ log(dec_CBSP_PDU(c_reset));
+ log(dec_CBSP_PDU(c_reset_compl));
+ log(dec_CBSP_PDU(c_msg_sts_q));
+ log(dec_CBSP_PDU(c_msg_sts_q_fail));
+ log(dec_CBSP_PDU(c_kill));
+ log(dec_CBSP_PDU(c_kill_fail));
+ log(dec_CBSP_PDU(c_write_repl));
+ log(dec_CBSP_PDU(c_write_repl_compl));
+ log(dec_CBSP_PDU(c_write_repl_fail));
+ log(dec_CBSP_PDU(c_msg_s_q));
+ log(dec_CBSP_PDU(c_msg_s_q_compl));
+ log(dec_CBSP_PDU(c_kill_compl));
+}
+
+}
diff --git a/cbc/gen_links.sh b/cbc/gen_links.sh
new file mode 100755
index 0000000..8dea495
--- /dev/null
+++ b/cbc/gen_links.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+BASEDIR=../deps
+
+. ../gen_links.sh.inc
+
+DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
+FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn TCCConversion.cc TCCInterface.cc TCCInterface_ip.h"
+FILES+=" TCCEncoding_Functions.ttcn TCCEncoding.cc " # GSM 7-bit coding
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src
+FILES="Socket_API_Definitions.ttcn"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.TestPorts.IPL4asp/src
+FILES="IPL4asp_Functions.ttcn IPL4asp_PT.cc IPL4asp_PT.hh IPL4asp_PortType.ttcn IPL4asp_Types.ttcn IPL4asp_discovery.cc IPL4asp_protocol_L234.hh"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.TestPorts.SCTPasp/src
+FILES="SCTPasp_PT.cc SCTPasp_PT.hh SCTPasp_PortType.ttcn SCTPasp_Types.ttcn"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.TestPorts.TELNETasp/src
+FILES="TELNETasp_PT.cc TELNETasp_PT.hh TELNETasp_PortType.ttcn"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.ProtocolModules.BSSMAP_v11.2.0/src
+FILES="BSSAP_Types.ttcn"
+gen_links $DIR $FILES
+
+DIR=../library
+FILES="Misc_Helpers.ttcn General_Types.ttcn GSM_Types.ttcn Osmocom_Types.ttcn Native_Functions.ttcn Native_FunctionDefs.cc "
+FILES+="CBSP_Types.ttcn CBSP_Templates.ttcn "
+FILES+="CBSP_CodecPort.ttcn CBSP_CodecPort_CtrlFunct.ttcn CBSP_CodecPort_CtrlFunctdef.cc CBSP_Adapter.ttcn "
+gen_links $DIR $FILES
+
+ignore_pp_results
diff --git a/cbc/regen_makefile.sh b/cbc/regen_makefile.sh
new file mode 100755
index 0000000..fcacb17
--- /dev/null
+++ b/cbc/regen_makefile.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+FILES="*.ttcn TCCConversion.cc TCCInterface.cc TCCEncoding.cc IPL4asp_PT.cc IPL4asp_discovery.cc TELNETasp_PT.cc Native_FunctionDefs.cc SCTPasp_PT.cc CBSP_CodecPort_CtrlFunctdef.cc "
+#FILES+="*.ttcnpp *.c *.asn"
+
+export CPPFLAGS_TTCN3=""
+
+../regen-makefile.sh CBC_Tests.ttcn $FILES
+
+sed -i -e 's/^LINUX_LIBS = -lxml2/LINUX_LIBS = -lxml2 -lfftranscode/' Makefile