summaryrefslogtreecommitdiff
path: root/cesar/ce/rx/bitloading/test/src/test_intervals.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/ce/rx/bitloading/test/src/test_intervals.c')
-rw-r--r--cesar/ce/rx/bitloading/test/src/test_intervals.c145
1 files changed, 132 insertions, 13 deletions
diff --git a/cesar/ce/rx/bitloading/test/src/test_intervals.c b/cesar/ce/rx/bitloading/test/src/test_intervals.c
index d159ab444f..3e59cb2331 100644
--- a/cesar/ce/rx/bitloading/test/src/test_intervals.c
+++ b/cesar/ce/rx/bitloading/test/src/test_intervals.c
@@ -570,13 +570,79 @@ test_suite_ce_rx_bl_intervals_update_default_tm (test_t t)
uint old_repetition_nb = ce_rx_bl_intervals_repetition_count_;
ce_rx_t ce_rx;
+ mac_config_t mac_config;
sta_t sta;
- tonemap_t tm;
- int i;
-
+ tonemask_info_t ti;
+ tonemap_t *tm_4;
+ tonemap_t *tm_5;
+ tonemap_t *tm_6;
+ tonemap_t *tm_7;
+ uint mod;
+ uint i;
+
+ const uint tone_en = tonemask_default (ti.tonemask);
+ mac_config.tonemask_info.tonemap_robo[PHY_MOD_ROBO].bits_per_symbol = 458;
+ ce_rx.mac_config = &mac_config;
+
+ tm_4 = tonemap_alloc ();
+ tm_4->fecrate = PHY_FEC_RATE_16_21;
+ tm_4->gil = PHY_GIL_567;
+ TONEMAP_WRITE_BEGIN (tm_4, ti.tonemask)
+ {
+ TONEMAP_WRITE_MOD (4);
+ }
+ TONEMAP_WRITE_END;
+ tm_5 = tonemap_alloc ();
+ tm_5->fecrate = PHY_FEC_RATE_1_2;
+ tm_5->gil = PHY_GIL_417;
+ i = 0;
+ TONEMAP_WRITE_BEGIN (tm_5, ti.tonemask)
+ {
+ if (i < tone_en / 2)
+ mod = 3;
+ else
+ mod = 5;
+ TONEMAP_WRITE_MOD (mod);
+ i++;
+ }
+ TONEMAP_WRITE_END;
+ tm_6 = tonemap_alloc ();
+ tm_6->fecrate = PHY_FEC_RATE_16_21;
+ tm_6->gil = PHY_GIL_417;
+ i = 0;
+ TONEMAP_WRITE_BEGIN (tm_6, ti.tonemask)
+ {
+ if (i < tone_en / 2)
+ mod = 2;
+ else
+ mod = 6;
+ TONEMAP_WRITE_MOD (mod);
+ i++;
+ }
+ TONEMAP_WRITE_END;
+ tm_7 = tonemap_alloc ();
+ tm_7->fecrate = PHY_FEC_RATE_1_2;
+ tm_7->gil = PHY_GIL_567;
+ i = 0;
+ TONEMAP_WRITE_BEGIN (tm_7, ti.tonemask)
+ {
+ if (i < tone_en / 3)
+ mod = 1;
+ else
+ mod = 0;
+ TONEMAP_WRITE_MOD (mod);
+ i++;
+ }
+ TONEMAP_WRITE_END;
sta.rx_tonemaps = tonemaps_alloc ();
- sta.rx_tonemaps->tm[4] = &tm;
+ sta.rx_tonemaps->tm[4] = tm_4;
sta.rx_tonemaps->tm[4]->released = 0;
+ sta.rx_tonemaps->tm[5] = tm_5;
+ sta.rx_tonemaps->tm[5]->released = 0;
+ sta.rx_tonemaps->tm[6] = tm_6;
+ sta.rx_tonemaps->tm[6]->released = 0;
+ sta.rx_tonemaps->tm[7] = tm_7;
+ sta.rx_tonemaps->tm[7]->released = 0;
/* This tests only works if the number of intervals is known, so I prefer
* to manage this locally. */
@@ -652,25 +718,79 @@ test_suite_ce_rx_bl_intervals_update_default_tm (test_t t)
test_fail_if (sta.rx_tonemaps->tm[4]->released
!= TONEMAP_RELEASE_TIMER_S);
- /* TODO: add cases of new tonemap calculation (see #3880). */
+ sta.rx_tonemaps->default_tmi = 4;
+ sta.rx_tonemaps->tm[4]->released = 0;
+
+ sta.intervals->tmi[0] = 0;
+ ce_rx_bl_intervals_update_default_tm (&ce_rx, &sta);
+ test_fail_if (sta.rx_tonemaps->default_tmi != 0);
+ test_fail_if (sta.rx_tonemaps->tm[4]->released
+ != TONEMAP_RELEASE_TIMER_S);
+
+ sta.rx_tonemaps->default_tmi = 4;
+ sta.rx_tonemaps->tm[4]->released = 0;
+
+ sta.intervals->tmi[0] = 6;
+ ce_rx_bl_intervals_update_default_tm (&ce_rx, &sta);
+ test_fail_if (sta.rx_tonemaps->default_tmi != 8);
+ test_fail_if (sta.rx_tonemaps->tm[4]->released
+ != TONEMAP_RELEASE_TIMER_S);
+ test_fail_if (sta.rx_tonemaps->tm[8]->fecrate != PHY_FEC_RATE_1_2);
+ test_fail_if (sta.rx_tonemaps->tm[8]->gil != PHY_GIL_417);
+ i = 0;
+ TONEMAP_READ_BEGIN (sta.rx_tonemaps->tm[8], ti.tonemask, mod)
+ {
+ if (i < tone_en / 2)
+ test_fail_if (mod != 2);
+ else
+ test_fail_if (mod != 5);
+ i++;
+ }
+ TONEMAP_READ_END;
+
+ sta.rx_tonemaps->default_tmi = 4;
+ sta.rx_tonemaps->tm[4]->released = 0;
+
+ sta.intervals->tmi[0] = 7;
+ ce_rx_bl_intervals_update_default_tm (&ce_rx, &sta);
+ test_fail_if (sta.rx_tonemaps->default_tmi != 0);
+ test_fail_if (sta.rx_tonemaps->tm[4]->released
+ != TONEMAP_RELEASE_TIMER_S);
} test_end;
sta.rx_tonemaps->default_tmi = 4;
sta.rx_tonemaps->tm[4]->released = 0;
+ sta.intervals->tmi[0] = 6;
test_begin (t, "Several intervals, one restarting for a better tonemap.")
{
- /* TODO: This will change with new tonemap calculation (see #3880). */
- sta.intervals->tmi[0] = TONEMAP_SRC_INTERVAL_UNAVAILABLE;
- sta.intervals->intervals[0]->default_robo = false;
+ sta.intervals->tmi[1] = TONEMAP_SRC_INTERVAL_UNAVAILABLE;
+ sta.intervals->intervals[1]->default_robo = false;
ce_rx_bl_intervals_update_default_tm (&ce_rx, &sta);
- test_fail_if (sta.rx_tonemaps->default_tmi != 4);
- test_fail_if (sta.rx_tonemaps->tm[4]->released != 0);
+ test_fail_if (sta.rx_tonemaps->default_tmi != 9);
+ test_fail_if (sta.rx_tonemaps->tm[4]->released
+ != TONEMAP_RELEASE_TIMER_S);
+ test_fail_if (sta.rx_tonemaps->tm[9]->fecrate != PHY_FEC_RATE_1_2);
+ test_fail_if (sta.rx_tonemaps->tm[9]->gil != PHY_GIL_567);
+ i = 0;
+ TONEMAP_READ_BEGIN (sta.rx_tonemaps->tm[9], ti.tonemask, mod)
+ {
+ if (i < tone_en / 2)
+ test_fail_if (mod != 2);
+ else
+ test_fail_if (mod != 4);
+ i++;
+ }
+ TONEMAP_READ_END;
} test_end;
+
+ sta.rx_tonemaps->default_tmi = 4;
+ sta.rx_tonemaps->tm[4]->released = 0;
+
test_begin (t, "Several intervals, one restarting for a worst tonemap.")
{
- sta.intervals->tmi[1] = TONEMAP_SRC_INTERVAL_UNAVAILABLE;
- sta.intervals->intervals[1]->default_robo = true;
+ sta.intervals->tmi[2] = TONEMAP_SRC_INTERVAL_UNAVAILABLE;
+ sta.intervals->intervals[2]->default_robo = true;
ce_rx_bl_intervals_update_default_tm (&ce_rx, &sta);
test_fail_if (sta.rx_tonemaps->default_tmi != 0);
test_fail_if (sta.rx_tonemaps->tm[4]->released
@@ -678,7 +798,6 @@ test_suite_ce_rx_bl_intervals_update_default_tm (test_t t)
} test_end;
/* Clean. */
- sta.rx_tonemaps->tm[4] = NULL;
tonemaps_release (sta.rx_tonemaps);
ce_rx_bl_intervals_free (sta.intervals);
ce_rx_bl_intervals_fsm_count_ = old_fsm_nb;