Neels Hofmeyr | 3dc2c64 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 1 | /* Osmocom MSC+VLR end-to-end tests */ |
| 2 | |
| 3 | /* (C) 2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de> |
| 4 | * |
| 5 | * All Rights Reserved |
| 6 | * |
| 7 | * Author: Neels Hofmeyr <nhofmeyr@sysmocom.de> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU Affero General Public License as published by |
| 11 | * the Free Software Foundation; either version 3 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU Affero General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Affero General Public License |
| 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include "msc_vlr_tests.h" |
| 25 | |
| 26 | void test_early_stage() |
| 27 | { |
| 28 | comment_start(); |
| 29 | |
| 30 | btw("NULL conn"); |
| 31 | EXPECT_ACCEPTED(false); |
| 32 | |
| 33 | btw("freshly allocated conn"); |
| 34 | g_conn = msc_subscr_con_allocate(net); |
| 35 | g_conn->bts = the_bts; |
| 36 | EXPECT_ACCEPTED(false); |
| 37 | |
| 38 | btw("conn_fsm present, in state NEW"); |
| 39 | OSMO_ASSERT(msc_create_conn_fsm(g_conn, "test") == 0); |
| 40 | OSMO_ASSERT(g_conn->conn_fsm); |
| 41 | OSMO_ASSERT(g_conn->conn_fsm->state == SUBSCR_CONN_S_NEW); |
| 42 | EXPECT_ACCEPTED(false); |
| 43 | |
| 44 | thwart_rx_non_initial_requests(); |
| 45 | |
| 46 | btw("fake: acceptance"); |
| 47 | g_conn->vsub = vlr_subscr_alloc(net->vlr); |
| 48 | OSMO_ASSERT(g_conn->vsub); |
| 49 | /* mark as silent call so it sticks around */ |
| 50 | g_conn->silent_call = 1; |
| 51 | osmo_fsm_inst_state_chg(g_conn->conn_fsm, SUBSCR_CONN_S_ACCEPTED, 0, 0); |
| 52 | EXPECT_CONN_COUNT(1); |
| 53 | EXPECT_ACCEPTED(true); |
| 54 | |
| 55 | btw("CLOSE event marks conn_fsm as released and frees the conn"); |
| 56 | osmo_fsm_inst_dispatch(g_conn->conn_fsm, SUBSCR_CONN_E_CN_CLOSE, NULL); |
| 57 | EXPECT_CONN_COUNT(0); |
| 58 | |
| 59 | clear_vlr(); |
| 60 | comment_end(); |
| 61 | } |
| 62 | |
| 63 | void test_cm_service_without_lu() |
| 64 | { |
| 65 | comment_start(); |
| 66 | |
| 67 | btw("CM Service Request without a prior Location Updating"); |
| 68 | ms_sends_msg("05247803305886089910070000006402"); |
| 69 | |
| 70 | btw("conn was released"); |
| 71 | EXPECT_CONN_COUNT(0); |
| 72 | |
| 73 | clear_vlr(); |
| 74 | comment_end(); |
| 75 | } |
| 76 | |
| 77 | void test_two_lu() |
| 78 | { |
| 79 | comment_start(); |
| 80 | |
| 81 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 82 | lu_result_sent = RES_NONE; |
| 83 | gsup_expect_tx("04010809710000004026f0"); |
| 84 | ms_sends_msg("050802008168000130089910070000006402"); |
| 85 | OSMO_ASSERT(gsup_tx_confirmed); |
| 86 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 87 | |
| 88 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 89 | gsup_rx("10010809710000004026f00804036470f1", |
| 90 | "12010809710000004026f0"); |
| 91 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 92 | |
| 93 | btw("having received subscriber data does not mean acceptance"); |
| 94 | EXPECT_ACCEPTED(false); |
| 95 | |
| 96 | thwart_rx_non_initial_requests(); |
| 97 | |
| 98 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 99 | |
| 100 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
| 101 | gsup_rx("06010809710000004026f0", NULL); |
| 102 | |
| 103 | btw("LU was successful, and the conn has already been closed"); |
| 104 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 105 | EXPECT_CONN_COUNT(0); |
| 106 | |
| 107 | |
| 108 | BTW("verify that the MS can send another LU request"); |
| 109 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 110 | lu_result_sent = RES_NONE; |
| 111 | gsup_expect_tx("04010809710000004026f0"); |
| 112 | ms_sends_msg("050802008168000130089910070000006402"); |
| 113 | OSMO_ASSERT(gsup_tx_confirmed); |
| 114 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 115 | |
| 116 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 117 | gsup_rx("10010809710000004026f00804036470f1", |
| 118 | "12010809710000004026f0"); |
| 119 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 120 | |
| 121 | btw("having received subscriber data does not mean acceptance"); |
| 122 | EXPECT_ACCEPTED(false); |
| 123 | |
| 124 | thwart_rx_non_initial_requests(); |
| 125 | |
| 126 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 127 | |
| 128 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
| 129 | gsup_rx("06010809710000004026f0", NULL); |
| 130 | |
| 131 | btw("LU was successful, and the conn has already been closed"); |
| 132 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 133 | EXPECT_CONN_COUNT(0); |
| 134 | |
| 135 | BTW("subscriber detaches"); |
| 136 | ms_sends_msg("050130089910070000006402"); |
| 137 | |
| 138 | EXPECT_CONN_COUNT(0); |
| 139 | clear_vlr(); |
| 140 | comment_end(); |
| 141 | } |
| 142 | |
| 143 | void test_lu_unknown_tmsi() |
| 144 | { |
| 145 | comment_start(); |
| 146 | |
| 147 | btw("Location Update request with unknown TMSI sends ID Request for IMSI"); |
| 148 | lu_result_sent = RES_NONE; |
| 149 | dtap_expect_tx("051801"); |
| 150 | ms_sends_msg("050802008168000130" "05f4" "23422342"); |
| 151 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 152 | |
| 153 | EXPECT_ACCEPTED(false); |
| 154 | thwart_rx_non_initial_requests(); |
| 155 | |
| 156 | btw("MS tells us the IMSI, causes a GSUP LU request to HLR"); |
| 157 | gsup_expect_tx("04010809710000004026f0"); |
| 158 | ms_sends_msg("0559089910070000006402"); |
| 159 | OSMO_ASSERT(gsup_tx_confirmed); |
| 160 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 161 | |
| 162 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 163 | gsup_rx("10010809710000004026f00804036470f1", |
| 164 | "12010809710000004026f0"); |
| 165 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 166 | |
| 167 | btw("having received subscriber data does not mean acceptance"); |
| 168 | EXPECT_ACCEPTED(false); |
| 169 | thwart_rx_non_initial_requests(); |
| 170 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 171 | |
| 172 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
| 173 | gsup_rx("06010809710000004026f0", NULL); |
| 174 | |
| 175 | btw("LU was successful, and the conn has already been closed"); |
| 176 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 177 | EXPECT_CONN_COUNT(0); |
| 178 | clear_vlr(); |
| 179 | comment_end(); |
| 180 | } |
| 181 | |
| 182 | msc_vlr_test_func_t msc_vlr_tests[] = { |
| 183 | test_early_stage, |
| 184 | test_cm_service_without_lu, |
| 185 | test_two_lu, |
| 186 | test_lu_unknown_tmsi, |
| 187 | NULL |
| 188 | }; |