blob: f953be449c94bf38df7c8794ace80e381788f6ae [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
Alexander Couzens355ab562020-07-26 22:04:33 +0200112 alt {
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100113 /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */
Alexander Couzens355ab562020-07-26 22:04:33 +0200114 [] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { setverdict(pass); };
115 [] NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) { repeat; }
116 }
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100117}
118
119/* Test for NS-RESET after NS-ALIVE timeout */
120testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT {
121 f_init_ns_codec(guard_secs := 100.0);
122 f_init_pcuif();
123
124 /* Expect inbound NS-RESET procedure */
125 as_rx_ns_reset_ack(oneshot := true);
126
127 /* wait for at least one NS-ALIVE */
Alexander Couzens355ab562020-07-26 22:04:33 +0200128 alt {
129 [] as_rx_alive_tx_ack(oneshot := true) { };
130 [] NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) { repeat; }
131 }
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100132
133 /* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */
134 alt {
135 [] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); }
136 [] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { repeat; }
Alexander Couzens355ab562020-07-26 22:04:33 +0200137 [] NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) { repeat; }
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100138 }
139}
140
141/* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */
142testcase TC_ns_unblock() runs on RAW_Test_CT {
143 f_init_ns_codec();
144 f_init_pcuif();
145
146 /* Expect inbound NS-RESET procedure */
147 as_rx_ns_reset_ack(oneshot := true);
148
Alexander Couzens355ab562020-07-26 22:04:33 +0200149 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100150 activate(as_rx_alive_tx_ack());
151
152 as_rx_ns_unblock_ack(oneshot := true);
153 setverdict(pass);
154}
155
156/* test for NS-UNBLOCK re-transmissions */
157testcase TC_ns_unblock_retrans() runs on RAW_Test_CT {
158 f_init_ns_codec();
159 f_init_pcuif();
160
161 /* Expect inbound NS-RESET procedure */
162 as_rx_ns_reset_ack(oneshot := true);
163
Alexander Couzens355ab562020-07-26 22:04:33 +0200164 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100165 activate(as_rx_alive_tx_ack());
166
167 /* wait for first NS-UNBLOCK, don't respond */
168 NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK));
169
170 /* wait for re-transmission of NS-UNBLOCK */
171 as_rx_ns_unblock_ack(oneshot := true);
172 setverdict(pass);
173}
174
175/* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */
176testcase TC_ns_full_bringup() runs on RAW_Test_CT {
177 f_init_ns_codec();
178 f_init_pcuif();
179
180 /* Expect inbound NS-RESET procedure */
181 as_rx_ns_reset_ack(oneshot := true);
182
Alexander Couzens355ab562020-07-26 22:04:33 +0200183 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100184 activate(as_rx_alive_tx_ack());
185
186 as_rx_ns_unblock_ack(oneshot := true);
187
188 f_outgoing_ns_alive();
189
190 /* Expect BVC-RESET for signaling (0) and ptp BVCI */
191 as_rx_bvc_reset_tx_ack(0, oneshot := true);
192 as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true);
193 as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true);
194
195 /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */
196 as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true);
197 activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci));
198 setverdict(pass);
199}
200
201/* test outbound (SGSN-originated) NS-BLOCK procedure */
202testcase TC_ns_so_block() runs on RAW_Test_CT {
203 f_init_ns_codec();
204 f_init_pcuif();
205
206 /* Expect inbound NS-RESET procedure */
207 as_rx_ns_reset_ack(oneshot := true);
208
Alexander Couzens355ab562020-07-26 22:04:33 +0200209 /* keep it alive */
Pau Espin Pedrol4536c822019-12-30 13:22:32 +0100210 activate(as_rx_alive_tx_ack());
211
212 as_rx_ns_unblock_ack(oneshot := true);
213
214 f_outgoing_ns_alive();
215
216 f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE);
217 setverdict(pass);
218}
219
220
221control {
222 execute( TC_ns_reset() );
223 execute( TC_ns_reset_retrans() );
224 execute( TC_ns_alive() );
225 execute( TC_ns_alive_timeout_reset() );
226 execute( TC_ns_unblock() );
227 execute( TC_ns_unblock_retrans() );
228 execute( TC_ns_full_bringup() );
229 execute( TC_ns_so_block() );
230}
231
232}