aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-06-20 17:18:38 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-06-24 08:17:12 +0200
commitf169a75fc41c2474bb0602d5f6b6401213f03633 (patch)
tree84917f00cda01e84bf5ee476accbd5e230c52293 /tests
parent43b4176f0e0e4d1e73463e9ff21a69e6e2848215 (diff)
sysmobts: Introduce an auto-band config to ease DCS/DCS, PCS/PCS changes
During development one switches from GSM900 to GSM1800 and GSM850 to GSM1900. This commit attempts to make this switch more easy. GSM1800 and GSM1900 have overlapping ARFCNs. This means that the mapping from bands to arfcn is not injective. Because of that I removed the code to deduce the band from the ARFCN. This was done in commit 8c3d807b3fc785ffb18aeb97355150c92221e8a0. The auto-band option allows to move between GSM900/GSM1800 and GSM850/GSM1900. Add a simple testcase with these auto-band configurations.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/sysmobts/Makefile.am9
-rw-r--r--tests/sysmobts/sysmobts_test.c122
-rw-r--r--tests/sysmobts/sysmobts_test.ok19
4 files changed, 151 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1d548f95..5fb128f1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = paging cipher
+SUBDIRS = paging cipher sysmobts
# The `:;' works around a Bash 3.2 bug when the output is not writeable.
$(srcdir)/package.m4: $(top_srcdir)/configure.ac
diff --git a/tests/sysmobts/Makefile.am b/tests/sysmobts/Makefile.am
new file mode 100644
index 00000000..d884237b
--- /dev/null
+++ b/tests/sysmobts/Makefile.am
@@ -0,0 +1,9 @@
+AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -I$(OPENBSC_INCDIR) -I$(top_srcdir)/src/osmo-bts-sysmo
+AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS)
+LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) -lortp
+
+noinst_PROGRAMS = sysmobts_test
+EXTRA_DIST = sysmobts_test.ok
+
+sysmobts_test_SOURCES = sysmobts_test.c $(top_srcdir)/src/osmo-bts-sysmo/utils.c
+sysmobts_test_LDADD = $(LDADD)
diff --git a/tests/sysmobts/sysmobts_test.c b/tests/sysmobts/sysmobts_test.c
new file mode 100644
index 00000000..938bd8ca
--- /dev/null
+++ b/tests/sysmobts/sysmobts_test.c
@@ -0,0 +1,122 @@
+/*
+ * (C) 2013 by Holger Hans Peter Freyther
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <osmo-bts/bts.h>
+
+#include "femtobts.h"
+#include "utils.h"
+
+#include <stdio.h>
+
+static int direct_map[][3] = {
+ { GSM_BAND_850, GsmL1_FreqBand_850, 128 },
+ { GSM_BAND_900, GsmL1_FreqBand_900, 1 },
+ { GSM_BAND_1800, GsmL1_FreqBand_1800, 600 },
+ { GSM_BAND_1900, GsmL1_FreqBand_1900, 600 },
+};
+
+static int dcs_to_dcs[][3] = {
+ { GSM_BAND_900, GsmL1_FreqBand_1800, 600 },
+ { GSM_BAND_1800, GsmL1_FreqBand_900, 1 },
+ { GSM_BAND_900, -1, 438 },
+};
+
+static int pcs_to_pcs[][3] = {
+ { GSM_BAND_850, GsmL1_FreqBand_1900, 512 },
+ { GSM_BAND_1900, GsmL1_FreqBand_850, 128 },
+ { GSM_BAND_900, -1, 438 },
+};
+
+static void test_sysmobts_auto_band(void)
+{
+ struct gsm_bts bts;
+ struct gsm_bts_role_bts btsb;
+ int i;
+
+ memset(&bts, 0, sizeof(bts));
+ memset(&btsb, 0, sizeof(btsb));
+ bts.role = &btsb;
+
+ /* start with the current option */
+ printf("Testing the no auto-band mapping.\n");
+ for (i = 0; i < ARRAY_SIZE(direct_map); ++i) {
+ uint16_t arfcn;
+ int res;
+
+ btsb.auto_band = 0;
+ bts.band = direct_map[i][0];
+ arfcn = direct_map[i][2];
+ res = sysmobts_select_femto_band(&bts, arfcn);
+ printf("No auto-band band(%d) arfcn(%u) want(%d) got(%d)\n",
+ bts.band, arfcn, direct_map[i][1], res);
+ OSMO_ASSERT(res == direct_map[i][1]);
+ }
+
+ /* Check if auto-band does not break things */
+ printf("Checking the mapping with auto-band.\n");
+ for (i = 0; i < ARRAY_SIZE(direct_map); ++i) {
+ uint16_t arfcn;
+ int res;
+
+ btsb.auto_band = 1;
+ bts.band = direct_map[i][0];
+ arfcn = direct_map[i][2];
+ res = sysmobts_select_femto_band(&bts, arfcn);
+ printf("Auto-band band(%d) arfcn(%u) want(%d) got(%d)\n",
+ bts.band, arfcn, direct_map[i][1], res);
+ OSMO_ASSERT(res == direct_map[i][1]);
+ }
+
+ /* Check DCS to DCS change */
+ printf("Checking DCS to DCS\n");
+ for (i = 0; i < ARRAY_SIZE(dcs_to_dcs); ++i) {
+ uint16_t arfcn;
+ int res;
+
+ btsb.auto_band = 1;
+ bts.band = dcs_to_dcs[i][0];
+ arfcn = dcs_to_dcs[i][2];
+ res = sysmobts_select_femto_band(&bts, arfcn);
+ printf("DCS to DCS band(%d) arfcn(%u) want(%d) got(%d)\n",
+ bts.band, arfcn, dcs_to_dcs[i][1], res);
+ OSMO_ASSERT(res == dcs_to_dcs[i][1]);
+ }
+
+ /* Check for a PCS to PCS change */
+ printf("Checking PCS to PCS\n");
+ for (i = 0; i < ARRAY_SIZE(pcs_to_pcs); ++i) {
+ uint16_t arfcn;
+ int res;
+
+ btsb.auto_band = 1;
+ bts.band = pcs_to_pcs[i][0];
+ arfcn = pcs_to_pcs[i][2];
+ res = sysmobts_select_femto_band(&bts, arfcn);
+ printf("PCS to PCS band(%d) arfcn(%u) want(%d) got(%d)\n",
+ bts.band, arfcn, pcs_to_pcs[i][1], res);
+ OSMO_ASSERT(res == pcs_to_pcs[i][1]);
+ }
+}
+
+int main(int argc, char **argv)
+{
+ printf("Testing sysmobts routines\n");
+ test_sysmobts_auto_band();
+ return 0;
+}
diff --git a/tests/sysmobts/sysmobts_test.ok b/tests/sysmobts/sysmobts_test.ok
new file mode 100644
index 00000000..1f534172
--- /dev/null
+++ b/tests/sysmobts/sysmobts_test.ok
@@ -0,0 +1,19 @@
+Testing sysmobts routines
+Testing the no auto-band mapping.
+No auto-band band(1) arfcn(128) want(0) got(0)
+No auto-band band(2) arfcn(1) want(1) got(1)
+No auto-band band(4) arfcn(600) want(2) got(2)
+No auto-band band(8) arfcn(600) want(3) got(3)
+Checking the mapping with auto-band.
+Auto-band band(1) arfcn(128) want(0) got(0)
+Auto-band band(2) arfcn(1) want(1) got(1)
+Auto-band band(4) arfcn(600) want(2) got(2)
+Auto-band band(8) arfcn(600) want(3) got(3)
+Checking DCS to DCS
+DCS to DCS band(2) arfcn(600) want(2) got(2)
+DCS to DCS band(4) arfcn(1) want(1) got(1)
+DCS to DCS band(2) arfcn(438) want(-1) got(-1)
+Checking PCS to PCS
+PCS to PCS band(1) arfcn(512) want(3) got(3)
+PCS to PCS band(8) arfcn(128) want(0) got(0)
+PCS to PCS band(2) arfcn(438) want(-1) got(-1)