aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests/gsm0408
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-05-08 23:25:31 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-05-09 00:26:01 +0200
commit6950d14c5bf301fbb3061f5a4fe67f5f57b76040 (patch)
tree1ae01412e3f15a6a7358ea5ad2a63cd6862a45f8 /openbsc/tests/gsm0408
parentcf2ca648e9f8b9ed753b4ffb588305b0a3430208 (diff)
parentcd5e52605cdb77bdc6f36fce81a6a1bac7fbda48 (diff)
Merge branch 'master' into sysmocom/iu, with tweakssysmocom/iu_orig_history
Numerous manual adjustments are included to make sense on the sysmocom/iu branch: * gsm_04_08_gprs.h has moved to libosmocore on the master branch, but sysmocom/iu has added some entries. Until it is clear whether to move the additions to libosmocore as well, keep gsm_04_08_gprs.h on sysmocom/iu with merely the additions. * Thus, keep using the old gsm_04_08_gprs.[hc] from openbsc in the Makefiles, but only where the sysmocom/iu additions are needed. * In openbsc's gsm_04_08_gprs.h, * include the libosmocore gsm_04_08_gprs.h, * use '#pragma once' instead of #ifndef and * add a TODO comment about moving the rest to libosmocore. * Apply the addition of an osmo_auth_vector to gsm_auth_tuple: in the Iu auth vector hacks, use the gsm_auth_tuple.vec instead of a local struct. See iu_hack__get_hardcoded_auth_tuple() and gsm48_rx_gmm_att_req(). * In the si2q tests, pass NULL as ctx to gsm_network_init(). * In cscn_main.c, add a debug log that was originally added to osmo-nitb. * openbsc/.gitignore: keep only one addition of 'writtenconfig' Conflicts: openbsc/include/openbsc/gprs_sgsn.h openbsc/include/openbsc/gsm_04_08_gprs.h openbsc/src/gprs/gsm_04_08_gprs.c openbsc/src/libmsc/gsm_04_08.c openbsc/src/osmo-cscn/cscn_main.c openbsc/tests/gsm0408/Makefile.am
Diffstat (limited to 'openbsc/tests/gsm0408')
-rw-r--r--openbsc/tests/gsm0408/Makefile.am3
-rw-r--r--openbsc/tests/gsm0408/gsm0408_test.c128
-rw-r--r--openbsc/tests/gsm0408/gsm0408_test.ok21
3 files changed, 134 insertions, 18 deletions
diff --git a/openbsc/tests/gsm0408/Makefile.am b/openbsc/tests/gsm0408/Makefile.am
index 619618652..d87913671 100644
--- a/openbsc/tests/gsm0408/Makefile.am
+++ b/openbsc/tests/gsm0408/Makefile.am
@@ -7,5 +7,6 @@ EXTRA_DIST = gsm0408_test.ok
gsm0408_test_SOURCES = gsm0408_test.c
gsm0408_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \
$(top_builddir)/src/libxsc/libxsc.a \
+ $(top_builddir)/src/libtrau/libtrau.a \
$(top_builddir)/src/libcommon/libcommon.a \
- $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) -ldbi
+ $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOABIS_LIBS) -ldbi
diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c
index 88da271f2..1379c42ce 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.c
+++ b/openbsc/tests/gsm0408/gsm0408_test.c
@@ -29,7 +29,11 @@
#include <openbsc/gsm_subscriber.h>
#include <openbsc/debug.h>
#include <openbsc/arfcn_range_encode.h>
+#include <openbsc/system_information.h>
+#include <openbsc/abis_rsl.h>
+
#include <osmocom/core/application.h>
+#include <osmocom/gsm/sysinfo.h>
#define COMPARE(result, op, value) \
if (!((result) op (value))) {\
@@ -79,6 +83,104 @@ static void test_location_area_identifier(void)
COMPARE(lai48.lac, ==, htons(0x000f));
}
+static inline void add_arfcn_b(struct osmo_earfcn_si2q *e, uint16_t earfcn,
+ uint8_t bw)
+{
+ int r = osmo_earfcn_add(e, earfcn, bw);
+ if (r)
+ printf("failed to add EARFCN %u: %s\n", earfcn, strerror(r));
+ else
+ printf("added EARFCN %u - ", earfcn);
+}
+
+static inline void gen(struct gsm_bts *bts)
+{
+ int r = gsm_generate_si(bts, SYSINFO_TYPE_2quater);
+ if (r > 0)
+ printf("generated SI2quater: [%d] %s\n", r,
+ osmo_hexdump(bts->si_buf[SYSINFO_TYPE_2quater], r));
+ else
+ printf("failed to generate SI2quater: %s\n", strerror(-r));
+}
+
+static inline void _bts_uarfcn_add(struct gsm_bts *bts, uint16_t arfcn,
+ uint16_t scramble, bool diversity)
+{
+ int r = bts_uarfcn_add(bts, arfcn, scramble, diversity);
+ if (r < 0)
+ printf("failed to add UARFCN to SI2quater: %s\n", strerror(-r));
+ else
+ gen(bts);
+}
+
+static inline void test_si2q_u(void)
+{
+ struct gsm_bts *bts;
+ struct gsm_network *network = gsm_network_init(NULL, 1, 1, NULL);
+ printf("Testing SYSINFO_TYPE_2quater UARFCN generation:\n");
+
+ if (!network)
+ exit(1);
+ bts = gsm_bts_alloc(network);
+
+ _bts_uarfcn_add(bts, 1982, 13, 1);
+ _bts_uarfcn_add(bts, 1982, 44, 0);
+ _bts_uarfcn_add(bts, 1982, 61, 1);
+ _bts_uarfcn_add(bts, 1982, 89, 1);
+ _bts_uarfcn_add(bts, 1982, 113, 0);
+ _bts_uarfcn_add(bts, 1982, 123, 0);
+ _bts_uarfcn_add(bts, 1982, 56, 1);
+ _bts_uarfcn_add(bts, 1982, 72, 1);
+ _bts_uarfcn_add(bts, 1982, 223, 1);
+ _bts_uarfcn_add(bts, 1982, 14, 0);
+ _bts_uarfcn_add(bts, 1982, 88, 0);
+ gen(bts);
+}
+
+static inline void test_si2q_e(void)
+{
+ struct gsm_bts *bts;
+ struct gsm_network *network = gsm_network_init(NULL, 1, 1, NULL);
+ printf("Testing SYSINFO_TYPE_2quater EARFCN generation:\n");
+
+ if (!network)
+ exit(1);
+ bts = gsm_bts_alloc(network);
+
+ bts->si_common.si2quater_neigh_list.arfcn =
+ bts->si_common.data.earfcn_list;
+ bts->si_common.si2quater_neigh_list.meas_bw =
+ bts->si_common.data.meas_bw_list;
+ bts->si_common.si2quater_neigh_list.length = MAX_EARFCN_LIST;
+ bts->si_common.si2quater_neigh_list.thresh_hi = 5;
+
+ osmo_earfcn_init(&bts->si_common.si2quater_neigh_list);
+
+ add_arfcn_b(&bts->si_common.si2quater_neigh_list, 1917, 1);
+ gen(bts);
+
+ add_arfcn_b(&bts->si_common.si2quater_neigh_list, 1932,
+ OSMO_EARFCN_MEAS_INVALID);
+ gen(bts);
+
+ add_arfcn_b(&bts->si_common.si2quater_neigh_list, 1937, 2);
+ gen(bts);
+
+ add_arfcn_b(&bts->si_common.si2quater_neigh_list, 1945,
+ OSMO_EARFCN_MEAS_INVALID);
+ gen(bts);
+
+ add_arfcn_b(&bts->si_common.si2quater_neigh_list, 1965,
+ OSMO_EARFCN_MEAS_INVALID);
+ gen(bts);
+
+ add_arfcn_b(&bts->si_common.si2quater_neigh_list, 1967, 4);
+ gen(bts);
+
+ add_arfcn_b(&bts->si_common.si2quater_neigh_list, 1982, 3);
+ gen(bts);
+}
+
static void test_mi_functionality(void)
{
const char *imsi_odd = "987654321098763";
@@ -162,11 +264,7 @@ static int test_single_range_encoding(int range, const int *orig_arfcns,
f0, &f0_included);
memset(w, 0, sizeof(w));
- rc = range_enc_arfcns(range, arfcns, arfcns_used, w, 0);
- if (rc != 0) {
- printf("Cannot compute range W(k), rc = %d\n", rc);
- return 1;
- }
+ range_enc_arfcns(range, arfcns, arfcns_used, w, 0);
if (!silent)
fprintf(stderr, "range=%d, arfcns_used=%d, f0=%d, f0_included=%d\n",
@@ -175,24 +273,20 @@ static int test_single_range_encoding(int range, const int *orig_arfcns,
/* Select the range and the amount of bits needed */
switch (range) {
case ARFCN_RANGE_128:
- rc = range_enc_range128(chan_list, f0, w);
+ range_enc_range128(chan_list, f0, w);
break;
case ARFCN_RANGE_256:
- rc = range_enc_range256(chan_list, f0, w);
+ range_enc_range256(chan_list, f0, w);
break;
case ARFCN_RANGE_512:
- rc = range_enc_range512(chan_list, f0, w);
+ range_enc_range512(chan_list, f0, w);
break;
case ARFCN_RANGE_1024:
- rc = range_enc_range1024(chan_list, f0, f0_included, w);
+ range_enc_range1024(chan_list, f0, f0_included, w);
break;
default:
return 1;
};
- if (rc != 0) {
- printf("Cannot encode range, rc = %d\n", rc);
- return 1;
- }
if (!silent)
printf("chan_list = %s\n",
@@ -403,8 +497,7 @@ static void test_print_encoding()
break;
}
- rc = range_enc_range512(chan_list, (1 << 9) | 0x96, w);
- VERIFY(rc, ==, 0);
+ range_enc_range512(chan_list, (1 << 9) | 0x96, w);
printf("Range512: %s\n", osmo_hexdump(chan_list, ARRAY_SIZE(chan_list)));
}
@@ -428,8 +521,7 @@ static void test_si_range_helpers()
printf("Element is: %d => freqs[i] = %d\n", i, i >= 0 ? freqs3[i] : -1);
VERIFY(i, ==, 0);
- i = range_enc_arfcns(1023, freqs1, ARRAY_SIZE(freqs1), ws, 0);
- VERIFY(i, ==, 0);
+ range_enc_arfcns(1023, freqs1, ARRAY_SIZE(freqs1), ws, 0);
for (i = 0; i < sizeof(freqs1)/sizeof(freqs1[0]); ++i) {
printf("w[%d]=%d\n", i, ws[i]);
@@ -486,6 +578,8 @@ int main(int argc, char **argv)
test_range_encoding();
test_gsm411_rp_ref_wrap();
+ test_si2q_e();
+ test_si2q_u();
printf("Done.\n");
return EXIT_SUCCESS;
}
diff --git a/openbsc/tests/gsm0408/gsm0408_test.ok b/openbsc/tests/gsm0408/gsm0408_test.ok
index 058563aab..7b7a2cc76 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.ok
+++ b/openbsc/tests/gsm0408/gsm0408_test.ok
@@ -62,4 +62,25 @@ testing RP-Reference wrap
Allocated reference: 255
Allocated reference: 0
Allocated reference: 1
+Testing SYSINFO_TYPE_2quater EARFCN generation:
+added EARFCN 1917 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be c8 50 0b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
+added EARFCN 1932 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 30 14 03 2b 2b 2b 2b 2b 2b 2b 2b
+added EARFCN 1937 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 31 07 91 a0 a0 2b 2b 2b 2b 2b 2b
+added EARFCN 1945 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 31 07 91 a8 3c c8 28 0b 2b 2b 2b
+added EARFCN 1965 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1e 31 07 91 a8 3c ca 0f 5a 0a 03 2b
+added EARFCN 1967 - failed to generate SI2quater: Cannot allocate memory
+added EARFCN 1982 - failed to generate SI2quater: Cannot allocate memory
+Testing SYSINFO_TYPE_2quater UARFCN generation:
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 0c 1a 10 99 64 00 0b 2b 2b 2b 2b 2b 2b 2b 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 14 1a 1f 00 44 b2 00 03 2b 2b 2b 2b 2b 2b 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 18 58 12 f0 84 86 59 00 03 2b 2b 2b 2b 2b 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 20 58 2e f0 f2 04 86 59 00 03 2b 2b 2b 2b 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 28 58 2e 22 f2 4e 84 86 59 00 03 2b 2b 2b 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 34 1a 64 26 5d f2 05 04 86 59 00 03 2b 2b 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 38 58 12 22 fd ce 8e 05 04 86 59 00 03 2b 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 40 58 1d 22 fa ce 88 85 7b 00 44 b2 00 03 2b
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 4c 7a 34 0e 64 77 85 43 55 c8 10 99 64 00 0b
+failed to add UARFCN to SI2quater: No space left on device
+failed to add UARFCN to SI2quater: No space left on device
+generated SI2quater: [23] 59 06 07 c0 00 25 0f 7c 4c 7a 34 0e 64 77 85 43 55 c8 10 99 64 00 0b
Done.