aboutsummaryrefslogtreecommitdiffstats
path: root/tests/emu
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2021-01-13 18:54:38 +0100
committerpespin <pespin@sysmocom.de>2021-01-18 10:37:05 +0000
commitac3fd120268a38fb4794982823c6abc8e964cfe8 (patch)
treebc88fdd84f73ace721b35db63efac5935848a952 /tests/emu
parent695ce771676732045ac89ac03b43ba071befeafb (diff)
Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold both PCU global fields and BTS specific fields, all mangled together. The BTS is even accessed in lots of places by means of a singleton. This patch introduces a new struct gprs_pcu object aimed at holding all global state, and several fields are already moved from BTS to it. The new object can be accessed as global variable "the_pcu", reusing and including an already exisitng "the_pcu" global variable only used for bssgp related purposes so far. This is only a first step towards having a complete split global pcu and BTS, some fields are still kept in BTS and will be moved over follow-up smaller patches in the future (since this patch is already quite big). So far, the code still only supports one BTS, which can be accessed using the_pcu->bts. In the future that field will be replaced with a list, and the BTS singletons will be removed. The cur_fn output changes in TbfTest are actually a side effect fix, since the singleton main_bts() now points internally to the_pcu->bts, hence the same we allocate and assign in the test. Beforehand, "the_bts" was allocated in the stack while main_bts() still returned an unrelated singleton BTS object instance. Related: OS#4935 Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
Diffstat (limited to 'tests/emu')
-rw-r--r--tests/emu/pcu_emu.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/tests/emu/pcu_emu.cpp b/tests/emu/pcu_emu.cpp
index 2b864570..7534b841 100644
--- a/tests/emu/pcu_emu.cpp
+++ b/tests/emu/pcu_emu.cpp
@@ -73,9 +73,12 @@ static void init_main_bts()
bts->n3103 = 4;
bts->n3105 = 8;
bts->alpha = 0; /* a = 0.0 */
+}
- if (!bts->alloc_algorithm)
- bts->alloc_algorithm = alloc_algorithm_b;
+static void init_pcu(struct gprs_pcu *pcu)
+{
+ if (!pcu->alloc_algorithm)
+ pcu->alloc_algorithm = alloc_algorithm_b;
}
static void bvci_unblocked(struct gprs_bssgp_pcu *pcu)
@@ -114,7 +117,9 @@ void create_and_connect_bssgp(struct gprs_rlcmac_bts *bts,
int main(int argc, char **argv)
{
- struct gprs_rlcmac_bts *bts = bts_main_data();
+ struct gprs_pcu *pcu = gprs_pcu_alloc(tall_pcu_ctx);
+ the_pcu = pcu; /* globally avaialable object */
+ pcu->bts = bts_alloc(pcu);
tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile Emu-PCU context");
if (!tall_pcu_ctx)
@@ -123,8 +128,8 @@ int main(int argc, char **argv)
msgb_talloc_ctx_init(tall_pcu_ctx, 0);
osmo_init_logging2(tall_pcu_ctx, &gprs_log_info);
- bts->nsi = gprs_ns2_instantiate(tall_pcu_ctx, &gprs_ns_prim_cb, NULL);
- if (!bts->nsi) {
+ pcu->nsi = gprs_ns2_instantiate(tall_pcu_ctx, &gprs_ns_prim_cb, NULL);
+ if (!pcu->nsi) {
LOGP(DBSSGP, LOGL_ERROR, "Failed to create NS instance\n");
abort();
}
@@ -134,9 +139,10 @@ int main(int argc, char **argv)
current_test = 0;
+ init_pcu(pcu);
init_main_bts();
- bssgp_set_bssgp_callback(gprs_gp_send_cb, bts->nsi);
- create_and_connect_bssgp(bts, INADDR_LOOPBACK, 23000);
+ bssgp_set_bssgp_callback(gprs_gp_send_cb, pcu->nsi);
+ create_and_connect_bssgp(bts_data(pcu->bts), INADDR_LOOPBACK, 23000);
for (;;)
osmo_select_main(0);