alloc: Load balancing for algo A

Currently only the first enabled PDCH will be used. Beside the
throughput this will also limit the number of TBFs:

  - number of UL TBFs <= 7
  - number of DL TBFs <= 32

This commit changes the allocation algorithm to use the PDCH with the
least number of attached TBFs. This will improve the troughput in
both directions and the UL limits:

  - number of UL TBFs <= min(32, N_PDCH * 7) UL TBFs

Ticket: #1794
Sponsored-by: On-Waves ehf
diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index 5a91f6a..b918132 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -110,11 +110,11 @@
 {
 	/* slots 2 - 3 */
 	test_alloc_a(GPRS_RLCMAC_DL_TBF, 0x0c, 32);
-	test_alloc_a(GPRS_RLCMAC_UL_TBF, 0x0c, 7);
+	test_alloc_a(GPRS_RLCMAC_UL_TBF, 0x0c, 14);
 
 	/* slots 1 - 5 */
 	test_alloc_a(GPRS_RLCMAC_DL_TBF, 0x1e, 32);
-	test_alloc_a(GPRS_RLCMAC_UL_TBF, 0x1e, 7);
+	test_alloc_a(GPRS_RLCMAC_UL_TBF, 0x1e, 28);
 }
 
 static void dump_assignment(struct gprs_rlcmac_tbf *tbf, const char *dir)
@@ -557,13 +557,13 @@
 	}
 
 	printf("  Successfully allocated %d UL TBFs\n", counter);
-	OSMO_ASSERT(counter >= expect_num);
+	OSMO_ASSERT(counter == expect_num);
 }
 
 static void test_successive_allocation()
 {
 	test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_UL_AND_DL,
-		7, "algorithm A (UL and DL)");
+		32, "algorithm A (UL and DL)");
 	test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_UL_AND_DL,
 		7, "algorithm B class 10 (UL and DL)");
 	test_successive_allocation(alloc_algorithm_b, 12, 12, TEST_MODE_UL_AND_DL,
@@ -574,29 +574,29 @@
 		18, "algorithm B class 1-29 (UL and DL)");
 
 	test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_DL_AND_UL,
-		7, "algorithm A (DL and UL)");
+		32, "algorithm A (DL and UL)");
 	test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_DL_AND_UL,
 		7, "algorithm B class 10 (DL and UL)");
 
 	test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_DL_AFTER_UL,
-		7, "algorithm A (DL after UL)");
+		32, "algorithm A (DL after UL)");
 	test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_DL_AFTER_UL,
-		7, "algorithm B class 10 (DL after UL)");
+		32, "algorithm B class 10 (DL after UL)");
 
 	test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_UL_AFTER_DL,
-		7, "algorithm A (UL after DL)");
+		32, "algorithm A (UL after DL)");
 	test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_UL_AFTER_DL,
 		7, "algorithm B class 10 (UL after DL)");
 
 	test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_UL_ONLY,
-		7, "algorithm A (UL only)");
+		32, "algorithm A (UL only)");
 	test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_UL_ONLY,
 		7, "algorithm B class 10 (UL only)");
 
 	test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_DL_ONLY,
-		7, "algorithm A (DL ONLY)");
+		32, "algorithm A (DL ONLY)");
 	test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_DL_ONLY,
-		7, "algorithm B class 10 (DL ONLY)");
+		32, "algorithm B class 10 (DL ONLY)");
 }
 
 int main(int argc, char **argv)