summaryrefslogtreecommitdiff
path: root/mac/sar/test/unit_test/ecos
diff options
context:
space:
mode:
authorlaranjeiro2008-03-17 17:24:56 +0000
committerlaranjeiro2008-03-17 17:24:56 +0000
commiteef404d8729d50cebd1b8995102ce52cf049794c (patch)
tree20fe95a371582dd16acb3707e4c8d92436bbaeb6 /mac/sar/test/unit_test/ecos
parente4f02cafa0b213caa23d2c294da73f6955a750f2 (diff)
Added new tests to verify the bug in the segmentation process. When only one
pb is necessary in two jobs it did not provide the pb at the end of the second job to the pbproc. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1612 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'mac/sar/test/unit_test/ecos')
-rw-r--r--mac/sar/test/unit_test/ecos/Makefile5
-rw-r--r--mac/sar/test/unit_test/ecos/src/beacon.c78
-rw-r--r--mac/sar/test/unit_test/ecos/src/msdu-timeout.c108
-rw-r--r--mac/sar/test/unit_test/ecos/src/test-segmentation-provide-pb.c129
4 files changed, 319 insertions, 1 deletions
diff --git a/mac/sar/test/unit_test/ecos/Makefile b/mac/sar/test/unit_test/ecos/Makefile
index df3deecc8c..649aa4b378 100644
--- a/mac/sar/test/unit_test/ecos/Makefile
+++ b/mac/sar/test/unit_test/ecos/Makefile
@@ -7,7 +7,7 @@ TARGET_PROGRAMS = reassembly_complete rea_cov_test \
reassembly_mfs_update_expiration_date sar_call_back_ul \
lib_sar_expiration sar_mf_function_test \
sar_mfs_resising segmentation_complete test_store_memory test_crc_error \
- msdu-timeout beacon_path
+ msdu-timeout beacon_path test-seg-provide-pb
test_store_memory_SOURCES = test_store_memory.c
test_store_memory_MODULES = lib mac/common mac/sar/bridgedma
@@ -68,6 +68,9 @@ beacon_path_SOURCES = beacon.c
beacon_path_MODULES = lib mac/sar mac/common mac/sar/bridgedma \
mac/sar/test
+test-seg-provide-pb_SOURCES = test-segmentation-provide-pb.c
+test-seg-provide-pb_MODULES = lib mac/sar mac/common mac/sar/bridgedma \
+ mac/sar/test mac/pbproc
mac_pbproc_MODULE_SOURCES = mfs.c
diff --git a/mac/sar/test/unit_test/ecos/src/beacon.c b/mac/sar/test/unit_test/ecos/src/beacon.c
new file mode 100644
index 0000000000..bf4fb4895f
--- /dev/null
+++ b/mac/sar/test/unit_test/ecos/src/beacon.c
@@ -0,0 +1,78 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/sar/test/unit_test/ecos/src/beacon.c
+ * \brief Send beacon.
+ * \ingroup sar
+ *
+ * Coverage use only, the function tested is only a path to the mac layer, the
+ * sar only provide the beacon to the pbproc and does nothing with it.
+ */
+#include <cyg/kernel/kapi.h>
+#include <cyg/hal/hal_arch.h>
+
+#include "common/std.h"
+
+#include "lib/test.h"
+
+#include "mac/sar/sar.h"
+#include "mac/sar/inc/sar_context.h"
+
+int
+main (void)
+{
+ test_t test;
+ sar_t *sar;
+ pb_beacon_t *beacon;
+ mfs_tx_t *mfs;
+
+ test_init (test, 0, NULL);
+
+ sar = blk_alloc ();
+ sar->pbproc_ctx = blk_alloc ();
+ beacon = blk_alloc ();
+ mfs = blk_alloc ();
+
+ mfs->beacon = true;
+ mfs->head = NULL;
+ mfs->tail = NULL;
+ sar_beacon_send (sar, beacon, mfs, sar);
+
+ blk_release (sar->pbproc_ctx);
+ blk_release (sar);
+ blk_release (beacon);
+ blk_release (mfs);
+
+ test_begin (test, "Memory test")
+ {
+ test_fail_if (blk_check_memory() == false, "Memory not freed");
+ }
+ test_end;
+
+
+ test_result (test);
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+}
+
+void
+pbproc_mfs_provide (mfs_tx_t *mfs, uint nb) {return;}
+
+pb_t *
+pbproc_mfs_extract_tail (mfs_tx_t *mfs) {return NULL;}
+
+void
+pbproc_mfs_insert (mfs_tx_t *mfs, pb_t *first, pb_t *last, uint nb, uint cap) {return;}
+
+void
+pbproc_mfs_beacon_prepare (pbproc_t *ctx, mfs_tx_t *mfs, pb_beacon_t *pb,
+ const pbproc_tx_beacon_params_t *params)
+{
+ return;
+}
+
diff --git a/mac/sar/test/unit_test/ecos/src/msdu-timeout.c b/mac/sar/test/unit_test/ecos/src/msdu-timeout.c
new file mode 100644
index 0000000000..641071fb00
--- /dev/null
+++ b/mac/sar/test/unit_test/ecos/src/msdu-timeout.c
@@ -0,0 +1,108 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mac/sar/test/unit_test/ecos/src/msdu-timeout.c
+ * \brief Test the msdu expiration.
+ * \ingroup mac_sar
+ *
+ */
+#include "common/std.h"
+
+#include <cyg/kernel/kapi.h>
+#include <cyg/hal/hal_arch.h>
+
+
+#include "lib/test.h"
+#include "mac/sar/sar.h"
+#include "mac/common/ntb.h"
+
+#include "mac/sar/inc/sar_context.h"
+
+bool expired;
+
+bool tx_msdu_expiration (sar_t *ctx, sar_msdu_t * msdu);
+
+/**
+ * Segmentation process for the SAR module.
+ *
+ * \param ctx the sar context
+ * \param msdu the msdu to process
+ */
+void segmentation_run (sar_t *ctx, sar_msdu_t *msdu);
+
+void
+seg_done (void *user_data, u8 *buffer)
+{
+ expired = true;
+}
+
+int
+main (void)
+{
+ test_t test;
+ sar_t *sar;
+ mac_config_t mac_config;
+ sar_msdu_t msdu_exp;
+ sar_msdu_t msdu;
+
+ test_init (test, 0, NULL);
+ sar = blk_alloc ();
+
+ mac_ntb_init ((phy_t *)sar, &mac_config);
+ sar_init_segmentation_data_cb (sar, seg_done);
+ sar_init_segmentation_mme_cb (sar, seg_done);
+
+ msdu_exp.ats_confounder = 0;
+ msdu.ats_confounder = 26000000;
+ msdu.mfs = blk_alloc ();
+ msdu.mfs->common.mme = true;
+
+ msdu_exp.mfs = msdu.mfs;
+
+ expired = false;
+ segmentation_run (sar, &msdu_exp);
+
+ test_begin (test, "Expired")
+ {
+ test_fail_if (expired != true, "MSDU shall expire : Wrong expiration");
+ }
+ test_end;
+
+ expired = false;
+ msdu_exp.mfs->common.mme = false;
+ segmentation_run (sar, &msdu_exp);
+
+ test_begin (test, "Expired")
+ {
+ test_fail_if (expired != true, "MSDU shall expire : Wrong expiration");
+ }
+ test_end;
+
+
+ test_begin (test, "No Expiration")
+ {
+ test_fail_if (tx_msdu_expiration (sar, &msdu) != false, "MSDU shall not expire");
+ }
+ test_end;
+
+
+ blk_release (sar);
+ blk_release (msdu.mfs);
+
+ test_result (test);
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+
+}
+
+u32
+phy_date (phy_t * phy)
+{
+ return 25000000;
+}
+
diff --git a/mac/sar/test/unit_test/ecos/src/test-segmentation-provide-pb.c b/mac/sar/test/unit_test/ecos/src/test-segmentation-provide-pb.c
new file mode 100644
index 0000000000..23e8b001f1
--- /dev/null
+++ b/mac/sar/test/unit_test/ecos/src/test-segmentation-provide-pb.c
@@ -0,0 +1,129 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/test-segmentation-provide-pb.c
+ * \brief Test segmentation.
+ * \ingroup mac_sar
+ *
+ * This test will test the providing of PBs when a segmentation of some frames
+ * are requested in a same MFS.
+ */
+#include <cyg/kernel/kapi.h>
+#include <cyg/hal/hal_arch.h>
+
+#include "common/std.h"
+
+#include "lib/test.h"
+
+#include "mac/common/ntb.h"
+
+#include "mac/sar/sar.h"
+#include "mac/sar/inc/sar_context.h"
+
+void
+sar_seg_done (void *user_data, u8 *buffer)
+{
+}
+
+int
+main (void)
+{
+ test_t test;
+ u8 buffer[2048];
+ uint list[4];
+ uint i;
+
+ mac_config_t mac_config;
+
+ sar_t *sar;
+ pbproc_t *pbproc;
+ ca_t *ca;
+ phy_t *phy;
+
+ mfs_tx_t *mfs;
+ mac_store_t *mac_store;
+
+ test_init (test, 0, NULL);
+
+ mfs = blk_alloc ();
+ phy = blk_alloc ();
+ ca = blk_alloc ();
+
+ mfs_tx_init (mfs, false, false, 1, 1);
+ mfs->common.ats = true;
+
+ mac_config_init (&mac_config);
+ mac_store = mac_store_init ();
+ pbproc = pbproc_init (&mac_config, mac_store);
+ mac_ntb_init (phy, &mac_config);
+ sar = sar_init (mac_store, pbproc, ca);
+
+ sar_init_data_context (sar, NULL);
+ sar_init_segmentation_data_cb (sar, sar_seg_done);
+ sar_init_segmentation_mme_cb (sar, sar_seg_done);
+
+ list[0] = 1024 - 10;
+ list[1] = 224 - 10;
+ list[2] = 700 - 10;
+ list[3] = 1024 - 10;
+
+ test_begin (test, "Verifying the MFS state")
+ {
+ for (i = 0; i < 4; i++)
+ {
+ /* Add a msdu to the sar. */
+ sar_msdu_add (sar, buffer, list[i], 0x12345678, mfs);
+ sar_launch (sar);
+
+ /* Launch the segementation. */
+ sar_launch (sar);
+ sar_launch (sar);
+
+ switch (i)
+ {
+ case 0:
+ test_fail_if (mfs->seg_nb != 3, "Wrong seg nb, shall be 3 and have : %d", mfs->seg_nb);
+ test_fail_if (mfs->pending_seg_nb != 0, "Wrong seg nb pending");
+ break;
+ case 1:
+ test_fail_if (mfs->seg_nb != 3, "Wrong seg nb, shall be 3 and have : %d", mfs->seg_nb);
+ test_fail_if (mfs->pending_seg_nb != 0, "Wrong seg nb pending");
+ break;
+ case 2:
+ test_fail_if (mfs->seg_nb != 4, "Wrong seg nb, shall be 3 and have : %d", mfs->seg_nb);
+ test_fail_if (mfs->pending_seg_nb != 0, "Wrong seg nb pending");
+ break;
+ case 3:
+ test_fail_if (mfs->seg_nb != 6, "Wrong seg nb, shall be 3 and have : %d", mfs->seg_nb);
+ test_fail_if (mfs->pending_seg_nb != 0, "Wrong seg nb pending");
+ break;
+
+ }
+ }
+ }
+ test_end;
+
+ /* Free the PBs in the MFS. */
+ pb_free_range (mfs->head);
+
+ blk_release (mfs);
+ blk_release (phy);
+ blk_release (ca);
+
+ test_begin (test, "Memory test")
+ {
+ test_fail_if (blk_check_memory() == false, "Memory not freed");
+ }
+ test_end;
+
+
+ test_result (test);
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+}
+