summaryrefslogtreecommitdiff
path: root/cesar/cp
diff options
context:
space:
mode:
authorNélio Laranjeiro2011-05-30 11:47:17 +0200
committerNélio Laranjeiro2011-06-01 14:25:55 +0200
commitd6bb308c4b569c1048ddd8d867ed2f8c29806b32 (patch)
tree30ffeb3b5a8ff849dd11dd7c1cd31aaec17653f0 /cesar/cp
parent26fba1b7ee9badb89ed25db1470e7d7d1cf68712 (diff)
cesar/cp/sta/mgr: use real mactotei table in unit tests, refs #442
Diffstat (limited to 'cesar/cp')
-rw-r--r--cesar/cp/sta/mgr/test/Makefile5
-rw-r--r--cesar/cp/sta/mgr/test/src/sta_mgr.c62
-rw-r--r--cesar/cp/sta/mgr/test/src/test_sta_mgr.c64
3 files changed, 22 insertions, 109 deletions
diff --git a/cesar/cp/sta/mgr/test/Makefile b/cesar/cp/sta/mgr/test/Makefile
index 03229a4995..c43b7d5326 100644
--- a/cesar/cp/sta/mgr/test/Makefile
+++ b/cesar/cp/sta/mgr/test/Makefile
@@ -6,6 +6,9 @@ HOST_PROGRAMS = test_sta_mgr
test_sta_mgr_SOURCES = core_stub.c net_test.c sar_stub.c sta_mgr.c \
sta-test.c station_test.c test_sta_mgr.c
test_sta_mgr_MODULES = lib cp/sta/mgr mac/common cp/fsm/stub \
- cp/cco/action/stub cl/stub bsu/stub cp/msg/stub
+ cp/cco/action/stub bsu/stub cp/msg/stub \
+ cl cl/stub
+
+cl_MODULE_SOURCES = cl_mactotei.c
include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/sta/mgr/test/src/sta_mgr.c b/cesar/cp/sta/mgr/test/src/sta_mgr.c
index 7d8d20db9e..702dc92292 100644
--- a/cesar/cp/sta/mgr/test/src/sta_mgr.c
+++ b/cesar/cp/sta/mgr/test/src/sta_mgr.c
@@ -982,23 +982,16 @@ test_case__cp_sta_mgr_set_our_avln__no_net (test_t test)
test_fail_unless (
MAC_TEI_IS_STA (cp.mac_config->partial_ack_tei_default));
- /* The table of the CL mac to tei as been stubbed for this test, the
- * real CL mactotei does not allow the user to get data as the
- * following instructions. To do some, use the functions API's in the
- * CL mactotei module. */
- cl_mactotei_t *table;
- table = (cl_mactotei_t*) cp.cl->mactotei;
for (i = 1; i < 4; i++)
{
sta_store = mac_store_sta_get (cp.mac_store, i);
sta = cp_sta_mgr_sta_get_assoc (&cp, net, i);
- test_fail_if (table[i-1].tei != i);
- test_fail_if (table[i-1].mac != i);
- test_fail_if (sta_store == NULL);
- test_fail_if (sta == NULL);
- test_fail_if (cp_sta_get_tei (sta) != table[i-1].tei);
- test_fail_if (cp_sta_get_mac_address (sta) != table[i-1].mac);
-
+ test_fail_if (cp_sta_get_tei (sta) != i);
+ test_fail_if (cp_sta_get_mac_address (sta) != i);
+ test_fail_unless (
+ cl_mactotei_table_find_tei_from_mac (cp.cl, i) == i);
+ test_fail_unless (sta_store);
+ test_fail_unless (sta);
slab_release (sta);
blk_release (sta_store);
}
@@ -1040,24 +1033,16 @@ test_case__cp_sta_mgr_set_our_avln__with_net (test_t test)
cp_sta_mgr_set_our_avln (&cp, net);
test_fail_unless (
MAC_TEI_IS_STA (cp.mac_config->partial_ack_tei_default));
-
-
- /* The table of the CL mac to tei as been stubbed for this test, the
- * real CL mactotei does not allow the user to get data as the
- * following instructions. To do some, use the functions API's in the
- * CL mactotei module. */
- cl_mactotei_t *table;
- table = (cl_mactotei_t*) cp.cl->mactotei;
for (i = 1; i < 4; i++)
{
sta_store = mac_store_sta_get (cp.mac_store, i);
sta = cp_sta_mgr_sta_get_assoc (&cp, net, i);
- test_fail_if (table[i-1].tei != i);
- test_fail_if (table[i-1].mac != i);
+ test_fail_unless (
+ cl_mactotei_table_find_tei_from_mac (cp.cl, i) == i);
test_fail_if (sta_store == NULL);
test_fail_if (sta == NULL);
- test_fail_if (cp_sta_get_tei (sta) != table[i-1].tei);
- test_fail_if (cp_sta_get_mac_address (sta) != table[i-1].mac);
+ test_fail_if (cp_sta_get_tei (sta) != i);
+ test_fail_if (cp_sta_get_mac_address (sta) != i);
slab_release (sta);
blk_release (sta_store);
@@ -1075,21 +1060,16 @@ test_case__cp_sta_mgr_set_our_avln__with_net (test_t test)
cp_sta_mgr_set_our_avln (&cp, net);
- /* The table of the CL mac to tei as been stubbed for this test, the
- * real CL mactotei does not allow the user to get data as the
- * following instructions. To do some, use the functions API's in the
- * CL mactotei module. */
- table = (cl_mactotei_t*) cp.cl->mactotei;
for (i = 1; i < 4; i++)
{
sta_store = mac_store_sta_get (cp.mac_store, i + 3);
sta = cp_sta_mgr_sta_get_assoc (&cp, net, i + 3);
- test_fail_if (table[i-1].tei != i + 3);
- test_fail_if (table[i-1].mac != i + 3);
+ test_fail_unless (
+ cl_mactotei_table_find_tei_from_mac (cp.cl, i+3) == i+3);
test_fail_if (sta_store == NULL);
test_fail_if (sta == NULL);
- test_fail_if (cp_sta_get_tei (sta) != table[i-1].tei);
- test_fail_if (cp_sta_get_mac_address (sta) != table[i-1].mac);
+ test_fail_if (cp_sta_get_tei (sta) != i + 3);
+ test_fail_if (cp_sta_get_mac_address (sta) != i + 3);
slab_release (sta);
blk_release (sta_store);
@@ -1130,22 +1110,16 @@ test_case__cp_sta_mgr_set_our_avln__with_net_to_unassoc (test_t test)
test_fail_unless (
MAC_TEI_IS_STA (cp.mac_config->partial_ack_tei_default));
- /* The table of the CL mac to tei as been stubbed for this test, the
- * real CL mactotei does not allow the user to get data as the
- * following instructions. To do some, use the functions API's in the
- * CL mactotei module. */
- cl_mactotei_t *table;
- table = (cl_mactotei_t*) cp.cl->mactotei;
for (i = 1; i < 4; i++)
{
sta_store = mac_store_sta_get (cp.mac_store, i);
sta = cp_sta_mgr_sta_get_assoc (&cp, net, i);
- test_fail_if (table[i-1].tei != i);
- test_fail_if (table[i-1].mac != i);
+ test_fail_unless (
+ cl_mactotei_table_find_tei_from_mac (cp.cl, i) == i);
test_fail_if (sta_store == NULL);
test_fail_if (sta == NULL);
- test_fail_if (cp_sta_get_tei (sta) != table[i-1].tei);
- test_fail_if (cp_sta_get_mac_address (sta) != table[i-1].mac);
+ test_fail_if (cp_sta_get_tei (sta) != i);
+ test_fail_if (cp_sta_get_mac_address (sta) != i);
slab_release (sta);
blk_release (sta_store);
diff --git a/cesar/cp/sta/mgr/test/src/test_sta_mgr.c b/cesar/cp/sta/mgr/test/src/test_sta_mgr.c
index 3cab4bdf25..f1b69ff15a 100644
--- a/cesar/cp/sta/mgr/test/src/test_sta_mgr.c
+++ b/cesar/cp/sta/mgr/test/src/test_sta_mgr.c
@@ -13,9 +13,6 @@
#include "common/std.h"
#include "cp/sta/mgr/test/test_sta_mgr.h"
-static cl_mactotei_t table[10];
-static uint table_index;
-
void
test_sta_mgr_init (cp_t *cp)
{
@@ -41,67 +38,6 @@ test_sta_mgr_uninit (cp_t *cp)
mac_store_uninit (cp->mac_store);
}
-/**
- * Create a new table to be filled by the CP.
- *
- * \return a pointer to the new block to be fill with the mac to tei table
- * data
- */
-cl_mactotei_blk_t *
-cl_mactotei_new (void)
-{
- memset (table, 0, sizeof (table));
- table_index = 0;
- return (cl_mactotei_blk_t *) &table;
-}
-
-/**
- * Add a new tupple of data to the table.
- *
- * \param table the table pointer to add a new mac to tei correspondance.
- * \param mac_addr the mac addr to add
- * \param tei the tei corresponding to the STA.
- * \param tag the CP tag provide to indentifier a network.
- */
-void cl_mactotei_addr_add (cl_mactotei_blk_t *table, mac_t mac_addr,
- uint tei, uint tag)
-{
- cl_mactotei_t *curr;
-
- curr = (cl_mactotei_t*) table;
- curr[table_index].tag = tag;
- curr[table_index].tei = tei;
- curr[table_index].mac = mac_addr;
- table_index ++;
-}
-
-/**
- * Request the CL to use the new table and remove the old one.
- *
- * \param ctx the CL context
- * \param table the new table to use.
- */
-void
-cl_mactotei_use_table (cl_t *ctx, cl_mactotei_blk_t *table)
-{
- dbg_assert (table);
- dbg_assert (ctx);
-
- ctx->mactotei = (cl_mactotei_table_t *) table;
-}
-
-/**
- * Release the complete table from the memory.
- *
- * \param ctx the convergence layer context
- */
-void cl_mactotei_release_table (cl_t *ctx)
-{
- dbg_assert (ctx);
- memset (table, 0, sizeof (table));
- ctx->mactotei = NULL;
-}
-
void
test_suite_sta_mgr (test_t test);