neels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/31631 )
Change subject: bsc_test.c: test FSM IDs that contain pchan names ...................................................................... bsc_test.c: test FSM IDs that contain pchan names Show the timeslot_fsm, lchan_fsm, assignment_fsm fi->id strings. The IDs include the current pchan configuration. I want to tweak the composition of these in an upcoming patch, so the test should show whether any FSM IDs change from that. Change-Id: If369f23fa140b9d7792f5a511815cbbd14b371e9 --- M include/osmocom/bsc/assignment_fsm.h M src/osmo-bsc/assignment_fsm.c M tests/bsc/bsc_test.c M tests/bsc/bsc_test.ok 4 files changed, 130 insertions(+), 1 deletion(-) Approvals: laforge: Looks good to me, but someone else must approve neels: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/include/osmocom/bsc/assignment_fsm.h b/include/osmocom/bsc/assignment_fsm.h index 17f8c4f..70cb88c 100644 --- a/include/osmocom/bsc/assignment_fsm.h +++ b/include/osmocom/bsc/assignment_fsm.h @@ -48,3 +48,4 @@ void assignment_fsm_start(struct gsm_subscriber_connection *conn, struct gsm_bts *bts, struct assignment_request *req); void assignment_reset(struct gsm_subscriber_connection *conn); +void assignment_fsm_update_id(struct gsm_subscriber_connection *conn); diff --git a/src/osmo-bsc/assignment_fsm.c b/src/osmo-bsc/assignment_fsm.c index b9a7930..8ffacca 100644 --- a/src/osmo-bsc/assignment_fsm.c +++ b/src/osmo-bsc/assignment_fsm.c @@ -303,7 +303,7 @@ osmo_fsm_inst_term(conn->assignment.fi, OSMO_FSM_TERM_REGULAR, 0); } -static void assignment_fsm_update_id(struct gsm_subscriber_connection *conn) +void assignment_fsm_update_id(struct gsm_subscriber_connection *conn) { /* Assignment can do a new channel activation, in which case new_lchan points at the new lchan. * Or assignment can Channel Mode Modify the already used lchan, in which case new_lchan == NULL. */ diff --git a/tests/bsc/bsc_test.c b/tests/bsc/bsc_test.c index 4a97b9f..62757b4 100644 --- a/tests/bsc/bsc_test.c +++ b/tests/bsc/bsc_test.c @@ -29,6 +29,12 @@ #include <osmocom/bsc/osmo_bsc.h> #include <osmocom/bsc/bsc_msc_data.h> +#include <osmocom/bsc/bss.h> +#include <osmocom/bsc/bts.h> +#include <osmocom/bsc/timeslot_fsm.h> +#include <osmocom/bsc/lchan_fsm.h> +#include <osmocom/bsc/assignment_fsm.h> +#include <osmocom/bsc/bsc_subscr_conn_fsm.h> #include <osmocom/gsm/gad.h> #include <osmocom/core/application.h> @@ -180,6 +186,61 @@ bsc_gsmnet = NULL; } +static void test_fsm_ids_with_pchan_names(void) +{ + struct gsm_network *net; + struct gsm_bts *bts; + struct gsm_bts_trx *trx; + struct gsm_bts_trx_ts *ts; + struct gsm_lchan *lchan; + enum gsm_phys_chan_config pchan; + struct gsm_subscriber_connection *conn; + + rate_ctr_init(ctx); + tall_bsc_ctx = ctx; + bsc_network_alloc(); + net = bsc_gsmnet; + + /* Have a BTS so that we have trx, timeslots, lchans that have FSMs to check the id of */ + bts = bsc_bts_alloc_register(net, GSM_BTS_TYPE_UNKNOWN, HARDCODED_BSIC); + trx = gsm_bts_trx_alloc(bts); + + printf("\nTesting FSM ids that contain pchan names\n"); + ts = &trx->ts[0]; + lchan = &ts->lchan[0]; + + conn = bsc_subscr_con_allocate(net); + conn->lchan = lchan; + conn->assignment.new_lchan = lchan; + conn->sccp.conn_id = 123; + conn->bsub = bsc_subscr_find_or_create_by_tmsi(net->bsc_subscribers, 0x423, "test"); + gscon_update_id(conn); + + /* dirty dirty hack, to just point at some fi so we can update the id */ + conn->assignment.fi = trx->ts[1].fi; + + for (pchan = 0; pchan < _GSM_PCHAN_MAX; pchan++) { + ts->pchan_from_config = pchan; + /* trigger ID update in ts and lchan */ + osmo_fsm_inst_dispatch(ts->fi, TS_EV_OML_READY, NULL); + + if (lchan->fi) + assignment_fsm_update_id(conn); + + printf("pchan=%s:\n ts->fi->id = %s\n lchan->fi->id = %s\n assignment.fi->id = %s\n", + gsm_pchan_name(pchan), + ts->fi->id, + lchan->fi ? lchan->fi->id : "null", + lchan->fi ? conn->assignment.fi->id : "null"); + + osmo_fsm_inst_dispatch(ts->fi, TS_EV_OML_DOWN, NULL); + } + + talloc_free(net); + bsc_gsmnet = NULL; + printf("\n"); +} + static const struct log_info_cat log_categories[] = { [DNM] = { .name = "DNM", @@ -216,6 +277,7 @@ osmo_init_logging2(ctx, &log_info); test_scan(); + test_fsm_ids_with_pchan_names(); printf("Testing execution completed.\n"); talloc_free(ctx); diff --git a/tests/bsc/bsc_test.ok b/tests/bsc/bsc_test.ok index 0564bf0..fbfc49a 100644 --- a/tests/bsc/bsc_test.ok +++ b/tests/bsc/bsc_test.ok @@ -1,4 +1,55 @@ Testing BTS<->MSC message scan. Going to test item: 0 Going to test item: 1 + +Testing FSM ids that contain pchan names +pchan=NONE: + ts->fi->id = 0-1-0-NONE + lchan->fi->id = null + assignment.fi->id = null +pchan=CCCH: + ts->fi->id = 0-1-0-CCCH + lchan->fi->id = null + assignment.fi->id = null +pchan=CCCH+SDCCH4: + ts->fi->id = 0-1-0-CCCH_SDCCH4 + lchan->fi->id = 0-1-0-CCCH_SDCCH4-0 + assignment.fi->id = msc4294967295-conn123_subscr-TMSI-0x00000423_0-1-0-CCCH_SDCCH4-0 +pchan=TCH/F: + ts->fi->id = 0-1-0-TCH_F + lchan->fi->id = 0-1-0-TCH_F-0 + assignment.fi->id = msc4294967295-conn123_subscr-TMSI-0x00000423_0-1-0-TCH_F-0 +pchan=TCH/H: + ts->fi->id = 0-1-0-TCH_H + lchan->fi->id = 0-1-0-TCH_H-0 + assignment.fi->id = msc4294967295-conn123_subscr-TMSI-0x00000423_0-1-0-TCH_H-0 +pchan=SDCCH8: + ts->fi->id = 0-1-0-SDCCH8 + lchan->fi->id = 0-1-0-SDCCH8-0 + assignment.fi->id = msc4294967295-conn123_subscr-TMSI-0x00000423_0-1-0-SDCCH8-0 +pchan=PDCH: + ts->fi->id = 0-1-0-PDCH + lchan->fi->id = null + assignment.fi->id = null +pchan=DYNAMIC/IPACCESS: + ts->fi->id = 0-1-0-TCH_F_PDCH + lchan->fi->id = 0-1-0-TCH_F_PDCH-0 + assignment.fi->id = msc4294967295-conn123_subscr-TMSI-0x00000423_0-1-0-TCH_F_PDCHasTCH_F-0 +pchan=UNKNOWN: + ts->fi->id = 0-1-0-UNKNOWN + lchan->fi->id = null + assignment.fi->id = null +pchan=CCCH+SDCCH4+CBCH: + ts->fi->id = 0-1-0-CCCH_SDCCH4_CBCH + lchan->fi->id = 0-1-0-CCCH_SDCCH4_CBCH-0 + assignment.fi->id = msc4294967295-conn123_subscr-TMSI-0x00000423_0-1-0-CCCH_SDCCH4_CBCH-0 +pchan=SDCCH8+CBCH: + ts->fi->id = 0-1-0-SDCCH8_CBCH + lchan->fi->id = 0-1-0-SDCCH8_CBCH-0 + assignment.fi->id = msc4294967295-conn123_subscr-TMSI-0x00000423_0-1-0-SDCCH8_CBCH-0 +pchan=DYNAMIC/OSMOCOM: + ts->fi->id = 0-1-0-OSMO_DYN + lchan->fi->id = 0-1-0-OSMO_DYN-0 + assignment.fi->id = msc4294967295-conn123_subscr-TMSI-0x00000423_0-1-0-OSMO_DYNasNONE-0 + Testing execution completed. -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/31631 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: If369f23fa140b9d7792f5a511815cbbd14b371e9 Gerrit-Change-Number: 31631 Gerrit-PatchSet: 9 Gerrit-Owner: neels <nhofm...@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de> Gerrit-Reviewer: laforge <lafo...@osmocom.org> Gerrit-Reviewer: neels <nhofm...@sysmocom.de> Gerrit-Reviewer: pespin <pes...@sysmocom.de> Gerrit-MessageType: merged