summaryrefslogtreecommitdiff
path: root/cesar/cp2/cco/bw/test
diff options
context:
space:
mode:
authorboure2008-06-19 15:51:03 +0000
committerboure2008-06-19 15:51:03 +0000
commit9ad32055632329f322d8e39b2bc59e655ac58794 (patch)
tree6977ebac78dbaf54feb523131d1c290916064a60 /cesar/cp2/cco/bw/test
parent5e6399b5758b0583275012777c4187d351769843 (diff)
allocation functions implemented test in motion
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2389 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp2/cco/bw/test')
-rw-r--r--cesar/cp2/cco/bw/test/Makefile8
-rw-r--r--cesar/cp2/cco/bw/test/src/bw_test.c317
2 files changed, 159 insertions, 166 deletions
diff --git a/cesar/cp2/cco/bw/test/Makefile b/cesar/cp2/cco/bw/test/Makefile
index ce2a6cb277..51e2c63b5f 100644
--- a/cesar/cp2/cco/bw/test/Makefile
+++ b/cesar/cp2/cco/bw/test/Makefile
@@ -7,10 +7,10 @@ TARGET_PROGRAMS = schedules bw_prio_heap_test bw_test
schedules_SOURCES = bw_list_alloc_test.c
schedules_MODULES = lib cp2/cco/bw
-bw_prio_heap_test_SOURCES = bw_prio_heap_test.c msg_stub.c
-bw_prio_heap_test_MODULES = lib cp2/cco/bw cp2/conn cp2/sta/mgr cl
+bw_prio_heap_test_SOURCES = bw_prio_heap_test.c msg_stub.c pwl_stub.c
+bw_prio_heap_test_MODULES = lib cp2/cco/bw cp2/conn cp2/sta/mgr cl mac/common
-bw_test_SOURCES = bw_test.c msg_stub.c
-bw_test_MODULES = lib cp2/cco/bw cp2/conn cp2/sta/mgr cl
+bw_test_SOURCES = bw_test.c msg_stub.c pwl_stub.c
+bw_test_MODULES = lib cp2/cco/bw cp2/conn cp2/sta/mgr cl mac/common
include $(BASE)/common/make/top.mk
diff --git a/cesar/cp2/cco/bw/test/src/bw_test.c b/cesar/cp2/cco/bw/test/src/bw_test.c
index c18d820a94..826d0411fa 100644
--- a/cesar/cp2/cco/bw/test/src/bw_test.c
+++ b/cesar/cp2/cco/bw/test/src/bw_test.c
@@ -15,12 +15,18 @@
*/
#include "common/std.h"
+#include "cp2/cp.h"
+#include "cp2/inc/context.h"
+
#include "lib/blk.h"
#include "lib/test.h"
#include "string.h"
+#include "mac/common/timings.h"
#include "lib/bitstream.h"
+#include "cp2/pwl/pwl.h"
+
#include "cp2/cco/bw/bw.h"
#include "cp2/cco/bw/inc/bw.h"
#include "cp2/cco/bw/bw_prio_heap.h"
@@ -31,104 +37,151 @@
#include "cp2/conn/inc/conn.h"
#include "cp2/conn/conn_mgr.h"
-#include "cp2/cp.h"
-#include "cp2/inc/context.h"
-
#include "lib/list.h"
#include <stdio.h>
+
#define INIT_TEST(val)\
if (val == 1){\
\
nb_ble = 10;\
\
- alloc[0].st_atu = 0;\
- alloc[0].et_atu = 10;\
- alloc[1].st_atu = 600;\
- alloc[1].et_atu = 610;\
- alloc[2].st_atu = 1000;\
- alloc[2].et_atu = 1510;\
- alloc[3].st_atu = 2200;\
- alloc[3].et_atu = 2310;\
+ alloc[0].st_atu = 782;\
+ alloc[0].et_atu = 792;\
+ alloc[1].st_atu = 1052;\
+ alloc[1].et_atu = 1062;\
+ alloc[2].st_atu = 1257;\
+ alloc[2].et_atu = 1267;\
+ alloc[3].st_atu = 1302;\
+ alloc[3].et_atu = 1312;\
+ alloc[4].st_atu = 1683;\
+ alloc[4].et_atu = 1693;\
+ alloc[5].st_atu = 2083;\
+ alloc[5].et_atu = 2093;\
+ alloc[6].st_atu = 2925;\
+ alloc[6].et_atu = 2935;\
+ alloc[7].st_atu = 3802;\
+ alloc[7].et_atu = 3812;\
+ alloc[8].st_atu = 3838;\
+ alloc[8].et_atu = 3848;\
+ alloc[9].st_atu = 3874;\
+ alloc[9].et_atu = 3896;\
\
- nb_pb = 350;\
+ nb_pb = 45;\
+ \
+ alloc[0].cid = 0;\
+ alloc[1].cid = 0;\
+ alloc[2].cid = 0;\
+ alloc[3].cid = 0;\
+ alloc[4].cid = 0;\
+ alloc[5].cid = 0;\
+ alloc[6].cid = 0;\
+ alloc[7].cid = 0;\
+ alloc[8].cid = 0;\
+ alloc[9].cid = 0;\
\
}
-
-u16 ble_value[10] = {10, 220, 300, 100, 50, 350, 100, 80, 100, 550};
-u16 ble_end_time[10] = {210, 500, 1000, 1400, 1600, 1850, 2200, 2500, 3000, 3906};
+u16 ble_value[10] = {100, 50, 80, 150, 35, 40, 25, 30, 300, 200};\
+u16 ble_end_time[10] = {782, 1052, 1257, 1302, 1683, 2083, 2925, 3802, 3838, 3906};
u16 nb_pb;
u16 nb_ble;
-cp_cco_bw_alloc_t alloc[4];
+cp_cco_bw_alloc_t alloc[10];
void
test_case_bw_init_new_sched (test_t test)
{
cp_t cp;
- cp_cco_bw_new_sched(&cp);
+
+ cp_cco_bw_alloc_t *beacon;
+ cp_cco_bw_alloc_t *mincsma;
+ cp_cco_bw_alloc_t *cfpi;
+ cp_cco_bw_alloc_t *end_tdma;
+
+ u16 beacon_st;
+ u16 beacon_et;
+ u16 mincsma_glid;
+ u16 mincsma_st;
+ u16 mincsma_et;
+ u16 cfpi_glid;
+ u16 cfpi_st;
+ u16 cfpi_et;
+ u16 end_tdma_glid;
+ u16 end_tdma_st;
+ u16 end_tdma_et;
test_case_begin(test, "\nInit new schedule");
+ cp_cco_bw_new_sched(&cp);
+
+ beacon = PARENT_OF(cp_cco_bw_alloc_t, node, list_begin(&cp.bw.actual_schedule));
+ beacon_st = beacon->st_atu;
+ beacon_et = beacon->et_atu;
+
+ mincsma = PARENT_OF(cp_cco_bw_alloc_t, node, list_next(&beacon->node));
+ mincsma_glid = mincsma->glid;
+ mincsma_st = mincsma->st_atu;
+ mincsma_et = mincsma->et_atu;
+
+ cfpi = PARENT_OF(cp_cco_bw_alloc_t, node, list_next(&mincsma->node));
+ cfpi_glid = cfpi->glid;
+ cfpi_st = cfpi->st_atu;
+ cfpi_et = cfpi->et_atu;
+
+ end_tdma = PARENT_OF(cp_cco_bw_alloc_t, node, list_next(&cfpi->node));
+ end_tdma_glid = end_tdma->glid;
+ end_tdma_st = end_tdma->st_atu;
+ end_tdma_et = end_tdma->et_atu;
+
test_begin(test,"Init new schedule")
{
- test_fail_if(PARENT_OF(cp_cco_bw_alloc_t, node,
- list_begin(&cp.bw.actual_schedule))->glid != 0xFF,
+ test_fail_if(beacon_st != 0,
+ "wrong beacon start time ");
+ test_fail_if(beacon_et != 141,
+ "wrong beacon end time");
+ test_fail_if(mincsma_glid != 0xFF,
"wrong mincsma GLID");
- test_fail_if(PARENT_OF(cp_cco_bw_alloc_t, node,
- list_begin(&cp.bw.actual_schedule))->st_atu != 141,
+ test_fail_if(mincsma_st != 141,
"wrong mincsma start time ");
- test_fail_if(PARENT_OF(cp_cco_bw_alloc_t, node,
- list_begin(&cp.bw.actual_schedule))->et_atu != 141+147,
+ test_fail_if(mincsma_et != 288,
"wrong mincsma end time");
- test_fail_if(PARENT_OF(cp_cco_bw_alloc_t, node,
- list_next(list_begin(&cp.bw.actual_schedule)))->glid != 0xFC,
+ test_fail_if(cfpi_glid != 0xFC,
"wrong cfpi GLID");
- test_fail_if(PARENT_OF(cp_cco_bw_alloc_t, node,
- list_next(list_begin(&cp.bw.actual_schedule)))->st_atu != 141+147,
+ test_fail_if(cfpi_st != 288,
"wrong cfpi start time");
- test_fail_if(PARENT_OF(cp_cco_bw_alloc_t, node,
- list_next(list_begin(&cp.bw.actual_schedule)))->et_atu != 141+147+390,
+ test_fail_if(cfpi_et != 678,
"wrong cfpi end time");
- test_fail_if(PARENT_OF(cp_cco_bw_alloc_t, node,
- list_rbegin(&cp.bw.actual_schedule))->glid!=0xFF,
- "wrong end TDMA protection GLID");
- test_fail_if(PARENT_OF(cp_cco_bw_alloc_t, node,
- list_rbegin(&cp.bw.actual_schedule))->st_atu!=3906-10,
+ test_fail_if(end_tdma_glid != 0xFF,
+ "wrong end TDMA protection GLID");
+ test_fail_if(end_tdma_st != 3896,
"wrong end TDMA protection start time");
- test_fail_if(PARENT_OF(cp_cco_bw_alloc_t, node,
- list_rbegin(&cp.bw.actual_schedule))->et_atu!=3906,
+ test_fail_if(end_tdma_et != 3906,
"wrong end TDMA protection end time");
}
test_end;
}
-/* Try to find out if there is enough free time to allocate the connection.
- * Won't use the default schedule but will initiate one for the test.
- *
- * Number of PB to allocate :
- * Actual schedule :
- *
- * Result wanted :
- *
- * */
void
-test_case_unique_allocation (test_t test)
+test_case_get_last_ble(test_t test)
{
u16 i;
-
+ cp_t ctx;
cp_link_t *link;
cp_link_ble_interval_t *first_ble_interval;
- cp_link_ble_interval_t last_ble[3];
- u16 et_test[3];
- u16 st_test[3];
+ cp_link_ble_interval_t last_ble;
cp_cco_bw_alloc_t first_alloc;
cp_cco_bw_alloc_t last_alloc;
-
+ u16 beacon_period_atu;
+
bool result[3];
+
+ cp_pwl_init(&ctx);
+
+ beacon_period_atu = MAC_TCK_TO_ATU(ctx.pwl.bp_avln_ntb[2] - ctx.pwl.bp_avln_ntb[1]);
+
/*Fill BLE*/
link = cp_link_init();
@@ -139,46 +192,38 @@ test_case_unique_allocation (test_t test)
first_ble_interval = PARENT_OF(cp_link_ble_interval_t, node, list_begin(&link->list_ble));
- /* Default first alloc */
- first_alloc.st_atu = 0;
- first_alloc.et_atu = 20;
- /* Default a last alloc */
- last_alloc.st_atu = CP_CCO_BW_ALLOC_TIME_BEACON_PERIOD_ATU -10;
- last_alloc.et_atu = CP_CCO_BW_ALLOC_TIME_BEACON_PERIOD_ATU;
+ test_case_begin(test, "try to find free time to allocate");
- /*Test 0 default values */
- result[0] = cp_cco_bw_get_last_ble(first_ble_interval, &last_ble[0], nb_pb, &first_alloc, &last_alloc);
-
- if(!result[0])
- cp_cco_bw_calculation_of_alloc_time(first_ble_interval, &last_ble[0], nb_pb, &st_test[0], &et_test[0], &first_alloc, &last_alloc);
+ /*Test 0 */
+ first_alloc= alloc[0];
- /* Test 1 */
- last_alloc.st_atu = 550;
- last_alloc.et_atu = 560;
+ while(first_ble_interval->et_atu < first_alloc.et_atu)
+ first_ble_interval = PARENT_OF(cp_link_ble_interval_t, node,list_next(&first_ble_interval->node));
- result[1] = cp_cco_bw_get_last_ble(first_ble_interval, &last_ble[1], nb_pb, &first_alloc, &last_alloc);
- if(!result[1])
- cp_cco_bw_calculation_of_alloc_time(first_ble_interval, &last_ble[1], nb_pb, &st_test[1], &et_test[1], &first_alloc, &last_alloc);
- /* Test 2*/
+ last_alloc = alloc[1];
- first_alloc.st_atu = 500;
- first_alloc.et_atu = 520;
+ result[0] = cp_cco_bw_get_last_ble(first_ble_interval, &last_ble, nb_pb, &first_alloc, &last_alloc);
+
+ /* Test 1 */
+ first_alloc = alloc[2];
while(first_ble_interval->et_atu < first_alloc.et_atu)
first_ble_interval = PARENT_OF(cp_link_ble_interval_t, node,list_next(&first_ble_interval->node));
-// printf("\n--- first interval ble : %d\n",first_ble_interval->ble);
-// printf("\n--- first interval et : %d\n",first_ble_interval->et_atu);
-
- last_alloc.st_atu = 2950;
- last_alloc.et_atu = 2960;
- result[2] = cp_cco_bw_get_last_ble(first_ble_interval, &last_ble[2], nb_pb, &first_alloc, &last_alloc);
+ last_alloc = alloc[3];
- if(!result[2])
- cp_cco_bw_calculation_of_alloc_time(first_ble_interval, &last_ble[2], nb_pb, &st_test[2], &et_test[2], &first_alloc, &last_alloc);
+ result[1] = cp_cco_bw_get_last_ble(first_ble_interval, &last_ble, nb_pb, &first_alloc, &last_alloc);
- test_case_begin(test, "try to find free time to allocate");
+ /* Test 2*/
+ first_alloc = alloc[6];
+
+ while(first_ble_interval->et_atu < first_alloc.et_atu)
+ first_ble_interval = PARENT_OF(cp_link_ble_interval_t, node,list_next(&first_ble_interval->node));
+
+ last_alloc = alloc[7];
+
+ result[2] = cp_cco_bw_get_last_ble(first_ble_interval, &last_ble, nb_pb, &first_alloc, &last_alloc);
test_begin(test, "try to find free time to allocate")
{
@@ -188,6 +233,7 @@ test_case_unique_allocation (test_t test)
}
test_end;
}
+
void
test_case_complete_allocation (test_t test)
{
@@ -197,13 +243,6 @@ test_case_complete_allocation (test_t test)
cp_conn_t *conn;
cp_cco_bw_alloc_t *alloc_test;
- cp_link_ble_interval_t *first_ble_interval;
- cp_link_ble_interval_t last_ble[3];
- u16 et_test[3];
- u16 st_test[3];
- cp_cco_bw_alloc_t first_alloc;
- cp_cco_bw_alloc_t last_alloc;
-
/*Initiate the bw context and conn context*/
cp_cco_bw_init(&ctx);
cp_conn_mgr_init(&ctx);
@@ -226,18 +265,18 @@ test_case_complete_allocation (test_t test)
}
/*Add the fake allocation to test the allocation fonction*/
- cp_cco_bw_prio_heap_add_conn(&ctx, conn->conn_info->cid, 3);
+ for(i=0;i<10;i++)
+ cp_cco_bw_alloc_add(&ctx, &alloc[i]);
+
+ test_case_begin(test, "Try to allocate into the Beacon Period");
+
cp_cco_bw_alloc(&ctx, 666);
alloc_test = cp_cco_bw_alloc_get(&ctx, 666);
- /* printf("\nalloc_test cid : %d\n",alloc_test->cid);
- printf("\nalloc_test st : %d\n",alloc_test->st_atu);
- printf("\nalloc_test et : %d\n",alloc_test->et_atu);*/
-
- test_begin(test, "Add allocation")
+ test_begin(test, "Try to allocate into the Beacon Period")
{
- test_fail_if(alloc_test->st_atu != 1000,
+ test_fail_if(alloc_test->st_atu != 1062,
"wrong allocation");
}
test_end;
@@ -245,84 +284,37 @@ test_case_complete_allocation (test_t test)
}
void
-test_case_add_alloc(test_t test)
+test_case_add_get_alloc(test_t test)
{
+ cp_t ctx;
+ cp_cco_bw_alloc_t *alloc;
+ cp_cco_bw_alloc_t *test_alloc;
- cp_t cp;
- u16 i;
- u16 default_alloc_time = 678;
- cp_cco_bw_alloc_t *alloc[2];
- cp_cco_bw_alloc_t *misc_alloc;
- cp_cco_bw_alloc_t *test_alloc[3];
-
- cp_cco_bw_init(&cp);
-
- misc_alloc = blk_alloc();
- misc_alloc->st_atu = 1000;
- misc_alloc->et_atu = 1100;
-
- cp_cco_bw_alloc_add(&cp, misc_alloc);
-
- for(i=0;i<2;i++)
- {
- alloc[i] = blk_alloc();
- alloc[i]->st_atu = i*100 + default_alloc_time;
- alloc[i]->et_atu = alloc[i]->st_atu+100;
- cp_cco_bw_alloc_add(&cp, alloc[i]);
- }
-
- /*Mincsma allocation*/
- test_alloc[0] = cp_cco_bw_get_first_alloc_global(&cp);
+ cp_cco_bw_init(&ctx);
- /*CFPI allocation*/
- test_alloc[0]= cp_cco_bw_get_next_alloc_global(test_alloc[0]);
+ alloc = blk_alloc();
+ alloc->st_atu = 1000;
+ alloc->et_atu = 2000;
+ alloc->cid = 100;
- /*First allocation*/
- test_alloc[0]= cp_cco_bw_get_next_alloc_global(test_alloc[0]);
-
- /*Second alloc*/
- test_alloc[1] = cp_cco_bw_get_next_alloc_global(test_alloc[0]);
+ test_case_begin(test, "Add Get Allocation");
- /*Third alloc*/
- test_alloc[2] = cp_cco_bw_get_next_alloc_global(test_alloc[1]);
+ cp_cco_bw_alloc_add(&ctx, alloc);
+ test_alloc = cp_cco_bw_alloc_get(&ctx, 100);
- test_case_begin(test, "Add allocation");
-
- test_begin(test, "Add allocation")
+ test_begin(test, "Add Get Allocation")
{
- test_fail_if(test_alloc[0]->st_atu !=default_alloc_time,
- "wrong first alloc st");
- test_fail_if(test_alloc[0]->et_atu !=100 + default_alloc_time,
- "wrong first alloc et");
- test_fail_if(test_alloc[1]->st_atu !=100 + default_alloc_time,
- "wrong 2nd alloc st");
- test_fail_if(test_alloc[1]->et_atu !=200 + default_alloc_time,
- "wrong 2nd alloc et");
- test_fail_if(test_alloc[2]->st_atu !=1000,
- "wrong 3nd alloc st");
- test_fail_if(test_alloc[2]->et_atu !=1100,
- "wrong 3nd alloc et");
+ test_fail_if(test_alloc->st_atu != 1000,
+ "wrong allocation st");
+ test_fail_if(test_alloc->et_atu != 2000,
+ "wrong allocation et");
+ test_fail_if(test_alloc->cid != 100,
+ "wrong allocation cid");
}
test_end;
-}
-void
-test_case_set_next_allocation(test_t test)
-{
- cp_t cp;
-
- cp_cco_bw_alloc_t *alloc;
- cp_cco_bw_alloc_t *next_alloc;
- cp_cco_bw_alloc_t *tmp_alloc;
-
- tmp_alloc = blk_alloc();
- alloc = cp_cco_bw_get_first_alloc_global(&cp);
- next_alloc = cp_cco_bw_get_next_alloc_global(alloc);
-
-
}
-
int
main (void){
test_t test;
@@ -331,10 +323,11 @@ main (void){
INIT_TEST(1);
- test_case_add_alloc(test);
test_case_bw_init_new_sched (test);
- test_case_unique_allocation (test);
+ test_case_add_get_alloc(test);
+
+ test_case_get_last_ble(test);
test_case_complete_allocation (test);