This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged. Change subject: Fix tests after rate_ctr change ...................................................................... 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 --- M tests/gsm0408/gsm0408_test.c M tests/gsm0408/gsm0408_test.ok 2 files changed, 62 insertions(+), 48 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c index 72a1772..d2085a9 100644 --- a/tests/gsm0408/gsm0408_test.c +++ b/tests/gsm0408/gsm0408_test.c @@ -144,30 +144,37 @@ } } -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); @@ -176,18 +183,15 @@ _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,18 +208,15 @@ _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; @@ -237,18 +238,15 @@ 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; @@ -285,6 +283,9 @@ _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 @@ 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 @@ int rc; - bts->network = network; bts->c0->arfcn = 23; printf("Testing if BA-IND is set as expected in SI2xxx and SI5xxx\n"); @@ -710,8 +710,16 @@ 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 @@ 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"); diff --git a/tests/gsm0408/gsm0408_test.ok b/tests/gsm0408/gsm0408_test.ok index 536287c..b85141a 100644 --- a/tests/gsm0408/gsm0408_test.ok +++ b/tests/gsm0408/gsm0408_test.ok @@ -58,6 +58,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 [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 -- To view, visit https://gerrit.osmocom.org/5486 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie1537a1ee9ee812eaaf9f58dc4bc86d4add8c31f Gerrit-PatchSet: 1 Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Owner: Max <msuraev at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>