/* Cesar project {{{ * * Copyright (C) 2007 Spidcom * * <<>> * * }}} */ /** * \file ./src/test_cei.c * \brief « brief description » * \ingroup « module » * * « long description » */ #include "common/std.h" #define RXCE #define TXCE #include "ce/inc/cei.h" #include "lib/test.h" #include "mac/common/tonemask.h" #include "ce/test/common/tonemap_utils.h" #include "ce/test/common/print_utils.h" void test_exchange (test_t test, tonemaps_t *rx_tms, tonemaps_t *tx_tms, u8 *mask, uint tmi, uint max_rnd, uint offset) { u8 buffer[1536]; int i; for (i=0; i<1536; i++) buffer[i]=0; create_tm (rx_tms, mask, tmi, max_rnd, offset); ce_print_tonemaps (rx_tms); cei_create (buffer, mask, rx_tms, tmi, TONEMAP_INDEX_NULL); ce_print_buffer (buffer, 512); cei_decode (tx_tms, CM_CHAN_EST_IND, buffer, mask); ce_print_tonemaps (tx_tms); compare_tonemaps (test, rx_tms, tx_tms, mask); } int main (int argc, char **argv) { int i; u8 mask[(PHY_CARRIER_NB+7)/8]; for (i=0; i<(PHY_CARRIER_NB+7)/8; i++) mask[i] = 0xFF; mask[i-1] = ((1<<(PHY_CARRIER_NB%8))-1); test_t test; lib_rnd_init (&rnd, 12); test_init (test, argc, argv); tonemaps_t *rx_tms = tonemaps_alloc(); tonemaps_t *tx_tms = tonemaps_alloc(); test_case_begin (test, "CE-cei-full mask"); test_exchange (test, rx_tms, tx_tms, mask, 0, 3, 1); test_exchange (test, rx_tms, tx_tms, mask, 1, 2, 6); test_exchange (test, rx_tms, tx_tms, mask, 2, 1, 3); test_exchange (test, rx_tms, tx_tms, mask, 3, 0, 3); tonemaps_release (rx_tms); tonemaps_release (tx_tms); test_begin (test, "check alloc/free") { test_fail_unless (blk_check_memory()); } test_end; rx_tms = tonemaps_alloc(); tx_tms = tonemaps_alloc(); tonemask_default (mask); test_case_begin (test, "CE-cei-default mask"); test_exchange (test, rx_tms, tx_tms, mask, 0, 3, 1); test_exchange (test, rx_tms, tx_tms, mask, 1, 2, 6); test_exchange (test, rx_tms, tx_tms, mask, 2, 1, 3); test_exchange (test, rx_tms, tx_tms, mask, 3, 0, 3); tonemaps_release (rx_tms); tonemaps_release (tx_tms); test_begin (test, "check alloc/free") { test_fail_unless (blk_check_memory()); } test_end; test_result (test); return (test_nb_failed (test) == 0 ? 0 : 1); }