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; |
Pau Espin Pedrol | 8dd59fb | 2020-04-29 15:08:16 +0200 | [diff] [blame] | 15 | import from PCU_Tests all; |
Pau Espin Pedrol | 0e6ed2e | 2020-04-29 14:33:13 +0200 | [diff] [blame] | 16 | import from SGSN_Components all; |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 17 | import from Osmocom_Gb_Types all; |
| 18 | import from NS_CodecPort all; |
| 19 | import from NS_Types all; |
| 20 | import from BSSGP_Types all; |
| 21 | import from UD_Types all; |
| 22 | import from NS_CodecPort all; |
| 23 | import from NS_CodecPort_CtrlFunct all; |
| 24 | import from NS_Emulation all; |
| 25 | import from Native_Functions all; |
| 26 | import from IPL4asp_Types all; |
| 27 | import from PCUIF_Types all; |
| 28 | import from PCUIF_CodecPort all; |
Alexander Couzens | 3c268da | 2020-09-07 04:25:05 +0200 | [diff] [blame] | 29 | import from RAW_NS all; |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 30 | |
| 31 | type 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 | |
| 37 | type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT { |
| 38 | } |
| 39 | |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 40 | function 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 | |
| 58 | function 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 Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 62 | /* ensure no matching message is received within 'tout' */ |
| 63 | function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0) |
| 64 | runs 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 Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 77 | /* test the NS-RESET procedure */ |
| 78 | testcase 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 */ |
| 89 | testcase 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 */ |
| 105 | testcase 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 Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 112 | alt { |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 113 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
Alexander Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 114 | [] 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 Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | /* Test for NS-RESET after NS-ALIVE timeout */ |
| 120 | testcase 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 Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 128 | alt { |
| 129 | [] as_rx_alive_tx_ack(oneshot := true) { }; |
| 130 | [] NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) { repeat; } |
| 131 | } |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 132 | |
| 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 Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 137 | [] NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) { repeat; } |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 138 | } |
| 139 | } |
| 140 | |
| 141 | /* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */ |
| 142 | testcase 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 Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 149 | /* keep it alive */ |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 150 | 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 */ |
| 157 | testcase 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 Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 164 | /* keep it alive */ |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 165 | 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 */ |
| 176 | testcase 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 Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 183 | /* keep it alive */ |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 184 | 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 */ |
| 202 | testcase 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 Couzens | 355ab56 | 2020-07-26 22:04:33 +0200 | [diff] [blame] | 209 | /* keep it alive */ |
Pau Espin Pedrol | 4536c82 | 2019-12-30 13:22:32 +0100 | [diff] [blame] | 210 | 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 | |
| 221 | control { |
| 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 | } |