summaryrefslogtreecommitdiff
path: root/cesar/cp2/cco/bw/test
diff options
context:
space:
mode:
authorboure2008-05-23 11:39:48 +0000
committerboure2008-05-23 11:39:48 +0000
commita69edde568317fc291fd9eeac676605258a7f7fc (patch)
treeaed03628d4eef6481b083ee329d6dfff90a53fe8 /cesar/cp2/cco/bw/test
parent942f7d1fd967238abab8767d8e2d48f1f0ce5504 (diff)
inversion complete de fichier restoration de la version antérieure
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2083 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp2/cco/bw/test')
-rw-r--r--cesar/cp2/cco/bw/test/src/bw_list_alloc_test.c307
1 files changed, 59 insertions, 248 deletions
diff --git a/cesar/cp2/cco/bw/test/src/bw_list_alloc_test.c b/cesar/cp2/cco/bw/test/src/bw_list_alloc_test.c
index 48eba3e4ac..7fc40c53d1 100644
--- a/cesar/cp2/cco/bw/test/src/bw_list_alloc_test.c
+++ b/cesar/cp2/cco/bw/test/src/bw_list_alloc_test.c
@@ -1,4 +1,4 @@
- /* Cesar project {{{
+/* Cesar project {{{
*
* Copyright (C) 2008 Spidcom
*
@@ -6,284 +6,95 @@
*
* }}} */
/**
- * \file bw.c
- * \brief bandwidth manager module
- * \ingroup cp2_cco_bw
+ * \file src/beacon_schedules.c
+ * \brief Test the beacon schedules list.
+ * \ingroup cp2_beacon
*
- * Control the schedule of the becon period
*/
#include "common/std.h"
-#include "lib/blk.h"
+#include "lib/set.h"
#include "lib/test.h"
-#include "string.h"
-
-#include "lib/bitstream.h"
-
-#include "cp2/cco/bw/bw.h"
-#include "cp2/cco/bw/bw_prio_heap.h"
-
-#include "cp2/conn/conn.h"
-#include "cp2/cp.h"
-#include "cp2/inc/context.h"
+#include "lib/blk.h"
-#include "lib/list.h"
+#include "cp2/cco/bw/bw_lib_alloc.h"
-/**
- * Test the initialisation of the prio heaps
- * \param test test paramters
+/**
+ * Add a node to the set.
+ * \param test the test object.
*
- *
+ * Test at the same time:
+ * - Init function
+ * - uninit function
+ * - get first.
+ * - get next.
*/
-
void
-test_case_bw_prio_heap_init (test_t test)
+test_case_bw_schedules_add (test_t test)
{
+ set_t set;
+ cp_cco_bw_alloc_conn_t *alloc;
- cp_cco_bw_prio_heap_t *heap[4];
- cp_t cp;
+ cp_cco_bw_schedules_init (&set);
- test_case_begin (test, "Init prio heaps");
+ alloc = blk_alloc();
+ alloc->st_atu = 10;
+ alloc->et_atu = 13;
+ alloc->stpf = true;
+ alloc->glid = 1;
- cp_cco_bw_init(&cp);
+ cp_cco_bw_schedules_add (&set, alloc);
+ alloc = NULL;
- heap[3] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_begin(cp.bw.prio_heap));
- heap[2] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap[3]->node));
- heap[1] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap[2]->node));
- heap[0] = PARENT_OF(cp_cco_bw_prio_heap_t,
- node,
- list_next(&heap[1]->node));
-
- test_begin(test,"Init prio heaps"){
- test_fail_if(heap[3]->nb_conn_allocated != 0,
- "There shouldn't be any connection allocated") ;
- test_fail_if(heap[3]->nb_conn != 0,
- "There shouldn't be any connection");
- test_fail_if(heap[3]->table_priority_level != 3,
- "The priority is false");
- test_fail_if(heap[0]->table_priority_level != 0,
- "The heaps aren't well linked");
- }
- test_end;
-}
-/**
- * Test the initialisation of the prio heaps
- * \param test test paramters
- *
- *
- */
+ alloc = blk_alloc();
+ alloc->et_atu = 15;
+ alloc->stpf = false;
+ alloc->glid = 2;
-void
-test_case_bw_prio_heap_uninit (test_t test)
-{
+ cp_cco_bw_schedules_add (&set, alloc);
+ alloc = NULL;
- cp_cco_bw_prio_heap_t *heap[4];
- cp_t cp;
- test_case_begin (test, "Init prio heaps");
+ test_case_begin (test, "Add a node");
- cp_cco_bw_init(&cp);
- cp_cco_bw_uninit(&cp);
-
- test_begin(test,"Init prio heaps"){
- test_fail_if(list_empty(cp.bw.prio_heap),
- "Tbe ") ;
- test_fail_if(heap[3]->nb_conn != 0,
- "There shouldn't be any connection");
- test_fail_if(heap[3]->table_priority_level != 3,
- "The priority is false");
- test_fail_if(heap[0]->table_priority_level != 0,
- "The heaps aren't well linked");
+ test_begin (test, "Get the node")
+ {
+ alloc = cp_cco_bw_schedules_get_first (&set);
+ test_fail_if (alloc == NULL, "shall exist");
+ test_fail_if (alloc->st_atu != 10, "Wrong start time");
+ test_fail_if (alloc->et_atu != 13, "Wrong end time");
+ test_fail_if (alloc->glid != 1, "Wrong GLID");
+ test_fail_if (alloc->stpf != true, "Wrong stpf");
+
+ alloc = cp_cco_bw_schedules_get_next (&set, alloc);
+ test_fail_if (alloc == NULL, "shall exist");
+ test_fail_if (alloc->et_atu != 15, "Wrong end time");
+ test_fail_if (alloc->glid != 2, "Wrong GLID");
+ test_fail_if (alloc->stpf != false, "Wrong stpf");
}
test_end;
-}
-
-void
-test_case_bw_prio_heap_add_conns (test_t test)
-{
-
-/* cp_cco_bw_prio_heap_t *prio_heap;
- cp_cco_bw_prio_heap_t *heaps[4];
- cp_t *ctx;
-
- u8 cid[3][4];
- u8 prio[4];
- int i;
- int j;
- ctx = (cp_t*)blk_alloc();
-
- cp_cco_bw_prio_heap_init(ctx);
-
- heaps[3] = prio_heap;
- heaps[2] = prio_heap->next_heap;
- heaps[1] = prio_heap->next_heap->next_heap;
- heaps[0] = prio_heap->next_heap->next_heap->next_heap;
- test_case_begin (test, "Add connections into prio heaps");
-
- for(i=0;i<4;i++){
- for(j=0;j<3;j++)
- cid[j][i] = (i*10)+j;
- prio[i] = i;
- }
- for(i=0;i<4;i++)
- for(j=0;j<3;j++)
- cp_cco_bw_prio_heap_add_conn(prio_heap,cid[j][i],prio[i]);
-
- test_begin(test,"add connection into prio heaps"){
- test_fail_if(heaps[3]->first_conn->cid != 30,
- "failure add : cid prio 3 conn 0"); */
- /* test_fail_if(heaps[2]->first_conn->next_conn->cid != 21,
- "failure add :cid prio 2 conn 1");
- test_fail_if(heaps[1]->first_conn->next_conn->next_conn->cid != 12,
- "failure add :cid prio 1 conn 2");
- test_fail_if(heaps[0]->first_conn->next_conn->next_conn->cid != 02,
- "failure add :cid prio 0 conn 2");*/
- // }
- // test_end;
+ cp_cco_bw_schedules_uninit (&set);
}
-void
-test_case_bw_prio_heap_del_conns (test_t test){
-
- /* cp_cco_bw_prio_heap_t *prio_heap;
- cp_cco_bw_prio_heap_t *heaps[4];
-
- u8 cid[3][4];
- u8 prio[4];
- int i;
- int j;
-
- ctx = (cp_t*)blk_alloc();
- ctx = (cp_t*)blk_alloc();
- prio_heap = cp_cco_bw_prio_heap_init();
-
- heaps[3] = prio_heap;
- heaps[2] = prio_heap->next_heap;
- heaps[1] = prio_heap->next_heap->next_heap;
- heaps[0] = prio_heap->next_heap->next_heap->next_heap;
-
- for(i=0;i<4;i++){
- for(j=0;j<3;j++)
- cid[j][i] = (i*10)+j;
- prio[i] = i;
- }
- for(i=0;i<4;i++)
- for(j=0;j<3;j++)
- cp_cco_bw_prio_heap_add_conn(prio_heap,cid[j][i],prio[i]);
-
- test_case_begin (test, "\nDel connections into prio heaps\n\n");
-
- //Del all add 1st
- cp_cco_bw_prio_heap_del_conn(prio_heap,30);
- cp_cco_bw_prio_heap_del_conn(prio_heap,31);
- cp_cco_bw_prio_heap_del_conn(prio_heap,32);
- cp_cco_bw_prio_heap_add_conn(prio_heap,35,3);
-
- //Add last remove all firsts
- cp_cco_bw_prio_heap_add_conn(prio_heap,25,2);
- cp_cco_bw_prio_heap_del_conn(prio_heap,20);
- cp_cco_bw_prio_heap_del_conn(prio_heap,21);
- cp_cco_bw_prio_heap_del_conn(prio_heap,22);
-
- //Del Last add Last
- cp_cco_bw_prio_heap_del_conn(prio_heap,12);
- cp_cco_bw_prio_heap_add_conn(prio_heap,12,1);
-
- //Del first add last
- cp_cco_bw_prio_heap_del_conn(prio_heap,0);
- cp_cco_bw_prio_heap_add_conn(prio_heap,0,0);
-
-
- test_begin(test,"Del connection into prio heaps"){
- test_fail_if(heaps[3]->first_conn->cid != 35,
- "failure remove all conn + add 1st");
- test_fail_if(heaps[2]->first_conn->cid != 25,
- "failure add 1 remove all");
-*/ /* test_fail_if(heaps[1]->first_conn->next_conn->next_conn->cid != 12,
- "failure remove last add last");
- test_fail_if(heaps[0]->first_conn->next_conn->next_conn->cid != 0,
- "failure remove first add last");*/
- //}
- //test_end;
-}
-
-void
-test_case_bw_prio_get_most_prior_conn (test_t test){
-
- /* cp_cco_bw_prio_heap_t *prio_heap;
- cp_cco_bw_prio_heap_t *heaps[4];
-
- u8 most_prior_conn[5];
-
- prio_heap = cp_cco_bw_prio_heap_init();
-
- heaps[3] = prio_heap;
- heaps[2] = prio_heap->next_heap;
- heaps[1] = prio_heap->next_heap->next_heap;
- heaps[0] = prio_heap->next_heap->next_heap->next_heap;
-
- test_case_begin(test, "\nGet most prior conn");
-
- most_prior_conn[0] = cp_cco_bw_prio_heap_get_most_prior_conn(prio_heap);
-
- cp_cco_bw_prio_heap_add_conn(prio_heap,1,0);
-
- most_prior_conn[1] = cp_cco_bw_prio_heap_get_most_prior_conn(prio_heap);
-
- cp_cco_bw_prio_heap_add_conn(prio_heap,2,0);
- cp_cco_bw_prio_heap_add_conn(prio_heap,3,0);
-
- most_prior_conn[2] = cp_cco_bw_prio_heap_get_most_prior_conn(prio_heap);
+int
+main (void)
+{
+ test_t test;
- cp_cco_bw_prio_heap_add_conn(prio_heap,10,1);
- cp_cco_bw_prio_heap_add_conn(prio_heap,20,2);
- cp_cco_bw_prio_heap_add_conn(prio_heap,21,2);
+ test_init (test, 0, NULL);
- most_prior_conn[3] = cp_cco_bw_prio_heap_get_most_prior_conn(prio_heap);
-
- cp_cco_bw_prio_heap_add_conn(prio_heap,30,3);
- cp_cco_bw_prio_heap_add_conn(prio_heap,31,3);
- cp_cco_bw_prio_heap_add_conn(prio_heap,32,3);
+ test_case_bw_schedules_add (test);
- most_prior_conn[4] = cp_cco_bw_prio_heap_get_most_prior_conn(prio_heap);
-
- test_begin(test,"Get most prior conn")
+ test_case_begin (test, "Memory allocation");
+ test_begin (test, "memory leaks")
{
- */ /* test_fail_if(most_prior_conn[0] != NULL,
- "There shouldn't be any connection"); */
- /* test_fail_if(most_prior_conn[1] != 1,
- "Only one connection");
- test_fail_if(most_prior_conn[2] != 1,
- "First conn not prior");
- test_fail_if(most_prior_conn[3] != 20,
- "Priority 2 first element shoud be prior");
- test_fail_if(most_prior_conn[4] != 30,
- "Priority 3 first element shoul be prior");
+ test_fail_if (blk_check_memory () != true, "Memory leaks");
}
- test_end;*/
-}
-
-int
-main (void){
- test_t test;
-
- test_init(test, 0, NULL);
-
- test_case_bw_prio_heap_init (test);
- test_case_bw_prio_heap_uninit (test);
- // test_case_bw_prio_heap_add_conns (test);
- // test_case_bw_prio_heap_del_conns (test);
- // test_case_bw_prio_get_most_prior_conn (test);
+ test_end;
test_result (test);
HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
return test_nb_failed (test) == 0 ? 0 : 1;
-
}
+