Review at  https://gerrit.osmocom.org/4956

Clarify alloc tests

* add wrapper for single-class tests
* rename top-level function to avoid confusion
* reformat to improve readability
* drop confusing wrapper

Change-Id: I3feeb92237ffb9557ac6998540b740f1f67186b3
Related: OS#2282
---
M tests/alloc/AllocTest.cpp
1 file changed, 48 insertions(+), 53 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/56/4956/1

diff --git a/tests/alloc/AllocTest.cpp b/tests/alloc/AllocTest.cpp
index a88f477..cd24de1 100644
--- a/tests/alloc/AllocTest.cpp
+++ b/tests/alloc/AllocTest.cpp
@@ -475,6 +475,19 @@
        TEST_MODE_UL_AFTER_DL,
 };
 
+static inline char *test_mode_descr(enum test_mode t)
+{
+       switch (t) {
+       case TEST_MODE_UL_ONLY: return (char*)"UL only";
+       case TEST_MODE_DL_ONLY: return (char*)"DL ONLY";
+       case TEST_MODE_UL_AND_DL: return (char*)"UL and DL";
+       case TEST_MODE_DL_AND_UL: return (char*)"DL and UL";
+       case TEST_MODE_DL_AFTER_UL: return (char*)"DL after UL";
+       case TEST_MODE_UL_AFTER_DL: return (char*)"UL after DL";
+       default: return NULL;
+       }
+}
+
 static GprsMs *alloc_tbfs(BTS *the_bts, GprsMs *ms, unsigned ms_class,
        enum test_mode mode)
 {
@@ -660,7 +673,8 @@
        struct gprs_rlcmac_trx *trx;
        unsigned counter;
 
-       printf("Going to test assignment with many TBF, %s\n", text);
+       printf("Going to test assignment with many TBF, algorithm %s (%s)\n",
+              text, test_mode_descr(mode));
 
        bts = the_bts.bts_data();
        bts->alloc_algorithm = algo;
@@ -683,6 +697,12 @@
        check_tfi_usage(&the_bts);
 }
 
+static inline void test_successive_allocation_single(algo_t algo, unsigned 
ms_class, enum test_mode mode,
+                                                    unsigned expect_num, const 
char *text)
+{
+       test_successive_allocation(algo, ms_class, ms_class, mode, expect_num, 
text);
+}
+
 static void test_many_connections(algo_t algo, unsigned expect_num,
        const char *text)
 {
@@ -698,7 +718,7 @@
                TEST_MODE_DL_ONLY,
        };
 
-       printf("Going to test assignment with many connections, %s\n", text);
+       printf("Going to test assignment with many connections, algorithm 
%s\n", text);
 
        bts = the_bts.bts_data();
        bts->alloc_algorithm = algo;
@@ -738,62 +758,35 @@
        OSMO_ASSERT(expect_num == (unsigned)counter1);
 }
 
-static void test_successive_allocation()
+static void test_successive_allocations()
 {
-       test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_UL_AND_DL,
-               35, "algorithm A (UL and DL)");
-       test_successive_allocation(alloc_algorithm_b, 10, 10, 
TEST_MODE_UL_AND_DL,
-               32, "algorithm B class 10 (UL and DL)");
-       test_successive_allocation(alloc_algorithm_b, 12, 12, 
TEST_MODE_UL_AND_DL,
-               32, "algorithm B class 12 (UL and DL)");
-       test_successive_allocation(alloc_algorithm_b, 1, 12, 
TEST_MODE_UL_AND_DL,
-               32, "algorithm B class 1-12 (UL and DL)");
-       test_successive_allocation(alloc_algorithm_b, 1, 29, 
TEST_MODE_UL_AND_DL,
-               32, "algorithm B class 1-29 (UL and DL)");
-       test_successive_allocation(alloc_algorithm_dynamic, 1, 29, 
TEST_MODE_UL_AND_DL,
-               35, "algorithm dynamic class 1-29 (UL and DL)");
+       test_successive_allocation_single(alloc_algorithm_a, 1, 
TEST_MODE_UL_AND_DL, 35, "A");
+       test_successive_allocation_single(alloc_algorithm_b, 10, 
TEST_MODE_UL_AND_DL, 32, "B class 10");
+       test_successive_allocation_single(alloc_algorithm_b, 12, 
TEST_MODE_UL_AND_DL, 32, "B class 12");
 
-       test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_DL_AND_UL,
-               35, "algorithm A (DL and UL)");
-       test_successive_allocation(alloc_algorithm_b, 10, 10, 
TEST_MODE_DL_AND_UL,
-               32, "algorithm B class 10 (DL and UL)");
-       test_successive_allocation(alloc_algorithm_dynamic, 10, 10, 
TEST_MODE_DL_AND_UL,
-               32, "algorithm dynamic class 10 (DL and UL)");
+       test_successive_allocation(alloc_algorithm_b, 1, 12, 
TEST_MODE_UL_AND_DL, 32, "B class 1-12");
+       test_successive_allocation(alloc_algorithm_b, 1, 29, 
TEST_MODE_UL_AND_DL, 32, "B class 1-29");
+       test_successive_allocation(alloc_algorithm_dynamic, 1, 29, 
TEST_MODE_UL_AND_DL, 35, "dynamic class 1-29");
 
-       test_successive_allocation(alloc_algorithm_a, 1, 1, 
TEST_MODE_DL_AFTER_UL,
-               160, "algorithm A (DL after UL)");
-       test_successive_allocation(alloc_algorithm_b, 10, 10, 
TEST_MODE_DL_AFTER_UL,
-               32, "algorithm B class 10 (DL after UL)");
-       test_successive_allocation(alloc_algorithm_dynamic, 10, 10, 
TEST_MODE_DL_AFTER_UL,
-               95, "algorithm dynamic class 10 (DL after UL)");
+       test_successive_allocation_single(alloc_algorithm_a, 1, 
TEST_MODE_DL_AND_UL, 35, "A");
+       test_successive_allocation_single(alloc_algorithm_b, 10, 
TEST_MODE_DL_AND_UL, 32, "B class 10");
+       test_successive_allocation_single(alloc_algorithm_dynamic, 10, 
TEST_MODE_DL_AND_UL, 32, "dynamic class 10");
 
-       test_successive_allocation(alloc_algorithm_a, 1, 1, 
TEST_MODE_UL_AFTER_DL,
-               35, "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)");
-       test_successive_allocation(alloc_algorithm_dynamic, 10, 10, 
TEST_MODE_UL_AFTER_DL,
-               35, "algorithm dynamic class 10 (UL after DL)");
+       test_successive_allocation_single(alloc_algorithm_a, 1, 
TEST_MODE_DL_AFTER_UL, 160, "A");
+       test_successive_allocation_single(alloc_algorithm_b, 10, 
TEST_MODE_DL_AFTER_UL, 32, "B class 10");
+       test_successive_allocation_single(alloc_algorithm_dynamic, 10, 
TEST_MODE_DL_AFTER_UL, 95, "dynamic class 10");
 
-       test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_UL_ONLY,
-               35, "algorithm A (UL only)");
-       test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_UL_ONLY,
-               32, "algorithm B class 10 (UL only)");
-       test_successive_allocation(alloc_algorithm_dynamic, 10, 10, 
TEST_MODE_UL_ONLY,
-               35, "algorithm dynamic class 10 (UL only)");
+       test_successive_allocation_single(alloc_algorithm_a, 1, 
TEST_MODE_UL_AFTER_DL, 35, "A");
+       test_successive_allocation_single(alloc_algorithm_b, 10, 
TEST_MODE_UL_AFTER_DL, 32, "B class 10");
+       test_successive_allocation_single(alloc_algorithm_dynamic, 10, 
TEST_MODE_UL_AFTER_DL, 35, "dynamic class 10");
 
-       test_successive_allocation(alloc_algorithm_a, 1, 1, TEST_MODE_DL_ONLY,
-               160, "algorithm A (DL ONLY)");
-       test_successive_allocation(alloc_algorithm_b, 10, 10, TEST_MODE_DL_ONLY,
-               32, "algorithm B class 10 (DL ONLY)");
-       test_successive_allocation(alloc_algorithm_dynamic, 10, 10, 
TEST_MODE_DL_ONLY,
-               101, "algorithm dynamic class 10 (DL ONLY)");
-}
+       test_successive_allocation_single(alloc_algorithm_a, 1, 
TEST_MODE_UL_ONLY, 35, "A");
+       test_successive_allocation_single(alloc_algorithm_b, 10, 
TEST_MODE_UL_ONLY, 32, "B class 10");
+       test_successive_allocation_single(alloc_algorithm_dynamic, 10, 
TEST_MODE_UL_ONLY, 35, "dynamic class 10");
 
-static void test_many_connections()
-{
-       test_many_connections(alloc_algorithm_a, 160, "algorithm A");
-       test_many_connections(alloc_algorithm_b, 32, "algorithm B");
-       test_many_connections(alloc_algorithm_dynamic, 160, "algorithm 
dynamic");
+       test_successive_allocation_single(alloc_algorithm_a, 1, 
TEST_MODE_DL_ONLY, 160, "A");
+       test_successive_allocation_single(alloc_algorithm_b, 10, 
TEST_MODE_DL_ONLY, 32, "B class 10");
+       test_successive_allocation_single(alloc_algorithm_dynamic, 10, 
TEST_MODE_DL_ONLY, 101, "dynamic class 10");
 }
 
 static void test_2_consecutive_dl_tbfs()
@@ -861,8 +854,10 @@
 
        test_alloc_a();
        test_alloc_b();
-       test_successive_allocation();
-       test_many_connections();
+       test_successive_allocations();
+       test_many_connections(alloc_algorithm_a, 160, "A");
+       test_many_connections(alloc_algorithm_b, 32, "B");
+       test_many_connections(alloc_algorithm_dynamic, 160, "dynamic");
        test_2_consecutive_dl_tbfs();
        return EXIT_SUCCESS;
 }

-- 
To view, visit https://gerrit.osmocom.org/4956
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3feeb92237ffb9557ac6998540b740f1f67186b3
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max <msur...@sysmocom.de>

Reply via email to