summaryrefslogtreecommitdiff
path: root/cesar/mac/sar/test/functional/src/test_functions.c
diff options
context:
space:
mode:
authorNélio Laranjeiro2010-10-01 10:30:16 +0200
committerNélio Laranjeiro2010-10-11 14:00:49 +0200
commitbd9028f50ded8c1144ccd0aef535ce027901268b (patch)
tree35effe09e089d89f7ba8689ca6a80ab680dbbecf /cesar/mac/sar/test/functional/src/test_functions.c
parente053b3b3959ae26b5ed307680e74684b9541905f (diff)
cesar/mac/sar/test/functional: add a full TX/RX test, refs #1927
Diffstat (limited to 'cesar/mac/sar/test/functional/src/test_functions.c')
-rw-r--r--cesar/mac/sar/test/functional/src/test_functions.c140
1 files changed, 92 insertions, 48 deletions
diff --git a/cesar/mac/sar/test/functional/src/test_functions.c b/cesar/mac/sar/test/functional/src/test_functions.c
index 3f9d024e95..88f69cdabc 100644
--- a/cesar/mac/sar/test/functional/src/test_functions.c
+++ b/cesar/mac/sar/test/functional/src/test_functions.c
@@ -146,6 +146,56 @@ sar_test_change_pb (bitstream_t *ctx, void *user_data)
}
void
+test_mpdu_reception (sar_test_ctx_t *ctx, pb_t *pb_head, pb_t *pb_tail,
+ uint nb)
+{
+ mfs_rx_t *mfs;
+ bool added;
+ pbproc_rx_desc_t *sar_mpdu;
+ uint i;
+ u8 *buffer;
+ /* Activate the SAR. */
+ sar_activate (ctx->sar, true);
+ /* Provide the buffer to the SAR. */
+ for (i = 0; i < COUNT (buffers); i++)
+ {
+ buffer = ARCH_CPU_TO_UNCACHEABLE (buffers[i]);
+ memset (buffer, 0x0, ETH_PACKET_MAX_SIZE);
+ sar_data_buffer_add (ctx->sar, buffer);
+ }
+ /* Prepare the MPDU for the SAR. */
+ sar_mpdu = (pbproc_rx_desc_t*) blk_alloc_desc ();
+ sar_mpdu->rx->params.tei = 1;
+ sar_mpdu->rx->params.lid = 2;
+ sar_mpdu->rx->params.eks = 0;
+ sar_mpdu->rx->params.mfs_cmd_data = MFS_FSM_CMD_NOP;
+ sar_mpdu->rx->params.mfs_cmd_mme = MFS_FSM_CMD_NOP;
+ sar_mpdu->rx->params.multi_net_bcast = false;
+ sar_mpdu->rx->params.bcast = false;
+ sar_mpdu->rx->params.sound = false;
+ sar_mpdu->rx->mfs = NULL;
+ sar_mpdu->rx->mfs_mme = NULL;
+ sar_mpdu->rx->pb_first = pb_head;
+ sar_mpdu->rx->pb_last = pb_tail;
+ sar_mpdu->rx->pb_nb = nb;
+ sar_mpdu->rx->chandata_first = NULL;
+ sar_mpdu->rx->chandata_nb = 0;
+ sar_mpdu->rx->params.preamble_ntb = mac_ntb();
+ /* Crete the necessary MFS. */
+ mfs = mac_store_mfs_add_rx (ctx->mac_store, sar_mpdu->rx->params.bcast,
+ false /* mme */, sar_mpdu->rx->params.lid,
+ sar_mpdu->rx->params.tei, &added);
+ mfs->ssn_min = 0;
+ dbg_assert (added);
+ /* Add the MFS to the expiration mechanism of the SAR. */
+ sar_mfs_add (ctx->sar, (mfs_t*) mfs);
+ /* Release the current reference on the MFS. */
+ blk_release (mfs);
+ /* Add the mpdu. */
+ sar_mpdu_add (ctx->sar, sar_mpdu);
+}
+
+void
test_simulate_mpdu_reception (sar_test_ctx_t *ctx, uint eth_frame_nb,
uint eth_frame_len)
{
@@ -155,9 +205,6 @@ test_simulate_mpdu_reception (sar_test_ctx_t *ctx, uint eth_frame_nb,
u8 *buffer;
blk_t *pb_first, *pb_last;
pb_t *pb_current;
- mfs_rx_t *mfs;
- bool added;
- pbproc_rx_desc_t *sar_mpdu;
uint pb_nb;
u16 ssn = 0;
uint i, j;
@@ -226,54 +273,11 @@ test_simulate_mpdu_reception (sar_test_ctx_t *ctx, uint eth_frame_nb,
bitstream_write (&stream, 0xff, 8);
bitstream_write (&stream, crc, 32);
}
+ bitstream_write_finalise (&stream);
/* Request the Leon processor to write all the data buffered. */
arch_write_buffer_flush ();
-
- /* Activate the SAR. */
- sar_activate (ctx->sar, true);
-
- /* Provide the buffer to the SAR. */
- for (i = 0; i < eth_frame_nb; i++)
- {
- buffer = ARCH_CPU_TO_UNCACHEABLE (buffers[i]);
- memset (buffer, 0x0, ETH_PACKET_MAX_SIZE);
-
- sar_data_buffer_add (ctx->sar, buffer);
- }
-
- /* Prepare the MPDU for the SAR. */
- sar_mpdu = (pbproc_rx_desc_t*) blk_alloc_desc ();
- sar_mpdu->rx->params.tei = 1;
- sar_mpdu->rx->params.lid = 2;
- sar_mpdu->rx->params.eks = 0;
- sar_mpdu->rx->params.mfs_cmd_data = MFS_FSM_CMD_NOP;
- sar_mpdu->rx->params.mfs_cmd_mme = MFS_FSM_CMD_NOP;
- sar_mpdu->rx->params.multi_net_bcast = false;
- sar_mpdu->rx->params.bcast = false;
- sar_mpdu->rx->params.sound = false;
- sar_mpdu->rx->mfs = NULL;
- sar_mpdu->rx->mfs_mme = NULL;
- sar_mpdu->rx->pb_first = (pb_t*) pb_first;
- sar_mpdu->rx->pb_last = (pb_t*) pb_last;
- sar_mpdu->rx->pb_nb = pb_nb;
- sar_mpdu->rx->chandata_first = NULL;
- sar_mpdu->rx->chandata_nb = 0;
- sar_mpdu->rx->params.preamble_ntb = mac_ntb();
-
- /* Crete the necessary MFS. */
- mfs = mac_store_mfs_add_rx (ctx->mac_store, sar_mpdu->rx->params.bcast,
- false /* mme */, sar_mpdu->rx->params.lid,
- sar_mpdu->rx->params.tei, &added);
- mfs->ssn_min = 0;
- dbg_assert (added);
- /* Add the MFS to the expiration mechanism of the SAR. */
- sar_mfs_add (ctx->sar, (mfs_t*) mfs);
- /* Release the current reference on the MFS. */
- blk_release (mfs);
-
- /* Add the mpdu. */
- sar_mpdu_add (ctx->sar, sar_mpdu);
+ test_mpdu_reception (ctx, (pb_t*) pb_first, (pb_t *)pb_last, pb_nb);
}
void
@@ -413,6 +417,7 @@ test_simulate_msdu_emission_check (sar_test_ctx_t *ctx, test_t test,
bitstream_skip (&stream, frames_len * 8);
test_fail_unless (bitstream_read (&stream, 32) == crc);
}
+ bitstream_finalise (&stream);
}
test_end;
@@ -422,6 +427,8 @@ test_simulate_msdu_emission_check (sar_test_ctx_t *ctx, test_t test,
blk_release (mfs);
}
+
+
void
sar_test_tx_multiple_frames (uint frames_nb, uint frames_len)
{
@@ -510,3 +517,40 @@ sar_test_rx_tx_multiple_frames (uint frames_nb, uint frames_len)
HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
#endif
}
+
+void
+sar_test_tx_out_in_rx_multiple_frames (uint frames_nb, uint frames_len)
+{
+ test_t test;
+ sar_test_ctx_t ctx;
+ trace_init ();
+ hal_trace_init ();
+ test_init (test, 0, NULL);
+ lib_stats_init ();
+ /* Initialise the test. */
+ sar_test_init (&ctx);
+ test_simulate_msdu_emission (&ctx, frames_nb, frames_len);
+ /* Get segmented PBs. */
+ mfs_tx_t *mfs = mac_store_mfs_get_tx (ctx.mac_store, false, false, 1, 1);
+ dbg_assert (mfs);
+ pb_t *head = mfs->head;
+ pb_t *tail = mfs->tail;
+ uint nb = mfs->seg_nb;
+ mfs->head = NULL;
+ mfs->tail = NULL;
+ mfs->seg_nb = 0;
+ mac_store_mfs_remove (ctx.mac_store, PARENT_OF (mfs_t, tx, mfs));
+ blk_release (mfs);
+ pb_t *pb;
+ for (pb = head; pb; pb = pb->next)
+ pb->phy_pb.pb_rx.pb_measurement.crc_error = false;
+ test_mpdu_reception (&ctx, head, tail, nb);
+ test_simulate_mpdu_reception_check (&ctx, test, frames_nb, frames_len);
+ lib_stats_uninit ();
+ test_result (test);
+ /* Uninitialise the test. */
+ sar_test_uninit (&ctx);
+#ifndef __sparc__
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+#endif
+}