This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.org
Review at https://gerrit.osmocom.org/6629
Add initial OsmoBTS test suite
This Test suite implements the BSC-side of Abis RSL and is used to
test OsmoBTS. It contains provisions for using L1CTL against
(virt_phy + osmo-bts-virtual) or (trxcon + fake_trx + osmo-bts-trx)
to also simulate the MS/Um side, bu those provisions are not used
yet.
Implemented tests currently are only related to RSL dedicated channel
activation / deactivation.
We still terminate OML inside OsmoBSC, and let the test suite deal
exclusively with RSL to keep complexity low.
Change-Id: I8ced0d29777aad3ec842d54eabea87dfcc943c79
---
M Makefile
A bts/BTS_Tests.ttcn
A bts/gen_links.sh
A bts/regen_makefile.sh
4 files changed, 315 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/29/6629/1
diff --git a/Makefile b/Makefile
index 2fcc561..3f2230b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-SUBDIRS=bsc bsc-nat ggsn_tests gprs_gb lapdm mgw msc selftest sgsn sysinfo
+SUBDIRS=bsc bsc-nat bts ggsn_tests gprs_gb lapdm mgw msc selftest sgsn sysinfo
PARALLEL_MAKE:=-j4
diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
new file mode 100644
index 0000000..16372f7
--- /dev/null
+++ b/bts/BTS_Tests.ttcn
@@ -0,0 +1,261 @@
+module BTS_Tests {
+
+import from General_Types all;
+import from GSM_Types all;
+import from Osmocom_Types all;
+import from GSM_Types all;
+import from LAPDm_RAW_PT all;
+import from Osmocom_CTRL_Adapter all;
+
+import from RSL_Types all;
+import from IPA_Emulation all;
+import from RSL_Emulation all;
+
+modulepar {
+ charstring mp_rsl_ip := "127.0.0.2";
+ integer mp_rsl_port := 3003;
+}
+
+type component test_CT extends CTRL_Adapter_CT {
+ var IPA_Emulation_CT vc_IPA;
+
+ var RSL_Emulation_CT vc_RSL;
+ port RSL_CCHAN_PT RSL_CCHAN;
+}
+
+/* an individual call / channel */
+type component ConnHdlr extends RSL_DchanHdlr {
+ var lapdm_CT vc_LAPDm;
+ port LAPDm_PT L1;
+
+ timer g_Tguard;
+
+ var ConnHdlrPars g_pars;
+}
+
+function f_init_rsl(charstring id) runs on test_CT {
+ vc_IPA := IPA_Emulation_CT.create(id & "-RSL-IPA");
+ vc_RSL := RSL_Emulation_CT.create(id & "-RSL");
+
+ map(vc_IPA:IPA_PORT, system:IPA_CODEC_PT);
+ connect(vc_IPA:IPA_RSL_PORT, vc_RSL:IPA_PT);
+ connect(self:RSL_CCHAN, vc_RSL:CCHAN_PT);
+
+ vc_IPA.start(IPA_Emulation.main_server(mp_rsl_ip, mp_rsl_port));
+ vc_RSL.start(RSL_Emulation.main(false));
+}
+
+type record ConnHdlrPars {
+ RslChannelNr chan_nr,
+ RSL_IE_ChannelMode chan_mode,
+ float t_guard
+}
+
+
+/* global init function */
+function f_init(charstring id) runs on test_CT {
+ f_init_rsl(id);
+ RSL_CCHAN.receive(ASP_IPA_Event:{up_down := ASP_IPA_EVENT_UP});
+}
+
+type function void_fn(charstring id) runs on ConnHdlr;
+
+/* create a new test component */
+function f_start_handler(void_fn fn, ConnHdlrPars pars)
+runs on test_CT return ConnHdlr {
+ var charstring id := testcasename();
+ var ConnHdlr vc_conn;
+
+ vc_conn := ConnHdlr.create(id);
+ /* connect to RSL Emulation main component */
+ connect(vc_conn:RSL, vc_RSL:CLIENT_PT);
+ connect(vc_conn:RSL_PROC, vc_RSL:RSL_PROC);
+
+ vc_conn.start(f_handler_init(fn, id, pars));
+ return vc_conn;
+}
+
+private altstep as_Tguard() runs on ConnHdlr {
+ [] g_Tguard.timeout {
+ setverdict(fail, "Tguard timeout");
+ self.stop;
+ }
+}
+
+/* first function started in ConnHdlr component */
+private function f_handler_init(void_fn fn, charstring id, ConnHdlrPars pars)
+runs on ConnHdlr {
+ g_pars := pars;
+ g_chan_nr := pars.chan_nr;
+
+ /* start the L1 / LAPDm-Codec port to 'trxcon' or 'virt_phy' */
+/*
+ vc_LAPDm := lapdm_CT.create(id & "-L1");
+ connect(self:L1, vc_LAPDm:LAPDM_SP);
+ map(vc_LAPDm:L1CTL, system:L1CTL);
+ vc_LAPDm.start(LAPDmStart());
+*/
+
+ g_Tguard.start(pars.t_guard);
+ activate(as_Tguard());
+
+ f_rslem_register(0, pars.chan_nr);
+
+ /* call the user-supplied test case function */
+ fn.apply(id);
+}
+
+
+function f_rsl_chan_act(RSL_IE_ChannelMode mode) runs on RSL_DchanHdlr {
+ RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, mode));
+ alt {
+ [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) { }
+ [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
+ setverdict(fail, "Unexpected RF CHAN ACT NACK");
+ }
+ }
+}
+
+function f_rsl_chan_deact() runs on RSL_DchanHdlr {
+ timer T := 3.0;
+ RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
+ T.start;
+ alt {
+ [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) { }
+ [] T.timeout {
+ setverdict(fail, "Timeout waiting for RF CHAN REL ACK");
+ }
+ }
+}
+
+
+private template ConnHdlrPars t_Pars(template RslChannelNr chan_nr,
+ template RSL_IE_ChannelMode chan_mode,
+ float t_guard := 20.0) := {
+ chan_nr := valueof(chan_nr),
+ chan_mode := valueof(chan_mode),
+ t_guard := t_guard
+}
+
+/* Stress test: Do 500 channel activations/deactivations in rapid succession */
+function f_TC_chan_act_stress(charstring id) runs on ConnHdlr {
+ for (var integer i := 0; i < 500; i := i+1) {
+ f_rsl_chan_act(g_pars.chan_mode);
+ f_rsl_chan_deact();
+ }
+ setverdict(pass);
+}
+testcase TC_chan_act_stress() runs on test_CT {
+ var ConnHdlr vc_conn;
+ var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
+ f_init(testcasename());
+ vc_conn := f_start_handler(refers(f_TC_chan_act_stress), pars);
+ vc_conn.done;
+}
+
+/* Test if re-activation of an already active channel fails as expected */
+function f_TC_chan_act_react(charstring id) runs on ConnHdlr {
+ f_rsl_chan_act(g_pars.chan_mode);
+ /* attempt to activate the same lchan again -> expect reject */
+ RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
+ alt {
+ [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
+ setverdict(fail, "Unexpected CHAN ACT ACK on double activation");
+ }
+ [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
+ setverdict(pass);
+ }
+ }
+ f_rsl_chan_deact();
+}
+testcase TC_chan_act_react() runs on test_CT {
+ var ConnHdlr vc_conn;
+ var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
+ f_init(testcasename());
+ vc_conn := f_start_handler(refers(f_TC_chan_act_react), pars);
+ vc_conn.done;
+}
+
+/* Attempt to de-activate a channel that's not active */
+function f_TC_chan_deact_not_active(charstring id) runs on ConnHdlr {
+ timer T := 3.0;
+ RSL.send(ts_RSL_RF_CHAN_REL(g_chan_nr));
+ T.start;
+ alt {
+ [] RSL.receive(tr_RSL_RF_CHAN_REL_ACK(g_chan_nr)) {
+ setverdict(pass);
+ }
+ [] T.timeout {
+ setverdict(fail, "Timeout expecting RF_CHAN_REL_ACK");
+ }
+ }
+}
+testcase TC_chan_deact_not_active() runs on test_CT {
+ var ConnHdlrPars pars := valueof(t_Pars(t_RslChanNr_Bm(1), ts_RSL_ChanMode_SIGN));
+ f_init(testcasename());
+ var ConnHdlr vc_conn := f_start_handler(refers(f_TC_chan_deact_not_active), pars);
+ vc_conn.done;
+}
+
+/* attempt to activate channel with wrong RSL Channel Nr IE; expect NACK */
+function f_TC_chan_act_wrong_nr(charstring id) runs on ConnHdlr {
+ RSL.send(ts_RSL_CHAN_ACT(g_chan_nr, g_pars.chan_mode));
+ alt {
+ [] RSL.receive(tr_RSL_CHAN_ACT_ACK(g_chan_nr)) {
+ setverdict(fail, "Unexpected CHAN ACT ACK");
+ }
+ [] RSL.receive(tr_RSL_CHAN_ACT_NACK(g_chan_nr)) {
+ setverdict(pass);
+ }
+ }
+}
+private type record WrongChanNrCase {
+ RslChannelNr chan_nr,
+ charstring description
+}
+private type record of WrongChanNrCase WrongChanNrCases;
+private template WrongChanNrCase t_WCN(template RslChannelNr chan_nr, charstring desc) := {
+ chan_nr := chan_nr,
+ description := desc
+}
+
+testcase TC_chan_act_wrong_nr() runs on test_CT {
+ var ConnHdlr vc_conn;
+ var ConnHdlrPars pars;
+
+ f_init(testcasename());
+
+ var WrongChanNrCases wrong := {
+/*
+ valueof(t_WCN(t_RslChanNr_RACH(0), "RACH is not a dedicated channel")),
+ valueof(t_WCN(t_RslChanNr_RACH(1), "RACH doesn't exist on timeslot")),
+ valueof(t_WCN(t_RslChanNr_BCCH(0), "BCCH is not a dedicated channel")),
+ valueof(t_WCN(t_RslChanNr_PCH_AGCH(0), "PCH/AGCH is not a dedicated channel")), */
+ valueof(t_WCN(t_RslChanNr_Bm(0), "TS0 cannot be TCH/F")),
+ valueof(t_WCN(t_RslChanNr_Lm(0, 0), "TS0 cannot be TCH/H")),
+ valueof(t_WCN(t_RslChanNr_Lm(0, 1), "TS0 cannot be TCH/H")),
+ valueof(t_WCN(t_RslChanNr_PDCH(0), "TS0 cannot be PDCH")),
+ valueof(t_WCN(t_RslChanNr_SDCCH8(0, 0), "TS0 cannot be SDCCH/8")),
+ valueof(t_WCN(t_RslChanNr_SDCCH8(0, 7), "TS0 cannot be SDCCH/8")),
+ valueof(t_WCN(t_RslChanNr_SDCCH4(7, 0), "TS7 cannot be SDCCH/4")),
+ valueof(t_WCN(t_RslChanNr_SDCCH4(7, 3), "TS7 cannot be SDCCH/4")),
+ valueof(t_WCN(t_RslChanNr_Lm(1, 0), "TS1 cannot be TCH/H"))
+ };
+
+ for (var integer i := 0; i < sizeof(wrong); i := i+1) {
+ pars := valueof(t_Pars(wrong[i].chan_nr, ts_RSL_ChanMode_SIGN));
+ vc_conn := f_start_handler(refers(f_TC_chan_act_wrong_nr), pars);
+ vc_conn.done;
+ }
+}
+
+
+control {
+ execute( TC_chan_act_stress() );
+ execute( TC_chan_act_react() );
+ execute( TC_chan_deact_not_active() );
+ execute( TC_chan_act_wrong_nr() );
+}
+
+
+}
diff --git a/bts/gen_links.sh b/bts/gen_links.sh
new file mode 100755
index 0000000..0314eb2
--- /dev/null
+++ b/bts/gen_links.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+BASEDIR=../deps
+
+gen_links() {
+ DIR=$1
+ FILES=$*
+ for f in $FILES; do
+ echo "Linking $f"
+ ln -sf $DIR/$f $f
+ done
+}
+
+#DIR=$BASEDIR/titan.TestPorts.UNIX_DOMAIN_SOCKETasp/src
+#FILES="UD_PT.cc UD_PT.hh UD_PortType.ttcn UD_Types.ttcn"
+#gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
+FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn TCCConversion.cc TCCInterface.cc TCCInterface_ip.h"
+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.UNIX_DOMAIN_SOCKETasp/src
+FILES="UD_PT.cc UD_PT.hh UD_PortType.ttcn UD_Types.ttcn"
+gen_links $DIR $FILES
+
+DIR=$BASEDIR/titan.ProtocolModules.MobileL3_v13.4.0/src
+FILES="MobileL3_CC_Types.ttcn MobileL3_CommonIE_Types.ttcn MobileL3_GMM_SM_Types.ttcn MobileL3_MM_Types.ttcn MobileL3_RRM_Types.ttcn MobileL3_SMS_Types.ttcn MobileL3_SS_Types.ttcn MobileL3_Types.ttcn"
+gen_links $DIR $FILES
+
+DIR=../library
+FILES="General_Types.ttcn GSM_Types.ttcn GSM_RR_Types.ttcn Osmocom_Types.ttcn RLCMAC_Types.ttcn RLCMAC_CSN1_Types.ttcn RLCMAC_EncDec.cc L1CTL_Types.ttcn L1CTL_PortType.ttcn LAPDm_RAW_PT.ttcn LAPDm_Types.ttcn "
+#FILES+="NS_Emulation.ttcn NS_CodecPort.ttcn NS_CodecPort_CtrlFunct.ttcn NS_CodecPort_CtrlFunctDef.cc "
+#FILES+="BSSGP_Emulation.ttcn Osmocom_Gb_Types.ttcn "
+FILES+="IPA_Types.ttcn IPA_CodecPort.ttcn IPA_CodecPort_CtrlFunct.ttcn IPA_CodecPort_CtrlFunctDef.cc IPA_Emulation.ttcnpp IPA_CodecPort.ttcn RSL_Types.ttcn RSL_Emulation.ttcn "
+FILES+="Osmocom_CTRL_Types.ttcn Osmocom_CTRL_Functions.ttcn Osmocom_CTRL_Adapter.ttcn "
+FILES+="L3_Templates.ttcn L3_Common.ttcn "
+FILES+="Native_Functions.ttcn Native_FunctionDefs.cc "
+gen_links $DIR $FILES
diff --git a/bts/regen_makefile.sh b/bts/regen_makefile.sh
new file mode 100755
index 0000000..b920803
--- /dev/null
+++ b/bts/regen_makefile.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+FILES="*.ttcn *.ttcnpp IPA_CodecPort_CtrlFunctDef.cc IPL4asp_PT.cc IPL4asp_discovery.cc TCCConversion.cc TCCInterface.cc UD_PT.cc RLCMAC_EncDec.cc Native_FunctionDefs.cc "
+
+export CPPFLAGS_TTCN3="-DIPA_EMULATION_RSL"
+
+../regen-makefile.sh BTS_Tests.ttcn $FILES
--
To view, visit https://gerrit.osmocom.org/6629
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ced0d29777aad3ec842d54eabea87dfcc943c79
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>