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.c123
1 files changed, 104 insertions, 19 deletions
diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c
index 629bbcd206..12a0498da5 100644
--- a/cesar/bsu/test/utest/src/bsut.c
+++ b/cesar/bsu/test/utest/src/bsut.c
@@ -108,34 +108,117 @@ test_case_bsu_process (test_t test)
}
void
+test_case_bsu_update_init (bsu_test_t *test, bsu_beacon_t *beacon)
+{
+ uint i;
+ bsu_test_create_beacon (test, beacon);
+ bsu_test_create_beacon (test, &test->bsu->beacon);
+ for (i = 0; i < COUNT (test->bsu->aclf->bpsd); i++)
+ test->bsu->aclf->bpsd[i] = i * BSU_ACLF_BP_50HZ_TCK;
+ beacon->beacon_period_start_date =
+ bsu_aclf_beacon_period_start_date_next (test->bsu->aclf)
+ - BSU_ACLF_BP_50HZ_TCK;
+}
+
+void
test_case_bsu_update (test_t test)
{
+ bsu_test_t t;
+ bsu_beacon_t beacon;
+ bsu_test_init (&t);
test_case_begin (test, "BSU Update");
- test_begin (test, "update bsu")
+ test_begin (test, "update BSU in time")
{
- 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;
+ bsu_test_create_beacon (&t, &beacon);
+ beacon.beacon_period_start_date =
+ bsu_aclf_beacon_period_start_date_next (t.bsu->aclf);
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 (memcmp (&t.bsu->beacon, &beacon,
+ sizeof (bsu_beacon_t)) == 0);
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 (memcmp (&t.bsu->beacon, &beacon,
+ sizeof (bsu_beacon_t)) == 0);
test_fail_unless (t.bsu->is_sta == false);
- bsu_test_uninit (&t);
}
test_end;
+ test_begin (test, "Old data")
+ {
+ test_case_bsu_update_init (&t, &beacon);
+ t.bsu->is_sta = false;
+ t.bsu->beacon.bmis.ps.ps[0].pscd--;
+ t.bsu->beacon.bmis.ps.ps[1].pscd--;
+ bsu_update (&beacon, true /* is station. */);
+ test_fail_unless (memcmp (&t.bsu->beacon, &beacon,
+ sizeof (bsu_beacon_t)) != 0);
+ test_fail_unless (t.bsu->is_sta == true);
+ }
+ test_end;
+ test_begin (test, "New persistent schedule")
+ {
+ test_case_bsu_update_init (&t, &beacon);
+ t.bsu->beacon.bmis.ps.nb = 1;
+ bsu_update (&beacon, true /* is station. */);
+ /* Only the second schedules should be touched by the function. */
+ t.bsu->beacon.bmis.ps.ps[1].pscd++;
+ test_fail_unless (t.bsu->beacon.bmis.ps.nb == beacon.bmis.ps.nb);
+ uint i;
+ for (i = 0; i < beacon.bmis.ps.nb; i++)
+ {
+ test_fail_unless (t.bsu->beacon.bmis.ps.ps[i].cscd
+ == beacon.bmis.ps.ps[i].cscd);
+ test_fail_unless (t.bsu->beacon.bmis.ps.ps[i].pscd
+ == beacon.bmis.ps.ps[i].pscd);
+ }
+ }
+ test_end;
+ test_begin (test, "Beacon entries without countdown.")
+ {
+ test_case_bsu_update_init (&t, &beacon);
+ t.bsu->beacon.bmis.mac_address_present.present = false;
+ t.bsu->beacon.bmis.discover.present = false;
+ t.bsu->beacon.bmis.discover_info.present = false;
+ t.bsu->beacon.bmis.bpsto.present = false;
+ t.bsu->beacon.bmis.nps.ns = 0;
+ t.bsu->beacon.bmis.region.nb = 0;
+ bsu_update (&beacon, true /* is station. */);
+ test_fail_unless (t.bsu->beacon.bmis.mac_address_present.present ==
+ true);
+ test_fail_unless (t.bsu->beacon.bmis.discover.present == true);
+ test_fail_unless (t.bsu->beacon.bmis.discover_info.present == true);
+ test_fail_unless (t.bsu->beacon.bmis.bpsto.present == true);
+ test_fail_unless (t.bsu->beacon.bmis.nps.ns == beacon.bmis.nps.ns);
+ test_fail_unless (t.bsu->beacon.bmis.region.nb ==
+ beacon.bmis.region.nb);
+ }
+ test_end;
+ test_begin (test, "Beacon entries with countdown.")
+ {
+ test_case_bsu_update_init (&t, &beacon);
+ t.bsu->beacon.bmis.eks.present = false;
+ t.bsu->beacon.bmis.handover.present = false;
+ t.bsu->beacon.bmis.relocation.present = false;
+ t.bsu->beacon.bmis.aclsc.present = false;
+ t.bsu->beacon.bmis.cns.present = false;
+ t.bsu->beacon.bmis.change_hm.present = false;
+ t.bsu->beacon.bmis.change_snid.present = false;
+ t.bsu->beacon.bmis.mac_address_present.present = false;
+ bsu_update (&beacon, true /* is station. */);
+ test_fail_unless (t.bsu->beacon.bmis.eks.present == true);
+ test_fail_unless (t.bsu->beacon.bmis.handover.present == true);
+ test_fail_unless (t.bsu->beacon.bmis.relocation.present == true);
+ test_fail_unless (t.bsu->beacon.bmis.aclsc.present == true);
+ test_fail_unless (t.bsu->beacon.bmis.cns.present == true);
+ test_fail_unless (t.bsu->beacon.bmis.change_hm.present == true);
+ test_fail_unless (t.bsu->beacon.bmis.change_snid.present == true);
+ test_fail_unless (t.bsu->beacon.bmis.mac_address_present.present
+ == true);
+ }
+ test_end;
+ bsu_test_uninit (&t);
}
void
@@ -185,6 +268,8 @@ test_case_bsu_timer_event (test_t test)
bsu_test_create_beacon (&t, &beacon);
/* First case, update beacon in time. */
bsu_test_upper_layer_beacon_received_init (&t);
+ beacon.beacon_period_start_date =
+ bsu_aclf_beacon_period_start_date_next (t.bsu->aclf);
bsu_update (&beacon, false /* CCo */);
bsu_timer_event_process (t.bsu);
test_fail_unless (t.ul.beacon != INVALID_PTR);
@@ -199,7 +284,7 @@ test_case_bsu_timer_event (test_t test)
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;
+ 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);
@@ -211,10 +296,10 @@ test_case_bsu_timer_event (test_t test)
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);
+ == 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 ==
+ == t.bsu->beacon.bmis.ps.ps[j].cscd);
+ test_fail_unless (t.bsu->beacon.bmis.ps.nb ==
cmp_avln.bs.schedules.ps.nb);
}
}