summaryrefslogtreecommitdiff
path: root/cesar/mac/sar/test/functional/src/test_functions.c
diff options
context:
space:
mode:
authorlaranjeiro2009-11-27 08:50:51 +0000
committerlaranjeiro2009-11-27 08:50:51 +0000
commitbc91c4cbc133d1c245c29dac56fa83562a46b46f (patch)
tree33734d0b6e48c9827f100e2b2a667db1a153b6d1 /cesar/mac/sar/test/functional/src/test_functions.c
parent4f620c0663c7ea1c4bb33fafb1a76ffb6ba5484d (diff)
cesar/mac/sar: add more function test
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6496 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/mac/sar/test/functional/src/test_functions.c')
-rw-r--r--cesar/mac/sar/test/functional/src/test_functions.c149
1 files changed, 105 insertions, 44 deletions
diff --git a/cesar/mac/sar/test/functional/src/test_functions.c b/cesar/mac/sar/test/functional/src/test_functions.c
index cd47604f1b..029aa7f382 100644
--- a/cesar/mac/sar/test/functional/src/test_functions.c
+++ b/cesar/mac/sar/test/functional/src/test_functions.c
@@ -42,7 +42,8 @@ static u8 buffers[BUFFERS_MAX][2048] __attribute__ ((section(".private")));
static u8 buffers[BUFFERS_MAX][2048];
#endif
-static uint nb_frames;
+static uint nb_frames_tx;
+static uint nb_frames_rx;
/* Stubbed Functions. */
static bool
@@ -60,17 +61,36 @@ sar_test_segmentation_done__do_nothing (void *user,
u8* buffer,
void *user_data)
{
- nb_frames++;
+ nb_frames_tx++;
}
static void
sar_reassembly_done__do_nothing (void *user, u8* buffer, uint length,
mfs_rx_t *mfs, bool encrypted)
{
- nb_frames++;
+ nb_frames_rx++;
}
/*-- End stubbed functions. --*/
+u8*
+sar_test_get_buffer (uint buffer_nb)
+{
+ dbg_assert (buffer_nb < BUFFERS_MAX);
+ return ARCH_CPU_TO_UNCACHEABLE (buffers[buffer_nb]);
+}
+
+uint
+sar_test_rx_frames (void)
+{
+ return nb_frames_rx;
+}
+
+uint
+sar_test_tx_frames (void)
+{
+ return nb_frames_tx;
+}
+
void
sar_test_init (sar_test_ctx_t *test_ctx)
{
@@ -99,7 +119,8 @@ sar_test_init (sar_test_ctx_t *test_ctx)
sar_init_reassembly_mme_cb (test_ctx->sar,
sar_reassembly_done__do_nothing);
- nb_frames = 0;
+ nb_frames_tx = 0;
+ nb_frames_rx = 0;
}
void
@@ -254,24 +275,36 @@ test_simulate_mpdu_reception (sar_test_ctx_t *ctx, uint eth_frame_nb,
sar_mpdu_add (ctx->sar, sar_mpdu);
}
-u8*
-sar_test_get_buffer (uint buffer_nb)
+void
+test_simulate_mpdu_reception_check (sar_test_ctx_t *ctx, test_t test,
+ uint frames_nb, uint frames_len)
{
- dbg_assert (buffer_nb < BUFFERS_MAX);
- return ARCH_CPU_TO_UNCACHEABLE (buffers[buffer_nb]);
-}
+ u8 *buffer;
+ dbg_assert (ctx);
-uint
-sar_test_nb_ethernet_frames_received (void)
-{
- return nb_frames;
+ test_case_begin (test, "Verify reassembly");
+
+ test_begin (test, "Sar reassembly")
+ {
+ uint i, j;
+ test_fail_unless (frames_nb == sar_test_rx_frames ());
+
+ for (j = 0; j < frames_nb; j++)
+ {
+ buffer = sar_test_get_buffer (j);
+ for (i = 0; i < frames_len; i++)
+ test_fail_unless (bitstream_direct_read (buffer, i*8, 8)
+ == 0xFF);
+ }
+ }
+ test_end;
}
+
void
sar_test_rx_multiple_frames (uint frames_nb, uint frames_len)
{
test_t test;
- u8 *buffer;
sar_test_ctx_t ctx;
trace_init ();
@@ -281,32 +314,12 @@ sar_test_rx_multiple_frames (uint frames_nb, uint frames_len)
/* Initialise the test. */
sar_test_init (&ctx);
- /* 200 frames of 60 bytes each. */
test_simulate_mpdu_reception (&ctx, frames_nb, frames_len);
/* Wait some time. */
cyg_thread_delay (50);
- /* Uninitialise the test. */
- sar_test_uninit (&ctx);
-
- test_case_begin (test, "Verify reassembly");
-
- test_begin (test, "Sar reassembly")
- {
- uint i, j;
- test_fail_unless (frames_nb ==
- sar_test_nb_ethernet_frames_received());
-
- for (j = 0; j < frames_nb; j++)
- {
- buffer = sar_test_get_buffer (j);
- for (i = 0; i < frames_len; i++)
- test_fail_unless (bitstream_direct_read (buffer, i*8, 8)
- == 0xFF);
- }
- }
- test_end;
+ test_simulate_mpdu_reception_check (&ctx, test, frames_nb, frames_len);
test_result (test);
#ifndef __sparc__
@@ -356,6 +369,7 @@ test_simulate_msdu_emission_check (sar_test_ctx_t *ctx, test_t test,
u8 *buffer;
pb_t *pb_current;
bitstream_t stream;
+ uint i;
mfs = mac_store_mfs_get_tx (ctx->mac_store, false, false, 1, 1);
@@ -382,15 +396,11 @@ test_simulate_msdu_emission_check (sar_test_ctx_t *ctx, test_t test,
test_begin (test, "Sar")
{
- test_fail_unless (frames_nb ==
- sar_test_nb_ethernet_frames_received());
-
+ test_fail_unless (frames_nb == sar_test_tx_frames ());
pb_current = mfs->head;
bitstream_read_init (&stream, pb_current->data, BLK_SIZE);
- for (;
- pb_current;
- pb_current = pb_current->next)
+ for (i = 0; i < frames_nb; i++)
{
bitstream_init_buffer_cb (&stream, sar_test_change_pb,
&pb_current);
@@ -409,7 +419,6 @@ 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)
{
@@ -424,16 +433,68 @@ sar_test_tx_multiple_frames (uint frames_nb, uint frames_len)
sar_test_init (&ctx);
test_simulate_msdu_emission (&ctx, frames_nb, frames_len);
+ test_simulate_msdu_emission_check (&ctx, test, frames_nb, frames_len);
- /* Wait some time. */
- cyg_thread_delay (50);
+ test_result (test);
+ /* Uninitialise the test. */
+ sar_test_uninit (&ctx);
+
+#ifndef __sparc__
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+#endif
+}
+
+void
+sar_test_tx_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);
+
+ /* Initialise the test. */
+ sar_test_init (&ctx);
+
+ test_simulate_msdu_emission (&ctx, frames_nb, frames_len);
+ test_simulate_mpdu_reception (&ctx, frames_nb, frames_len);
test_simulate_msdu_emission_check (&ctx, test, frames_nb, frames_len);
+ test_simulate_mpdu_reception_check (&ctx, test, frames_nb, frames_len);
+ test_result (test);
/* Uninitialise the test. */
sar_test_uninit (&ctx);
+#ifndef __sparc__
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+#endif
+}
+
+void
+sar_test_rx_tx_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);
+
+ /* Initialise the test. */
+ sar_test_init (&ctx);
+
+ test_simulate_mpdu_reception (&ctx, frames_nb, frames_len);
+ test_simulate_msdu_emission (&ctx, frames_nb, frames_len);
+
+ test_simulate_mpdu_reception_check (&ctx, test, frames_nb, frames_len);
+ test_simulate_msdu_emission_check (&ctx, test, frames_nb, frames_len);
+
test_result (test);
+ /* Uninitialise the test. */
+ sar_test_uninit (&ctx);
+
#ifndef __sparc__
HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
#endif