summaryrefslogtreecommitdiff
path: root/cesar/ce/rx/test/src/test_rx.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/ce/rx/test/src/test_rx.c')
-rw-r--r--cesar/ce/rx/test/src/test_rx.c104
1 files changed, 99 insertions, 5 deletions
diff --git a/cesar/ce/rx/test/src/test_rx.c b/cesar/ce/rx/test/src/test_rx.c
index 3cb75365b8..10ae32f8a2 100644
--- a/cesar/ce/rx/test/src/test_rx.c
+++ b/cesar/ce/rx/test/src/test_rx.c
@@ -17,6 +17,7 @@
#include "ce/rx/measure.h"
#include "ce/rx/inc/measure.h"
#include "ce/rx/inc/rx.h"
+#include "ce/rx/bitloading/fsm/fsm.h"
#include "lib/test.h"
#include "lib/blk.h"
@@ -29,12 +30,22 @@ cyg_handle_t thread_handler;
cyg_thread thread;
test_t test;
static int mbox_size = 0;
+static ce_rx_measure_mbox_t test_measure;
/* Stub bitloadling. */
void
-ce_rx_bitloading_update (ce_rx_t *ce_rx, ce_rx_measure_mbox_t *measure)
+ce_rx_bl_fsm_handle_event (ce_rx_t *ce_rx, sta_t *sta,
+ ce_rx_bl_fsm_event_type_t e,
+ ce_rx_bitloading_fsm_event_param_t data)
{
mbox_size--;
+ /* Copy measure for analysis in test. */
+ test_measure = *data.measure;
+ /* Suspend CE thread otherwise measure will be directly processed and can
+ * not be used any more.
+ * This is the normal behavior because SAR has higher priority than
+ * CE. */
+ cyg_thread_suspend (ce_rx->thread_handler);
}
void
@@ -71,21 +82,104 @@ test_ce_rx_measure_suite (test_t t)
test_begin (t, "no RX params, no channel data & no PB measurements")
{
- ce_rx_measure_sar_cb (ce_rx, NULL, 0, NULL, NULL, NULL, 0, NULL);
+ bool catch = false;
+ char *message;
+ mbox_size = 1;
+ dbg_fatal_try_begin
+ {
+ ce_rx_measure_sar_cb (ce_rx, NULL, 0, NULL, NULL, NULL, 0, NULL);
+ }
+ dbg_fatal_try_catch (message)
+ {
+ catch = true;
+ }
+ dbg_fatal_try_end;
+ test_fail_if (!catch);
+ test_fail_if (mbox_size != 1);
+ /* Resume CE thread. */
+ cyg_thread_resume (ce_rx->thread_handler);
test_fail_if (mbox_peek (&ce_rx->measure_mbox) != 0);
} test_end;
test_begin (t, "some RX params, but no channel data & no PB measurements")
{
- ce_rx_measure_sar_cb (ce_rx, &rx_params, 0, NULL, NULL, NULL, 0, NULL);
+ bool catch = false;
+ char *message;
+ mbox_size = 1;
+ dbg_fatal_try_begin
+ {
+ ce_rx_measure_sar_cb (ce_rx, &rx_params, 0, NULL, NULL, NULL, 0, NULL);
+ }
+ dbg_fatal_try_catch (message)
+ {
+ catch = true;
+ }
+ dbg_fatal_try_end;
+ test_fail_if (!catch);
+ test_fail_if (mbox_size != 1);
+ /* Resume CE thread. */
+ cyg_thread_resume (ce_rx->thread_handler);
test_fail_if (mbox_peek (&ce_rx->measure_mbox) != 0);
} test_end;
- test_begin (t, "some RX params and some channel data & no PB measurements")
+ test_begin (t, "some RX params & some channel data & no PB measurements")
{
pb_t *pb = (pb_t *) blk_alloc_desc ();
- mbox_size++;
+ mbox_size = 1;
ce_rx_measure_sar_cb (ce_rx, &rx_params, 0, NULL, NULL, pb, 1, NULL);
+ test_fail_if (test_measure.chan_data_count != 1);
+ test_fail_if (test_measure.chan_data != (phy_chandata_t *) pb);
+ test_fail_if (test_measure.pb_measurements_count != 0);
+ test_fail_if (mbox_size != 0);
+ /* Resume CE thread. */
+ cyg_thread_resume (ce_rx->thread_handler);
+ test_fail_if (mbox_peek (&ce_rx->measure_mbox) != 0);
+ } test_end;
+
+ test_begin (t, "some RX params & some channel data & one PB measurements")
+ {
+ pb_t *pb = (pb_t *) blk_alloc_desc ();
+ blk_t *fpm = NULL, *lpm = NULL;
+ uint offset = 4242;
+ mbox_size = 1;
+ ce_rx_measure_sar_cb (ce_rx, &rx_params, 1, &fpm, &lpm, pb, 1, &offset);
+ test_fail_if (fpm == NULL);
+ test_fail_if (lpm == NULL);
+ test_fail_if (fpm != lpm);
+ test_fail_if (offset != 0);
+ test_fail_if (mbox_size != 0);
+ test_fail_if (test_measure.chan_data_count != 1);
+ test_fail_if (test_measure.chan_data != (phy_chandata_t *) pb);
+ test_fail_if (test_measure.pb_measurements_count != 1);
+ test_fail_if (test_measure.pb_measurements != fpm);
+ /* Resume CE thread. */
+ cyg_thread_resume (ce_rx->thread_handler);
+ test_fail_if (mbox_peek (&ce_rx->measure_mbox) != 0);
+ } test_end;
+
+ test_begin (t, "some RX params & some channel data & many PB measurements")
+ {
+ pb_t *pb = (pb_t *) blk_alloc_desc ();
+ blk_t *fpm = NULL, *lpm = NULL;
+ uint offset = 4242;
+ mbox_size = 1;
+ /* More than one block of PB measurements. */
+ ce_rx_measure_sar_cb (ce_rx, &rx_params,
+ BLK_SIZE / sizeof (pb_measurement_t) + 1,
+ &fpm, &lpm, pb, 1, &offset);
+ test_fail_if (fpm == NULL);
+ test_fail_if (lpm == NULL);
+ test_fail_if (fpm == lpm);
+ test_fail_if (fpm->next != lpm);
+ test_fail_if (offset != 0);
+ test_fail_if (test_measure.chan_data_count != 1);
+ test_fail_if (test_measure.chan_data != (phy_chandata_t *) pb);
+ test_fail_if (test_measure.pb_measurements_count != BLK_SIZE / sizeof
+ (pb_measurement_t) + 1);
+ test_fail_if (test_measure.pb_measurements != fpm);
+ test_fail_if (mbox_size != 0);
+ /* Resume CE thread. */
+ cyg_thread_resume (ce_rx->thread_handler);
test_fail_if (mbox_peek (&ce_rx->measure_mbox) != 0);
} test_end;