summaryrefslogtreecommitdiff
path: root/cesar/bsu/test
diff options
context:
space:
mode:
authorYacine Belkadi2013-04-02 17:38:42 +0200
committerYacine Belkadi2013-05-22 10:53:37 +0200
commit46b9d84d9dfca1a27cea6f3b85af148cd72a2434 (patch)
treeed6cf26bf8bbb5a634b6ce758d7fad484160d271 /cesar/bsu/test
parent21ef1bf39c7cbbeff2c333e74b24c8ad426006e3 (diff)
cesar/{bsu,cp}/beacon: make bsu send a fake beacon to cp when no beacon is received
On a Sta, when an expected beacon is not received, make the bsu send a fake beacon to the cp. This allows the bsu to communicate with the cp when no beacon is received, and will be used in following commits.
Diffstat (limited to 'cesar/bsu/test')
-rw-r--r--cesar/bsu/test/utest/src/bsut.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c
index e82cb6b761..0edc94d8c3 100644
--- a/cesar/bsu/test/utest/src/bsut.c
+++ b/cesar/bsu/test/utest/src/bsut.c
@@ -641,6 +641,8 @@ test_case_bsu_timer_event_cco_ucco (test_t test, bsu_test_t *t,
cmp_avln.beacon.vf.nm = MAC_NM_UNCOORDINATED;
bsu_timer_event_process (t->bsu);
test_fail_unless (t->ul.beacon != INVALID_PTR);
+ test_fail_unless (t->ul.beacon->params.direction
+ == BSU_BEACON_DIRECTION_TO_PLC);
test_fail_unless (t->ul.beacon->next == NULL);
/* Release the reference handled by the CP. */
blk_release (t->ul.beacon);
@@ -660,6 +662,8 @@ test_case_bsu_timer_event_cco_ucco (test_t test, bsu_test_t *t,
bsu_avln_schedules_decrease_countdown (t->bsu, &cmp_avln);
bsu_timer_event_process (t->bsu);
test_fail_unless (t->ul.beacon != INVALID_PTR);
+ test_fail_unless (t->ul.beacon->params.direction
+ == BSU_BEACON_DIRECTION_TO_PLC);
blk_release (t->ul.beacon);
for (j = 0; j < cmp_avln.beacon.bmis.ps.nb; j++)
{
@@ -720,10 +724,64 @@ test_case_bsu_timer_event (test_t test)
test_fail_unless (t.bsu->sta_avln->beacon.bmis.ps.ps[i].cscd
== cmp_avln.beacon.bmis.ps.ps[i].cscd);
}
+ /* Fake beacon sent to the upper layer (i.e. the cp)? */
+ test_fail_unless (t.ul.beacon != INVALID_PTR);
+ test_fail_unless (t.ul.beacon->params.direction
+ == BSU_BEACON_DIRECTION_FROM_BSU);
+ blk_release (t.ul.beacon);
+ t.ul.beacon = INVALID_PTR;
}
bsu_test_uninit (&t);
}
test_end;
+ test_begin (test, "STA:Fake beacon from bsu:PLC beacon received")
+ {
+ bsu_test_t t;
+ bsu_test_init (&t);
+ bsu_activate (t.bsu, true);
+ bsu_beacon_t beacon;
+ bsu_test_create_beacon (&t, &beacon);
+ bsu_update (t.bsu, &beacon, BSU_UPDATE_STA_TYPE_STA);
+ t.phy->phy_date = 0;
+ t.bsu->sta_avln->sync.init = true;
+
+ u32 bpsd0;
+ bsu_aclf_beacon_period_start_date (t.bsu->aclf, &bpsd0, 1);
+ t.bsu->sta_avln->beacon.beacon_period_start_date = bpsd0 + 1;
+
+ bsu_timer_event_process (t.bsu);
+
+ test_fail_unless (t.ul.beacon == INVALID_PTR);
+ bsu_test_uninit (&t);
+ }
+ test_end;
+ test_begin (test, "STA:Fake beacon from bsu:PLC beacon not received")
+ {
+ bsu_test_t t;
+ bsu_test_init (&t);
+ bsu_activate (t.bsu, true);
+ bsu_beacon_t beacon;
+ bsu_test_create_beacon (&t, &beacon);
+ bsu_update (t.bsu, &beacon, BSU_UPDATE_STA_TYPE_STA);
+ t.phy->phy_date = 0;
+ t.bsu->sta_avln->sync.init = true;
+
+ u32 bpsd0;
+ bsu_aclf_beacon_period_start_date (t.bsu->aclf, &bpsd0, 1);
+ t.bsu->sta_avln->beacon.beacon_period_start_date
+ = bpsd0 - t.bsu->aclf->beacon_period_tck;
+
+ bsu_timer_event_process (t.bsu);
+
+ test_fail_unless (t.ul.beacon != INVALID_PTR);
+ test_fail_unless (t.ul.beacon->params.direction
+ == BSU_BEACON_DIRECTION_FROM_BSU);
+
+ blk_release (t.ul.beacon);
+ t.ul.beacon = INVALID_PTR;
+ bsu_test_uninit (&t);
+ }
+ test_end;
test_begin (test, "CCo")
{
bsu_test_t t;
@@ -747,7 +805,11 @@ test_case_bsu_timer_event (test_t test)
t.bsu->is_sta = BSU_UPDATE_STA_TYPE_CCO;
bsu_timer_event_process (t.bsu);
test_fail_unless (t.ul.beacon);
+ test_fail_unless (t.ul.beacon->params.direction
+ == BSU_BEACON_DIRECTION_TO_PLC);
test_fail_unless (t.ul.beacon->next);
+ test_fail_unless (t.ul.beacon->next->params.direction
+ == BSU_BEACON_DIRECTION_TO_PLC);
blk_release (t.ul.beacon->next);
blk_release (t.ul.beacon);
mfs = mac_store_mfs_get (t.mac_store, true, true, false,