summaryrefslogtreecommitdiff
path: root/cesar/mac/sar/test/functional/src
diff options
context:
space:
mode:
authorlaranjeiro2010-06-15 12:27:37 +0000
committerlaranjeiro2010-06-15 12:27:37 +0000
commitc5c791afde303519ecae53ed762b29d6dfa2b5eb (patch)
tree4ecfc10a2af4c4fc5b5ba41454f8d861b82fea6c /cesar/mac/sar/test/functional/src
parenteb5e017003ac0a95bf18c21d4c5a0b61e438fa5c (diff)
cesar/mac/sar: remove duplicated tests
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7214 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/mac/sar/test/functional/src')
-rw-r--r--cesar/mac/sar/test/functional/src/sar_rx.c296
-rw-r--r--cesar/mac/sar/test/functional/src/sar_tx.c248
2 files changed, 0 insertions, 544 deletions
diff --git a/cesar/mac/sar/test/functional/src/sar_rx.c b/cesar/mac/sar/test/functional/src/sar_rx.c
deleted file mode 100644
index be357930f5..0000000000
--- a/cesar/mac/sar/test/functional/src/sar_rx.c
+++ /dev/null
@@ -1,296 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2009 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file src/sar_rx.c
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-#include "common/std.h"
-#include "common/defs/homeplugAV.h"
-
-#include <cyg/kernel/kapi.h>
-#include <cyg/hal/hal_arch.h>
-#include <string.h>
-
-#include "lib/test.h"
-#include "lib/blk.h"
-#include "lib/crc.h"
-#include "lib/bitstream.h"
-#include "lib/read_word.h"
-#include "lib/trace.h"
-#include "lib/stats.h"
-
-#include "mac/common/ntb.h"
-#include "mac/sar/sar.h"
-
-#include "hal/arch/arch.h"
-#include "hal/phy/bridgedma.h"
-#include "hal/phy/soft/bridgedma/inc/bridgedma.h"
-#include "hal/phy/soft/bridgedma/bridgedma_crc.h"
-#include "mac/sar/test/functional/test_functions.h"
-
-/* Variables needed by the test. */
-#ifdef __sparc__
-static u8 buffers[2][2048] __attribute__ ((section(".private")));
-#else
-static u8 buffers[2][2048];
-#endif
-static sar_t *sar_ctx;
-
-/* Thread data for the test. */
-cyg_thread my_test_thread;
-cyg_handle_t my_test_thread_handle;
-u8 my_test_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
-
-void rea_comp_sar_rea_done (void *user, u8* buffer, uint length,
- mfs_rx_t *mfs, bool encrypted)
-{
-}
-
-void
-prepare_pbs (test_t test)
-{
- uint pb_nb = 6;
- pb_t *pb_list[pb_nb + 1];
- uint i;
- pbproc_rx_desc_t *rx;
- crc_t crc_ctx;
- u32 crc;
- u32 enc_tab[256];
- u8 *buffer;
-
- /* Prepare a series of PBs to give it to the SAR.
- * The PBs are configured to be DATA PBs. */
- for (i = 0; i < pb_nb; i++)
- {
- pb_list[i] = (pb_t *) blk_alloc_desc ();
- pb_list[i]->phy_pb.pb_rx.pb_measurement.crc_error = false;
- pb_list[i]->header.ssn = i;
- pb_list[i]->header.vpbf = true;
- pb_list[i]->header.mmqf = false;
- pb_list[i]->header.opsf = false;
- pb_list[i]->header.mfbf = true;
- pb_list[i]->header.mfbo = 0;
- pb_list[i]->next = NULL;
-
- /* Initialise the data in the PB, only for the test. */
- memset (pb_list[i]->data, 0xFF, BLK_SIZE);
- }
-
- /* First Frame.
- * Data frame, payload length = 1430
- * complete length = 1440.
- * ATS = 0x12345678.
- * type = DATA. */
- pb_list[0]->header.mfbf = true;
- bitstream_direct_write (pb_list[0]->data, 0, SAR_MF_TYPE_DATA, 2);
- bitstream_direct_write (pb_list[0]->data, 2, 1433, 14);
- pb_list[2]->header.mfbf = true;
- pb_list[2]->header.mfbo = 416;
-
- /* Second Frame.
- * Data frame, payload length = 1330.
- * complete length = 1340.
- * ATS = 0x12345678.
- * type = DATA. */
- bitstream_direct_write (pb_list[2]->data, 416 * 8, SAR_MF_TYPE_DATA, 2);
- bitstream_direct_write (pb_list[2]->data, 416 * 8 + 2, 1333, 14);
- pb_list[5]->header.mfbf = true;
- pb_list[5]->header.mfbo = 220;
-
- /* Store 00 to the last PB to indicate an end of data.*/
- bitstream_direct_write (pb_list[5]->data, 220 * 8, 0, 2);
-
- /* Compute the CRC. */
- crc_ctx.width = 32;
- crc_ctx.generator = HPAV_CRC32_GENERATOR;
- crc_ctx.init = HPAV_CRC32_INIT;
- crc_ctx.refin = true;
- crc_ctx.refout = true;
- crc_ctx.xorout = 0xffffffff;
- crc_ctx.reg_init = 0;
- crc_ctx.table.t32 = enc_tab;
- crc_init(&crc_ctx);
-
- buffer = buffers[0];
- memset (buffer, 0xff, 2048);
-
- crc = crc_compute_begin (&crc_ctx);
- crc = bridgedma_crc_compute_continue_block (&crc_ctx, crc, buffer, 1434);
- crc = crc_compute_end (&crc_ctx, crc);
- bitstream_direct_write (pb_list[2]->data, 412 * 8, crc, 32);
-
- crc = crc_compute_begin (&crc_ctx);
- crc = bridgedma_crc_compute_continue_block (&crc_ctx, crc, buffer, 1334);
- crc = crc_compute_end (&crc_ctx, crc);
- bitstream_direct_write (pb_list[5]->data, 216 * 8, crc, 32);
- memset (buffer, 0, 2048);
-
- /* Mix the PBs. */
- pb_list[5]->next = pb_list[3];
- pb_list[3]->next = pb_list[4];
- pb_list[3]->next = pb_list[4];
- pb_list[4]->next = pb_list[1];
- pb_list[1]->next = pb_list[2];
- pb_list[2]->next = pb_list[0];
- pb_list[0]->next = NULL;
-
-#ifdef __sparc__
- /* Request the Leon processor to write all the data buffered. */
- arch_write_buffer_flush ();
-#endif
-
- test_case_begin (test, "Verify MF headers in the PBs");
-
- test_begin (test, "Frame 1 and 2")
- {
- sar_mf_t sar_mf;
-
- sar_mf_header (pb_list[0], 0, &sar_mf);
- test_fail_unless (sar_mf.type == SAR_MF_TYPE_DATA);
- test_fail_unless (sar_mf.length == 1434);
- test_fail_unless (sar_mf.length_complete == 1440);
- test_fail_unless (sar_mf.qte == 3);
-
- sar_mf_header (pb_list[2], 416, &sar_mf);
- test_fail_unless (sar_mf.type == SAR_MF_TYPE_DATA);
- test_fail_unless (sar_mf.length == 1334);
- test_fail_unless (sar_mf.length_complete == 1340);
- test_fail_unless (sar_mf.qte == 4);
- }
- test_end;
-
- test_begin (test, "Non aligned address")
- {
- pb_t *pb_test;
- sar_mf_t sar_mf_2;
-
- pb_test = (pb_t*) blk_alloc_desc ();
- bitstream_direct_write (pb_test->data + 1, 0, SAR_MF_TYPE_DATA, 2);
- bitstream_direct_write (pb_test->data + 1, 2, 105, 14);
-
-#ifdef __sparc__
- /* Request the Leon processor to write all the data buffered. */
- arch_write_buffer_flush ();
-#endif
- sar_mf_header (pb_test, 1, &sar_mf_2);
-
- test_fail_unless (sar_mf_2.type == SAR_MF_TYPE_DATA);
- test_fail_unless (sar_mf_2.length == 106);
-
- blk_release_desc ((blk_t*) pb_test);
- }
- test_end;
-
- /* Give the PB list to the SAR. */
- sar_activate (sar_ctx, true);
-
- /* Provide buffers to the SAR. */
- for (i = 0; i < 2; i++)
- {
- buffer = ARCH_CPU_TO_UNCACHEABLE (buffers[i]);
- sar_data_buffer_add (sar_ctx, buffer);
- }
-
- rx = (pbproc_rx_desc_t*) blk_alloc_desc ();
- rx->rx->params.tei = 1;
- rx->rx->params.lid = 1;
- rx->rx->params.preamble_ntb = mac_ntb();
- rx->rx->params.eks = MAC_EKS_MIN;
- rx->rx->pb_first = pb_list[pb_nb-1];
- rx->rx->pb_last = pb_list[0];
- rx->rx->pb_nb = pb_nb;
- rx->rx->mfs_mme = NULL;
- rx->rx->mfs = NULL;
- rx->rx->chandata_first = NULL;
- rx->rx->chandata_nb = 0;
-
- sar_mpdu_add (sar_ctx, rx);
-}
-
-void
-test_thread_process (cyg_addrword_t data)
-{
- test_t test;
- mac_config_t mac_config;
- uint ca;
- uint pbproc;
- mac_store_t *mac_store;
- u8 *buffer;
- uint i;
-
- trace_init ();
- test_init (test, 0, NULL);
- lib_stats_init ();
-
- /* Initialise the test. */
- mac_ntb_init (&mac_config);
- mac_store = mac_store_init ();
- sar_ctx = sar_init (mac_store, (pbproc_t *) &pbproc, (ca_t *) &ca, 0x1);
- sar_activate (sar_ctx, true);
-
- sar_init_data_context (sar_ctx, sar_ctx);
- sar_init_mme_context (sar_ctx, sar_ctx);
- sar_init_reassembly_data_cb (sar_ctx, rea_comp_sar_rea_done);
- sar_init_reassembly_mme_cb (sar_ctx, rea_comp_sar_rea_done);
- sar_init_measure_context (sar_ctx, sar_ctx);
- sar_init_measurement_cb (sar_ctx, ce_measurements);
-
- prepare_pbs (test);
-
- /* Wait some time. */
- cyg_thread_delay (1);
-
- test_case_begin (test, "Verify reassembly");
-
- test_begin (test, "Sar reassembly")
- {
- buffer = ARCH_CPU_TO_UNCACHEABLE (buffers[0]);
- for (i = 0; i < 1434; i++)
- test_fail_unless (read_u8_from_word (buffer + i) == 0xFF);
-
- buffer = ARCH_CPU_TO_UNCACHEABLE (buffers[1]);
- for (i = 0; i < 1334; i++)
- test_fail_unless (read_u8_from_word (buffer + i) == 0xFF);
- }
- test_end;
-
- test_result (test);
-
- sar_uninit (sar_ctx);
- pbproc_uninit ((pbproc_t *) &pbproc);
-
- dbg_check (mac_store_sta_remove (mac_store, 0x1));
- mac_store_uninit (mac_store);
- mac_ntb_uninit();
- trace_uninit();
- lib_stats_uninit ();
-
-#ifndef __sparc__
- HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
-#endif
-}
-
-int
-cyg_user_start (void)
-{
- // Create the thread.
- cyg_thread_create( 10,
- &test_thread_process,
- (cyg_addrword_t) 0,
- "TEST_THREAD",
- my_test_thread_stack,
- CYGNUM_HAL_STACK_SIZE_TYPICAL,
- &my_test_thread_handle,
- &my_test_thread);
- cyg_thread_resume (my_test_thread_handle);
-
- return 0;
-}
diff --git a/cesar/mac/sar/test/functional/src/sar_tx.c b/cesar/mac/sar/test/functional/src/sar_tx.c
deleted file mode 100644
index d2c92dd35d..0000000000
--- a/cesar/mac/sar/test/functional/src/sar_tx.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2009 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file src/sar_tx.c
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-#include "common/std.h"
-#include "common/defs/homeplugAV.h"
-
-#include "lib/test.h"
-#include "lib/bitstream.h"
-#include "lib/crc.h"
-#include "lib/trace.h"
-#include "lib/stats.h"
-
-#include <cyg/kernel/kapi.h>
-#include <cyg/hal/hal_arch.h>
-#include <string.h>
-
-#include "hal/arch/arch.h"
-
-#include "mac/common/ntb.h"
-#include "mac/common/store.h"
-
-#include "mac/pbproc/pbproc.h"
-#include "mac/sar/sar.h"
-#include "hal/phy/bridgedma.h"
-
-#include "mac/sar/inc/sar_context.h"
-#include "hal/phy/soft/bridgedma/inc/bridgedma.h"
-#include "hal/phy/soft/bridgedma/bridgedma_crc.h"
-#include "mac/sar/test/functional/test_functions.h"
-
-/* Variables needed by the test. */
-#ifdef __sparc__
-static u8 skbuffer[2048] __attribute__ ((section(".private")));
-#else
-static u8 skbuffer[2048];
-#endif
-static sar_t *sar_ctx = NULL;
-static mac_store_t *mac_store = NULL;
-
-static uint count = 0;
-static u32 crcb1;
-static u32 crcb2;
-
-/* Thread data for the test. */
-cyg_thread my_test_thread;
-cyg_handle_t my_test_thread_handle;
-u8 my_test_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
-
-void
-segmentation_done (void *ctx, u8 *buffer, void *user_data)
-{
- count ++;
-}
-
-void
-prepare_test (test_t test)
-{
- uint i;
- u8 *buffer = NULL;
- mfs_tx_t *mfs = NULL;
- bool added = false;
- crc_t crc_ctx;
- u32 enc_tab[256];
-
- /* Prepare the buffer. */
- buffer = ARCH_CPU_TO_UNCACHEABLE (skbuffer);
- for (i = 0; i < 2048/4; i++)
- bitstream_direct_write (buffer, i*8, 0xffffffff, 32);
-
- /* Compute the CRC. */
- crc_ctx.width = 32;
- crc_ctx.generator = HPAV_CRC32_GENERATOR;
- crc_ctx.init = HPAV_CRC32_INIT;
- crc_ctx.refin = true;
- crc_ctx.refout = true;
- crc_ctx.xorout = 0xffffffff;
- crc_ctx.reg_init = 0;
- crc_ctx.table.t32 = enc_tab;
- crc_init(&crc_ctx);
-
- crcb1 = crc_compute_begin (&crc_ctx);
- crcb1 = bridgedma_crc_compute_continue_block (&crc_ctx, crcb1, buffer, 1434);
- crcb1 = crc_compute_end (&crc_ctx, crcb1);
-
- crcb2 = crc_compute_begin (&crc_ctx);
- crcb2 = bridgedma_crc_compute_continue_block (&crc_ctx, crcb2, buffer, 1334);
- crcb2 = crc_compute_end (&crc_ctx, crcb2);
-
- /* Add the MFS. */
- mfs = mac_store_mfs_add_tx (mac_store, false, false, 1, 1, &added);
- dbg_assert (mfs);
-
- if (added)
- sar_mfs_add (sar_ctx, (mfs_t *)mfs);
-
- /* Add the first frame. */
- sar_msdu_add (sar_ctx, buffer, 1434, mfs, NULL, mac_ntb());
- /* Add the second frame. */
- sar_msdu_add (sar_ctx, buffer, 1334, mfs, NULL, mac_ntb());
-
- /* Release the reference on the MFS. */
- blk_release (mfs);
-}
-
-void
-verify_test (test_t test)
-{
- mfs_tx_t *mfs = NULL;
- pb_t *pb_first = NULL;
- pb_t *pb_last = NULL;
- sar_mf_t sar_mf;
- pb_t *pb_list[6 + 1];
- pb_t *pb_current = NULL;
- uint i = 0;
- u32 crc;
-
- mfs = mac_store_mfs_get_tx (mac_store, false, false, 1, 1);
- dbg_assert (mfs);
-
- test_case_begin (test, "SAR TX");
-
- test_begin (test, "Verify PBs")
- {
- test_fail_unless (count == 2);
- test_fail_unless (mfs->seg_nb == 6);
- test_fail_unless (mfs->fsm_state != MFS_FSM_CMD_RELEASE);
- test_fail_unless (mfs->head != NULL);
- test_fail_unless (mfs->tail!= NULL);
- test_fail_unless (mfs->head != mfs->tail);
- test_fail_unless (mfs->tail->header.ssn + 1 == mfs->seg_nb);
-
- pb_first = mfs->head;
- pb_last = mfs->tail;
- pb_last->next = NULL;
- mfs->head = NULL;
- mfs->tail = NULL;
-
- for (i = 0, pb_current = pb_first;
- pb_current;
- i++, pb_current = pb_current->next)
- {
- pb_list[i] = pb_current;
- arch_load_cache ((u32*) &(pb_current->header), 1);
- arch_load_cache ((u32*) (pb_current->data), BLK_SIZE / 4);
- test_fail_unless (pb_current->header.ssn == i);
- }
-
- /* Test the header mfbf and mfbo. */
- test_fail_unless (pb_list[0]->header.mfbf == true);
- test_fail_unless (pb_list[0]->header.mfbo == 0);
- test_fail_unless (pb_list[2]->header.mfbf == true);
- test_fail_unless (pb_list[2]->header.mfbo == 416);
-
- /* Verify the headers. */
- sar_mf_header (pb_list[0], 0, &sar_mf);
- test_fail_unless (sar_mf.type == SAR_MF_TYPE_DATA);
- test_fail_unless (sar_mf.length == 1434);
-
- sar_mf_header (pb_list[2], 416, &sar_mf);
- test_fail_unless (sar_mf.type == SAR_MF_TYPE_DATA);
- test_fail_unless (sar_mf.length == 1334);
-
- /* Verify the CRC. */
- crc = bitstream_direct_read (pb_list[2]->data, 412 * 8, 32);
- test_fail_unless (crc == crcb1);
-
- crc = bitstream_direct_read (pb_list[5]->data, 216 * 8, 32);
- test_fail_unless (crc == crcb2);
-
- sar_mfs_free_tx (sar_ctx, mfs);
- }
- test_end;
-
- blk_release (mfs);
-}
-
-void
-test_thread_process (cyg_addrword_t data)
-{
- test_t test;
- mac_config_t mac_config;
- uint ca;
- uint pbproc;
-
- test_init (test, 0, NULL);
- trace_init ();
- lib_stats_init ();
-
- /* Initialise the test. */
- mac_ntb_init (&mac_config);
- mac_store = mac_store_init ();
- sar_ctx = sar_init (mac_store, (pbproc_t *) &pbproc, (ca_t *) &ca, 0x1);
- sar_activate (sar_ctx, true);
-
- sar_init_data_context (sar_ctx, sar_ctx);
- sar_init_mme_context (sar_ctx, sar_ctx);
- sar_init_measurement_cb (sar_ctx, ce_measurements);
- sar_init_segmentation_data_cb (sar_ctx, segmentation_done);
- sar_init_segmentation_mme_cb (sar_ctx, segmentation_done);
-
- prepare_test (test);
-
- /* Wait the bridgedma ends its job. */
- cyg_thread_delay (1);
- verify_test (test);
-
- test_result (test);
-
- sar_uninit (sar_ctx);
- pbproc_uninit ((pbproc_t *) &pbproc);
-
- dbg_check (mac_store_sta_remove (mac_store, 0x1));
- mac_store_uninit (mac_store);
- mac_ntb_uninit();
- lib_stats_uninit ();
-
-#ifndef __sparc__
- HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
-#endif
-}
-
-int
-cyg_user_start (void)
-{
- // Create the thread.
- cyg_thread_create( 10,
- &test_thread_process,
- (cyg_addrword_t) 0,
- "TEST_THREAD",
- my_test_thread_stack,
- CYGNUM_HAL_STACK_SIZE_TYPICAL,
- &my_test_thread_handle,
- &my_test_thread);
- cyg_thread_resume (my_test_thread_handle);
-
- return 0;
-}