alloc/test: Delete first TBF after the second is allocated

Currently when using the test modes TEST_MODE_DL_AFTER_UL or
TEST_MODE_UL_AFTER_DL, the first TBF is deleted before the second is
allocated. The far more interesting case were to keep the first TBF a
little bit longer until the second TBF has been created and delete
then. This comes closer the the situation observed with real MS,
where the first TBF takes some time (timeout or waiting for Ack)
before it gets deleted and thus detached from the MS object.

This commit delays the call to tbf_free accordingly.

The effect can be observed in the results of the algo A tests, where
the uniform distribution of the allocated PDCH is lost.

Sponsored-by: On-Waves ehf
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index 874f907..bf93f57 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -461,6 +461,24 @@
 
 	GprsMs::Guard guard(ms);
 
+	/* Continue with what is needed next */
+	switch (mode) {
+	case TEST_MODE_UL_ONLY:
+	case TEST_MODE_DL_ONLY:
+		/* We are done */
+		break;
+
+	case TEST_MODE_DL_AFTER_UL:
+	case TEST_MODE_UL_AND_DL:
+		ms = alloc_tbfs(the_bts, ms, ms_class, TEST_MODE_DL_ONLY);
+		break;
+
+	case TEST_MODE_UL_AFTER_DL:
+	case TEST_MODE_DL_AND_UL:
+		ms = alloc_tbfs(the_bts, ms, ms_class, TEST_MODE_UL_ONLY);
+		break;
+	}
+
 	/* Optionally delete the TBF */
 	switch (mode) {
 	case TEST_MODE_DL_AFTER_UL:
@@ -472,23 +490,7 @@
 		break;
 	}
 
-	/* Continue with what is needed next */
-	switch (mode) {
-	case TEST_MODE_UL_ONLY:
-	case TEST_MODE_DL_ONLY:
-		/* We are done */
-		return ms;
-
-	case TEST_MODE_DL_AFTER_UL:
-	case TEST_MODE_UL_AND_DL:
-		return alloc_tbfs(the_bts, ms, ms_class, TEST_MODE_DL_ONLY);
-
-	case TEST_MODE_UL_AFTER_DL:
-	case TEST_MODE_DL_AND_UL:
-		return alloc_tbfs(the_bts, ms, ms_class, TEST_MODE_UL_ONLY);
-	}
-
-	return  NULL;
+	return  ms;
 }
 
 static void test_successive_allocation(algo_t algo, unsigned min_class,
@@ -584,7 +586,7 @@
 		32, "algorithm B class 10 (DL after UL)");
 
 	test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_UL_AFTER_DL,
-		32, "algorithm A (UL after DL)");
+		7, "algorithm A (UL after DL)");
 	test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_UL_AFTER_DL,
 		32, "algorithm B class 10 (UL after DL)");