aboutsummaryrefslogtreecommitdiffstats
path: root/tests/channel/channel_test.c
diff options
context:
space:
mode:
authorAlexander Chemeris <Alexander.Chemeris@gmail.com>2017-07-11 01:42:41 +0630
committerNeels Hofmeyr <neels@hofmeyr.de>2017-08-27 03:52:46 +0200
commit0796a6c0fcd31f2d52a50a1ffd699897d658b088 (patch)
treea75046818819e35cd48083413d1fcb9bf696d236 /tests/channel/channel_test.c
parent256867da516e9537caddbc7b124598ebdc9ceb34 (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 'tests/channel/channel_test.c')
-rw-r--r--tests/channel/channel_test.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/channel/channel_test.c b/tests/channel/channel_test.c
index f6869691c..beae658e9 100644
--- a/tests/channel/channel_test.c
+++ b/tests/channel/channel_test.c
@@ -31,6 +31,35 @@
#include <openbsc/gsm_subscriber.h>
#include <openbsc/vlr.h>
+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;
@@ -66,6 +95,7 @@ int main(int argc, char **argv)
osmo_init_logging(&log_info);
test_dyn_ts_subslots();
+ test_bts_debug_print();
return EXIT_SUCCESS;
}