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
This commit is contained in:
Neels Hofmeyr 2023-03-02 01:41:13 +01:00 committed by neels
parent 76ea8562db
commit 879e7595f0
4 changed files with 115 additions and 1 deletions

View File

@ -48,3 +48,4 @@ int reassignment_request_to_chan_type(enum assign_for assign_for, struct gsm_lch
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);

View File

@ -303,7 +303,7 @@ static void assignment_success(struct gsm_subscriber_connection *conn)
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. */

View File

@ -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 @@ out:
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 @@ int main(int argc, char **argv)
osmo_init_logging2(ctx, &log_info);
test_scan();
test_fsm_ids_with_pchan_names();
printf("Testing execution completed.\n");
talloc_free(ctx);

View File

@ -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.