ms: Get rid of ms->delay field

Simply apply the content of the configured timer when the MS goes idle.
Having that field is convenient to do tricky stuff in unit tests, but
makes the main osmo-pcu app more complex for no good enough reason.

Change-Id: I8d44318b37b6605afd84db8ccec0d75e6db293b9
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index 8a67152..a84bd64 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -225,7 +225,7 @@
 	ms = ms_alloc(bts, __func__);
 	ms_set_ms_class(ms, ms_class);
 	/* Avoid delaying free to avoid tons of to-be-freed ms objects queuing */
-	ms_set_timeout(ms, 0);
+	OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2030, 0, OSMO_TDEF_S) == 0);
 	ul_tbf = ul_tbf_alloc(bts, ms, -1, true);
 	if (!ul_tbf) {
 		ms_unref(ms, __func__);
@@ -273,7 +273,7 @@
 	ms = ms_alloc(bts, __func__);
 	ms_set_ms_class(ms, ms_class);
 	/* Avoid delaying free to avoid tons of to-be-freed ms objects queuing */
-	ms_set_timeout(ms, 0);
+	OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2030, 0, OSMO_TDEF_S) == 0);
 	dl_tbf = dl_tbf_alloc(bts, ms, -1, true);
 	if (!dl_tbf) {
 		ms_unref(ms, __func__);
@@ -329,7 +329,7 @@
 	ms = ms_alloc(bts, __func__);
 	ms_set_ms_class(ms, ms_class);
 	/* Avoid delaying free to avoid tons of to-be-freed ms objects queuing */
-	ms_set_timeout(ms, 0);
+	OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2030, 0, OSMO_TDEF_S) == 0);
 	ul_tbf = ul_tbf_alloc(bts, ms, -1, false);
 	if (!ul_tbf) {
 		ms_unref(ms, __func__);
diff --git a/tests/ms/MsTest.cpp b/tests/ms/MsTest.cpp
index 2a15a7b..776f77c7 100644
--- a/tests/ms/MsTest.cpp
+++ b/tests/ms/MsTest.cpp
@@ -378,9 +378,10 @@
 
 	printf("=== start %s ===\n", __func__);
 
+	OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2030, 1, OSMO_TDEF_S) == 0);
+
 	ms = ms_alloc(bts, __func__);
 	ms_set_tlli(ms, tlli);
-	ms_set_timeout(ms, 1);
 
 	OSMO_ASSERT(ms_is_idle(ms));
 
@@ -415,6 +416,8 @@
 	talloc_free(ul_tbf);
 	talloc_free(bts);
 	printf("=== end %s ===\n", __func__);
+	/* Return the timer to the usually expected value 0 for other tests: */
+	OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2030, 0, OSMO_TDEF_S) == 0);
 }
 
 static void test_ms_cs_selection()
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index ad08318..76394e2 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -627,7 +627,7 @@
 	fprintf(stderr, "=== end %s ===\n", __func__);
 
 	/* Restore MS release timeout to 0 to make sure it is freed immediately: */
-	ms_set_timeout(ms, 0);
+	OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2030, 0, OSMO_TDEF_S) == 0);
 	TALLOC_FREE(the_pcu);
 }
 
diff --git a/tests/ulc/PdchUlcTest.cpp b/tests/ulc/PdchUlcTest.cpp
index be370bd..a13479f 100644
--- a/tests/ulc/PdchUlcTest.cpp
+++ b/tests/ulc/PdchUlcTest.cpp
@@ -320,6 +320,7 @@
 	log_parse_category_mask(osmo_stderr_target, "DPCU,1:DRLCMAC,1:DRLCMACUL,1:DMS,1");
 
 	the_pcu = gprs_pcu_alloc(tall_pcu_ctx);
+	OSMO_ASSERT(osmo_tdef_set(the_pcu->T_defs, -2030, 0, OSMO_TDEF_S) == 0);
 
 	test_reserve_multiple();
 	test_fn_wrap_around();