Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 1 | module PCU_Tests_NS { |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 2 | |
| 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 | |
| 13 | import from General_Types all; |
| 14 | import from Osmocom_Types all; |
Alexander Couzens | 8094254 | 2021-04-06 15:53:10 +0200 | [diff] [blame] | 15 | import from Osmocom_VTY_Functions all; |
| 16 | import from TELNETasp_PortType all; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 17 | import from PCU_Tests all; |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 18 | import from SGSN_Components all; |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 19 | import from Osmocom_Gb_Types all; |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 20 | import from NS_Types all; |
| 21 | import from BSSGP_Types all; |
| 22 | import from UD_Types all; |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 23 | import from NS_Emulation all; |
| 24 | import from Native_Functions all; |
| 25 | import from IPL4asp_Types all; |
| 26 | import from PCUIF_Types all; |
| 27 | import from PCUIF_CodecPort all; |
Alexander Couzens | 3c268da | 2020-09-07 04:25:05 +0200 | [diff] [blame] | 28 | import from RAW_NS all; |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 29 | |
| 30 | type component RAW_PCU_CT { |
| 31 | /* PCUIF (we emulate the BTS part) */ |
| 32 | port PCUIF_CODEC_PT PCU; |
| 33 | var ConnectionId g_pcu_conn_id := -1; |
Alexander Couzens | 8094254 | 2021-04-06 15:53:10 +0200 | [diff] [blame] | 34 | /* VTY connection to the PCU */ |
| 35 | port TELNETasp_PT PCUVTY; |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT { |
| 39 | } |
| 40 | |
Alexander Couzens | 8094254 | 2021-04-06 15:53:10 +0200 | [diff] [blame] | 41 | function f_init_vty(charstring id) runs on RAW_PCU_CT { |
| 42 | map(self:PCUVTY, system:PCUVTY); |
| 43 | f_vty_set_prompts(PCUVTY); |
| 44 | f_vty_transceive(PCUVTY, "enable"); |
| 45 | } |
| 46 | |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 47 | function f_init_pcuif() runs on RAW_PCU_CT { |
| 48 | var PCUIF_info_ind info_ind; |
| 49 | map(self:PCU, system:PCU); |
| 50 | |
| 51 | |
| 52 | info_ind := valueof(ts_PCUIF_INFO_default); |
| 53 | |
| 54 | /* Connect the Unix Domain Socket */ |
| 55 | g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path); |
| 56 | PCU.receive(UD_connected:?); |
| 57 | |
| 58 | /* Wait for PCU_VERSION and return INFO_IND */ |
| 59 | PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?))); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 60 | /* FIXME: make sure to use parameters from mp_gb_cfg.bvc[0].cell_id in the PCU INFO IND */ |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 61 | var template PCUIF_Message info_ind_msg := ts_PCUIF_INFO_IND(0, info_ind); |
| 62 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind_msg)); |
| 63 | } |
| 64 | |
| 65 | function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT { |
| 66 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg)); |
| 67 | } |
| 68 | |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 69 | /* ensure no matching message is received within 'tout' */ |
| 70 | function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0) |
| 71 | runs on RAW_Test_CT { |
| 72 | timer T := tout; |
| 73 | T.start; |
| 74 | alt { |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 75 | [] NSCP[idx].receive(ns) { |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 76 | setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint"); |
| 77 | } |
| 78 | [] T.timeout { |
| 79 | setverdict(pass); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 84 | /* test the NS-RESET procedure */ |
| 85 | testcase TC_ns_reset() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 86 | f_init_ns_codec(mp_nsconfig); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 87 | f_init_pcuif(); |
| 88 | |
| 89 | |
| 90 | /* Expect inbound NS-RESET procedure */ |
| 91 | as_rx_ns_reset_ack(oneshot := true); |
| 92 | setverdict(pass); |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 93 | f_clean_ns_codec(); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | /* ensure NS-RESET are re-transmitted */ |
| 97 | testcase TC_ns_reset_retrans() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 98 | f_init_ns_codec(mp_nsconfig); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 99 | f_init_pcuif(); |
| 100 | |
| 101 | var integer i; |
| 102 | for (i := 0; i < 3; i := i+1) { |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 103 | NSCP[0].receive(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, |
| 104 | g_nsconfig.nsvc[0].nsvci, g_nsconfig.nsei)); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | /* Expect inbound NS-RESET procedure */ |
| 108 | as_rx_ns_reset_ack(oneshot := true); |
| 109 | setverdict(pass); |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 110 | f_clean_ns_codec(); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | /* test the inbound NS-ALIVE procedure after NS-RESET */ |
| 114 | testcase TC_ns_alive() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 115 | f_init_ns_codec(mp_nsconfig); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 116 | f_init_pcuif(); |
| 117 | |
| 118 | /* Expect inbound NS-RESET procedure */ |
| 119 | as_rx_ns_reset_ack(oneshot := true); |
| 120 | |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 121 | alt { |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 122 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 123 | [] NSCP[0].receive(t_NS_ALIVE) { setverdict(pass); }; |
| 124 | [] NSCP[0].receive(t_NS_UNBLOCK) { repeat; } |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 125 | } |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 126 | f_clean_ns_codec(); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | /* Test for NS-RESET after NS-ALIVE timeout */ |
| 130 | testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 131 | f_init_ns_codec(mp_nsconfig, guard_secs := 100.0); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 132 | f_init_pcuif(); |
| 133 | |
| 134 | /* Expect inbound NS-RESET procedure */ |
| 135 | as_rx_ns_reset_ack(oneshot := true); |
| 136 | |
| 137 | /* wait for at least one NS-ALIVE */ |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 138 | alt { |
| 139 | [] as_rx_alive_tx_ack(oneshot := true) { }; |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 140 | [] NSCP[0].receive(t_NS_UNBLOCK) { repeat; } |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 141 | } |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 142 | |
| 143 | /* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */ |
| 144 | alt { |
| 145 | [] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); } |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 146 | [] NSCP[0].receive(t_NS_ALIVE) { repeat; } |
| 147 | [] NSCP[0].receive(t_NS_UNBLOCK) { repeat; } |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 148 | } |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 149 | |
| 150 | f_clean_ns_codec(); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | /* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */ |
| 154 | testcase TC_ns_unblock() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 155 | f_init_ns_codec(mp_nsconfig); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 156 | f_init_pcuif(); |
| 157 | |
| 158 | /* Expect inbound NS-RESET procedure */ |
| 159 | as_rx_ns_reset_ack(oneshot := true); |
| 160 | |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 161 | /* keep it alive */ |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 162 | activate(as_rx_alive_tx_ack()); |
| 163 | |
| 164 | as_rx_ns_unblock_ack(oneshot := true); |
| 165 | setverdict(pass); |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 166 | f_clean_ns_codec(); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | /* test for NS-UNBLOCK re-transmissions */ |
| 170 | testcase TC_ns_unblock_retrans() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 171 | f_init_ns_codec(mp_nsconfig); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 172 | f_init_pcuif(); |
| 173 | |
| 174 | /* Expect inbound NS-RESET procedure */ |
| 175 | as_rx_ns_reset_ack(oneshot := true); |
| 176 | |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 177 | /* keep it alive */ |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 178 | activate(as_rx_alive_tx_ack()); |
| 179 | |
| 180 | /* wait for first NS-UNBLOCK, don't respond */ |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 181 | NSCP[0].receive(t_NS_UNBLOCK); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 182 | |
| 183 | /* wait for re-transmission of NS-UNBLOCK */ |
| 184 | as_rx_ns_unblock_ack(oneshot := true); |
| 185 | setverdict(pass); |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 186 | f_clean_ns_codec(); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | /* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */ |
| 190 | testcase TC_ns_full_bringup() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 191 | f_init_ns_codec(mp_nsconfig); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 192 | f_init_pcuif(); |
| 193 | |
| 194 | /* Expect inbound NS-RESET procedure */ |
| 195 | as_rx_ns_reset_ack(oneshot := true); |
| 196 | |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 197 | /* keep it alive */ |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 198 | activate(as_rx_alive_tx_ack()); |
| 199 | |
| 200 | as_rx_ns_unblock_ack(oneshot := true); |
| 201 | |
| 202 | f_outgoing_ns_alive(); |
| 203 | |
| 204 | /* Expect BVC-RESET for signaling (0) and ptp BVCI */ |
Pau Espin Pedrol | eef4607 | 2021-02-26 13:39:43 +0100 | [diff] [blame] | 205 | as_rx_bvc_reset_tx_ack(0, omit, omit, oneshot := true); |
Harald Welte | e97e3af | 2020-10-09 14:56:54 +0200 | [diff] [blame] | 206 | as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvc[0].bvci, mp_gb_cfg.bvc[0].cell_id, omit, oneshot := true); |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 207 | as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 208 | |
| 209 | /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */ |
Harald Welte | 5339b2e | 2020-10-04 22:52:56 +0200 | [diff] [blame] | 210 | as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci, oneshot := true); |
| 211 | activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvc[0].bvci)); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 212 | setverdict(pass); |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 213 | f_clean_ns_codec(); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | /* test outbound (SGSN-originated) NS-BLOCK procedure */ |
| 217 | testcase TC_ns_so_block() runs on RAW_Test_CT { |
Alexander Couzens | 2beaa20 | 2020-09-11 20:08:41 +0200 | [diff] [blame] | 218 | f_init_ns_codec(mp_nsconfig); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 219 | f_init_pcuif(); |
| 220 | |
| 221 | /* Expect inbound NS-RESET procedure */ |
| 222 | as_rx_ns_reset_ack(oneshot := true); |
| 223 | |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 224 | /* keep it alive */ |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 225 | activate(as_rx_alive_tx_ack()); |
| 226 | |
| 227 | as_rx_ns_unblock_ack(oneshot := true); |
| 228 | |
| 229 | f_outgoing_ns_alive(); |
| 230 | |
| 231 | f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE); |
| 232 | setverdict(pass); |
Alexander Couzens | c316572 | 2021-01-11 02:51:45 +0100 | [diff] [blame] | 233 | f_clean_ns_codec(); |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | |
| 237 | control { |
| 238 | execute( TC_ns_reset() ); |
| 239 | execute( TC_ns_reset_retrans() ); |
| 240 | execute( TC_ns_alive() ); |
| 241 | execute( TC_ns_alive_timeout_reset() ); |
| 242 | execute( TC_ns_unblock() ); |
| 243 | execute( TC_ns_unblock_retrans() ); |
| 244 | execute( TC_ns_full_bringup() ); |
| 245 | execute( TC_ns_so_block() ); |
| 246 | } |
| 247 | |
| 248 | } |