aboutsummaryrefslogtreecommitdiffstats
path: root/tests/ms/MsTest.cpp
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-05-12 17:54:33 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-05-20 11:36:12 +0200
commit536708617505a017b6b263a32f592471913ec464 (patch)
treef28edb7214a6bfac7d9386b50ea456c6eb9898f5 /tests/ms/MsTest.cpp
parentdfef28de887eba43747bca52584f8310450e243a (diff)
ms: Add MS storage class
Currently the MS objects are contained in the TBF objects only. To allow for an extended life time after the TBF objects have been freed and to find them based on TLLI, a container for the MS objects is needed. This commit adds the container class and also adds the corresponding m_list member to GprsMs. Further integration into the PCU code is not yet done. Ticket: #1674 Sponsored-by: On-Waves ehf
Diffstat (limited to 'tests/ms/MsTest.cpp')
-rw-r--r--tests/ms/MsTest.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/ms/MsTest.cpp b/tests/ms/MsTest.cpp
index 03b1c18d..0895e4db 100644
--- a/tests/ms/MsTest.cpp
+++ b/tests/ms/MsTest.cpp
@@ -23,6 +23,7 @@
#include "tbf.h"
#include "gprs_debug.h"
#include "gprs_ms.h"
+#include "gprs_ms_storage.h"
extern "C" {
#include "pcu_vty.h"
@@ -231,6 +232,58 @@ static void test_ms_replace_tbf()
printf("=== end %s ===\n", __func__);
}
+static void test_ms_storage()
+{
+ uint32_t tlli = 0xffeeddbb;
+ gprs_rlcmac_ul_tbf *ul_tbf;
+ GprsMs *ms;
+ GprsMsStorage store;
+
+ printf("=== start %s ===\n", __func__);
+
+ ul_tbf = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf);
+ ul_tbf->direction = GPRS_RLCMAC_UL_TBF;
+
+ ms = store.get_ms(tlli + 0);
+ OSMO_ASSERT(ms == NULL);
+
+ ms = store.get_or_create_ms(tlli + 0);
+ OSMO_ASSERT(ms->tlli() == tlli + 0);
+
+ ms = store.get_ms(tlli + 0);
+ OSMO_ASSERT(ms != NULL);
+ OSMO_ASSERT(ms->tlli() == tlli + 0);
+
+ ms = store.get_or_create_ms(tlli + 1);
+ OSMO_ASSERT(ms->tlli() == tlli + 1);
+
+ ms = store.get_ms(tlli + 1);
+ OSMO_ASSERT(ms != NULL);
+ OSMO_ASSERT(ms->tlli() == tlli + 1);
+
+ /* delete ms */
+ ms = store.get_ms(tlli + 0);
+ OSMO_ASSERT(ms != NULL);
+ ms->attach_tbf(ul_tbf);
+ ms->detach_tbf(ul_tbf);
+ ms = store.get_ms(tlli + 0);
+ OSMO_ASSERT(ms == NULL);
+ ms = store.get_ms(tlli + 1);
+ OSMO_ASSERT(ms != NULL);
+
+ /* delete ms */
+ ms = store.get_ms(tlli + 1);
+ OSMO_ASSERT(ms != NULL);
+ ms->attach_tbf(ul_tbf);
+ ms->detach_tbf(ul_tbf);
+ ms = store.get_ms(tlli + 1);
+ OSMO_ASSERT(ms == NULL);
+
+ talloc_free(ul_tbf);
+
+ printf("=== end %s ===\n", __func__);
+}
+
static const struct log_info_cat default_categories[] = {
{"DPCU", "", "GPRS Packet Control Unit (PCU)", LOGL_INFO, 1},
};
@@ -267,6 +320,7 @@ int main(int argc, char **argv)
test_ms_state();
test_ms_callback();
test_ms_replace_tbf();
+ test_ms_storage();
if (getenv("TALLOC_REPORT_FULL"))
talloc_report_full(tall_pcu_ctx, stderr);