blob: ce2560f89b7685a028da0c4e33f9a02a9fbb29f1 [file] [log] [blame]
Pau Espin Pedrol8dd59fb2020-04-29 15:08:16 +02001module PCU_Tests_NS {
Pau Espin Pedrol4536c822019-12-30 13:22:32 +01002
3/* Osmocom PCU test suite for IP Sub-Network-Service (SNS) in TTCN-3
4 * (C) 2018-2019 Harald Welte <laforge@gnumonks.org>
5 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12
13import from General_Types all;
14import from Osmocom_Types all;
Pau Espin Pedrol8dd59fb2020-04-29 15:08:16 +020015import from PCU_Tests all;
Pau Espin Pedrol0e6ed2e2020-04-29 14:33:13 +020016import from SGSN_Components all;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010017import from Osmocom_Gb_Types all;
18import from NS_CodecPort all;
19import from NS_Types all;
20import from BSSGP_Types all;
21import from UD_Types all;
22import from NS_CodecPort all;
23import from NS_CodecPort_CtrlFunct all;
24import from NS_Emulation all;
25import from Native_Functions all;
26import from IPL4asp_Types all;
27import from PCUIF_Types all;
28import from PCUIF_CodecPort all;
Alexander Couzens3c268da2020-09-07 04:25:05 +020029import from RAW_NS all;
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010030
31type component RAW_PCU_CT {
32 /* PCUIF (we emulate the BTS part) */
33 port PCUIF_CODEC_PT PCU;
34 var ConnectionId g_pcu_conn_id := -1;
35}
36
37type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT {
38}
39
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010040function f_init_pcuif() runs on RAW_PCU_CT {
41 var PCUIF_info_ind info_ind;
42 map(self:PCU, system:PCU);
43
44
45 info_ind := valueof(ts_PCUIF_INFO_default);
46
47 /* Connect the Unix Domain Socket */
48 g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path);
49 PCU.receive(UD_connected:?);
50
51 /* Wait for PCU_VERSION and return INFO_IND */
52 PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?)));
53 /* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */
54 var template PCUIF_Message info_ind_msg := ts_PCUIF_INFO_IND(0, info_ind);
55 PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind_msg));
56}
57
58function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT {
59 PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg));
60}
61
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010062/* ensure no matching message is received within 'tout' */
63function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0)
64runs on RAW_Test_CT {
65 timer T := tout;
66 T.start;
67 alt {
68 [] NSCP[idx].receive(t_NS_RecvFrom(ns)) {
69 setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint");
70 }
71 [] T.timeout {
72 setverdict(pass);
73 }
74 }
75}
76
Pau Espin Pedrol4536c822019-12-30 13:22:32 +010077/* test the NS-RESET procedure */
78testcase TC_ns_reset() runs on RAW_Test_CT {
79 f_init_ns_codec();
80 f_init_pcuif();
81
82
83 /* Expect inbound NS-RESET procedure */
84 as_rx_ns_reset_ack(oneshot := true);
85 setverdict(pass);
86}
87
88/* ensure NS-RESET are re-transmitted */
89testcase TC_ns_reset_retrans() runs on RAW_Test_CT {
90 f_init_ns_codec();
91 f_init_pcuif();
92
93 var integer i;
94 for (i := 0; i < 3; i := i+1) {
95 NSCP[0].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION,
96 g_nsconfig[0].nsvci, g_nsconfig[0].nsei)));
97 }
98
99 /* Expect inbound NS-RESET procedure */
100 as_rx_ns_reset_ack(oneshot := true);
101 setverdict(pass);
102}
103
104/* test the inbound NS-ALIVE procedure after NS-RESET */
105testcase TC_ns_alive() runs on RAW_Test_CT {
106 f_init_ns_codec();
107 f_init_pcuif();
108
109 /* Expect inbound NS-RESET procedure */
110 as_rx_ns_reset_ack(oneshot := true);
111
112 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
113 as_rx_alive_tx_ack(oneshot := true);
114 setverdict(pass);
115}
116
117/* Test for NS-RESET after NS-ALIVE timeout */
118testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT {
119 f_init_ns_codec(guard_secs := 100.0);
120 f_init_pcuif();
121
122 /* Expect inbound NS-RESET procedure */
123 as_rx_ns_reset_ack(oneshot := true);
124
125 /* wait for at least one NS-ALIVE */
126 NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE));
127
128 /* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */
129 alt {
130 [] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); }
131 [] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { repeat; }
132 }
133}
134
135/* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */
136testcase TC_ns_unblock() runs on RAW_Test_CT {
137 f_init_ns_codec();
138 f_init_pcuif();
139
140 /* Expect inbound NS-RESET procedure */
141 as_rx_ns_reset_ack(oneshot := true);
142
143 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
144 as_rx_alive_tx_ack(oneshot := true);
145 activate(as_rx_alive_tx_ack());
146
147 as_rx_ns_unblock_ack(oneshot := true);
148 setverdict(pass);
149}
150
151/* test for NS-UNBLOCK re-transmissions */
152testcase TC_ns_unblock_retrans() runs on RAW_Test_CT {
153 f_init_ns_codec();
154 f_init_pcuif();
155
156 /* Expect inbound NS-RESET procedure */
157 as_rx_ns_reset_ack(oneshot := true);
158
159 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
160 as_rx_alive_tx_ack(oneshot := true);
161 activate(as_rx_alive_tx_ack());
162
163 /* wait for first NS-UNBLOCK, don't respond */
164 NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK));
165
166 /* wait for re-transmission of NS-UNBLOCK */
167 as_rx_ns_unblock_ack(oneshot := true);
168 setverdict(pass);
169}
170
171/* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */
172testcase TC_ns_full_bringup() runs on RAW_Test_CT {
173 f_init_ns_codec();
174 f_init_pcuif();
175
176 /* Expect inbound NS-RESET procedure */
177 as_rx_ns_reset_ack(oneshot := true);
178
179 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
180 as_rx_alive_tx_ack(oneshot := true);
181 activate(as_rx_alive_tx_ack());
182
183 as_rx_ns_unblock_ack(oneshot := true);
184
185 f_outgoing_ns_alive();
186
187 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
188 as_rx_bvc_reset_tx_ack(0, oneshot := true);
189 as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true);
190 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true);
191
192 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
193 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true);
194 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci));
195 setverdict(pass);
196}
197
198/* test outbound (SGSN-originated) NS-BLOCK procedure */
199testcase TC_ns_so_block() runs on RAW_Test_CT {
200 f_init_ns_codec();
201 f_init_pcuif();
202
203 /* Expect inbound NS-RESET procedure */
204 as_rx_ns_reset_ack(oneshot := true);
205
206 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
207 as_rx_alive_tx_ack(oneshot := true);
208 activate(as_rx_alive_tx_ack());
209
210 as_rx_ns_unblock_ack(oneshot := true);
211
212 f_outgoing_ns_alive();
213
214 f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE);
215 setverdict(pass);
216}
217
218
219control {
220 execute( TC_ns_reset() );
221 execute( TC_ns_reset_retrans() );
222 execute( TC_ns_alive() );
223 execute( TC_ns_alive_timeout_reset() );
224 execute( TC_ns_unblock() );
225 execute( TC_ns_unblock_retrans() );
226 execute( TC_ns_full_bringup() );
227 execute( TC_ns_so_block() );
228}
229
230}