aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-04-20 15:57:13 +0200
committerHarald Welte <laforge@gnumonks.org>2016-04-22 14:55:33 +0200
commit26679e0475593aca645c7029e1aad899da73217a (patch)
treeb42d881edde2eccfbb350c26def3fd59d9de99db /openbsc/tests
parent27c3e76aa7e0912d3404b96a4a043e7208044d0f (diff)
Add basic UARFCN support
* add data structures, generation functions * vty interface for neightbor UARFCNs specific to SI2quater * vty test * unit test Fixes: OS#1666
Diffstat (limited to 'openbsc/tests')
-rw-r--r--openbsc/tests/gsm0408/gsm0408_test.c75
-rw-r--r--openbsc/tests/gsm0408/gsm0408_test.ok14
-rw-r--r--openbsc/tests/vty_test_runner.py23
3 files changed, 91 insertions, 21 deletions
diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c
index d6abce61c..2d91b68f0 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.c
+++ b/openbsc/tests/gsm0408/gsm0408_test.c
@@ -103,11 +103,55 @@ static inline void gen(struct gsm_bts *bts)
printf("failed to generate SI2quater: %s\n", strerror(-r));
}
-static inline void test_si2q(void)
+static inline void test_si2q_u(void)
{
struct gsm_bts *bts;
struct gsm_network *network = gsm_network_init(1, 1, NULL);
- printf("Testing SYSINFO_TYPE_2quater generation:\n");
+ printf("Testing SYSINFO_TYPE_2quater UARFCN generation:\n");
+
+ if (!network)
+ exit(1);
+ bts = gsm_bts_alloc(network);
+
+ bts_uarfcn_add(bts, 1982, 13, 1);
+ gen(bts);
+
+ bts_uarfcn_add(bts, 1982, 44, 0);
+ gen(bts);
+
+ bts_uarfcn_add(bts, 1982, 61, 1);
+ gen(bts);
+
+ bts_uarfcn_add(bts, 1982, 89, 1);
+ gen(bts);
+
+ bts_uarfcn_add(bts, 1982, 113, 0);
+ gen(bts);
+
+ bts_uarfcn_add(bts, 1982, 123, 0);
+ gen(bts);
+
+ bts_uarfcn_add(bts, 1982, 56, 1);
+ gen(bts);
+
+ bts_uarfcn_add(bts, 1982, 72, 1);
+ gen(bts);
+
+ bts_uarfcn_add(bts, 1982, 223, 1);
+ gen(bts);
+
+ bts_uarfcn_add(bts, 1982, 14, 0);
+ gen(bts);
+
+ 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(1, 1, NULL);
+ printf("Testing SYSINFO_TYPE_2quater EARFCN generation:\n");
if (!network)
exit(1);
@@ -230,11 +274,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",
@@ -243,24 +283,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",
@@ -471,8 +507,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)));
}
@@ -496,8 +531,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]);
@@ -554,7 +588,8 @@ int main(int argc, char **argv)
test_range_encoding();
test_gsm411_rp_ref_wrap();
- test_si2q();
+ 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 59319bfeb..565eac672 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.ok
+++ b/openbsc/tests/gsm0408/gsm0408_test.ok
@@ -62,7 +62,7 @@ testing RP-Reference wrap
Allocated reference: 255
Allocated reference: 0
Allocated reference: 1
-Testing SYSINFO_TYPE_2quater generation:
+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
@@ -70,4 +70,16 @@ added EARFCN 1945 - generated SI2quater: [23] 59 06 07 c0 00 04 86 59 83 be cc 1
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 generate SI2quater: Cannot allocate memory
+failed to generate SI2quater: Cannot allocate memory
Done.
diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index 7f64a80d3..c0888559e 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -244,6 +244,29 @@ class TestVTYNITB(TestVTYGenericBSC):
self.vty.command("si2quater neighbor-list del earfcn 1924")
self.vty.command("si2quater neighbor-list del earfcn 2111")
self.assertEquals(before, self.vty.command("show running-config"))
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 13 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 38 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 44 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 120 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 140 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 163 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 166 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 217 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 224 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 225 1")
+ self.vty.command("si2quater neighbor-list add uarfcn 1976 226 1")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 13")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 38")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 44")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 120")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 140")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 163")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 166")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 217")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 224")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 225")
+ self.vty.command("si2quater neighbor-list del uarfcn 1976 226")
+ self.assertEquals(before, self.vty.command("show running-config"))
def testEnableDisablePeriodicLU(self):
self.vty.enable()