summaryrefslogtreecommitdiff
path: root/cesar/cp2/cco/bw/test
diff options
context:
space:
mode:
authorboure2008-07-02 11:33:52 +0000
committerboure2008-07-02 11:33:52 +0000
commitb3a8c605a9b0bf0f8e5eff4a2be094feb4a46ee4 (patch)
tree7517ab56e47dc49580b7bb57cf96fd06980f80f6 /cesar/cp2/cco/bw/test
parent80d045a98a184d82b7954be3b3ecb59464dce021 (diff)
Correction of the implementation that allocates multiples TXOPs
Added tests git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2528 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp2/cco/bw/test')
-rw-r--r--cesar/cp2/cco/bw/test/Makefile7
-rw-r--r--cesar/cp2/cco/bw/test/overide/cp_fsm_defs.h38
-rw-r--r--cesar/cp2/cco/bw/test/src/bw_test.c151
-rw-r--r--cesar/cp2/cco/bw/test/src/fsm_stub.c29
4 files changed, 176 insertions, 49 deletions
diff --git a/cesar/cp2/cco/bw/test/Makefile b/cesar/cp2/cco/bw/test/Makefile
index 6c45ac8559..8d5aad4a40 100644
--- a/cesar/cp2/cco/bw/test/Makefile
+++ b/cesar/cp2/cco/bw/test/Makefile
@@ -1,16 +1,17 @@
BASE = ../../../..
ECOS=y
+INCLUDES = cp2/cco/bw/test/overide/
TARGET_PROGRAMS = schedules bw_prio_heap_test bw_test
-schedules_SOURCES = bw_list_alloc_test.c pwl_stub.c msg_stub.c #sta_stub.c
+schedules_SOURCES = bw_list_alloc_test.c pwl_stub.c msg_stub.c fsm_stub.c
schedules_MODULES = lib cp2/cco/bw cl mac/common cp2/sta/mgr
-bw_prio_heap_test_SOURCES = bw_prio_heap_test.c pwl_stub.c msg_stub.c #sta_stub.c
+bw_prio_heap_test_SOURCES = bw_prio_heap_test.c pwl_stub.c msg_stub.c fsm_stub.c
bw_prio_heap_test_MODULES = lib cp2/cco/bw cp2/conn cl mac/common cp2/sta/mgr
-bw_test_SOURCES = bw_test.c pwl_stub.c msg_stub.c #sta_stub.c
+bw_test_SOURCES = bw_test.c pwl_stub.c msg_stub.c fsm_stub.c
bw_test_MODULES = lib cp2/cco/bw cp2/conn cl mac/common cp2/sta/mgr
include $(BASE)/common/make/top.mk
diff --git a/cesar/cp2/cco/bw/test/overide/cp_fsm_defs.h b/cesar/cp2/cco/bw/test/overide/cp_fsm_defs.h
new file mode 100644
index 0000000000..130e4ec426
--- /dev/null
+++ b/cesar/cp2/cco/bw/test/overide/cp_fsm_defs.h
@@ -0,0 +1,38 @@
+#ifndef overide_cp_fsm_defs_h
+#define overide_cp_fsm_defs_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file overide/cp_fsm_defs.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+struct cp_fsm_transition_t
+{
+ uint titi;
+};
+typedef struct cp_fsm_transition_t cp_fsm_transition_t;
+
+enum cp_fsm_event_type_t
+{
+ CP_FSM_EVENT_TYPE_ALL_STA_LEAVED,
+ CP_FSM_EVENT_TYPE_NET_LIST_EMPTY,
+ CP_FSM_EVENT_TYPE_SNID_CONFLICT
+};
+typedef enum cp_fsm_event_type_t cp_fsm_event_type_t;
+
+struct cp_fsm_branch_t
+{
+ uint titi;
+};
+typedef struct cp_fsm_branch_t cp_fsm_branch_t;
+
+#endif /* overide_cp_fsm_defs_h */
diff --git a/cesar/cp2/cco/bw/test/src/bw_test.c b/cesar/cp2/cco/bw/test/src/bw_test.c
index 18c080c6b2..230e406dde 100644
--- a/cesar/cp2/cco/bw/test/src/bw_test.c
+++ b/cesar/cp2/cco/bw/test/src/bw_test.c
@@ -6,7 +6,7 @@
*
* }}} */
/**
- * \file bw.c
+ * \log bw.c
* \brief bandwidth manager module
* \ingroup cp2_cco_bw
*
@@ -171,15 +171,15 @@ if(val == 0){\
ble_value[8] = 70;\
ble_value[9] = 160;\
\
- ble_end_time[0] = 794;\
- ble_end_time[1] = 1054;\
- ble_end_time[2] = 1249;\
- ble_end_time[3] = 1292;\
- ble_end_time[4] = 1663;\
- ble_end_time[5] = 2053;\
- ble_end_time[6] = 2885;\
- ble_end_time[7] = 3752;\
- ble_end_time[8] = 3863;\
+ ble_end_time[0] = 935;\
+ ble_end_time[1] = 1195;\
+ ble_end_time[2] = 1390;\
+ ble_end_time[3] = 1429;\
+ ble_end_time[4] = 1785;\
+ ble_end_time[5] = 2175;\
+ ble_end_time[6] = 3007;\
+ ble_end_time[7] = 3735;\
+ ble_end_time[8] = 3839;\
ble_end_time[9] = 3906;\
\
conn_nb_pb[0]=10;\
@@ -241,8 +241,6 @@ test_case_bw_init_new_sched (test_t test)
cp_sta_mgr_init(&cp);
test_case_begin(test, "\nInit new schedule");
- /*Add 2 PCos*/
-
cp_cco_bw_new_sched(&cp);
beacon = PARENT_OF(cp_cco_bw_alloc_t, node, list_begin(&cp.bw.actual_schedule));
@@ -346,6 +344,8 @@ test_case_get_alloc_ble(test_t test, u8 test_id)
while(first_ble_interval->et_atu < first_alloc[i].et_atu)
first_ble_interval = PARENT_OF(cp_link_ble_interval_t, node,list_next(&first_ble_interval->node));
+ last_ble = *first_ble_interval;
+
result[i] = cp_cco_bw_get_alloc_ble(first_ble_interval, &last_ble, nb_pb, &first_alloc[i], &last_alloc[i]);
}
@@ -480,70 +480,70 @@ test_case_complete_schedule (test_t test)
alloc_test[0] = cp_cco_bw_get_first_alloc_actual(&cp);
- for(i = 1 ; i < 13 ; i++)
+ for(i = 1 ; i < 14 ; i++)
alloc_test[i] = cp_cco_bw_get_next_alloc_actual(alloc_test[i-1]);
test_begin(test, "Complete Schedule")
{
- test_fail_if(alloc_test[3]->st_atu != 678,
+ test_fail_if(alloc_test[4]->st_atu != 819,
"wrong allocation st");
- test_fail_if(alloc_test[3]->et_atu != 736,
+ test_fail_if(alloc_test[4]->et_atu != 877,
"wrong allocation st");
- test_fail_if(alloc_test[3]->cid != 100,
+ test_fail_if(alloc_test[4]->cid != 100,
"wrong allocation cid");
- test_fail_if(alloc_test[4]->st_atu != 736,
+ test_fail_if(alloc_test[5]->st_atu != 877,
"wrong allocation st");
- test_fail_if(alloc_test[4]->et_atu != 846,
+ test_fail_if(alloc_test[5]->et_atu != 987,
"wrong allocation st");
- test_fail_if(alloc_test[4]->cid != 20,
+ test_fail_if(alloc_test[5]->cid != 20,
"wrong allocation cid");
- test_fail_if(alloc_test[5]->st_atu != 877,
+ test_fail_if(alloc_test[6]->st_atu != 1018,
"wrong allocation st");
- test_fail_if(alloc_test[5]->et_atu != 1112,
+ test_fail_if(alloc_test[6]->et_atu != 1253,
"wrong allocation st");
- test_fail_if(alloc_test[5]->cid != 60,
+ test_fail_if(alloc_test[6]->cid != 60,
"wrong allocation cid");
- test_fail_if(alloc_test[6]->st_atu != 1112,
+ test_fail_if(alloc_test[7]->st_atu != 1253,
"wrong allocation st");
- test_fail_if(alloc_test[6]->et_atu != 1292,
+ test_fail_if(alloc_test[7]->et_atu != 1429,
"wrong allocation st");
- test_fail_if(alloc_test[6]->cid != 80,
+ test_fail_if(alloc_test[7]->cid != 80,
"wrong allocation cid");
- test_fail_if(alloc_test[7]->st_atu != 1292,
+ test_fail_if(alloc_test[8]->st_atu != 1429,
"wrong allocation st");
- test_fail_if(alloc_test[7]->et_atu != 1590,
+ test_fail_if(alloc_test[8]->et_atu != 1727,
"wrong allocation st");
- test_fail_if(alloc_test[7]->cid != 30,
+ test_fail_if(alloc_test[8]->cid != 30,
"wrong allocation cid");
- test_fail_if(alloc_test[8]->st_atu != 1663,
+ test_fail_if(alloc_test[9]->st_atu != 1785,
"wrong allocation st");
- test_fail_if(alloc_test[8]->et_atu != 1793,
+ test_fail_if(alloc_test[9]->et_atu != 1915,
"wrong allocation st");
- test_fail_if(alloc_test[8]->cid != 10,
+ test_fail_if(alloc_test[9]->cid != 10,
"wrong allocation cid");
- test_fail_if(alloc_test[9]->st_atu != 1793,
+ test_fail_if(alloc_test[10]->st_atu != 1915,
"wrong allocation st");
- test_fail_if(alloc_test[9]->et_atu != 1988,
+ test_fail_if(alloc_test[10]->et_atu != 2110,
"wrong allocation st");
- test_fail_if(alloc_test[9]->cid != 50,
+ test_fail_if(alloc_test[10]->cid != 50,
"wrong allocation cid");
- test_fail_if(alloc_test[10]->st_atu != 2885,
+ test_fail_if(alloc_test[11]->st_atu != 3007,
"wrong allocation st");
- test_fail_if(alloc_test[10]->et_atu != 3405,
+ test_fail_if(alloc_test[11]->et_atu != 3527,
"wrong allocation st");
- test_fail_if(alloc_test[10]->cid != 70,
+ test_fail_if(alloc_test[11]->cid != 70,
"wrong allocation cid");
- test_fail_if(alloc_test[11]->st_atu != 3734,
+ test_fail_if(alloc_test[12]->st_atu != 3735,
"wrong allocation st");
- test_fail_if(alloc_test[11]->et_atu != 3788,
+ test_fail_if(alloc_test[12]->et_atu != 3773,
"wrong allocation st");
- test_fail_if(alloc_test[11]->cid != 90,
+ test_fail_if(alloc_test[12]->cid != 90,
"wrong allocation cid");
- test_fail_if(alloc_test[12]->st_atu != 3788,
+ test_fail_if(alloc_test[13]->st_atu != 3816,
"wrong allocation st");
- test_fail_if(alloc_test[12]->et_atu != 3896,
+ test_fail_if(alloc_test[13]->et_atu != 3896,
"wrong allocation st");
- test_fail_if(alloc_test[12]->cid != 40,
+ test_fail_if(alloc_test[13]->cid != 40,
"wrong allocation cid");
}
test_end;
@@ -634,11 +634,38 @@ test_case_allocate_proxy(test_t test)
}
void
+test_case_alloc_discover(test_t test)
+{
+ cp_t cp;
+ cp_cco_bw_alloc_t *discover_alloc;
+
+ cp_pwl_init(&cp);
+ cp_sta_mgr_init(&cp);
+ cp_cco_bw_init(&cp);
+
+ test_case_begin(test, "Proxy allocation");
+
+ cp_cco_bw_alloc_discover(&cp);
+
+ discover_alloc = cp_cco_bw_get_first_alloc_actual(&cp);
+
+ test_begin(test, "Proxy allocation")
+ {
+ test_fail_if(discover_alloc->st_atu != 0,
+ "Discover wrong st");
+ test_fail_if(discover_alloc->et_atu != 141,
+ "Discover wrong et");
+ }
+ test_end;
+}
+
+void
test_case_allocate_multiple_txop (test_t test)
{
cp_t cp;
- u16 nb_txop = 3;
- u16 nb_pb = 20;
+ cp_conn_t *conn[2];
+ cp_cco_bw_alloc_t *alloc_test[7];
+ u16 j;
cp_pwl_init(&cp);
cp_conn_mgr_init(&cp);
@@ -646,10 +673,40 @@ test_case_allocate_multiple_txop (test_t test)
cp_cco_bw_new_sched(&cp);
+ conn[1]= cp_conn_init_conn(&cp);
+ conn[1]->conn_info->cid = 200;
+ conn[1]->conn_info->cspec->f_qmp->av_nb_pb = 50;
+ conn[1]->conn_info->cspec->f_qmp->nb_txop = 2;
+ cp_conn_add_conn(&cp, conn[1]);
+
+ /*Init the BLEs*/
+ for(j=0;j<nb_ble;j++)
+ cp_link_push_ble(conn[1]->flink, ble_value[j], ble_end_time[j]);
+
+ conn[0]= cp_conn_init_conn(&cp);
+ conn[0]->conn_info->cid = 100;
+ conn[0]->conn_info->cspec->f_qmp->av_nb_pb = 100;
+ conn[0]->conn_info->cspec->f_qmp->nb_txop = 3;
+ cp_conn_add_conn(&cp, conn[0]);
+
+ /*Init the BLEs*/
+ for(j=0;j<nb_ble;j++)
+ cp_link_push_ble(conn[0]->flink, ble_value[j], ble_end_time[j]);
+
+ cp_cco_bw_alloc_sched(&cp);
+
+ alloc_test[0] = cp_cco_bw_get_first_alloc_actual(&cp);
+
+ for(j = 1 ; j < 7 ; j++)
+ alloc_test[j] = cp_cco_bw_get_next_alloc_actual(alloc_test[j-1]);
+
test_case_begin(test, "Allocation with multiple TXOPs");
test_begin(test, "multiple TXOPs")
{
+ test_fail_if(alloc_test[4]->cid != 200,"wrong allocation");
+ test_fail_if(alloc_test[5]->cid != 200,"wrong allocation");
+ test_fail_if(alloc_test[6]->cid != 0,"wrong allocation");
}
test_end;
@@ -666,12 +723,14 @@ main (void){
test_case_bw_init_new_sched (test);
test_case_allocate_proxy(test);
+ test_case_alloc_discover(test);
test_case_add_get_alloc(test);
-//test_case_allocate_multiple_txop (test);
INIT_TEST_COMPLETE_SCHEDULE(0);
+ test_case_allocate_multiple_txop (test);
+
test_case_complete_schedule (test);
for(i=0;i<nb_test;i++)
diff --git a/cesar/cp2/cco/bw/test/src/fsm_stub.c b/cesar/cp2/cco/bw/test/src/fsm_stub.c
new file mode 100644
index 0000000000..a2f607bd1c
--- /dev/null
+++ b/cesar/cp2/cco/bw/test/src/fsm_stub.c
@@ -0,0 +1,29 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/fsm_stub.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "cp2/fsm/fsm.h"
+
+static cp_fsm_event_t fsm_event;
+
+cp_fsm_event_t *
+cp_fsm_event_bare_new (cp_t *ctx, cp_fsm_event_type_t type)
+{
+ return &fsm_event;
+}
+
+void
+cp_fsm_post (cp_t *ctx, cp_fsm_event_t *event)
+{
+}