diff options
author | Alexander Chemeris <Alexander.Chemeris@gmail.com> | 2017-07-11 01:42:41 +0630 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-08-13 22:38:04 +0000 |
commit | 84fe989151e00089c674658532ecfa5a7cacc173 (patch) | |
tree | 780e30bd0f3e5ec07838853727a82122d87cce40 /openbsc/tests/channel | |
parent | cf123c0c4e43c3cad124d535afaf97c9578dcd81 (diff) |
libcommon: Fix log output for bts>0.
Fixes regression probably introduced in c696cc28.
For bts>0 logging doesn't show bts number correctly when printing lchan
identification string - it will always show it as "bts=0". The reason for
this is that the identification string is cached before bts->nr value is
set to a proper value.
This patch sets bts->nr as part of the first step of the bts structure
initialization, before caching happens thus making sure the cached
identification string is cached with the correct values.
Change-Id: I61c18a7f021fcb1ec00d34a745f4e3ab03416c2d
Diffstat (limited to 'openbsc/tests/channel')
-rw-r--r-- | openbsc/tests/channel/channel_test.c | 33 | ||||
-rw-r--r-- | openbsc/tests/channel/channel_test.ok | 1 |
2 files changed, 33 insertions, 1 deletions
diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c index 88293d0a8..cf19aab4d 100644 --- a/openbsc/tests/channel/channel_test.c +++ b/openbsc/tests/channel/channel_test.c @@ -70,7 +70,7 @@ void test_request_chan(void) network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL); if (!network) exit(1); - bts = gsm_bts_alloc(network); + bts = gsm_bts_alloc(network, 0); bts->location_area_code = 23; s_conn.network = network; @@ -92,6 +92,36 @@ void test_request_chan(void) OSMO_ASSERT(s_end); } + +void test_bts_debug_print(void) +{ + struct gsm_network *network; + struct gsm_bts *bts; + struct gsm_bts_trx *trx; + + printf("Testing the lchan printing:"); + + /* Create a dummy network */ + network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL); + if (!network) + exit(1); + /* Add a BTS with some reasonanbly non-zero id */ + bts = gsm_bts_alloc(network, 45); + /* Add a second TRX to test on multiple TRXs */ + gsm_bts_trx_alloc(bts); + + llist_for_each_entry(trx, &bts->trx_list, list) { + char *name = gsm_lchan_name(&trx->ts[3].lchan[4]); + + if (name) + printf(" %s", name); + else + printf("NULL name"); + } + printf("\n"); +} + + void test_dyn_ts_subslots(void) { struct gsm_bts_trx_ts ts; @@ -128,6 +158,7 @@ int main(int argc, char **argv) test_request_chan(); test_dyn_ts_subslots(); + test_bts_debug_print(); return EXIT_SUCCESS; } diff --git a/openbsc/tests/channel/channel_test.ok b/openbsc/tests/channel/channel_test.ok index 33c819350..e2e93efcc 100644 --- a/openbsc/tests/channel/channel_test.ok +++ b/openbsc/tests/channel/channel_test.ok @@ -1,3 +1,4 @@ Testing the gsm_subscriber chan logic Reached, didn't crash, test passed Testing subslot numbers for pchan types +Testing the lchan printing: (bts=45,trx=0,ts=3,ss=4) (bts=45,trx=1,ts=3,ss=4) |