From 9d89d74ec0ddee61a287c8cc0e5095c96d5a31fb Mon Sep 17 00:00:00 2001 From: NĂ©lio Laranjeiro Date: Wed, 14 Nov 2012 14:06:30 +0100 Subject: cesar/bsu: add a tolerance to accept central beacons, closes #3502 --- cesar/bsu/test/utest/src/bsut.c | 57 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'cesar/bsu/test/utest') 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) { @@ -976,6 +980,58 @@ test_case_bsu_update_nid_snid (test_t t) test_end; } +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) { @@ -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); } -- cgit v1.2.3