summaryrefslogtreecommitdiff
path: root/cesar/bsu/test/utest
diff options
context:
space:
mode:
authorNélio Laranjeiro2012-11-14 14:06:30 +0100
committerNélio Laranjeiro2012-12-12 14:20:50 +0100
commit9d89d74ec0ddee61a287c8cc0e5095c96d5a31fb (patch)
tree5ea3a5f4cac998120fca0f3fc574aa412632a2d4 /cesar/bsu/test/utest
parente22ab5d3ecd40ba7a06bb405cd4959844dcb559a (diff)
cesar/bsu: add a tolerance to accept central beacons, closes #3502
Diffstat (limited to 'cesar/bsu/test/utest')
-rw-r--r--cesar/bsu/test/utest/src/bsut.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c
index 3d04407fe2..4f5d69f347 100644
--- a/cesar/bsu/test/utest/src/bsut.c
+++ b/cesar/bsu/test/utest/src/bsut.c
@@ -34,6 +34,10 @@ bsu_avln_schedules_decrease_countdown (bsu_t *ctx, bsu_avln_t *avln);
void
bsu_update__persistent_schedules (bsu_t *ctx, bsu_beacon_t *beacon);
+bsu_avln_t*
+bsu_beacon_process__avln_tracked (bsu_t *ctx, bsu_beacon_t *beacon,
+ pbproc_rx_beacon_params_t *params);
+
void
test_case_bsu_process (test_t test)
{
@@ -977,6 +981,58 @@ test_case_bsu_update_nid_snid (test_t t)
}
void
+test_bsu_process_track_beacon (test_t test, bsu_test_t *ctx, u32 bts)
+{
+ test_within (test);
+ bsu_beacon_t beacon;
+ pbproc_rx_beacon_params_t rx_params;
+ bool added;
+ uint i;
+ memset (&rx_params, 0, sizeof (pbproc_rx_beacon_params_t));
+ bsu_avln_add (ctx->bsu, 0x123456789abcull, 3,
+ MAC_ADDRESS (0x00, 0x13, 0xd7, 0x00, 0x00, 0x01),
+ &added);
+ ctx->bsu->sta_avln->sync.init = true;
+ ctx->bsu->sta_avln->sync.ntb_offset_tck = 0;
+ ctx->bsu->sta_avln->sync.fe = 0.0;
+ bsu_test_create_beacon (ctx, &beacon);
+ beacon.bmis.bpsto.bpsto = 0;
+ rx_params.preamble_sysdate =
+ rx_params.preamble_date =
+ rx_params.bts = bts;
+ bsu_beacon_process__avln_tracked (ctx->bsu, &beacon, &rx_params);
+ /* Verify the beacon period start date computed by the beacon
+ * reception. BPSD[0] is never modified by a beacon reception. */
+ test_fail_unless (ctx->bsu->aclf->bpsd[0] == 0);
+ for (i = 1; i < BSU_ACLF_BPSD_NB; i++)
+ {
+ test_fail_unless (i * ctx->bsu->aclf->beacon_period_theo_tck
+ - MAC_TOLERANCE_TCK == ctx->bsu->aclf->bpsd[i]);
+ }
+}
+
+void
+test_case_bsu_process_track_beacon (test_t test)
+{
+ test_case_begin (test, "Process a tracked central beacon");
+ bsu_test_t ctx;
+ bsu_test_init (&ctx);
+ test_begin (test, "received in the previous beacon period for the"
+ " next one")
+ {
+ test_bsu_process_track_beacon (test, &ctx, 0 - MAC_TOLERANCE_TCK);
+ }
+ test_end;
+ test_begin (test, "received in the previous beacon period for the"
+ " next one but just before the tolerance.")
+ {
+ test_bsu_process_track_beacon (test, &ctx, 0 - MAC_TOLERANCE_TCK - 1);
+ }
+ test_end;
+ bsu_test_uninit (&ctx);
+}
+
+void
test_suite_bsu (test_t t)
{
test_suite_begin (t, "BSU test");
@@ -993,4 +1049,5 @@ test_suite_bsu (test_t t)
test_case_bsu_add_avln_array_full (t);
test_case_bsu_avln_remove (t);
test_case_bsu_update_tracking (t);
+ test_case_bsu_process_track_beacon (t);
}