summaryrefslogtreecommitdiff
path: root/cesar/ce/rx/test
diff options
context:
space:
mode:
authorJérémy Dufour2012-09-27 14:38:40 +0200
committerJérémy Dufour2012-10-05 14:07:08 +0200
commit12deb22b5244c9a341ecf199039000a5159e12f2 (patch)
treee35d2d7acfd3d3603ae81f69d37dfcabd9d6978e /cesar/ce/rx/test
parentb81802b318761acb65c2367c6d544b251e7fb65d (diff)
parentb46712374a9d38b38f4a15c1ec21bc84769ded89 (diff)
Merge branch 'fix_ce_rx_test' into eoc-drv_fix_ce_rx_test_t3390
Diffstat (limited to 'cesar/ce/rx/test')
-rw-r--r--cesar/ce/rx/test/src/test_rx.c97
1 files changed, 63 insertions, 34 deletions
diff --git a/cesar/ce/rx/test/src/test_rx.c b/cesar/ce/rx/test/src/test_rx.c
index 4d5952aa0c..900f2c00c3 100644
--- a/cesar/ce/rx/test/src/test_rx.c
+++ b/cesar/ce/rx/test/src/test_rx.c
@@ -36,6 +36,42 @@ test_t test;
static int mbox_size = 0;
static ce_rx_measure_mbox_t *test_measure = NULL;
+/**
+ * Structure with all required tests context.
+ */
+typedef struct test_ce_rx
+{
+ sar_t *s;
+ pbproc_t *p;
+ mac_store_t *ms;
+ mac_config_t mc;
+} test_ce_rx_t;
+
+/**
+ * Common function to initialize lower layer.
+ * \param t test suite context
+ * \param tcr test ce rx context
+ */
+static void
+test_ce_rx_ll_init (test_t t, test_ce_rx_t *tcr)
+{
+ tcr->p = (pbproc_t *) t;
+ tcr->ms = mac_store_init ();
+ tcr->s = sar_init (tcr->ms, NULL, NULL, NULL, 0x1);
+ mac_config_init (&tcr->mc);
+}
+
+/**
+ * Common function to un-initialize lower layer.
+ * \param tcr test ce rx context
+ */
+static void
+test_ce_rx_ll_uninit (test_ce_rx_t *tcr)
+{
+ mac_store_uninit (tcr->ms);
+ sar_uninit (tcr->s);
+}
+
/* Stub bitloadling. */
void
ce_rx_bl_fsm_handle_event (ce_rx_t *ce_rx, sta_t *sta,
@@ -123,19 +159,18 @@ ce_rx_bl_fsm_measure_to_event (sta_t *sta,
void
test_rx_ce_suite (test_t t)
{
- mac_store_t *mac_store = mac_store_init ();
- sar_t *sar = sar_init (mac_store, NULL, NULL, NULL, 0x1);
- pbproc_t *pbproc = (pbproc_t *) t;
- mac_config_t mac_config;
+ test_ce_rx_t tcr;
+
+ test_ce_rx_ll_init (t, &tcr);
test_begin (t, "launch ce_rx thread")
{
- ce_rx_t *ce_rx = ce_rx_init (mac_store, sar, pbproc, &mac_config);
+ ce_rx_t *ce_rx = ce_rx_init (tcr.ms, tcr.s, tcr.p, &tcr.mc);
test_fail_if (mbox_peek (&ce_rx->measure_mbox) != 0);
ce_rx_uninit (ce_rx);
} test_end;
- mac_store_uninit (mac_store);
- sar_uninit (sar);
+
+ test_ce_rx_ll_uninit (&tcr);
}
void
@@ -146,23 +181,21 @@ test_ce_rx_measure_suite (test_t t)
rx_params.multi_net_bcast = false;
rx_params.preamble_ntb = 0;
rx_params.beacon_period_start_ntb = 42;
- mac_store_t *mac_store = mac_store_init ();
- sar_t *sar = sar_init (mac_store, NULL, NULL, NULL, 0x1);
- pbproc_t *pbproc = (pbproc_t *) t;
- mac_config_t mac_config;
+ test_ce_rx_t tcr;
+
+ test_ce_rx_ll_init (t, &tcr);
- ce_rx_t *ce_rx = ce_rx_init (mac_store, sar, pbproc, &mac_config);
+ ce_rx_t *ce_rx = ce_rx_init (tcr.ms, tcr.s, tcr.p, &tcr.mc);
test_begin (t, "no RX params, no channel data & no PB stats")
{
bool catch = false;
- char *message;
mbox_size = 1;
dbg_fatal_try_begin
{
ce_rx_measure_sar_cb (ce_rx, NULL, 0, NULL, 0, 0, 0);
}
- dbg_fatal_try_catch (message)
+ dbg_fatal_try_catch_void ()
{
catch = true;
}
@@ -177,13 +210,12 @@ test_ce_rx_measure_suite (test_t t)
test_begin (t, "some RX params, but no channel data & no PB stats")
{
bool catch = false;
- char *message;
mbox_size = 1;
dbg_fatal_try_begin
{
ce_rx_measure_sar_cb (ce_rx, &rx_params, 0, NULL, 0, 0, 0);
}
- dbg_fatal_try_catch (message)
+ dbg_fatal_try_catch_void ()
{
catch = true;
}
@@ -291,26 +323,23 @@ test_ce_rx_measure_suite (test_t t)
} test_end;
/* Clean. */
- dbg_assert (mac_store_sta_remove (mac_store, 1) == true);
+ dbg_assert (mac_store_sta_remove (tcr.ms, 1) == true);
ce_rx_uninit (ce_rx);
- mac_store_uninit (mac_store);
- sar_uninit (sar);
+ test_ce_rx_ll_uninit (&tcr);
}
void
test_ce_rx_get_snr (test_t t)
{
const uint tei = 1;
- mac_store_t *mac_store = mac_store_init ();
- sar_t *sar = sar_init (mac_store, NULL, NULL, NULL, 0x1);
- pbproc_t *pbproc = (pbproc_t *) t;
- mac_config_t mac_config;
+ test_ce_rx_t tcr;
u16 ber = 0x42;
- ce_rx_t *ce_rx = ce_rx_init (mac_store, sar, pbproc, &mac_config);
+ test_ce_rx_ll_init (t, &tcr);
+ ce_rx_t *ce_rx = ce_rx_init (tcr.ms, tcr.s, tcr.p, &tcr.mc);
- mac_store_sta_add (mac_store, tei);
- sta_t *sta = mac_store_sta_get (mac_store, tei);
+ mac_store_sta_add (tcr.ms, tei);
+ sta_t *sta = mac_store_sta_get (tcr.ms, tei);
dbg_assert (sta);
sta->ce_rx_bt.noise_nrj = INVALID_PTR;
@@ -346,10 +375,9 @@ test_ce_rx_get_snr (test_t t)
/* Clean. */
blk_release (sta);
- dbg_assert (mac_store_sta_remove (mac_store, tei) == true);
+ dbg_assert (mac_store_sta_remove (tcr.ms, tei) == true);
ce_rx_uninit (ce_rx);
- mac_store_uninit (mac_store);
- sar_uninit (sar);
+ test_ce_rx_ll_uninit (&tcr);
}
void
@@ -357,14 +385,13 @@ test_ce_rx_stats (test_t t)
{
test_case_begin (t, "stats");
- mac_store_t *mac_store = mac_store_init ();
- sar_t *sar = sar_init (mac_store, NULL, NULL, NULL, 0x1);
- pbproc_t *pbproc = (pbproc_t *) t;
- mac_config_t mac_config;
+ test_ce_rx_t tcr;
+
+ test_ce_rx_ll_init (t, &tcr);
test_begin (t, "init")
{
- ce_rx_t *ce_rx = ce_rx_init (mac_store, sar, pbproc, &mac_config);
+ ce_rx_t *ce_rx = ce_rx_init (tcr.ms, tcr.s, tcr.p, &tcr.mc);
test_fail_if (ce_rx->stats.resend_tm != 0);
ce_rx->stats.resend_tm = 0x42;
@@ -373,6 +400,8 @@ test_ce_rx_stats (test_t t)
ce_rx_uninit (ce_rx);
} test_end;
+
+ test_ce_rx_ll_uninit (&tcr);
}
void