diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/abis/abis_test.c | 4 | ||||
-rw-r--r-- | tests/bsc-nat/bsc_nat_test.c | 2 | ||||
-rw-r--r-- | tests/bsc/bsc_test.c | 4 | ||||
-rw-r--r-- | tests/bssap/Makefile.am | 1 | ||||
-rw-r--r-- | tests/bssap/bssap_test.c | 4 | ||||
-rw-r--r-- | tests/channel/channel_test.c | 1 | ||||
-rw-r--r-- | tests/gsm0408/gsm0408_test.c | 4 | ||||
-rw-r--r-- | tests/handover/Makefile.am | 6 | ||||
-rw-r--r-- | tests/handover/handover_test.c | 78 | ||||
-rw-r--r-- | tests/nanobts_omlattr/nanobts_omlattr_test.c | 4 |
10 files changed, 104 insertions, 4 deletions
diff --git a/tests/abis/abis_test.c b/tests/abis/abis_test.c index bb70a1505..7deb0f00f 100644 --- a/tests/abis/abis_test.c +++ b/tests/abis/abis_test.c @@ -182,3 +182,7 @@ int main(int argc, char **argv) return EXIT_SUCCESS; } + +struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *net) { + OSMO_ASSERT(0); +} diff --git a/tests/bsc-nat/bsc_nat_test.c b/tests/bsc-nat/bsc_nat_test.c index 09378ae6a..bb287ec4c 100644 --- a/tests/bsc-nat/bsc_nat_test.c +++ b/tests/bsc-nat/bsc_nat_test.c @@ -1590,3 +1590,5 @@ void bsc_nat_send_mgcp_to_msc(struct bsc_nat *nat, struct msgb *msg) { abort(); } + +struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *network) { return NULL; } diff --git a/tests/bsc/bsc_test.c b/tests/bsc/bsc_test.c index 541a44caf..744b9e1cb 100644 --- a/tests/bsc/bsc_test.c +++ b/tests/bsc/bsc_test.c @@ -235,3 +235,7 @@ int main(int argc, char **argv) printf("Testing execution completed.\n"); return 0; } + +struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *net) { + OSMO_ASSERT(0); +} diff --git a/tests/bssap/Makefile.am b/tests/bssap/Makefile.am index e4fe38b77..30a9246c8 100644 --- a/tests/bssap/Makefile.am +++ b/tests/bssap/Makefile.am @@ -29,7 +29,6 @@ bssap_test_SOURCES = \ $(top_srcdir)/src/osmo-bsc/osmo_bsc_sigtran.c \ $(top_srcdir)/src/osmo-bsc/osmo_bsc_filter.c \ $(top_srcdir)/src/osmo-bsc/osmo_bsc_grace.c \ - $(top_srcdir)/src/osmo-bsc/osmo_bsc_mgcp.c \ $(NULL) bssap_test_LDADD = \ diff --git a/tests/bssap/bssap_test.c b/tests/bssap/bssap_test.c index cf60e3871..5601e29a1 100644 --- a/tests/bssap/bssap_test.c +++ b/tests/bssap/bssap_test.c @@ -150,3 +150,7 @@ int main(int argc, char **argv) return 0; } + +struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *net) { + OSMO_ASSERT(0); +} diff --git a/tests/channel/channel_test.c b/tests/channel/channel_test.c index b41e3d6a7..78db1d4e3 100644 --- a/tests/channel/channel_test.c +++ b/tests/channel/channel_test.c @@ -119,5 +119,6 @@ void ipa_client_conn_open() {} void ipa_client_conn_send() {} void ipa_msg_push_header() {} void ipaccess_bts_handle_ccm() {} +struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *network) { return NULL; } struct tlv_definition nm_att_tlvdef; diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c index e8d5501bb..5a4c168dc 100644 --- a/tests/gsm0408/gsm0408_test.c +++ b/tests/gsm0408/gsm0408_test.c @@ -861,3 +861,7 @@ int main(int argc, char **argv) return EXIT_SUCCESS; } + +struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *net) { + OSMO_ASSERT(0); +} diff --git a/tests/handover/Makefile.am b/tests/handover/Makefile.am index 7133fcddc..957bbeeb9 100644 --- a/tests/handover/Makefile.am +++ b/tests/handover/Makefile.am @@ -9,6 +9,8 @@ AM_CFLAGS = \ $(LIBOSMOCORE_CFLAGS) \ $(LIBOSMOGSM_CFLAGS) \ $(LIBOSMOABIS_CFLAGS) \ + $(LIBOSMOSIGTRAN_CFLAGS) \ + $(LIBOSMOMGCPCLIENT_CFLAGS) \ $(NULL) AM_LDFLAGS = \ @@ -28,7 +30,7 @@ handover_test_SOURCES = \ $(NULL) handover_test_LDFLAGS =\ - -Wl,--wrap=abis_rsl_sendmsg \ + -Wl,--wrap=abis_rsl_sendmsg,--wrap=mgcp_conn_modify,--wrap=mgcp_conn_delete\ $(NULL) handover_test_LDADD = \ @@ -36,4 +38,6 @@ handover_test_LDADD = \ $(LIBOSMOCORE_LIBS) \ $(LIBOSMOGSM_LIBS) \ $(LIBOSMOABIS_LIBS) \ + $(LIBOSMOSIGTRAN_LIBS) \ + $(LIBOSMOMGCPCLIENT_LIBS) \ $(NULL) diff --git a/tests/handover/handover_test.c b/tests/handover/handover_test.c index bf7350c62..b03b65a6b 100644 --- a/tests/handover/handover_test.c +++ b/tests/handover/handover_test.c @@ -39,9 +39,59 @@ #include <osmocom/bsc/bss.h> #include <osmocom/bsc/bsc_api.h> #include <osmocom/bsc/osmo_bsc.h> +#include <osmocom/bsc/bsc_subscr_conn_fsm.h> struct gsm_network *bsc_gsmnet; +/* override, requires '-Wl,--wrap=mgcp_conn_modify'. + * Catch modification of an MGCP connection. */ +int __real_mgcp_conn_modify(struct osmo_fsm_inst *fi, uint32_t parent_evt, struct mgcp_conn_peer *conn_peer); +int __wrap_mgcp_conn_modify(struct osmo_fsm_inst *fi, uint32_t parent_evt, struct mgcp_conn_peer *conn_peer) +{ + /* CAUTION HACK: + * + * The pointer fi is misused to pass a reference to GSCON FSM ! + * + * This function is called from gscon_fsm_wait_ho_compl() from + * bsc_subscr_conn_fsm.c when GSCON_EV_HO_COMPL is dispatched to the + * GSCON FSM. By then, the GSCON FSM has already changed to the state + * ST_WAIT_MDCX_BTS_HO (see gscon_fsm_wait_mdcx_bts_ho()) and waits for + * GSCON_EV_MGW_MDCX_RESP_BTS. The signal GSCON_EV_MGW_MDCX_RESP_BTS + * is sent to this function using the parameter parent_evt. So we + * implicitly know the event that is needed to simulate a successful + * MGW negotiation to the GSCON FSM. All we need to do is to dispatch + * parent_evt back to the GSCON FSM in order to make it think that the + * MGW negotiation is done. + * + * Unfortunately, there is a problem with this test implementation. + * in order to simplfy the test we do not allocate any MGCP Client + * FSM but the GSCON FSM will call this function with the fi pointer + * pointing to the MGCP Client FSM. This means we get a nullpointer + * here and there is no way to distinguish which GSCON FSM called + * the function at all (normally we would know through the parent + * pointer). + * + * To get around this problem we populate the fi pointer with the + * reference to the GSCON FSM itsself, so we can know who called the + * function. This is a misuse of the pointer since it normally would + * hold an MGCP Client FSM instead of a GSCON FSM. + * + * See also note in function create_conn() */ + + osmo_fsm_inst_dispatch(fi, parent_evt, NULL); + return 0; +} + +/* override, requires '-Wl,--wrap=mgcp_conn_delete'. + * Catch deletion of an MGCP connection. */ +int __real_mgcp_conn_delete(struct osmo_fsm_inst *fi); +int __wrap_mgcp_conn_delete(struct osmo_fsm_inst *fi) +{ + /* Just do nothing and pretend that everything went well. + * We never have allocatec any MGCP connections. */ + return 0; +} + /* measurement report */ uint8_t meas_rep_ba = 0, meas_rep_valid = 1, meas_valid = 1, meas_multi_rep = 0; @@ -186,7 +236,24 @@ static struct gsm_bts *create_bts(int arfcn) void create_conn(struct gsm_lchan *lchan) { - lchan->conn = bsc_subscr_con_allocate(lchan); + struct gsm_subscriber_connection *conn; + conn = bsc_subscr_con_allocate(lchan->ts->trx->bts->network); + + /* CAUTION HACK: When __real_mgcp_conn_modify() is called by the GSCON + * FSM, then we need to know the reference to caller FSM (GSCON FSM). + * Unfortunately the function __real_mgcp_conn_modify() is called with + * fi_bts, which is unpopulated in this setup. The real function would + * perform the communication with the MGW and then dispatch a signal + * back to the parent FSM. Since we do not have all that in this setup + * we populate the fi_bts pointer with a reference to the GSCON FSM in + * order to have it available later in __real_mgcp_conn_modify(). */ + conn->user_plane.fi_bts = conn->fi; + + lchan->conn = conn; + conn->lchan = lchan; + /* kick the FSM from INIT through to the ACTIVE state */ + osmo_fsm_inst_dispatch(conn->fi, GSCON_EV_A_CONN_REQ, NULL); + osmo_fsm_inst_dispatch(conn->fi, GSCON_EV_A_CONN_CFM, NULL); } /* create lchan */ @@ -1256,6 +1323,11 @@ static const struct log_info_cat log_categories[] = { .color = "\033[1;35m", .enabled = 1, .loglevel = LOGL_DEBUG, }, + [DMSC] = { + .name = "DMSC", + .description = "Mobile Switching Center", + .enabled = 1, .loglevel = LOGL_DEBUG, + }, }; const struct log_info log_info = { @@ -1592,7 +1664,7 @@ int main(int argc, char **argv) struct gsm_subscriber_connection *conn = lchan[i]->conn; lchan[i]->conn = NULL; conn->lchan = NULL; - bsc_subscr_con_free(conn); + osmo_fsm_inst_term(conn->fi, OSMO_FSM_TERM_REGULAR, NULL); lchan_free(lchan[i]); } @@ -1615,3 +1687,5 @@ void trau_mux_unmap() {} void trau_mux_map_lchan() {} void trau_recv_lchan() {} void trau_send_frame() {} +int osmo_bsc_sigtran_send(struct gsm_subscriber_connection *conn, struct msgb *msg) { return 0; } +int osmo_bsc_sigtran_open_conn(struct gsm_subscriber_connection *conn, struct msgb *msg) { return 0; } diff --git a/tests/nanobts_omlattr/nanobts_omlattr_test.c b/tests/nanobts_omlattr/nanobts_omlattr_test.c index 6fa221c9d..663594cda 100644 --- a/tests/nanobts_omlattr/nanobts_omlattr_test.c +++ b/tests/nanobts_omlattr/nanobts_omlattr_test.c @@ -292,3 +292,7 @@ int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx) { abort(); } + +struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_network *net) { + OSMO_ASSERT(0); +} |