summaryrefslogtreecommitdiff
path: root/cesar/bsu/test/utest/src
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/bsu/test/utest/src')
-rw-r--r--cesar/bsu/test/utest/src/bsut.c46
-rw-r--r--cesar/bsu/test/utest/src/schedules.c157
-rw-r--r--cesar/bsu/test/utest/src/tests.c12
3 files changed, 107 insertions, 108 deletions
diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c
index 5d1fdd3e0b..df61f673a4 100644
--- a/cesar/bsu/test/utest/src/bsut.c
+++ b/cesar/bsu/test/utest/src/bsut.c
@@ -91,7 +91,6 @@ test_case_bsu_process (test_t test)
test_fail_unless (t.bsu->avlns[0].bs.nid == beacon_neighbour.vf.nid);
/* NTB called ? */
test_fail_unless (t.bsu->avlns[0].sync.init == true);
- test_fail_unless (t.bsu->avlns[0].sync.beacon_nb == 2);
blk_release_desc ((blk_t*) bneighbour);
test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
== 2);
@@ -140,6 +139,8 @@ test_case_bsu_process (test_t test)
brx.snid = 0x2;
b = bsu_beacon_write (&beacon, BSU_BEACON_TYPE_CENTRAL, &t.mac_config,
&btx);
+ t.bsu->sta_avln->beacon_recv_bps_tck = phy_date () -
+ BSU_ACLF_BP_50HZ_TCK - 1000;
bsu_beacon_process (t.bsu, b, &brx);
/* Change MAC config TEI for the test. */
bsu_beacon_track_info_t tinfo;
@@ -182,6 +183,8 @@ test_case_bsu_process (test_t test)
brx.snid = 0x3;
b = bsu_beacon_write (&beacon, BSU_BEACON_TYPE_DISCOVER,
&t.mac_config, &btx);
+ t.bsu->sta_avln->beacon_recv_bps_tck = phy_date () -
+ BSU_ACLF_BP_50HZ_TCK - 1000;
bsu_beacon_process (t.bsu, b, &brx);
bsu_avln_t *avln = bsu_avln_get (t.bsu, beacon.vf.nid, brx.snid);
test_fail_unless (avln == NULL);
@@ -389,6 +392,8 @@ test_case_bsu_timer_event_cco_ucco (test_t test, bsu_test_t *t,
t->bsu->beacon.beacon_period_start_date = t->bsu->aclf->bpsd[0] - 1;
for (i = 0; i < 7; i++)
{
+ cmp_avln.beacon_recv_bps_tck = phy_date () - BSU_ACLF_BP_50HZ_TCK -
+ 1000;
bsu_avln_schedules_decrease_countdown (t->bsu, &cmp_avln);
bsu_timer_event_process (t->bsu);
test_fail_unless (t->ul.beacon != INVALID_PTR);
@@ -434,8 +439,12 @@ test_case_bsu_timer_event (test_t test)
t.bsu->aclf->bpsd[i] = i * BSU_ACLF_BP_50HZ_TCK;
for (j = 0; j < 10; j++)
{
- bsu_timer_event_process (t.bsu);
+ t.bsu->sta_avln->beacon_recv_bps_tck = t.bsu->aclf->bpsd[0] -
+ BSU_ACLF_BP_50HZ_TCK;
+ cmp_avln.beacon_recv_bps_tck = t.bsu->aclf->bpsd[0] -
+ BSU_ACLF_BP_50HZ_TCK;
bsu_avln_schedules_decrease_countdown (t.bsu, &cmp_avln);
+ bsu_timer_event_process (t.bsu);
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);
@@ -544,16 +553,6 @@ test_case_bsu_power_on (test_t test)
bsu_update (&beacon, BSU_UPDATE_STA_TYPE_STA);
bsu_power_on (0xa);
test_fail_unless (t.bsu->sta_avln == &t.bsu->poweron);
- uint i;
- for (i = 0; i < COUNT (t.bsu->sta_avln->bs.schedules.hm); i++)
- {
- test_fail_unless (t.bsu->sta_avln->bs.schedules.hm [i]
- == beacon.vf.hm);
- test_fail_unless (t.bsu->sta_avln->bs.schedules.snid [i]
- == 0xa);
- test_fail_unless (t.bsu->sta_avln->bs.schedules.nek_switch[i]
- == 0);
- }
test_fail_unless (
memcmp (&t.bsu->sta_avln->bs.schedules.ps,
&t.bsu->beacon.bmis.ps,
@@ -666,19 +665,16 @@ test_case_bsu_nek_index (test_t test)
bsu_test_init (&t);
test_begin (test, "Current index")
{
- uint i;
- uint index = bsu_nek_index_current ();
- test_fail_unless (index == 0);
- index = bsu_nek_index_next ();
- test_fail_unless (index == 1);
- /* Change NEK index in schedules. */
- for (i = 0; i < BSU_BEACON_SCHEDULES_MAX; i++)
- t.bsu->sta_avln->bs.schedules.nek_switch [i] = 1;
- index = bsu_nek_index_current ();
- test_fail_unless (index == 1);
- /* Next index. */
- index = bsu_nek_index_next ();
- test_fail_unless (index == 0);
+ bsu_test_avln_create (&t, t.bsu->sta_avln);
+ test_fail_unless (bsu_nek_index_current () ==
+ t.bsu->sta_avln->bs.nek_switch);
+ test_fail_unless (bsu_nek_index_next () ==
+ !t.bsu->sta_avln->bs.nek_switch);
+ t.bsu->sta_avln->bs.nek_switch = 1;
+ test_fail_unless (bsu_nek_index_current () ==
+ t.bsu->sta_avln->bs.nek_switch);
+ test_fail_unless (bsu_nek_index_next () ==
+ !t.bsu->sta_avln->bs.nek_switch);
}
test_end;
bsu_test_uninit (&t);
diff --git a/cesar/bsu/test/utest/src/schedules.c b/cesar/bsu/test/utest/src/schedules.c
index 61953497a0..e9dff54852 100644
--- a/cesar/bsu/test/utest/src/schedules.c
+++ b/cesar/bsu/test/utest/src/schedules.c
@@ -117,58 +117,35 @@ test_case_ca_schedules (test_t test)
}
void
+test_case_bsu_schedules_countdowns_init (bsu_t *bsu, ca_schedule_t *cas)
+{
+ bsu->sta_avln->bs.schedules.snid.present = true;
+ bsu->sta_avln->bs.schedules.snid.snidccd = 3;
+ bsu->sta_avln->bs.schedules.snid.new_snid = 3;
+ bsu->sta_avln->bs.schedules.eks.present = true;
+ bsu->sta_avln->bs.schedules.eks.kccd = 3;
+ bsu->sta_avln->bs.schedules.eks.kbc = BSU_BEACON_EKS_KBC_NEK;
+ bsu->sta_avln->bs.schedules.eks.new_eks = 4;
+ bsu->sta_avln->bs.schedules.hm.present = true;
+ bsu->sta_avln->bs.schedules.hm.hmccd = 3;
+ bsu->sta_avln->bs.schedules.hm.newhm = 1;
+ bsu->sta_avln->bs.nek_switch = 0;
+ cas[0].snid = bsu->sta_avln->bs.snid;
+ cas[0].coexistence_mode = bsu->sta_avln->bs.hm;
+ cas[0].nek_switch = bsu->sta_avln->bs.nek_switch;
+ cas[1].snid = bsu->sta_avln->bs.snid;
+ cas[1].coexistence_mode = bsu->sta_avln->bs.hm;
+ cas[1].nek_switch = bsu->sta_avln->bs.nek_switch;
+ cas[2].snid = bsu->sta_avln->bs.schedules.snid.new_snid;
+ cas[2].coexistence_mode = bsu->sta_avln->bs.schedules.hm.newhm;
+ cas[2].nek_switch = !bsu->sta_avln->bs.nek_switch;
+}
+
+void
test_case_bsu_schedules_countdowns (test_t t)
{
test_suite_begin (t, "Countdowns");
- test_begin (t, "SNID/EKS/HM change On event process")
- {
- uint i, j;
- ca_schedule_t *casched;
- bsu_test_t ctx;
- bsu_test_init (&ctx);
- bsu_activate (true);
- ctx.bsu->is_sta = BSU_UPDATE_STA_TYPE_STA;
- bsu_test_avln_create (&ctx, ctx.bsu->sta_avln);
- for (i = 0; i < BSU_BEACON_SCHEDULES_MAX; i++)
- {
- ctx.bsu->sta_avln->bs.schedules.snid [i] = i;
- ctx.bsu->sta_avln->bs.schedules.nek_switch [i] = i;
- ctx.bsu->sta_avln->bs.schedules.hm [i] = i;
- }
- for (i = 0; i < 3; i++)
- {
- ctx.bsu->ca_index = 0;
- bsu_timer_event_process (ctx.bsu);
- for (j = 0; j < 3; j++)
- {
- casched = ca_alloc_get_schedule (INVALID_PTR, j);
- test_fail_unless (
- casched->snid ==
- ctx.bsu->sta_avln->bs.schedules.snid [j]);
- test_fail_unless (
- casched->nek_switch ==
- ctx.bsu->sta_avln->bs.schedules.nek_switch [j]);
- test_fail_unless (
- casched->coexistence_mode ==
- ctx.bsu->sta_avln->bs.schedules.hm [j]);
- }
- for (j = 0; j < BSU_BEACON_SCHEDULES_MAX - 1; j++)
- {
- ctx.bsu->sta_avln->bs.schedules.snid [j] =
- ctx.bsu->sta_avln->bs.schedules.snid [j+1];
- ctx.bsu->sta_avln->bs.schedules.nek_switch[j] =
- ctx.bsu->sta_avln->bs.schedules.nek_switch[j+1];
- ctx.bsu->sta_avln->bs.schedules.hm [j] =
- ctx.bsu->sta_avln->bs.schedules.hm [j+1];
- }
- ctx.bsu->sta_avln->bs.schedules.snid [2] = 2;
- ctx.bsu->sta_avln->bs.schedules.nek_switch [2] = 2;
- ctx.bsu->sta_avln->bs.schedules.hm [2] = 2;
- }
- bsu_test_uninit (&ctx);
- }
- test_end;
- test_begin (t, "SNID/EKS/HM change On beacon reception")
+ test_begin (t, "SNID/EKS/HM change")
{
uint i, j;
bsu_beacon_t beacon;
@@ -184,40 +161,68 @@ test_case_bsu_schedules_countdowns (test_t t)
bsu_track_avln (beacon.vf.nid, 0x0, ctx.mac_config.tei,
MAC_COEXISTENCE_FULL_HYBRID_MODE);
ctx.bsu->is_sta = BSU_UPDATE_STA_TYPE_STA;
- beacon.bmis.eks.kbc = BSU_BEACON_EKS_KBC_NEK;
- for (i = 0; i < 5; i++)
+ for (i = 0; i < BSU_ACLF_BPSD_NB; i++)
+ ctx.bsu->aclf->bpsd[i] = i * BSU_ACLF_BP_50HZ_TCK;
+ ca_schedule_t cas[3];
+ test_case_bsu_schedules_countdowns_init (ctx.bsu, cas);
+ beacon.bmis.change_hm = ctx.bsu->sta_avln->bs.schedules.hm;
+ beacon.bmis.change_hm.hmccd--;
+ beacon.bmis.change_snid = ctx.bsu->sta_avln->bs.schedules.snid;
+ beacon.bmis.change_snid.snidccd--;
+ beacon.bmis.eks = ctx.bsu->sta_avln->bs.schedules.eks;
+ beacon.bmis.eks.kccd--;
+ for (i = 0; i < COUNT (cas); i++)
{
- pb_beacon_t *b = bsu_beacon_write (
- &beacon, BSU_BEACON_TYPE_CENTRAL, &ctx.mac_config, &bparams);
- ((pb_t *) b)->phy_pb.pb_rx.pb_measurement.crc_error = false;
- bsu_beacon_recv (ctx.bsu, b, &bparamsrx);
ctx.bsu->ca_index = 0;
- for (j = 0; j < 3; j++)
+ /* Prepare expected results. */
+ for (i = 0; i < CA_SCHEDULE_NB; i++)
+ memset (ca_alloc_get_schedule (INVALID_PTR, i), 0xff,
+ sizeof (ca_schedule_t));
+ /* station does not receive the last beacon. */
+ ctx.bsu->sta_avln->beacon_recv_bps_tck = phy_date () -
+ BSU_ACLF_BP_50HZ_TCK;
+ if (i != 1)
+ {
+ pb_beacon_t *b = bsu_beacon_write (
+ &beacon, BSU_BEACON_TYPE_CENTRAL, &ctx.mac_config, &bparams);
+ ((pb_t *) b)->phy_pb.pb_rx.pb_measurement.crc_error = false;
+ bparamsrx.preamble_date = bparamsrx.preamble_sysdate = 0;
+ bparamsrx.bts = 0;
+ /* On beacon reception only schedules are read and CA is
+ * programmed with the current data. */
+ bsu_beacon_recv (ctx.bsu, b, &bparamsrx);
+ }
+ /* On timer event the snid change, NEK and hybrid mode are changed
+ * in the lower layers. */
+ bsu_timer_event_process (ctx.bsu);
+ for (j = 0; j < COUNT (cas); j++)
{
casched = ca_alloc_get_schedule (INVALID_PTR, j);
- test_fail_unless (
- casched->snid ==
- ctx.bsu->sta_avln->bs.schedules.snid [j]);
- test_fail_unless (
- casched->nek_switch ==
- ctx.bsu->sta_avln->bs.schedules.nek_switch[j]);
- test_fail_unless (
- casched->coexistence_mode ==
- ctx.bsu->sta_avln->bs.schedules.hm [j]);
+ test_fail_unless (casched->snid == cas[j].snid);
+ test_fail_unless (casched->nek_switch == cas[j].nek_switch);
+ test_fail_unless (casched->coexistence_mode ==
+ cas[j].coexistence_mode);
+ }
+ cas[0] = cas[1];
+ cas[1] = cas[2];
+ if (i != 1)
+ {
+ /* Release beacon. */
+ blk_release_desc ((blk_t*) ctx.ul.beacon);
+ ctx.ul.beacon = INVALID_PTR;
}
- /* Release beacon. */
- blk_release_desc ((blk_t*) ctx.ul.beacon);
- ctx.ul.beacon = INVALID_PTR;
beacon.bmis.change_snid.snidccd --;
+ beacon.bmis.change_snid.present =
+ beacon.bmis.change_snid.snidccd != 0;
+ if (beacon.bmis.change_snid.present == false)
+ bparamsrx.snid = beacon.bmis.change_snid.new_snid;
beacon.bmis.eks.kccd--;
+ beacon.bmis.eks.present = beacon.bmis.eks.kccd != 0;
beacon.bmis.change_hm.hmccd--;
+ beacon.bmis.change_hm.present = beacon.bmis.change_hm.hmccd != 0;
+ if (beacon.bmis.change_hm.present == false)
+ beacon.vf.hm = beacon.bmis.change_hm.newhm;
}
- test_fail_unless (ctx.bsu->sta_avln->bs.schedules.snid [0] ==
- beacon.bmis.change_snid.new_snid);
- test_fail_unless (ctx.bsu->sta_avln->bs.schedules.nek_switch [0] ==
- beacon.bmis.eks.new_eks);
- test_fail_unless (ctx.bsu->sta_avln->bs.schedules.hm [0] ==
- beacon.bmis.change_hm.newhm);
bsu_test_uninit (&ctx);
}
test_end;
@@ -255,8 +260,12 @@ test_case_ca_schedules_intellon (test_t test)
pbbeacon = bsu_beacon_write (
&beacon, BSU_BEACON_TYPE_CENTRAL, &t.mac_config, &btx);
pbbeacon->phy_pb.pb_rx.pb_measurement.crc_error = false;
+ /* The first time bsu receives a beacon of an AVLN. */
+ bsu_beacon_process (t.bsu, pbbeacon, &brx);
+ /* Control plane request to track this AVLN. */
bsu_track_avln (beacon.vf.nid, brx.snid, 0, beacon.vf.nm);
t.bsu->is_sta = BSU_UPDATE_STA_TYPE_STA;
+ /* BSU receives the next beacon. */
bsu_beacon_process (t.bsu, pbbeacon, &brx);
/* Schedules which should be present. */
test_fail_unless (t.bsu->sta_avln->bs.schedules.ps.nb == 1);
diff --git a/cesar/bsu/test/utest/src/tests.c b/cesar/bsu/test/utest/src/tests.c
index cc3c51100d..cb2d9fe39a 100644
--- a/cesar/bsu/test/utest/src/tests.c
+++ b/cesar/bsu/test/utest/src/tests.c
@@ -491,15 +491,9 @@ bsu_test_avln_create (bsu_test_t *ctx, bsu_avln_t *avln)
{
avln->bs.schedules.bpsto.present = true;
avln->bs.schedules.bpsto.bpsto = 0x45;
- avln->bs.schedules.hm[0] = MAC_COEXISTENCE_FULL_HYBRID_MODE;
- avln->bs.schedules.hm[1] = MAC_COEXISTENCE_FULL_HYBRID_MODE;
- avln->bs.schedules.hm[3] = MAC_COEXISTENCE_AV_ONLY_MODE;
- avln->bs.schedules.nek_switch[0] = 0;
- avln->bs.schedules.nek_switch[1] = 0;
- avln->bs.schedules.nek_switch[2] = 1;
- avln->bs.schedules.snid[0] = 0;
- avln->bs.schedules.snid[1] = 0;
- avln->bs.schedules.snid[2] = 1;
+ avln->bs.hm = MAC_COEXISTENCE_FULL_HYBRID_MODE;
+ avln->bs.nek_switch = 0;
+ avln->bs.snid = 0;
bsu_test_schedules_persistent (ctx, &avln->bs.schedules.ps);
bsu_test_schedules_non_persistent (ctx, &avln->bs.schedules.nps);
}