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/.
pespin gerrit-no-reply at lists.osmocom.orgpespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/24234 ) Change subject: MsTest: Set up tbf talloc destructor ...................................................................... MsTest: Set up tbf talloc destructor This is right now not an issue, but it will be whenever talloc destructor contains extra steps like freeing an FSM. Change-Id: I096ff56321c8ae5e66634537aae8b95804282c65 --- M tests/ms/MsTest.cpp 1 file changed, 42 insertions(+), 24 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/34/24234/1 diff --git a/tests/ms/MsTest.cpp b/tests/ms/MsTest.cpp index 498c835..2ff2fc2 100644 --- a/tests/ms/MsTest.cpp +++ b/tests/ms/MsTest.cpp @@ -46,6 +46,36 @@ int16_t spoof_mnc = 0, spoof_mcc = 0; bool spoof_mnc_3_digits = false; +static int ul_tbf_dtor(struct gprs_rlcmac_ul_tbf *tbf) +{ + tbf->~gprs_rlcmac_ul_tbf(); + return 0; +} + +static int dl_tbf_dtor(struct gprs_rlcmac_dl_tbf *tbf) +{ + tbf->~gprs_rlcmac_dl_tbf(); + return 0; +} + +static gprs_rlcmac_ul_tbf *alloc_ul_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms) +{ + gprs_rlcmac_ul_tbf *ul_tbf; + ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf); + talloc_set_destructor(ul_tbf, ul_tbf_dtor); + new (ul_tbf) gprs_rlcmac_ul_tbf(bts, ms); + return ul_tbf; +} + +static gprs_rlcmac_dl_tbf *alloc_dl_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms) +{ + gprs_rlcmac_dl_tbf *dl_tbf; + dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf); + talloc_set_destructor(dl_tbf, dl_tbf_dtor); + new (dl_tbf) gprs_rlcmac_dl_tbf(bts, ms); + return dl_tbf; +} + static void test_ms_state() { uint32_t tlli = 0xffeeddbb; @@ -59,10 +89,8 @@ ms = ms_alloc(bts, tlli); OSMO_ASSERT(ms_is_idle(ms)); - dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf); - new (dl_tbf) gprs_rlcmac_dl_tbf(bts, ms); - ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf); - new (ul_tbf) gprs_rlcmac_ul_tbf(bts, ms); + dl_tbf = alloc_dl_tbf(bts, ms); + ul_tbf = alloc_ul_tbf(bts, ms); ms_attach_tbf(ms, ul_tbf); OSMO_ASSERT(!ms_is_idle(ms)); @@ -125,10 +153,8 @@ OSMO_ASSERT(ms_is_idle(ms)); - dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf); - new (dl_tbf) gprs_rlcmac_dl_tbf(bts, ms); - ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf); - new (ul_tbf) gprs_rlcmac_ul_tbf(bts, ms); + dl_tbf = alloc_dl_tbf(bts, ms); + ul_tbf = alloc_ul_tbf(bts, ms); OSMO_ASSERT(last_cb == CB_UNKNOWN); @@ -199,12 +225,9 @@ OSMO_ASSERT(ms_is_idle(ms)); was_idle = false; - dl_tbf[0] = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf); - new (dl_tbf[0]) gprs_rlcmac_dl_tbf(bts, ms); - dl_tbf[1] = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf); - new (dl_tbf[1]) gprs_rlcmac_dl_tbf(bts, ms); - ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf); - new (ul_tbf) gprs_rlcmac_ul_tbf(bts, ms); + dl_tbf[0] = alloc_dl_tbf(bts, ms); + dl_tbf[1] = alloc_dl_tbf(bts, ms); + ul_tbf = alloc_ul_tbf(bts, ms); ms_attach_tbf(ms, dl_tbf[0]); OSMO_ASSERT(!ms_is_idle(ms)); @@ -419,8 +442,7 @@ /* delete ms */ ms = store.get_ms(tlli + 0); OSMO_ASSERT(ms != NULL); - ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf); - new (ul_tbf) gprs_rlcmac_ul_tbf(bts, ms); + ul_tbf = alloc_ul_tbf(bts, ms); ms_attach_tbf(ms, ul_tbf); ms_detach_tbf(ms, ul_tbf); ms = store.get_ms(tlli + 0); @@ -458,10 +480,8 @@ OSMO_ASSERT(ms_is_idle(ms)); - dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf); - new (dl_tbf) gprs_rlcmac_dl_tbf(bts, ms); - ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf); - new (ul_tbf) gprs_rlcmac_ul_tbf(bts, ms); + dl_tbf = alloc_dl_tbf(bts, ms); + ul_tbf = alloc_ul_tbf(bts, ms); OSMO_ASSERT(last_cb == CB_UNKNOWN); @@ -516,8 +536,7 @@ OSMO_ASSERT(ms_is_idle(ms)); - dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf); - new (dl_tbf) gprs_rlcmac_dl_tbf(bts, ms); + dl_tbf = alloc_dl_tbf(bts, ms); ms_attach_tbf(ms, dl_tbf); OSMO_ASSERT(!ms_is_idle(ms)); @@ -562,8 +581,7 @@ ms2 = ms_alloc(bts, tlli + 1); dump_ms(ms2, "2: with BTS defaults"); - dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf); - new (dl_tbf) gprs_rlcmac_dl_tbf(bts, ms2); + dl_tbf = alloc_dl_tbf(bts, ms2); ms_attach_tbf(ms2, dl_tbf); dump_ms(ms2, "2: after TBF attach "); -- To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/24234 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Change-Id: I096ff56321c8ae5e66634537aae8b95804282c65 Gerrit-Change-Number: 24234 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210514/9c0820a6/attachment.htm>