summaryrefslogtreecommitdiff
path: root/cesar/bsu/test/utest
diff options
context:
space:
mode:
authorlaranjeiro2010-05-17 09:08:26 +0000
committerlaranjeiro2010-05-17 09:08:26 +0000
commitb0d8a572256a6403d414b74fcb0190ff38cf78f4 (patch)
treeef98e94c0c769ea4a08e1f476d5d846f9235143e /cesar/bsu/test/utest
parent6ec835482cf758b3c565b753a15fac89daa605e0 (diff)
cesar/bsu: test timer_event and update functions
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7021 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/bsu/test/utest')
-rw-r--r--cesar/bsu/test/utest/Config1
-rw-r--r--cesar/bsu/test/utest/src/bsut.c130
-rw-r--r--cesar/bsu/test/utest/src/tests.c9
-rw-r--r--cesar/bsu/test/utest/tests.h7
4 files changed, 147 insertions, 0 deletions
diff --git a/cesar/bsu/test/utest/Config b/cesar/bsu/test/utest/Config
index dbdade324f..66476d3ef6 100644
--- a/cesar/bsu/test/utest/Config
+++ b/cesar/bsu/test/utest/Config
@@ -1 +1,2 @@
CONFIG_DEBUG_FATAL_CATCH=y
+CONFIG_RESTRACK=y
diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c
index c1bd688c9f..e394f93d6e 100644
--- a/cesar/bsu/test/utest/src/bsut.c
+++ b/cesar/bsu/test/utest/src/bsut.c
@@ -19,6 +19,12 @@
#include "bsu/inc/context.h"
void
+bsu_timer_event_process (void *ud);
+
+void
+bsu_avln_schedules_beacon_not_received (bsu_t *ctx, bsu_avln_t *avln);
+
+void
test_case_bsu_process (test_t test)
{
bsu_test_t t;
@@ -101,8 +107,132 @@ test_case_bsu_process (test_t test)
}
void
+test_case_bsu_update (test_t test)
+{
+ test_case_begin (test, "BSU Update");
+ test_begin (test, "update bsu")
+ {
+ bsu_test_t t;
+ bsu_beacon_t beacon;
+ bsu_test_init (&t);
+ beacon.beacon_period_start_date = phy_date (t.bsu->phy) + 1000000;
+ t.bsu->beacon = INVALID_PTR;
+ t.bsu->is_sta = false;
+ bsu_update (&beacon, true /* is station. */);
+ test_fail_unless (t.bsu->beacon == &beacon);
+ test_fail_unless (t.bsu->beacon->beacon_period_start_date
+ == phy_date (t.bsu->phy));
+ test_fail_unless (t.bsu->is_sta == true);
+ /* Change station situation. */
+ t.bsu->beacon = INVALID_PTR;
+ t.bsu->is_sta = true;
+ beacon.beacon_period_start_date = phy_date (t.bsu->phy) + 1000000;
+ bsu_update (&beacon, false /* is CCo. */);
+ test_fail_unless (t.bsu->beacon == &beacon);
+ test_fail_unless (t.bsu->beacon->beacon_period_start_date
+ == phy_date (t.bsu->phy));
+ test_fail_unless (t.bsu->is_sta == false);
+ bsu_test_uninit (&t);
+ }
+ test_end;
+}
+
+void
+test_case_bsu_timer_event (test_t test)
+{
+ test_case_begin (test, "Timer event called");
+ test_begin (test, "STA")
+ {
+ uint i, j;
+ bsu_test_t t;
+ bsu_avln_t cmp_avln;
+ bsu_test_init (&t);
+ bsu_test_avln_create (&t, &t.bsu->sta_avln);
+ bsu_test_avln_create (&t, &cmp_avln);
+ for (i = 0; i < BSU_ACLF_BPSD_NB; i++)
+ t.bsu->aclf.bpsd[i] = i * BSU_ACLF_BP_50HZ_TCK;
+ t.bsu->is_sta = true;
+ for (j = 0; j < 10; j++)
+ {
+ bsu_timer_event_process (t.bsu);
+ bsu_avln_schedules_beacon_not_received (t.bsu, &cmp_avln);
+ for (i = 0; i < BSU_ACLF_BPSD_NB; i++)
+ test_fail_unless (
+ t.bsu->aclf.bpsd[i] = (i+j+1) * BSU_ACLF_BP_50HZ_TCK);
+ for (i = 0; i < cmp_avln.bs.schedules.ps.nb; i++)
+ {
+ test_fail_unless (t.bsu->sta_avln.bs.schedules.ps.ps[i].pscd
+ == cmp_avln.bs.schedules.ps.ps[i].pscd);
+ test_fail_unless (t.bsu->sta_avln.bs.schedules.ps.ps[i].cscd
+ == cmp_avln.bs.schedules.ps.ps[i].cscd);
+ }
+ }
+ bsu_test_uninit (&t);
+ }
+ test_end;
+ test_begin (test, "CCo")
+ {
+ bsu_test_t t;
+ bsu_beacon_t beacon;
+ mfs_t *mfs;
+ uint i,j;
+ bsu_avln_t cmp_avln;
+ bsu_test_init (&t);
+ bsu_test_avln_create (&t, &cmp_avln);
+ for (i = 0; i < BSU_ACLF_BPSD_NB; i++)
+ t.bsu->aclf.bpsd[i] = i * BSU_ACLF_BP_50HZ_TCK;
+ bsu_test_create_beacon (&t, &beacon);
+ /* First case, update beacon in time. */
+ bsu_test_upper_layer_beacon_received_init (&t);
+ bsu_update (&beacon, false /* CCo */);
+ bsu_timer_event_process (t.bsu);
+ test_fail_unless (t.ul.beacon != INVALID_PTR);
+ test_fail_unless (t.ul.pparams != INVALID_PTR);
+ test_fail_unless (t.ul.bparams != INVALID_PTR);
+ /* Release the reference handled by the CP. */
+ blk_release_desc ((blk_t*) t.ul.beacon);
+ mfs = mac_store_mfs_get (t.mac_store, true, true, false,
+ MAC_LID_SPC_CENTRAL, MAC_TEI_BCAST);
+ mfs->tx.head = NULL;
+ test_fail_unless (mfs != NULL);
+ blk_release (mfs);
+ /* Second case, beacon not updated. */
+ bsu_test_upper_layer_beacon_received_init (&t);
+ t.bsu->beacon->beacon_period_start_date = t.bsu->aclf.bpsd[0] - 1;
+ for (i = 0; i < 7; i++)
+ {
+ bsu_avln_schedules_beacon_not_received (t.bsu, &cmp_avln);
+ bsu_timer_event_process (t.bsu);
+ test_fail_unless (t.ul.beacon != INVALID_PTR);
+ test_fail_unless (t.ul.pparams != INVALID_PTR);
+ test_fail_unless (t.ul.bparams != INVALID_PTR);
+ blk_release_desc ((blk_t*) t.ul.beacon);
+ for (j = 0; j < cmp_avln.bs.schedules.ps.nb; j++)
+ {
+ test_fail_unless (cmp_avln.bs.schedules.ps.ps[j].pscd
+ == t.bsu->beacon->bmis.ps.ps[j].pscd);
+ test_fail_unless (cmp_avln.bs.schedules.ps.ps[j].cscd
+ == t.bsu->beacon->bmis.ps.ps[j].cscd);
+ test_fail_unless (t.bsu->beacon->bmis.ps.nb ==
+ cmp_avln.bs.schedules.ps.nb);
+ }
+ }
+ mfs = mac_store_mfs_get (t.mac_store, true, true, false,
+ MAC_LID_SPC_CENTRAL, MAC_TEI_BCAST);
+ test_fail_unless (mfs != NULL);
+ /* Release MFS. */
+ mac_store_mfs_remove (t.mac_store, mfs);
+ blk_release (mfs);
+ bsu_test_uninit (&t);
+ }
+ test_end;
+}
+
+void
test_suite_bsu (test_t t)
{
test_suite_begin (t, "BSU test");
test_case_bsu_process (t);
+ test_case_bsu_update (t);
+ test_case_bsu_timer_event (t);
}
diff --git a/cesar/bsu/test/utest/src/tests.c b/cesar/bsu/test/utest/src/tests.c
index 06c9d05a4b..caf2b50a13 100644
--- a/cesar/bsu/test/utest/src/tests.c
+++ b/cesar/bsu/test/utest/src/tests.c
@@ -31,6 +31,15 @@ bsu_test_upper_layer_beacon_received (void *ctx, pb_beacon_t *beacon,
}
void
+bsu_test_upper_layer_beacon_received_init (bsu_test_t *ctx)
+{
+ dbg_assert (ctx);
+ ctx->ul.beacon = INVALID_PTR;
+ ctx->ul.pparams = INVALID_PTR;
+ ctx->ul.bparams = INVALID_PTR;
+}
+
+void
bsu_test_init (bsu_test_t *ctx)
{
dbg_assert (ctx);
diff --git a/cesar/bsu/test/utest/tests.h b/cesar/bsu/test/utest/tests.h
index 22701e2e3d..0ff9a39460 100644
--- a/cesar/bsu/test/utest/tests.h
+++ b/cesar/bsu/test/utest/tests.h
@@ -82,6 +82,13 @@ typedef struct bsu_test_t bsu_test_t;
BEGIN_DECLS
/**
+ * Initialise the upper layer stub to INVALID_PTR.
+ * \param ctx the test module context.
+ */
+void
+bsu_test_upper_layer_beacon_received_init (bsu_test_t *ctx);
+
+/**
* Initialise the test unit.
* \param ctx the tests context.
*/