summaryrefslogtreecommitdiff
path: root/cesar/bsu/test/utest/src/bsut.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/bsu/test/utest/src/bsut.c')
-rw-r--r--cesar/bsu/test/utest/src/bsut.c130
1 files changed, 130 insertions, 0 deletions
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);
}