Change in osmo-pcu[master]: MS store: move test helper to unit test

Max gerrit-no-reply at lists.osmocom.org
Tue Mar 19 15:05:52 UTC 2019


Max has submitted this change and it was merged. ( https://gerrit.osmocom.org/13213 )

Change subject: MS store: move test helper to unit test
......................................................................

MS store: move test helper to unit test

It's confusing to have test-specific helper with the same name as tested
function directly inside the GprsMsStorage class. Let's convert it into
static function and move to the unit test.

Change-Id: Ia2a5b90779051af894fe15d957c1d26f0a142f33
---
M src/gprs_ms_storage.cpp
M src/gprs_ms_storage.h
M tests/ms/MsTest.cpp
3 files changed, 18 insertions(+), 20 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  osmith: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/gprs_ms_storage.cpp b/src/gprs_ms_storage.cpp
index c7de6d3..04518c5 100644
--- a/src/gprs_ms_storage.cpp
+++ b/src/gprs_ms_storage.cpp
@@ -106,20 +106,3 @@
 
 	return ms;
 }
-
-GprsMs *GprsMsStorage::create_ms(uint32_t tlli, enum gprs_rlcmac_tbf_direction dir)
-{
-	GprsMs *ms = get_ms(tlli);
-
-	if (ms)
-		return ms;
-
-	ms = create_ms();
-
-	if (dir == GPRS_RLCMAC_UL_TBF)
-		ms->set_tlli(tlli);
-	else
-		ms->confirm_tlli(tlli);
-
-	return ms;
-}
diff --git a/src/gprs_ms_storage.h b/src/gprs_ms_storage.h
index 44ad0ed..14707f5 100644
--- a/src/gprs_ms_storage.h
+++ b/src/gprs_ms_storage.h
@@ -39,7 +39,6 @@
 	virtual void ms_active(class GprsMs *);
 
 	GprsMs *get_ms(uint32_t tlli, uint32_t old_tlli = 0, const char *imsi = 0) const;
-	GprsMs *create_ms(uint32_t tlli, enum gprs_rlcmac_tbf_direction dir);
 	GprsMs *create_ms();
 
 	const LListHead<GprsMs>& ms_list() const {return m_list;}
diff --git a/tests/ms/MsTest.cpp b/tests/ms/MsTest.cpp
index 728daf6..2b0bc0f 100644
--- a/tests/ms/MsTest.cpp
+++ b/tests/ms/MsTest.cpp
@@ -337,6 +337,22 @@
 	printf("=== end %s ===\n", __func__);
 }
 
+static GprsMs *prepare_ms(GprsMsStorage *st, uint32_t tlli, enum gprs_rlcmac_tbf_direction dir)
+{
+	GprsMs *ms = st->get_ms(tlli);
+	if (ms)
+		return ms;
+
+	ms = st->create_ms();
+
+	if (dir == GPRS_RLCMAC_UL_TBF)
+		ms->set_tlli(tlli);
+	else
+		ms->confirm_tlli(tlli);
+
+	return ms;
+}
+
 static void test_ms_storage()
 {
 	uint32_t tlli = 0xffeeddbb;
@@ -355,7 +371,7 @@
 	ms = store.get_ms(tlli + 0);
 	OSMO_ASSERT(ms == NULL);
 
-	ms = store.create_ms(tlli + 0, GPRS_RLCMAC_UL_TBF);
+	ms = prepare_ms(&store, tlli + 0, GPRS_RLCMAC_UL_TBF);
 	OSMO_ASSERT(ms != NULL);
 	OSMO_ASSERT(ms->tlli() == tlli + 0);
 	ms->set_imsi(imsi1);
@@ -371,7 +387,7 @@
 	ms_tmp = store.get_ms(0, 0, imsi2);
 	OSMO_ASSERT(ms_tmp == NULL);
 
-	ms = store.create_ms(tlli + 1, GPRS_RLCMAC_UL_TBF);
+	ms = prepare_ms(&store, tlli + 1, GPRS_RLCMAC_UL_TBF);
 	OSMO_ASSERT(ms != NULL);
 	OSMO_ASSERT(ms->tlli() == tlli + 1);
 	ms->set_imsi(imsi2);

-- 
To view, visit https://gerrit.osmocom.org/13213
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia2a5b90779051af894fe15d957c1d26f0a142f33
Gerrit-Change-Number: 13213
Gerrit-PatchSet: 2
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190319/59f2efce/attachment.html>


More information about the gerrit-log mailing list