From 5abe923a4e56cb5627eb0c378f67939b5565eef9 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Tue, 16 Aug 2011 15:31:22 +0200 Subject: cesar/bsu/test/utest: document test process --- cesar/bsu/test/utest/src/bsut.c | 48 ++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 20 deletions(-) (limited to 'cesar/bsu/test') diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c index b25a9cbd60..4ad6722117 100644 --- a/cesar/bsu/test/utest/src/bsut.c +++ b/cesar/bsu/test/utest/src/bsut.c @@ -51,10 +51,11 @@ test_case_bsu_process (test_t test) pbproc_tx_beacon_params_t bp_tx; pbproc_rx_beacon_params_t bpneighbour_rx; pbproc_rx_beacon_params_t bp_rx; - bsu_test_create_beacon (&t, &beacon_neighbour); memset (&bp_rx, 0, sizeof (pbproc_rx_beacon_params_t)); memset (&bpneighbour_rx, 0, sizeof (pbproc_rx_beacon_params_t)); t.mac_config.tei = 4; + /* => Neighbour beacon with bad CRC. */ + bsu_test_create_beacon (&t, &beacon_neighbour); bpneighbour_rx.snid = 0x4; bpneighbour_rx.bts = 0; bneighbour = bsu_beacon_write (&beacon_neighbour, @@ -64,80 +65,87 @@ test_case_bsu_process (test_t test) bneighbour->phy_pb.pb_rx.pb_measurement.crc_error = true; bprocessed = bsu_beacon_process (t.bsu, bneighbour, &bpneighbour_rx); blk_release_desc ((blk_t*) bneighbour); - /* Central beacon processed ? */ + /* 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] == 0); - /* NTB called ? */ + /* NTB called? */ test_fail_unless (t.bsu->avlns[0].sync.init == false); + /* => First neighbour beacon reception. */ bneighbour = bsu_beacon_write (&beacon_neighbour, BSU_BEACON_TYPE_CENTRAL, &t.mac_config, &bpneighbour_tx); bneighbour->phy_pb.pb_rx.pb_measurement.crc_error = false; bprocessed = bsu_beacon_process (t.bsu, bneighbour, &bpneighbour_rx); - /* Central beacon processed ? */ + /* Central beacon processed? */ test_fail_unless (bprocessed); - test_fail_unless (!bprocessed->params.frequency_error_valid); 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 ? */ + /* NTB called? */ test_fail_unless (t.bsu->avlns[0].sync.init == true); - /* Second shoot... */ + test_fail_unless (!bprocessed->params.frequency_error_valid); + /* Cleanup. */ + blk_release (bprocessed); + /* => Second neighbour beacon reception. */ bprocessed = bsu_beacon_process (t.bsu, bneighbour, &bpneighbour_rx); - /* Central beacon processed ? */ + /* 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); - /* NTB called ? */ + test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL] + == 2); + /* NTB called? */ test_fail_unless (t.bsu->avlns[0].sync.init == true); test_fail_unless (bprocessed->params.frequency_error_valid); + /* Cleanup. */ blk_release_desc ((blk_t*) bneighbour); - test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL] - == 2); blk_release (bprocessed); - /* Our AVLN. */ + /* => Our AVLN. */ bsu_track_avln (t.bsu, beacon_neighbour.vf.nid, 0x4, beacon_neighbour.vf.stei, beacon_neighbour.bmis.mac_address.mac_address); + /* Reset synchronisation. */ t.bsu->sta_avln->sync.init = false; + /* => Beacon with bad CRC. */ bsu_test_create_beacon (&t, &beacon); + bp_rx.snid = 0x4; + bp_rx.bts = 0; b = bsu_beacon_write (&beacon, BSU_BEACON_TYPE_CENTRAL, &t.mac_config, &bp_tx); b->phy_pb.pb_rx.pb_measurement.crc_error = true; bprocessed = bsu_beacon_process (t.bsu, b, &bp_rx); - /* Central beacon processed ? */ + blk_release_desc ((blk_t*) b); + /* 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] == 2); - blk_release_desc ((blk_t*) b); - /* NTB called ? */ + /* NTB called? */ test_fail_unless (t.bsu->sta_avln->sync.init == false); - bp_rx.snid = 0x4; - bp_rx.bts = 0; + /* => First beacon reception. */ b = bsu_beacon_write (&beacon, BSU_BEACON_TYPE_CENTRAL, &t.mac_config, &bp_tx); b->phy_pb.pb_rx.pb_measurement.crc_error = false; bprocessed = bsu_beacon_process (t.bsu, b, &bp_rx); - /* Central beacon processed ? */ + /* 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] == 3); - /* NTB called ? */ + /* NTB called? */ test_fail_unless (t.bsu->sta_avln->sync.init == true); test_fail_unless (t.bsu->sta_avln->sync.second_shoot); test_fail_unless (bprocessed->params.frequency_error_valid); + /* Cleanup. */ blk_release_desc ((blk_t*) b); blk_release (bprocessed); } -- cgit v1.2.3