aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests
diff options
context:
space:
mode:
Diffstat (limited to 'openbsc/tests')
-rw-r--r--openbsc/tests/channel/channel_test.c35
-rw-r--r--openbsc/tests/gsm0408/gsm0408_test.c99
-rw-r--r--openbsc/tests/gsm0408/gsm0408_test.ok6
3 files changed, 73 insertions, 67 deletions
diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c
index cf19aab4d..049786be7 100644
--- a/openbsc/tests/channel/channel_test.c
+++ b/openbsc/tests/channel/channel_test.c
@@ -59,28 +59,23 @@ int paging_request(struct gsm_bts *bts, struct bsc_subscr *bsub, int type, gsm_c
}
-void test_request_chan(void)
+void test_request_chan(struct gsm_network *net)
{
- struct gsm_network *network;
struct gsm_bts *bts;
printf("Testing the gsm_subscriber chan logic\n");
- /* Create a dummy network */
- network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
- if (!network)
- exit(1);
- bts = gsm_bts_alloc(network, 0);
+ bts = gsm_bts_alloc(net, 0);
bts->location_area_code = 23;
- s_conn.network = network;
+ s_conn.network = net;
/* Create a dummy subscriber */
struct gsm_subscriber *subscr = subscr_alloc();
subscr->lac = 23;
- subscr->group = network->subscr_group;
+ subscr->group = net->subscr_group;
OSMO_ASSERT(subscr->group);
- OSMO_ASSERT(subscr->group->net == network);
+ OSMO_ASSERT(subscr->group->net == net);
/* Ask for a channel... */
struct subscr_request *sr;
@@ -93,20 +88,15 @@ void test_request_chan(void)
}
-void test_bts_debug_print(void)
+void test_bts_debug_print(struct gsm_network *net)
{
- struct gsm_network *network;
struct gsm_bts *bts;
struct gsm_bts_trx *trx;
printf("Testing the lchan printing:");
- /* Create a dummy network */
- network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
- if (!network)
- exit(1);
/* Add a BTS with some reasonanbly non-zero id */
- bts = gsm_bts_alloc(network, 45);
+ bts = gsm_bts_alloc(net, 45);
/* Add a second TRX to test on multiple TRXs */
gsm_bts_trx_alloc(bts);
@@ -154,11 +144,18 @@ void test_dyn_ts_subslots(void)
int main(int argc, char **argv)
{
+ struct gsm_network *network;
+
osmo_init_logging(&log_info);
- test_request_chan();
+ /* Create a dummy network */
+ network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
+ if (!network)
+ return EXIT_FAILURE;
+
+ test_request_chan(network);
test_dyn_ts_subslots();
- test_bts_debug_print();
+ test_bts_debug_print(network);
return EXIT_SUCCESS;
}
diff --git a/openbsc/tests/gsm0408/gsm0408_test.c b/openbsc/tests/gsm0408/gsm0408_test.c
index 3882f05ad..6f48599a3 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.c
+++ b/openbsc/tests/gsm0408/gsm0408_test.c
@@ -145,31 +145,37 @@ static inline void _bts_uarfcn_add(struct gsm_bts *bts, uint16_t arfcn, uint16_t
}
}
-static inline void test_si2q_segfault(void)
+static inline struct gsm_bts *bts_init(void *ctx, struct gsm_network *net, const char *msg)
{
- struct gsm_bts *bts;
- struct gsm_network *network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
- printf("Test SI2quater UARFCN (same scrambling code and diversity):\n");
-
- if (!network)
+ struct gsm_bts *bts = gsm_bts_alloc(net, 0);
+ if (!bts) {
+ printf("BTS allocation failure in %s()\n", msg);
exit(1);
- bts = gsm_bts_alloc(network, 0);
+ }
+ printf("BTS allocation OK in %s()\n", msg);
+
+ bts->network = net;
+
+ return bts;
+}
+
+static inline void test_si2q_segfault(struct gsm_network *net)
+{
+ struct gsm_bts *bts = bts_init(tall_bsc_ctx, net, __func__);
+ printf("Test SI2quater UARFCN (same scrambling code and diversity):\n");
_bts_uarfcn_add(bts, 10564, 319, 0);
_bts_uarfcn_add(bts, 10612, 319, 0);
gen(bts, __func__);
+
+ talloc_free(bts);
}
-static inline void test_si2q_mu(void)
+static inline void test_si2q_mu(struct gsm_network *net)
{
- struct gsm_bts *bts;
- struct gsm_network *network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
+ struct gsm_bts *bts = bts_init(tall_bsc_ctx, net, __func__);
printf("Test SI2quater multiple UARFCNs:\n");
- if (!network)
- exit(1);
- bts = gsm_bts_alloc(network, 0);
-
_bts_uarfcn_add(bts, 10564, 318, 0);
_bts_uarfcn_add(bts, 10612, 319, 0);
_bts_uarfcn_add(bts, 10612, 31, 0);
@@ -177,19 +183,15 @@ static inline void test_si2q_mu(void)
_bts_uarfcn_add(bts, 10613, 64, 0);
_bts_uarfcn_add(bts, 10613, 164, 0);
_bts_uarfcn_add(bts, 10613, 14, 0);
+
+ talloc_free(bts);
}
-static inline void test_si2q_u(void)
+static inline void test_si2q_u(struct gsm_network *net)
{
- struct gsm_bts *bts;
- struct gsm_network *network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
+ struct gsm_bts *bts = bts_init(tall_bsc_ctx, net, __func__);
printf("Testing SYSINFO_TYPE_2quater UARFCN generation:\n");
- if (!network)
- exit(1);
-
- bts = gsm_bts_alloc(network, 0);
-
/* first generate invalid SI as no UARFCN added */
gen(bts, __func__);
@@ -205,19 +207,15 @@ static inline void test_si2q_u(void)
_bts_uarfcn_add(bts, 1982, 223, 1);
_bts_uarfcn_add(bts, 1982, 14, 0);
_bts_uarfcn_add(bts, 1982, 88, 0);
+
+ talloc_free(bts);
}
-static inline void test_si2q_e(void)
+static inline void test_si2q_e(struct gsm_network *net)
{
- struct gsm_bts *bts;
- struct gsm_network *network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
+ struct gsm_bts *bts = bts_init(tall_bsc_ctx, net, __func__);
printf("Testing SYSINFO_TYPE_2quater EARFCN generation:\n");
- if (!network)
- exit(1);
-
- bts = gsm_bts_alloc(network, 0);
-
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;
@@ -238,19 +236,15 @@ static inline void test_si2q_e(void)
add_earfcn_b(bts, 1965, OSMO_EARFCN_MEAS_INVALID);
add_earfcn_b(bts, 1967, 4);
add_earfcn_b(bts, 1982, 3);
+
+ talloc_free(bts);
}
-static inline void test_si2q_long(void)
+static inline void test_si2q_long(struct gsm_network *net)
{
- struct gsm_bts *bts;
- struct gsm_network *network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
+ struct gsm_bts *bts = bts_init(tall_bsc_ctx, net, __func__);
printf("Testing SYSINFO_TYPE_2quater combined EARFCN & UARFCN generation:\n");
- if (!network)
- exit(1);
-
- bts = gsm_bts_alloc(network, 0);
-
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;
@@ -286,6 +280,8 @@ static inline void test_si2q_long(void)
_bts_uarfcn_add(bts, 1976, 224, 1);
_bts_uarfcn_add(bts, 1976, 225, 1);
_bts_uarfcn_add(bts, 1976, 226, 1);
+
+ talloc_free(bts);
}
static void test_mi_functionality(void)
@@ -671,10 +667,10 @@ static void test_gsm411_rp_ref_wrap(void)
OSMO_ASSERT(res == 1);
}
-static void test_si_ba_ind(void)
+static void test_si_ba_ind(struct gsm_network *net)
{
- struct gsm_network *network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
- struct gsm_bts *bts = gsm_bts_alloc(network, 0);
+ struct gsm_bts *bts = bts_init(tall_bsc_ctx, net, __func__);
+
const struct gsm48_system_information_type_2 *si2 =
(struct gsm48_system_information_type_2 *) GSM_BTS_SI(bts, SYSINFO_TYPE_2);
const struct gsm48_system_information_type_2bis *si2bis =
@@ -690,7 +686,6 @@ static void test_si_ba_ind(void)
int rc;
- bts->network = network;
bts->c0->arfcn = 23;
printf("Testing if BA-IND is set as expected in SI2xxx and SI5xxx\n");
@@ -734,9 +729,17 @@ static void test_si_ba_ind(void)
int main(int argc, char **argv)
{
+ struct gsm_network *net;
+
osmo_init_logging(&log_info);
log_set_log_level(osmo_stderr_target, LOGL_INFO);
+ net = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
+ if (!net) {
+ printf("Network init failure.\n");
+ return EXIT_FAILURE;
+ }
+
test_location_area_identifier();
test_mi_functionality();
@@ -746,13 +749,13 @@ int main(int argc, char **argv)
test_range_encoding();
test_gsm411_rp_ref_wrap();
- test_si2q_segfault();
- test_si2q_e();
- test_si2q_u();
- test_si2q_mu();
- test_si2q_long();
+ test_si2q_segfault(net);
+ test_si2q_e(net);
+ test_si2q_u(net);
+ test_si2q_mu(net);
+ test_si2q_long(net);
- test_si_ba_ind();
+ test_si_ba_ind(net);
printf("Done.\n");
diff --git a/openbsc/tests/gsm0408/gsm0408_test.ok b/openbsc/tests/gsm0408/gsm0408_test.ok
index 4fff78f93..1039883c1 100644
--- a/openbsc/tests/gsm0408/gsm0408_test.ok
+++ b/openbsc/tests/gsm0408/gsm0408_test.ok
@@ -62,6 +62,7 @@ testing RP-Reference wrap
Allocated reference: 255
Allocated reference: 0
Allocated reference: 1
+BTS allocation OK in test_si2q_segfault()
Test SI2quater UARFCN (same scrambling code and diversity):
generating SI2quater for 0 EARFCNs and 1 UARFCNs...
generated valid SI2quater [00/00]: [23] 59 06 07 40 00 25 52 88 0a 7e 0b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
@@ -69,6 +70,7 @@ generating SI2quater for 0 EARFCNs and 2 UARFCNs...
generated valid SI2quater [00/00]: [23] 59 06 07 40 00 25 52 e8 0a 7f 52 88 0a 7e 0b 2b 2b 2b 2b 2b 2b 2b 2b
generating SI2quater for 0 EARFCNs and 2 UARFCNs...
generated valid SI2quater [00/00]: [23] 59 06 07 40 00 25 52 e8 0a 7f 52 88 0a 7e 0b 2b 2b 2b 2b 2b 2b 2b 2b
+BTS allocation OK in test_si2q_e()
Testing SYSINFO_TYPE_2quater EARFCN generation:
generating SI2quater for 0 EARFCNs and 0 UARFCNs...
generated invalid SI2quater [00/00]: [23] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
@@ -92,6 +94,7 @@ generated valid SI2quater [01/01]: [23] 59 06 07 42 20 04 86 59 83 d7 e0 50 0b 2
added EARFCN 1982 - generating SI2quater for 7 EARFCNs and 0 UARFCNs...
generated valid SI2quater [00/01]: [23] 59 06 07 40 20 04 86 59 83 be cc 1e 31 07 91 a8 3c ca 0f 5a 0a 03 2b
generated valid SI2quater [01/01]: [23] 59 06 07 42 20 04 86 59 83 d7 e4 1e fa c2 80 2b 2b 2b 2b 2b 2b 2b 2b
+BTS allocation OK in test_si2q_u()
Testing SYSINFO_TYPE_2quater UARFCN generation:
generating SI2quater for 0 EARFCNs and 0 UARFCNs...
generated invalid SI2quater [00/00]: [23] 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
@@ -117,6 +120,7 @@ generating SI2quater for 0 EARFCNs and 10 UARFCNs...
generated valid SI2quater [00/00]: [23] 59 06 07 40 00 25 0f 7c 50 1c 3b 31 fa dd 88 85 7b c4 1c 2b 2b 2b 2b
generating SI2quater for 0 EARFCNs and 11 UARFCNs...
generated valid SI2quater [00/00]: [23] 59 06 07 40 00 25 0f 7c 58 1c 3b 25 7a ea 08 91 fb c4 1f b0 2b 2b 2b
+BTS allocation OK in test_si2q_mu()
Test SI2quater multiple UARFCNs:
generating SI2quater for 0 EARFCNs and 1 UARFCNs...
generated valid SI2quater [00/00]: [23] 59 06 07 40 00 25 52 88 0a 7c 0b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b
@@ -134,6 +138,7 @@ generated valid SI2quater [01/01]: [23] 59 06 07 42 20 25 52 e8 28 81 df 7f fa 3
generating SI2quater for 0 EARFCNs and 7 UARFCNs...
generated valid SI2quater [00/01]: [23] 59 06 07 40 20 25 52 ea 10 81 ce a9 74 08 1f fa 54 ba 82 52 03 2b 2b
generated valid SI2quater [01/01]: [23] 59 06 07 42 20 25 52 e8 30 81 d3 7f fd b2 86 54 a2 02 9f 03 2b 2b 2b
+BTS allocation OK in test_si2q_long()
Testing SYSINFO_TYPE_2quater combined EARFCN & UARFCN generation:
generating SI2quater for 17 EARFCNs and 1 UARFCNs...
generated valid SI2quater [00/04]: [23] 59 06 07 40 80 25 0f 70 0c 1a 10 99 66 0f 04 83 c1 1c bb 2b 03 2b 2b
@@ -201,6 +206,7 @@ generated valid SI2quater [02/05]: [23] 59 06 07 44 a0 04 86 59 83 c2 ec 20 ff 6
generated valid SI2quater [03/05]: [23] 59 06 07 46 a0 04 86 59 84 21 54 21 4f 61 0a 99 08 55 b7 2e ca c1 2b
generated valid SI2quater [04/05]: [23] 59 06 07 48 a0 04 86 59 84 2b 54 21 27 61 09 59 08 4b b7 2e ca c1 2b
generated valid SI2quater [05/05]: [23] 59 06 07 4a a0 04 86 59 84 26 53 97 65 60 2b 2b 2b 2b 2b 2b 2b 2b 2b
+BTS allocation OK in test_si_ba_ind()
Testing if BA-IND is set as expected in SI2xxx and SI5xxx
SI2: 59 06 1a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SI2bis: 59 06 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00