fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/27382 )


Change subject: tests/gsm0408: add testing coverage for 
generate_cell_chan_list()
......................................................................

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/gsm0408_test.c
M tests/gsm0408/gsm0408_test.ok
2 files changed, 74 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/82/27382/1

diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index 90b294e..a7270a4 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -29,6 +29,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>
@@ -555,6 +556,71 @@
        msgb_free(msg);
 }

+/* 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[] = {
 };

@@ -591,6 +657,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 0bb7ee0..26ec931 100644
--- a/tests/gsm0408/gsm0408_test.ok
+++ b/tests/gsm0408/gsm0408_test.ok
@@ -187,4 +187,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 https://gerrit.osmocom.org/c/osmo-bsc/+/27382
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: 2021q4
Gerrit-Change-Id: Ied0519c70501f105673a9b36657101063d275058
Gerrit-Change-Number: 27382
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>
Gerrit-MessageType: newchange

Reply via email to