summaryrefslogtreecommitdiff
path: root/cp
diff options
context:
space:
mode:
authorlacour2007-07-16 07:12:06 +0000
committerlacour2007-07-16 07:12:06 +0000
commit4b7bd0d4a22f7b450e8ec74bae3bdb1ff32d3e75 (patch)
treeafd98cf1cb034f089ece0b45abcc6965e82fc42d /cp
parent6fb5695b4f83fef6bc8eea78388029802010376e (diff)
mv test_mme dans test/mme
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@477 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cp')
-rw-r--r--cp/ce/test/mme/src/test_ce_mme_transfer.c272
1 files changed, 272 insertions, 0 deletions
diff --git a/cp/ce/test/mme/src/test_ce_mme_transfer.c b/cp/ce/test/mme/src/test_ce_mme_transfer.c
new file mode 100644
index 0000000000..e55b4f3f80
--- /dev/null
+++ b/cp/ce/test/mme/src/test_ce_mme_transfer.c
@@ -0,0 +1,272 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ttt.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#include "common/std.h"
+#include "lib/rnd.h"
+#include "mac/common/tonemap.h"
+#include "cp/common/cst.h"
+#include "cp/cp.h"
+#include "lib/test.h"
+#include "mac/common/store.h"
+#include "cp/ce/ce.h"
+#include "mac/sar/sar.h"
+#include <stdio.h>
+
+#include <cyg/hal/hal_arch.h>
+#include <cyg/kernel/kapi.h>
+#include "cp/ce/test/inc/print_utils.h"
+
+
+#define TEI 0
+lib_rnd_t rnd;
+sta_t *sta;
+test_t t;
+
+u8 RX_MME_BUFFER[MME_BUFFER_SIZE];
+u8 TX_MME_BUFFER[MME_BUFFER_SIZE];
+cp_t *cp_ctx;
+
+/**
+ * Compare two tonemaps in the test environment
+ * \param t test
+ * \param tms1 tonemaps 1
+ * \param tms2 tonemaps 2
+ *
+ * Check all tonemap (TONEMAP_INDEX_NB)
+ */
+void
+compare_tonemaps (test_t t, tonemaps_t *tms1, tonemaps_t *tms2)
+{
+ test_begin (t, "tonemap transmission")
+ {
+ int i,j;
+
+ test_fail_if (tms1->max_fl_av != tms2->max_fl_av);
+ test_fail_if (tms1->rifs_av_one_sym_tck != tms2->rifs_av_one_sym_tck);
+ test_fail_if (tms1->rifs_av_two_sym_tck != tms2->rifs_av_two_sym_tck);
+ test_fail_if (tms1->rifs_av_g2_sym_tck != tms2->rifs_av_g2_sym_tck);
+ test_fail_if (tms1->max_tm != tms2->max_tm);
+ test_fail_if (tms1->cp_tmi_av != tms2->cp_tmi_av);
+ test_fail_if (tms1->scl_cp != tms2->scl_cp);
+ test_fail_if (tms1->scl_cfp != tms2->scl_cfp);
+
+ for (i=0; i<TONEMAP_INDEX_NB; i++)
+ {
+ if(tms1->tm[i] && tms2->tm[i])
+ {
+ //my_print ("test tm[%d]\n",i);
+ tonemap_t *tm1=tms1->tm[i];
+ tonemap_t *tm2=tms2->tm[i];
+ blk_reader_t *blk_reader1= blk_alloc();
+ blk_reader_t *blk_reader2= blk_alloc();
+ blk_t *blk1 = tm1->tmdma_desc_head;
+ blk_t *blk2 = tm2->tmdma_desc_head;
+ init_blk_reader (blk_reader1, blk1);
+ init_blk_reader (blk_reader2, blk2);
+ //test_fail_if (tm1->valid != tm2->valid);
+ test_fail_if (tm1->cpf != tm2->cpf);
+ test_fail_if (tm1->fecrate != tm2->fecrate);
+ test_fail_if (tm1->gil != tm2->gil);
+ //if (tm1->valid)
+ //{
+ for(j=0; j<(int)NON_MASKED_CARRIER_COUPLE_NB; j++)
+ {
+ //u8 d1 = read_in_blk (blk1, j);
+ //u8 d2 = read_in_blk (blk2, j);
+ u8 d1 = blk_read_u8 (blk_reader1);
+ u8 d2 = blk_read_u8 (blk_reader2);
+ //my_print ("%d",j);
+ test_fail_if ( d1 != d2 );
+ }
+ //}
+
+ test_fail_if (tms1->intervals_nb != tms2->intervals_nb);
+ for (j=0; j<(int)tms1->intervals_nb; j++)
+ {
+ tonemap_interval_t tmi1=tms1->intervals[j];
+ tonemap_interval_t tmi2=tms2->intervals[j];
+ test_fail_if ( tmi1.end_offset_atu != tmi2.end_offset_atu );
+ test_fail_if ( tmi1.tmi_av != tmi2.tmi_av );
+ }
+ }
+ else test_fail_if (tms1->tm[i] != tms2->tm[i]);
+ }
+
+ } test_end;
+
+
+}
+
+
+#define SAR_PRIORITY 6
+cyg_thread sar_thread;
+cyg_handle_t sar_handle;
+unsigned char sar_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+#define CP_RX_PRIORITY 5
+cyg_thread cp_rx_thread;
+cyg_handle_t cp_rx_handle;
+unsigned char cp_rx_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+#define CP_TX_PRIORITY 5
+cyg_thread cp_tx_thread;
+cyg_handle_t cp_tx_handle;
+unsigned char cp_tx_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+#define TEST_PRIORITY 8
+cyg_thread test_thread;
+cyg_handle_t test_handle;
+unsigned char test_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+
+
+/**
+ * Emulation of mme transfer. Callback execute by sar emulation.
+ * (The sar don't know the rx and tx mme buffer)
+ * The emulation copy from tx mme buffer to rx mme buffer
+ * And do this before segmentation_done is called. (The call of
+ * segmentation_done will free the tx buffer.
+ *
+ */
+void
+emul_transfer (void)
+{
+ memcpy (RX_MME_BUFFER, TX_MME_BUFFER, MME_BUFFER_SIZE );
+}
+
+
+/**
+ * Compare the rx_tonemaps and the tx_tonemaps every ~1200 ticks.
+ * Before, the computation of rx_tonemaps must be stopped
+ * and wait the last transfer instead of rx_tonemap and tx_tonemap
+ * be comparable.
+ *
+ * \param data
+ *
+ */
+void
+test_main (cyg_addrword_t data)
+{
+ int i=0;
+ my_print ("\t\t\t\t\t\t\t\t\t\t\t\t TEST STARTED\n");
+ cyg_thread_delay (50);
+ while (++i)
+ {
+ cp_tx_wait (cp_ctx);
+ while (cp_ctx->sar_ctx->status | cp_ctx->rx_buffer_status)
+ {
+ // my_print ("\t\t\t\t\t\t\t\t\t\t\t\t sar status = %d rx_buffer_status = %d \n",cp_ctx->sar_ctx->status , cp_ctx->rx_buffer_status);
+ cyg_thread_delay (1);
+ }
+ //my_print ("\t\t\t\t\t\t\t\t\t\t\t\t sar status = %d rx_buffer_status = %d \n",cp_ctx->sar_ctx->status , cp_ctx->rx_buffer_status);
+ //my_print ("\t\t\t\t\t\t\t\t\t\t\t\t DELAY 600\n");
+ //cyg_thread_delay (600);
+ my_print (" *\t\t\t\t\t\t\t\t\t\t\t\tCOMPARE TONEMAPS\n");
+ compare_tonemaps (t, sta->rx_tonemaps, sta->tx_tonemaps);
+ if (test_nb_failed (t))
+ {
+ my_print ("\nRX TONEMPAPS : \n");
+ print_tonemaps (sta->rx_tonemaps);
+ my_print ("\nTX TONEMPAPS : \n");
+ print_tonemaps (sta->tx_tonemaps);
+ }
+ else
+ {
+ my_print (" \t\t\t\t\t\t\t\t\t\t\t\t TEST OK\n");
+ }
+ test_result (t);
+ if (i == 10)
+ {
+ //cyg_thread_delay (2500);
+ break;
+ }
+ my_print (" \t\t\t\t\t\t\t\t\t\t\t\t RESTART TXCP\n");
+
+ cp_tx_restart (cp_ctx);
+ cyg_thread_delay (100);
+
+ }
+ my_print ("\nRX TONEMPAPS : \n");
+ print_tonemaps (sta->rx_tonemaps);
+ my_print ("\nTX TONEMPAPS : \n");
+ print_tonemaps (sta->tx_tonemaps);
+ cyg_thread_delete (cp_tx_handle);
+ cyg_thread_delete (sar_handle);
+ cyg_thread_delete (cp_rx_handle);
+ test_result (t);
+ cyg_thread_exit ();
+
+}
+
+
+
+int
+cyg_user_start (int argc, char **argv)
+{
+ test_init (t, argc, argv);
+ u8 oda[6] = {'O', 'D', 'A', 'o', 'd', 'a'};
+ lib_rnd_init (&rnd, 456);
+ mac_store_t *mac_store = mac_store_init ();
+ sta = mac_store_sta_new (mac_store, TEI);
+ init_sta (sta, TEI, oda);
+ cp_ctx = cp_init (mac_store, RX_MME_BUFFER, TX_MME_BUFFER);
+
+ cyg_thread_create (SAR_PRIORITY, &sar_main, 0, "sar",
+ sar_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &sar_handle, &sar_thread);
+ cyg_thread_create (CP_RX_PRIORITY, &cp_rx_main, (cyg_addrword_t) cp_ctx, "cp_rx",
+ cp_rx_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &cp_rx_handle, &cp_rx_thread);
+ cyg_thread_create (CP_TX_PRIORITY, &cp_tx_main, (cyg_addrword_t) cp_ctx, "cp_tx",
+ cp_tx_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &cp_tx_handle, &cp_tx_thread);
+
+
+ cyg_thread_create (TEST_PRIORITY, &test_main, 0, "test",
+ test_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &test_handle, &test_thread);
+
+
+ my_print ("resuming cp_rx_handle...\n");
+ cyg_thread_resume (cp_rx_handle);
+ my_print ("resuming cp_tx_handle...\n");
+ cyg_thread_resume (cp_tx_handle);
+ my_print ("resuming sar_handle...\n");
+ //cyg_thread_resume (sar_tx_handle);
+ cyg_thread_resume (sar_handle);
+ my_print ("resuming test_handle...\n");
+ cyg_thread_resume (test_handle);
+
+ return (0);
+}
+
+
+
+//int ref[75] =
+// {
+// 0,0,0,
+/*3-10*/// 8,9,10,11,12,13,14,15,
+/*11-18*/// 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
+/*19-26*/// 0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
+/*27-34*/// 0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,
+/*35-42*/// 0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,
+/*43-50*/// 0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
+/*51-58*/// 0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
+/*59-66*/// 0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
+/*67-74*/// 0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF
+// };
+
+
+