Fix tests after rate_ctr change
Recent change lin libosmocore disallow registering rate_ctr with the same name and indexing multiple times. To accommodate to this: * allocate network struct once and use it for all tests * deregister rate_ctr group after each test * free bts struct after each test Related: OS#2757 Change-Id: Ie1537a1ee9ee812eaaf9f58dc4bc86d4add8c31f
This commit is contained in:
parent
7abe7ae2d0
commit
4ab7268a90
|
@ -144,31 +144,38 @@ 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__);
|
||||
|
||||
rate_ctr_group_free(bts->bts_ctrs);
|
||||
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);
|
||||
|
@ -176,19 +183,16 @@ 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);
|
||||
|
||||
rate_ctr_group_free(bts->bts_ctrs);
|
||||
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(NULL, 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__);
|
||||
|
||||
|
@ -204,19 +208,16 @@ 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);
|
||||
|
||||
rate_ctr_group_free(bts->bts_ctrs);
|
||||
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(NULL, 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;
|
||||
|
@ -237,19 +238,16 @@ 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);
|
||||
|
||||
rate_ctr_group_free(bts->bts_ctrs);
|
||||
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;
|
||||
|
@ -285,6 +283,9 @@ 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);
|
||||
|
||||
rate_ctr_group_free(bts->bts_ctrs);
|
||||
talloc_free(bts);
|
||||
}
|
||||
|
||||
static void test_mi_functionality(void)
|
||||
|
@ -647,10 +648,10 @@ static void test_si_range_helpers()
|
|||
VERIFY(f0, ==, 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 =
|
||||
|
@ -666,7 +667,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");
|
||||
|
@ -710,9 +710,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();
|
||||
|
||||
|
@ -721,13 +729,13 @@ int main(int argc, char **argv)
|
|||
test_print_encoding();
|
||||
test_range_encoding();
|
||||
|
||||
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");
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ Random range test: range 127, max num ARFCNs 29
|
|||
Random range test: range 255, max num ARFCNs 22
|
||||
Random range test: range 511, max num ARFCNs 18
|
||||
Random range test: range 1023, max num ARFCNs 16
|
||||
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
|
||||
|
@ -65,6 +66,7 @@ generating SI2quater for 0 EARFCNs and 2 UARFCNs...
|
|||
generated valid SI2quater [00/00]: [23] 59 06 07 40 00 25 52 88 0a 7f 52 e8 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 88 0a 7f 52 e8 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
|
||||
|
@ -88,6 +90,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
|
||||
|
@ -113,6 +116,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
|
||||
|
@ -128,6 +132,7 @@ generating SI2quater for 0 EARFCNs and 6 UARFCNs...
|
|||
generated valid SI2quater [00/00]: [23] 59 06 07 40 00 25 52 88 0a 7d 52 e8 18 3f f4 90 54 ba 84 52 67 03 2b
|
||||
generating SI2quater for 0 EARFCNs and 7 UARFCNs...
|
||||
generated valid SI2quater [00/00]: [23] 59 06 07 40 00 25 52 88 0a 7d 52 e8 18 3f f4 90 54 ba 86 20 73 8c 81
|
||||
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 2b
|
||||
|
|
Loading…
Reference in New Issue