diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2020-10-23 18:41:40 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2020-10-24 22:14:42 +0200 |
commit | e9f77d377b1cfad300768821c90ccd17973e0a76 (patch) | |
tree | 572b054ed5e33e982b168189536f0f547e93a4c7 /tests/ms/MsTest.cpp | |
parent | 7bde60f26021b2f8cd01943e8624866120b1d703 (diff) |
tbf: Set MS during constructor time
This is another step forward towards a more clear data model where a TBF
always has a MS object (which may be lacking some information, and at a
later point when more information is found, it may actually be a
duplicated MS object and hence one duplicate removed and the TBF moved
to the object being kept).
This helps for instance in removing duplicated information stored in
the TBF which is really per MS, like ms_class, ta, etc. Since there's
always a MS object there's no need to keep a duplicate in both classes
in case there's no MS object.
It can already be seen looking at unit test logging that this kind of
data model already provides better information.
Some unit test parts were needed to adapt to the new model too.
Change-Id: I3cdf4d53e222777d5a2bf4c5aad3a7414105f14c
Diffstat (limited to 'tests/ms/MsTest.cpp')
-rw-r--r-- | tests/ms/MsTest.cpp | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/tests/ms/MsTest.cpp b/tests/ms/MsTest.cpp index b5e30fb8..05b1da4b 100644 --- a/tests/ms/MsTest.cpp +++ b/tests/ms/MsTest.cpp @@ -51,17 +51,18 @@ static void test_ms_state() uint32_t tlli = 0xffeeddbb; gprs_rlcmac_dl_tbf *dl_tbf; gprs_rlcmac_ul_tbf *ul_tbf; + BTS the_bts; GprsMs *ms; printf("=== start %s ===\n", __func__); - ms = new GprsMs(NULL, tlli); + ms = new GprsMs(&the_bts, tlli); OSMO_ASSERT(ms->is_idle()); dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf); - new (dl_tbf) gprs_rlcmac_dl_tbf(NULL); + new (dl_tbf) gprs_rlcmac_dl_tbf(&the_bts, ms); ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf); - new (ul_tbf) gprs_rlcmac_ul_tbf(NULL); + new (ul_tbf) gprs_rlcmac_ul_tbf(&the_bts, ms); ms->attach_tbf(ul_tbf); OSMO_ASSERT(!ms->is_idle()); @@ -96,6 +97,7 @@ static void test_ms_callback() uint32_t tlli = 0xffeeddbb; gprs_rlcmac_dl_tbf *dl_tbf; gprs_rlcmac_ul_tbf *ul_tbf; + BTS the_bts; GprsMs *ms; static enum {UNKNOWN, IS_IDLE, IS_ACTIVE} last_cb = UNKNOWN; @@ -114,15 +116,15 @@ static void test_ms_callback() printf("=== start %s ===\n", __func__); - ms = new GprsMs(NULL, tlli); + ms = new GprsMs(&the_bts, tlli); ms->set_callback(&cb); OSMO_ASSERT(ms->is_idle()); dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf); - new (dl_tbf) gprs_rlcmac_dl_tbf(NULL); + new (dl_tbf) gprs_rlcmac_dl_tbf(&the_bts, ms); ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf); - new (ul_tbf) gprs_rlcmac_ul_tbf(NULL); + new (ul_tbf) gprs_rlcmac_ul_tbf(&the_bts, ms); OSMO_ASSERT(last_cb == UNKNOWN); @@ -166,6 +168,7 @@ static void test_ms_replace_tbf() uint32_t tlli = 0xffeeddbb; gprs_rlcmac_dl_tbf *dl_tbf[2]; gprs_rlcmac_ul_tbf *ul_tbf; + BTS the_bts; GprsMs *ms; static bool was_idle; @@ -183,18 +186,18 @@ static void test_ms_replace_tbf() printf("=== start %s ===\n", __func__); - ms = new GprsMs(NULL, tlli); + ms = new GprsMs(&the_bts, tlli); ms->set_callback(&cb); OSMO_ASSERT(ms->is_idle()); was_idle = false; dl_tbf[0] = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf); - new (dl_tbf[0]) gprs_rlcmac_dl_tbf(NULL); + new (dl_tbf[0]) gprs_rlcmac_dl_tbf(&the_bts, ms); dl_tbf[1] = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf); - new (dl_tbf[1]) gprs_rlcmac_dl_tbf(NULL); + new (dl_tbf[1]) gprs_rlcmac_dl_tbf(&the_bts, ms); ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf); - new (ul_tbf) gprs_rlcmac_ul_tbf(NULL); + new (ul_tbf) gprs_rlcmac_ul_tbf(&the_bts, ms); ms->attach_tbf(dl_tbf[0]); OSMO_ASSERT(!ms->is_idle()); @@ -252,11 +255,12 @@ static void test_ms_change_tlli() uint32_t start_tlli = 0xaa000000; uint32_t new_ms_tlli = 0xff001111; uint32_t other_sgsn_tlli = 0xff00eeee; + BTS the_bts; GprsMs *ms; printf("=== start %s ===\n", __func__); - ms = new GprsMs(NULL, start_tlli); + ms = new GprsMs(&the_bts, start_tlli); OSMO_ASSERT(ms->is_idle()); @@ -363,14 +367,12 @@ static void test_ms_storage() const char *imsi2 = "001001987654322"; gprs_rlcmac_ul_tbf *ul_tbf; + BTS the_bts; GprsMs *ms, *ms_tmp; GprsMsStorage store(NULL); printf("=== start %s ===\n", __func__); - ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf); - new (ul_tbf) gprs_rlcmac_ul_tbf(NULL); - ms = store.get_ms(tlli + 0); OSMO_ASSERT(ms == NULL); @@ -410,6 +412,8 @@ static void test_ms_storage() /* 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(&the_bts, ms); ms->attach_tbf(ul_tbf); ms->detach_tbf(ul_tbf); ms = store.get_ms(tlli + 0); @@ -435,6 +439,7 @@ static void test_ms_timeout() uint32_t tlli = 0xffeeddbb; gprs_rlcmac_dl_tbf *dl_tbf; gprs_rlcmac_ul_tbf *ul_tbf; + BTS the_bts; GprsMs *ms; static enum {UNKNOWN, IS_IDLE, IS_ACTIVE} last_cb = UNKNOWN; @@ -453,16 +458,16 @@ static void test_ms_timeout() printf("=== start %s ===\n", __func__); - ms = new GprsMs(NULL, tlli); + ms = new GprsMs(&the_bts, tlli); ms->set_callback(&cb); ms->set_timeout(1); OSMO_ASSERT(ms->is_idle()); dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf); - new (dl_tbf) gprs_rlcmac_dl_tbf(NULL); + new (dl_tbf) gprs_rlcmac_dl_tbf(&the_bts, ms); ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf); - new (ul_tbf) gprs_rlcmac_ul_tbf(NULL); + new (ul_tbf) gprs_rlcmac_ul_tbf(&the_bts, ms); OSMO_ASSERT(last_cb == UNKNOWN); @@ -518,9 +523,9 @@ static void test_ms_cs_selection() OSMO_ASSERT(ms->is_idle()); dl_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_dl_tbf); - new (dl_tbf) gprs_rlcmac_dl_tbf(NULL); + new (dl_tbf) gprs_rlcmac_dl_tbf(&the_bts, ms); + ms->attach_tbf(dl_tbf); - dl_tbf->set_ms(ms); OSMO_ASSERT(!ms->is_idle()); OSMO_ASSERT(mcs_chan_code(ms->current_cs_dl()) == 3); @@ -565,9 +570,9 @@ static void test_ms_mcs_mode() 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(NULL); + new (dl_tbf) gprs_rlcmac_dl_tbf(&the_bts, ms2); + ms2->attach_tbf(dl_tbf); - dl_tbf->set_ms(ms2); dump_ms(ms2, "2: after TBF attach "); ms1->set_mode(EGPRS); |