diff options
author | Oliver Smith <osmith@sysmocom.de> | 2021-08-23 14:19:21 +0200 |
---|---|---|
committer | Oliver Smith <osmith@sysmocom.de> | 2021-08-23 14:51:18 +0200 |
commit | 3f79470453f7bede9ab7335d2b0fefcb2ac426c8 (patch) | |
tree | e339a20aea17d9b24919d92d0edcf14df4b76544 /tests/alloc/AllocTest.cpp | |
parent | 3bd648888910d8135e78c02b2f123163ac0ff2a3 (diff) |
bts: delete pch_timer list in destructor
Run bts_pch_timer_remove() on each entry of the BTS specific pch_timer
list, so we don't have a memory leak and so the timer doesn't
potentially fire for a deallocated BTS.
Fixes: d3c7591 ("Add counters: pcu.bts.N.pch.requests.timeout")
Change-Id: Ia5e33d1894408e93a51c452002ef2f5758808269
Diffstat (limited to 'tests/alloc/AllocTest.cpp')
-rw-r--r-- | tests/alloc/AllocTest.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp index 5f11ec56..35bbfc4d 100644 --- a/tests/alloc/AllocTest.cpp +++ b/tests/alloc/AllocTest.cpp @@ -24,6 +24,7 @@ #include "tbf_dl.h" #include "bts.h" #include "gprs_ms.h" +#include "bts_pch_timer.h" #include <string.h> #include <stdio.h> @@ -802,6 +803,23 @@ static void test_2_consecutive_dl_tbfs() talloc_free(bts); } +static void test_bts_pch_timer(void) +{ + struct gprs_rlcmac_bts *bts = bts_alloc(the_pcu, 0); + const char *imsi1 = "1234"; + const char *imsi2 = "5678"; + + fprintf(stderr, "Testing bts_pch_timer dealloc on bts dealloc\n"); + log_set_category_filter(osmo_stderr_target, DPCU, 1, LOGL_DEBUG); + + fprintf(stderr, "Starting PCH timer for 2 IMSI\n"); + bts_pch_timer_start(bts, imsi1); + bts_pch_timer_start(bts, imsi2); + + fprintf(stderr, "Deallocating BTS, expecting the PCH timer to be stopped and deallocated\n"); + talloc_free(bts); +} + int main(int argc, char **argv) { tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile AllocTest context"); @@ -828,6 +846,7 @@ int main(int argc, char **argv) test_many_connections(alloc_algorithm_b, 32, "B"); test_many_connections(alloc_algorithm_dynamic, 160, "dynamic"); test_2_consecutive_dl_tbfs(); + test_bts_pch_timer(); talloc_free(the_pcu); return EXIT_SUCCESS; |