summaryrefslogtreecommitdiff
path: root/cesar/bsu/test
diff options
context:
space:
mode:
authorNélio Laranjeiro2010-12-03 17:21:47 +0100
committerNélio Laranjeiro2011-01-11 15:39:47 +0100
commitbeb25f77a358fbdf4a6060483df7799779da328a (patch)
tree05f25b068c706844857b623695c3559fd59929ac /cesar/bsu/test
parent21a62f1168746cda1b5eb68d76593938dc371db1 (diff)
cesar/bsu: restore discover beacon procedure
Diffstat (limited to 'cesar/bsu/test')
-rw-r--r--cesar/bsu/test/utest/src/bsut.c54
-rw-r--r--cesar/bsu/test/utest/src/schedules.c16
2 files changed, 48 insertions, 22 deletions
diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c
index 57bcd23009..495fc7a78e 100644
--- a/cesar/bsu/test/utest/src/bsut.c
+++ b/cesar/bsu/test/utest/src/bsut.c
@@ -45,6 +45,7 @@ test_case_bsu_process (test_t test)
bsu_beacon_t beacon_neighbour;
pb_beacon_t *bneighbour;
bsu_beacon_t beacon;
+ bsu_beacon_t *bprocessed;
pb_beacon_t *b;
pbproc_tx_beacon_params_t bpneighbour_tx;
pbproc_tx_beacon_params_t bp_tx;
@@ -60,9 +61,10 @@ test_case_bsu_process (test_t test)
&t.mac_config,
&bpneighbour_tx);
bneighbour->phy_pb.pb_rx.pb_measurement.crc_error = true;
- bsu_beacon_process (t.bsu, bneighbour, &bpneighbour_rx);
+ bprocessed = bsu_beacon_process (t.bsu, bneighbour, &bpneighbour_rx);
blk_release_desc ((blk_t*) bneighbour);
/* Central beacon processed ? */
+ test_fail_unless (!bprocessed);
test_fail_unless (t.bsu->avlns[0].snid == 0);
test_fail_unless (t.bsu->avlns[0].beacon.vf.nid == 0);
test_fail_unless (t.bsu->beacon_nb_sent [BSU_BEACON_TYPE_CENTRAL]
@@ -74,18 +76,21 @@ test_case_bsu_process (test_t test)
&t.mac_config,
&bpneighbour_tx);
bneighbour->phy_pb.pb_rx.pb_measurement.crc_error = false;
- bsu_beacon_process (t.bsu, bneighbour, &bpneighbour_rx);
+ bprocessed = bsu_beacon_process (t.bsu, bneighbour, &bpneighbour_rx);
/* Central beacon processed ? */
+ test_fail_unless (bprocessed);
test_fail_unless (t.bsu->avlns[0].snid == bpneighbour_rx.snid);
test_fail_unless (t.bsu->avlns[0].beacon.vf.nid
== beacon_neighbour.vf.nid);
test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
== 1);
+ blk_release (bprocessed);
/* NTB called ? */
test_fail_unless (t.bsu->avlns[0].sync.init == true);
/* Second shoot... */
- bsu_beacon_process (t.bsu, bneighbour, &bpneighbour_rx);
+ bprocessed = bsu_beacon_process (t.bsu, bneighbour, &bpneighbour_rx);
/* Central beacon processed ? */
+ test_fail_unless (bprocessed);
test_fail_unless (t.bsu->avlns[0].snid == bpneighbour_rx.snid);
test_fail_unless (t.bsu->avlns[0].beacon.vf.nid
== beacon_neighbour.vf.nid);
@@ -94,6 +99,7 @@ test_case_bsu_process (test_t test)
blk_release_desc ((blk_t*) bneighbour);
test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
== 2);
+ blk_release (bprocessed);
/* Our AVLN. */
t.mac_config.tei = 1;
bsu_track_avln (beacon_neighbour.vf.nid, 0x4, t.mac_config.tei);
@@ -102,8 +108,9 @@ test_case_bsu_process (test_t test)
b = bsu_beacon_write (&beacon, BSU_BEACON_TYPE_CENTRAL,
&t.mac_config, &bp_tx);
b->phy_pb.pb_rx.pb_measurement.crc_error = true;
- bsu_beacon_process (t.bsu, b, &bp_rx);
+ bprocessed = bsu_beacon_process (t.bsu, b, &bp_rx);
/* Central beacon processed ? */
+ test_fail_unless (!bprocessed);
test_fail_unless (t.bsu->sta_avln->snid == t.bsu->snid_track);
test_fail_unless (t.bsu->sta_avln->beacon.vf.nid == t.bsu->nid_track);
test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
@@ -117,8 +124,9 @@ test_case_bsu_process (test_t test)
b = bsu_beacon_write (&beacon, BSU_BEACON_TYPE_CENTRAL,
&t.mac_config, &bp_tx);
b->phy_pb.pb_rx.pb_measurement.crc_error = false;
- bsu_beacon_process (t.bsu, b, &bp_rx);
+ bprocessed = bsu_beacon_process (t.bsu, b, &bp_rx);
/* Central beacon processed ? */
+ test_fail_unless (bprocessed);
test_fail_unless (t.bsu->sta_avln->snid == bp_rx.snid);
test_fail_unless (t.bsu->sta_avln->beacon.vf.nid == beacon.vf.nid);
test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
@@ -126,6 +134,7 @@ test_case_bsu_process (test_t test)
/* NTB called ? */
test_fail_unless (t.bsu->sta_avln->sync.init == true);
blk_release_desc ((blk_t*) b);
+ blk_release (bprocessed);
}
test_end;
test_begin (test, "Central beacon received with discover request")
@@ -141,7 +150,8 @@ test_case_bsu_process (test_t test)
&btx);
t.bsu->sta_avln->beacon.beacon_period_start_date =
phy_date () - BSU_ACLF_BP_50HZ_TCK - 1000;
- bsu_beacon_process (t.bsu, b, &brx);
+ bsu_beacon_t *bbeacon = bsu_beacon_process (t.bsu, b, &brx);
+ blk_release (bbeacon);
/* Change MAC config TEI for the test. */
bsu_track_avln (beacon.vf.nid, brx.snid, t.mac_config.tei);
t.mac_config.tei = beacon.bmis.discover.tei;
@@ -183,17 +193,21 @@ test_case_bsu_process (test_t test)
&t.mac_config, &btx);
t.bsu->sta_avln->beacon.beacon_period_start_date =
phy_date () - BSU_ACLF_BP_50HZ_TCK - 1000;
- bsu_beacon_process (t.bsu, b, &brx);
+ bsu_beacon_t *bprocessed = bsu_beacon_process (t.bsu, b, &brx);
bsu_avln_t *avln = bsu_avln_get (t.bsu, beacon.vf.nid, brx.snid);
+ test_fail_unless (bprocessed);
test_fail_unless (avln == NULL);
blk_release_desc ((blk_t*) b);
+ blk_release (bprocessed);
b = bsu_beacon_write (&beacon, BSU_BEACON_TYPE_CENTRAL,
&t.mac_config, &btx);
- bsu_beacon_process (t.bsu, b, &brx);
+ bprocessed = bsu_beacon_process (t.bsu, b, &brx);
+ test_fail_unless (bprocessed);
avln = bsu_avln_get (t.bsu, beacon.vf.nid, brx.snid);
test_fail_unless (avln != NULL);
test_fail_unless (avln != t.bsu->sta_avln);
blk_release_desc ((blk_t*) b);
+ blk_release (bprocessed);
bsu_track_avln (beacon.vf.nid, brx.snid, 1);
test_fail_unless (avln == t.bsu->sta_avln);
bsu_avln_remove (beacon.vf.nid, brx.snid);
@@ -211,11 +225,11 @@ test_case_bsu_process (test_t test)
bp_rx.snid = 0x4;
bp_rx.bts = 0;
/* Neighbour AVLN. */
- bsu_avln_t *avln = bsu_beacon_process (t.bsu, beacon, &bp_rx);
+ bsu_beacon_t *bbeacon = bsu_beacon_process (t.bsu, beacon, &bp_rx);
+ test_fail_unless (bbeacon == NULL);
+ bsu_avln_t *avln = bsu_avln_get (t.bsu, 0x3, 0x4);
test_fail_unless (avln == NULL);
- avln = bsu_avln_get (t.bsu, 0x3, 0x4);
- test_fail_unless (avln == NULL);
- blk_release_desc ((blk_t*) beacon);
+ blk_release_desc (&beacon->blk);
/* Our AVLN. */
beacon = (pb_beacon_t*) blk_alloc_desc ();
memset (beacon->data, 0, BLK_SIZE);
@@ -227,9 +241,9 @@ test_case_bsu_process (test_t test)
t.bsu->snid_track = bp_rx.snid;
t.bsu->tei_track = 0;
t.bsu->is_sta = BSU_UPDATE_STA_TYPE_STA;
- avln = bsu_beacon_process (t.bsu, beacon, &bp_rx);
- test_fail_unless (avln == NULL);
- blk_release_desc ((blk_t*) beacon);
+ bbeacon = bsu_beacon_process (t.bsu, beacon, &bp_rx);
+ test_fail_unless (bbeacon == NULL);
+ blk_release_desc (&beacon->blk);
}
test_end;
bsu_test_uninit (&t);
@@ -253,21 +267,23 @@ test_case_bsu_process_sta_is_cco (test_t test)
brx.snid = 0x2;
b = bsu_beacon_write (&beacon, BSU_BEACON_TYPE_CENTRAL, &t.mac_config,
&btx);
- bsu_avln_t *avln = bsu_beacon_process (t.bsu, b, &brx);
+ bsu_beacon_t *bbeacon = bsu_beacon_process (t.bsu, b, &brx);
test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
== 1);
- test_fail_unless (avln);
+ test_fail_unless (bbeacon);
test_fail_unless (t.bsu->sta_avln->sync.init == false);
blk_release_desc ((blk_t*) b);
+ blk_release (bbeacon);
b = bsu_beacon_write (&beacon, BSU_BEACON_TYPE_DISCOVER,
&t.mac_config, &btx);
b->phy_pb.pb_rx.pb_measurement.crc_error = false;
- avln = bsu_beacon_process (t.bsu, b, &brx);
+ bbeacon = bsu_beacon_process (t.bsu, b, &brx);
test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_DISCOVER]
== 1);
- test_fail_unless (avln == NULL);
+ test_fail_unless (bbeacon);
test_fail_unless (t.bsu->sta_avln->sync.init == false);
blk_release_desc ((blk_t*) b);
+ blk_release (bbeacon);
}
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 5aaa217f20..234aa8dcd2 100644
--- a/cesar/bsu/test/utest/src/schedules.c
+++ b/cesar/bsu/test/utest/src/schedules.c
@@ -20,6 +20,9 @@
#include "bsu/inc/interface.h"
#include <string.h>
+bsu_avln_t*
+bsu_avln_get (bsu_t *ctx, u64 nid, u8 snid);
+
void
bsu_schedules_merge (bsu_t *ctx, bsu_beacon_t *beacon,
ca_schedule_t *schedules, uint nb);
@@ -254,6 +257,7 @@ test_case_ca_schedules_intellon (test_t test)
bsu_test_t t;
bsu_test_init (&t);
bsu_beacon_t beacon;
+ bsu_beacon_t *bprocessed;
pb_beacon_t *pbbeacon;
bsu_test_create_beacon (&t, &beacon);
beacon.bmis.nps.ns = 0;
@@ -278,14 +282,16 @@ test_case_ca_schedules_intellon (test_t test)
pbbeacon->phy_pb.pb_rx.pb_measurement.crc_error = false;
/* The first time bsu receives a beacon of an AVLN. */
brx.bts = BSU_ACLF_BP_50HZ_TCK / 2;
- bsu_beacon_process (t.bsu, pbbeacon, &brx);
+ bprocessed = bsu_beacon_process (t.bsu, pbbeacon, &brx);
+ blk_release (bprocessed);
/* Control plane request to track this AVLN. */
bsu_track_avln (beacon.vf.nid, brx.snid, 0);
t.bsu->track_new = false;
t.bsu->is_sta = BSU_UPDATE_STA_TYPE_STA;
/* BSU receives the next beacon. */
- bsu_beacon_process (t.bsu, pbbeacon, &brx);
+ bprocessed = bsu_beacon_process (t.bsu, pbbeacon, &brx);
/* Schedules which should be present. */
+ test_fail_unless (bprocessed);
test_fail_unless (t.bsu->sta_avln->beacon.bmis.ps.nb == 1);
test_fail_unless (t.bsu->sta_avln->beacon.bmis.ps.ps[0].pscd == 0);
test_fail_unless (t.bsu->sta_avln->beacon.bmis.ps.ps[0].cscd == 7);
@@ -303,6 +309,7 @@ test_case_ca_schedules_intellon (test_t test)
test_fail_unless (brx.bts + i * BSU_ACLF_BP_50HZ_TCK == bpsd[i] +
t.bsu->sta_avln->sync.ntb_offset_tck);
blk_release_desc ((blk_t*) pbbeacon);
+ blk_release (bprocessed);
bsu_test_uninit (&t);
}
test_end;
@@ -373,9 +380,12 @@ test_case_track_new_beacon (test_t t, bsu_test_t *ctx, bsu_beacon_t *beacon)
ctx->mac_config.tei = 0;
params_rx.bts = ctx->bsu->aclf->bpsd[0] + BSU_ACLF_BP_50HZ_TCK / 2;
params_rx.snid = 1;
- bsu_avln_t *avln = bsu_beacon_process (ctx->bsu, pbbeacon, &params_rx);
+ bsu_beacon_t *bbeacon = bsu_beacon_process (ctx->bsu, pbbeacon, &params_rx);
blk_release_desc (&pbbeacon->blk);
/* Modify the ntb_offset_tck to have a real case. */
+ bsu_avln_t *avln = bsu_avln_get (ctx->bsu, bbeacon->vf.nid,
+ bbeacon->params.rx_parameters.snid);
+ blk_release (bbeacon);
avln->sync.ntb_offset_tck = 0;
avln->beacon.beacon_period_start_date = params_rx.bts;
return avln;