fixeria has uploaded this change for review.

View Change

tests/gsm0408: add testing coverage for generate_cell_chan_list()

This commit demonstrates what happens when a cell has channels in
both P-GSM and E-GSM bands (case 'c'). As can be seen from:

Case a) only the BCCH carrier: 10
Case b) more carriers from P-GSM band: 1 3 10 64 99 124
Case c) more carriers from E-GSM band: 1 3 10 64 99 124

in both cases 'b' and 'c' we have the same set of ARFCNs. Carriers
from the E-GSM band are not present at all. This is wrong and will
be fixed in the follow up change(s).

Change-Id: Ied0519c70501f105673a9b36657101063d275058
Related: SYS#5854
---
M tests/gsm0408/Makefile.am
M tests/gsm0408/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
3 files changed, 75 insertions(+), 0 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/80/27380/1
diff --git a/tests/gsm0408/Makefile.am b/tests/gsm0408/Makefile.am
index 571e7e6..b5a1ae5 100644
--- a/tests/gsm0408/Makefile.am
+++ b/tests/gsm0408/Makefile.am
@@ -29,6 +29,7 @@
$(top_builddir)/src/osmo-bsc/gsm_04_08_rr.o \
$(top_builddir)/src/osmo-bsc/arfcn_range_encode.o \
$(top_builddir)/src/osmo-bsc/bts.o \
+ $(top_builddir)/src/osmo-bsc/bts_unknown.o \
$(top_builddir)/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.o \
$(top_builddir)/src/osmo-bsc/bts_sm.o \
$(top_builddir)/src/osmo-bsc/bts_trx.o \
diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index 9a1d3cf..2018e53 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -30,6 +30,7 @@
#include <osmocom/bsc/system_information.h>
#include <osmocom/bsc/abis_rsl.h>
#include <osmocom/bsc/bts.h>
+#include <osmocom/bsc/bss.h>

#include <osmocom/core/application.h>
#include <osmocom/core/byteswap.h>
@@ -878,6 +879,71 @@
OSMO_ASSERT(rc == -EINVAL);
}

+/* Similar to list_arfcn() from system_information.c, but uses printf().
+ * Another difference is that the text is printed even if n is 0. */
+static void print_cell_chan_desc(uint8_t *cd, const char *text)
+{
+ struct gsm_sysinfo_freq freq[1024];
+ unsigned int n = 0, i;
+
+ memset(freq, 0, sizeof(freq));
+ gsm48_decode_freq_list(freq, cd, 16, 0xce, 1);
+
+ printf("%s:", text);
+ for (i = 0; i < 1024; i++) {
+ if (!freq[i].mask)
+ continue;
+ printf(" %u", i);
+ n++;
+ }
+ if (!n)
+ printf(" (empty set)");
+ printf("\n");
+}
+
+static void test_cell_chan_desc(struct gsm_network *net)
+{
+ struct gsm_bts *bts = bts_init(net);
+ uint8_t cell_chan_desc[16];
+
+ printf("Testing generation of the Cell Channel Description IE:\n");
+
+ bts_model_unknown_init();
+ bts->type = GSM_BTS_TYPE_UNKNOWN;
+ bts->model = bts_model_find(bts->type);
+ OSMO_ASSERT(bts->model != NULL);
+
+ bts->band = GSM_BAND_900;
+ bts->c0->arfcn = 10; /* BCCH carrier */
+
+ /* Case a) only the BCCH carrier */
+ bitvec_set_bit_pos(&bts->si_common.cell_alloc, bts->c0->arfcn, ONE);
+
+ OSMO_ASSERT(generate_cell_chan_list(&cell_chan_desc[0], bts) == 0);
+ print_cell_chan_desc(&cell_chan_desc[0], "Case a) only the BCCH carrier");
+
+ /* Case b) more carriers from P-GSM band */
+ bitvec_set_bit_pos(&bts->si_common.cell_alloc, 1, ONE);
+ bitvec_set_bit_pos(&bts->si_common.cell_alloc, 3, ONE);
+ bitvec_set_bit_pos(&bts->si_common.cell_alloc, 64, ONE);
+ bitvec_set_bit_pos(&bts->si_common.cell_alloc, 99, ONE);
+ bitvec_set_bit_pos(&bts->si_common.cell_alloc, 124, ONE);
+
+ OSMO_ASSERT(generate_cell_chan_list(&cell_chan_desc[0], bts) == 0);
+ print_cell_chan_desc(&cell_chan_desc[0], "Case b) more carriers from P-GSM band");
+
+ /* Case c) more carriers from E-GSM band */
+ bitvec_set_bit_pos(&bts->si_common.cell_alloc, 0, ONE);
+ bitvec_set_bit_pos(&bts->si_common.cell_alloc, 975, ONE);
+ bitvec_set_bit_pos(&bts->si_common.cell_alloc, 1001, ONE);
+ bitvec_set_bit_pos(&bts->si_common.cell_alloc, 1023, ONE);
+
+ OSMO_ASSERT(generate_cell_chan_list(&cell_chan_desc[0], bts) == 0);
+ print_cell_chan_desc(&cell_chan_desc[0], "Case c) more carriers from E-GSM band");
+
+ bts_del(bts);
+}
+
static const struct log_info_cat log_categories[] = {
};

@@ -919,6 +985,8 @@

test_gsm48_multirate_config();

+ test_cell_chan_desc(net);
+
printf("Done.\n");

return EXIT_SUCCESS;
diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok
index f1aa463..38b5b4b 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -243,4 +243,10 @@
gsm48_multirate_config(): rc=0, lv=0520340bf330
gsm48_multirate_config(): rc=0, lv=0420140bf0
gsm48_multirate_config(): rc=0, lv=022004
+BTS allocation OK in test_cell_chan_desc()
+Testing generation of the Cell Channel Description IE:
+Case a) only the BCCH carrier: 10
+Case b) more carriers from P-GSM band: 1 3 10 64 99 124
+Case c) more carriers from E-GSM band: 1 3 10 64 99 124
+BTS deallocated OK in test_cell_chan_desc()
Done.

To view, visit change 27380. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-bsc
Gerrit-Branch: 2021q1
Gerrit-Change-Id: Ied0519c70501f105673a9b36657101063d275058
Gerrit-Change-Number: 27380
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-MessageType: newchange