Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 1 | module PCU_Tests_RAW { |
| 2 | |
| 3 | /* "RAW" PCU tests: Talk directly to the PCU socket of OsmoPCU on the one hand side (emulating |
| 4 | the BTS/BSC side PCU socket server) and the Gb interface on the other hand side. No NS/BSSGP |
| 5 | Emulation is used; rather, we simply use the NS_CodecPort to implement both standard and non- |
| 6 | standard procedures on the NS and BSSGP level. The goal of these tests is to test exactly |
| 7 | those NS and BSSGP implementations on the BSS (PCU) side. */ |
| 8 | |
| 9 | import from General_Types all; |
| 10 | import from Osmocom_Types all; |
| 11 | import from NS_Types all; |
| 12 | import from BSSGP_Types all; |
| 13 | import from Osmocom_Gb_Types all; |
| 14 | |
| 15 | import from BSSGP_Emulation all; /* BssgpConfig */ |
| 16 | import from NS_Emulation all; /* NSConfiguration */ |
| 17 | |
| 18 | import from UD_Types all; |
| 19 | import from PCUIF_Types all; |
| 20 | import from PCUIF_CodecPort all; |
| 21 | import from IPL4asp_Types all; |
| 22 | import from NS_CodecPort all; |
| 23 | import from NS_CodecPort_CtrlFunct all; |
| 24 | import from Native_Functions all; |
| 25 | import from PCU_Tests all; |
| 26 | |
| 27 | modulepar { |
| 28 | charstring mp_pcu_sock_path := PCU_SOCK_DEFAULT; |
| 29 | } |
| 30 | |
| 31 | type component RAW_NS_CT { |
| 32 | /* UDP port towards the bottom (IUT) */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 33 | port NS_CODEC_PT NSCP[4]; |
| 34 | var ConnectionId g_ns_conn_id[4] := {-1, -1, -1, -1}; |
| 35 | var NSConfiguration g_nsconfig[4]; |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 36 | timer g_T_guard; |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 37 | } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 38 | |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 39 | type component RAW_PCU_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 40 | /* PCUIF (we emulate the BTS part) */ |
| 41 | port PCUIF_CODEC_PT PCU; |
| 42 | var ConnectionId g_pcu_conn_id := -1; |
| 43 | } |
| 44 | |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 45 | type component RAW_Test_CT extends RAW_NS_CT, RAW_PCU_CT { |
| 46 | } |
| 47 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 48 | private altstep as_Tguard() runs on RAW_NS_CT { |
| 49 | [] g_T_guard.timeout { |
| 50 | setverdict(fail, "Timeout of T_guard"); |
| 51 | mtc.stop; |
| 52 | } |
| 53 | } |
| 54 | |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 55 | function f_init_pcuif() runs on RAW_PCU_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 56 | map(self:PCU, system:PCU); |
| 57 | |
| 58 | /* Connect the Unix Domain Socket */ |
| 59 | g_pcu_conn_id := f_pcuif_listen(PCU, mp_pcu_sock_path); |
| 60 | PCU.receive(UD_connected:?); |
| 61 | |
| 62 | /* Wait for PCU_VERSION and return INFO_IND */ |
| 63 | PCU.receive(t_SD_PCUIF(g_pcu_conn_id, tr_PCUIF_TXT_IND(0, PCU_VERSION, ?))); |
| 64 | /* FIXME: make sure to use parameters from mp_gb_cfg.cell_id in the PCU INFO IND */ |
| 65 | var template PCUIF_Message info_ind := ts_PCUIF_INFO_IND(bts_nr := 0, |
| 66 | nsei := mp_nsconfig.nsei, |
| 67 | nsvci := mp_nsconfig.nsvci, |
| 68 | bvci := mp_gb_cfg.bvci, |
| 69 | local_port := mp_nsconfig.remote_udp_port, |
| 70 | remote_port := mp_nsconfig.local_udp_port, |
| 71 | remote_ip := f_inet_haddr(mp_nsconfig.local_ip) |
| 72 | ); |
| 73 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, info_ind)); |
| 74 | } |
| 75 | |
Harald Welte | 0466d16 | 2019-03-21 21:30:21 +0100 | [diff] [blame] | 76 | function f_pcuif_tx(template (value) PCUIF_Message msg) runs on RAW_PCU_CT { |
| 77 | PCU.send(t_SD_PCUIF(g_pcu_conn_id, msg)); |
| 78 | } |
| 79 | |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 80 | function f_init_ns_codec(integer idx := 0, float guard_secs := 60.0) runs on RAW_NS_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 81 | var Result res; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 82 | |
| 83 | if (not g_T_guard.running) { |
| 84 | g_T_guard.start(guard_secs); |
| 85 | activate(as_Tguard()); |
| 86 | } |
| 87 | |
| 88 | if (not isbound(g_nsconfig) or not isbound(g_nsconfig[idx])) { |
| 89 | /* copy most parts from mp_nsconfig */ |
| 90 | g_nsconfig[idx] := mp_nsconfig; |
| 91 | /* adjust those parts different for each NS-VC */ |
| 92 | g_nsconfig[idx].nsvci := mp_nsconfig.nsvci + idx; |
| 93 | g_nsconfig[idx].local_udp_port := mp_nsconfig.local_udp_port + idx; |
| 94 | } |
| 95 | |
| 96 | map(self:NSCP[idx], system:NSCP); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 97 | /* Connect the UDP socket */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 98 | log("connecting NSCP[", idx, "] to ", g_nsconfig[idx]); |
| 99 | res := f_IPL4_connect(NSCP[idx], g_nsconfig[idx].remote_ip, g_nsconfig[idx].remote_udp_port, |
| 100 | g_nsconfig[idx].local_ip, g_nsconfig[idx].local_udp_port, 0, { udp := {}}); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 101 | if (not ispresent(res.connId)) { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 102 | setverdict(fail, "Could not connect NS UDP socket, check your configuration ", g_nsconfig[idx]); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 103 | mtc.stop; |
| 104 | } |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 105 | g_ns_conn_id[idx] := res.connId; |
| 106 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 107 | } |
| 108 | |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 109 | function f_ns_exp(template PDU_NS exp_rx, integer idx := 0) runs on RAW_NS_CT return PDU_NS { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 110 | var NS_RecvFrom nrf; |
| 111 | log("f_ns_exp() expecting ", exp_rx); |
| 112 | alt { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 113 | [] NSCP[idx].receive(t_NS_RecvFrom(exp_rx)) -> value nrf { } |
| 114 | [] NSCP[idx].receive { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 115 | setverdict(fail, "Received unexpected NS: ", nrf); |
| 116 | mtc.stop; |
| 117 | } |
| 118 | } |
| 119 | return nrf.msg; |
| 120 | } |
| 121 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 122 | /* perform outbound NS-ALIVE procedure */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 123 | function f_outgoing_ns_alive(integer idx := 0) runs on RAW_NS_CT { |
| 124 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE)); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 125 | alt { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 126 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)); |
| 127 | [] NSCP[idx].receive { repeat; } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 128 | } |
| 129 | } |
| 130 | |
Harald Welte | ecd159e | 2019-03-16 13:36:07 +0100 | [diff] [blame] | 131 | /* perform outbound NS-ALIVE procedure */ |
| 132 | function f_outgoing_ns_alive_no_ack(integer idx := 0, float tout := 10.0) runs on RAW_NS_CT { |
| 133 | timer T := tout; |
| 134 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE)); |
| 135 | T.start; |
| 136 | alt { |
| 137 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE_ACK)) { |
| 138 | setverdict(fail, "Received unexpected NS-ALIVE ACK"); |
| 139 | } |
| 140 | [] NSCP[idx].receive { repeat; } |
| 141 | [] T.timeout { |
| 142 | setverdict(pass); |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | /* ensure no matching message is received within 'tout' */ |
| 148 | function f_ensure_no_ns(template PDU_NS ns := ?, integer idx := 0, float tout := 3.0) |
| 149 | runs on RAW_Test_CT { |
| 150 | timer T := tout; |
| 151 | T.start; |
| 152 | alt { |
| 153 | [] NSCP[idx].receive(t_NS_RecvFrom(ns)) { |
| 154 | setverdict(fail, "NS-ALIVE from unconfigured (possibly initial) endpoint"); |
| 155 | } |
| 156 | [] T.timeout { |
| 157 | setverdict(pass); |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 162 | /* perform outbound NS-BLOCK procedure */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 163 | function f_outgoing_ns_block(NsCause cause, integer idx := 0) runs on RAW_NS_CT { |
| 164 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_BLOCK(cause, g_nsconfig[idx].nsvci))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 165 | alt { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 166 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_BLOCK_ACK(g_nsconfig[idx].nsvci))); |
| 167 | [] NSCP[idx].receive { repeat; } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 168 | } |
| 169 | } |
| 170 | |
| 171 | /* receive NS-ALIVE and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 172 | altstep as_rx_alive_tx_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
| 173 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_ALIVE)) { |
| 174 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_ALIVE_ACK)); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 175 | if (not oneshot) { repeat; } |
| 176 | } |
| 177 | } |
| 178 | |
Harald Welte | 64d0731 | 2019-03-20 09:48:39 +0100 | [diff] [blame] | 179 | /* Transmit BSSGP RESET for given BVCI and expect ACK */ |
| 180 | function f_tx_bvc_reset_rx_ack(BssgpBvci bvci, integer idx := 0, boolean exp_ack := true) |
| 181 | runs on RAW_NS_CT { |
| 182 | var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET(BSSGP_CAUSE_NET_SV_CAP_MOD_GT_ZERO_KBPS, bvci, |
| 183 | mp_gb_cfg.cell_id)); |
| 184 | timer T := 5.0; |
| 185 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx)))); |
| 186 | T.start; |
| 187 | alt { |
| 188 | [exp_ack] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0, |
| 189 | decmatch tr_BVC_RESET_ACK(bvci, ?)))) { |
| 190 | setverdict(pass); |
| 191 | } |
| 192 | [exp_ack] T.timeout { |
| 193 | setverdict(fail, "No response to BVC-RESET"); |
| 194 | } |
| 195 | [not exp_ack] T.timeout { |
| 196 | setverdict(pass); |
| 197 | } |
| 198 | [] NSCP[idx].receive { repeat; } |
| 199 | } |
| 200 | } |
| 201 | |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 202 | /* Receive a BSSGP RESET for given BVCI and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 203 | altstep as_rx_bvc_reset_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 204 | var NS_RecvFrom ns_rf; |
| 205 | /* FIXME: nail down received cell_id in match */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 206 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0, |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 207 | decmatch tr_BVC_RESET(?, bvci, ?)))) |
| 208 | -> value ns_rf { |
| 209 | var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU); |
| 210 | var PDU_BSSGP bssgp_tx := valueof(ts_BVC_RESET_ACK(bvci, mp_gb_cfg.cell_id)); |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 211 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx)))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 212 | if (not oneshot) { repeat; } |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | |
| 217 | /* Receive a BSSGP UNBLOCK for given BVCI and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 218 | altstep as_rx_bvc_unblock_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 219 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 220 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, 0, |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 221 | decmatch t_BVC_UNBLOCK(bvci)))) |
| 222 | -> value ns_rf { |
| 223 | var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU); |
| 224 | var PDU_BSSGP bssgp_tx := valueof(t_BVC_UNBLOCK_ACK(bvci)); |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 225 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, 0, enc_PDU_BSSGP(bssgp_tx)))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 226 | if (not oneshot) { repeat; } |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | /* Receive a BSSGP FLOW-CONTROL-BVC and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 231 | altstep as_rx_bvc_fc_tx_ack(BssgpBvci bvci, boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 232 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 233 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_UNITDATA(t_SduCtrlB, bvci, |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 234 | decmatch tr_BVC_FC_BVC))) |
| 235 | -> value ns_rf { |
| 236 | var PDU_BSSGP bssgp_rx := dec_PDU_BSSGP(ns_rf.msg.pDU_NS_Unitdata.nS_SDU); |
| 237 | var OCT1 tag := bssgp_rx.pDU_BSSGP_FLOW_CONTROL_BVC.tag.unstructured_Value; |
| 238 | var PDU_BSSGP bssgp_tx := valueof(t_BVC_FC_BVC_ACK(tag)); |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 239 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_UNITDATA(t_SduCtrlB, bvci, enc_PDU_BSSGP(bssgp_tx)))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 240 | if (not oneshot) { repeat; } |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | /********************************************************************************** |
| 245 | * Classic Gb/IP bring-up test cases using NS-{RESET,BLOCK,UNBLOCK} and no IP-SNS * |
| 246 | **********************************************************************************/ |
| 247 | |
| 248 | /* Receive a NS-RESET and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 249 | private altstep as_rx_ns_reset_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 250 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 251 | [] NSCP[idx].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, g_nsconfig[idx].nsvci, |
| 252 | g_nsconfig[idx].nsei))) -> value ns_rf { |
| 253 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], ts_NS_RESET_ACK(g_nsconfig[idx].nsvci, |
| 254 | g_nsconfig[idx].nsei))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 255 | if (not oneshot) { repeat; } |
| 256 | } |
| 257 | } |
| 258 | /* Receive a NS-UNBLOCK and ACK it */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 259 | private altstep as_rx_ns_unblock_ack(boolean oneshot := false, integer idx := 0) runs on RAW_NS_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 260 | var NS_RecvFrom ns_rf; |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 261 | [] NSCP[idx].receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value ns_rf { |
| 262 | NSCP[idx].send(t_NS_Send(g_ns_conn_id[idx], t_NS_UNBLOCK_ACK)); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 263 | if (not oneshot) { repeat; } |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | /* test the NS-RESET procedure */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 268 | testcase TC_ns_reset() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 269 | f_init_ns_codec(); |
| 270 | f_init_pcuif(); |
| 271 | |
| 272 | |
| 273 | /* Expect inbound NS-RESET procedure */ |
| 274 | as_rx_ns_reset_ack(oneshot := true); |
| 275 | setverdict(pass); |
| 276 | } |
| 277 | |
| 278 | /* ensure NS-RESET are re-transmitted */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 279 | testcase TC_ns_reset_retrans() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 280 | f_init_ns_codec(); |
| 281 | f_init_pcuif(); |
| 282 | |
| 283 | var integer i; |
| 284 | for (i := 0; i < 3; i := i+1) { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 285 | NSCP[0].receive(t_NS_RecvFrom(tr_NS_RESET(NS_CAUSE_OM_INTERVENTION, |
| 286 | g_nsconfig[0].nsvci, g_nsconfig[0].nsei))); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | /* Expect inbound NS-RESET procedure */ |
| 290 | as_rx_ns_reset_ack(oneshot := true); |
| 291 | setverdict(pass); |
| 292 | } |
| 293 | |
| 294 | /* test the inbound NS-ALIVE procedure after NS-RESET */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 295 | testcase TC_ns_alive() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 296 | f_init_ns_codec(); |
| 297 | f_init_pcuif(); |
| 298 | |
| 299 | /* Expect inbound NS-RESET procedure */ |
| 300 | as_rx_ns_reset_ack(oneshot := true); |
| 301 | |
| 302 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 303 | as_rx_alive_tx_ack(oneshot := true); |
| 304 | setverdict(pass); |
| 305 | } |
| 306 | |
| 307 | /* Test for NS-RESET after NS-ALIVE timeout */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 308 | testcase TC_ns_alive_timeout_reset() runs on RAW_Test_CT { |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 309 | f_init_ns_codec(guard_secs := 100.0); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 310 | f_init_pcuif(); |
| 311 | |
| 312 | /* Expect inbound NS-RESET procedure */ |
| 313 | as_rx_ns_reset_ack(oneshot := true); |
| 314 | |
| 315 | /* wait for at least one NS-ALIVE */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 316 | NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 317 | |
| 318 | /* wait for NS-RESET to re-appear, ignoring any NS-ALIVE until then */ |
| 319 | alt { |
| 320 | [] as_rx_ns_reset_ack(oneshot := true) { setverdict(pass); } |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 321 | [] NSCP[0].receive(t_NS_RecvFrom(t_NS_ALIVE)) { repeat; } |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 322 | } |
| 323 | } |
| 324 | |
| 325 | /* test for NS-RESET/NS-ALIVE/NS-UNBLOCK */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 326 | testcase TC_ns_unblock() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 327 | f_init_ns_codec(); |
| 328 | f_init_pcuif(); |
| 329 | |
| 330 | /* Expect inbound NS-RESET procedure */ |
| 331 | as_rx_ns_reset_ack(oneshot := true); |
| 332 | |
| 333 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 334 | as_rx_alive_tx_ack(oneshot := true); |
| 335 | activate(as_rx_alive_tx_ack()); |
| 336 | |
| 337 | as_rx_ns_unblock_ack(oneshot := true); |
| 338 | setverdict(pass); |
| 339 | } |
| 340 | |
| 341 | /* test for NS-UNBLOCK re-transmissions */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 342 | testcase TC_ns_unblock_retrans() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 343 | f_init_ns_codec(); |
| 344 | f_init_pcuif(); |
| 345 | |
| 346 | /* Expect inbound NS-RESET procedure */ |
| 347 | as_rx_ns_reset_ack(oneshot := true); |
| 348 | |
| 349 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 350 | as_rx_alive_tx_ack(oneshot := true); |
| 351 | activate(as_rx_alive_tx_ack()); |
| 352 | |
| 353 | /* wait for first NS-UNBLOCK, don't respond */ |
Harald Welte | bf76824 | 2019-02-21 22:19:21 +0100 | [diff] [blame] | 354 | NSCP[0].receive(t_NS_RecvFrom(t_NS_UNBLOCK)); |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 355 | |
| 356 | /* wait for re-transmission of NS-UNBLOCK */ |
| 357 | as_rx_ns_unblock_ack(oneshot := true); |
| 358 | setverdict(pass); |
| 359 | } |
| 360 | |
| 361 | /* full bring-up of the Gb link for NS and BSSGP layer up to BVC-FC */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 362 | testcase TC_ns_full_bringup() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 363 | f_init_ns_codec(); |
| 364 | f_init_pcuif(); |
| 365 | |
| 366 | /* Expect inbound NS-RESET procedure */ |
| 367 | as_rx_ns_reset_ack(oneshot := true); |
| 368 | |
| 369 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 370 | as_rx_alive_tx_ack(oneshot := true); |
| 371 | activate(as_rx_alive_tx_ack()); |
| 372 | |
| 373 | as_rx_ns_unblock_ack(oneshot := true); |
| 374 | |
| 375 | f_outgoing_ns_alive(); |
| 376 | |
| 377 | /* Expect BVC-RESET for signaling (0) and ptp BVCI */ |
| 378 | as_rx_bvc_reset_tx_ack(0, oneshot := true); |
| 379 | as_rx_bvc_reset_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 380 | as_rx_bvc_unblock_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 381 | |
| 382 | /* wait for one FLOW-CONTROL BVC and then ACK any further in the future */ |
| 383 | as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci, oneshot := true); |
| 384 | activate(as_rx_bvc_fc_tx_ack(mp_gb_cfg.bvci)); |
| 385 | setverdict(pass); |
| 386 | } |
| 387 | |
| 388 | /* test outbound (SGSN-originated) NS-BLOCK procedure */ |
Harald Welte | ea3c7e9 | 2019-03-01 19:34:55 +0100 | [diff] [blame] | 389 | testcase TC_ns_so_block() runs on RAW_Test_CT { |
Harald Welte | 9fbcf4b | 2018-12-07 07:56:52 +0100 | [diff] [blame] | 390 | f_init_ns_codec(); |
| 391 | f_init_pcuif(); |
| 392 | |
| 393 | /* Expect inbound NS-RESET procedure */ |
| 394 | as_rx_ns_reset_ack(oneshot := true); |
| 395 | |
| 396 | /* wait for one ALIVE cycle, then ACK any further ALIVE in the background */ |
| 397 | as_rx_alive_tx_ack(oneshot := true); |
| 398 | activate(as_rx_alive_tx_ack()); |
| 399 | |
| 400 | as_rx_ns_unblock_ack(oneshot := true); |
| 401 | |
| 402 | f_outgoing_ns_alive(); |
| 403 | |
| 404 | f_outgoing_ns_block(NS_CAUSE_EQUIPMENT_FAILURE); |
| 405 | setverdict(pass); |
| 406 | } |
| 407 | |
| 408 | |
| 409 | control { |
| 410 | execute( TC_ns_reset() ); |
| 411 | execute( TC_ns_reset_retrans() ); |
| 412 | execute( TC_ns_alive() ); |
| 413 | execute( TC_ns_alive_timeout_reset() ); |
| 414 | execute( TC_ns_unblock() ); |
| 415 | execute( TC_ns_unblock_retrans() ); |
| 416 | execute( TC_ns_full_bringup() ); |
| 417 | execute( TC_ns_so_block() ); |
| 418 | } |
| 419 | |
| 420 | |
| 421 | |
| 422 | |
| 423 | |
| 424 | |
| 425 | } |