summaryrefslogtreecommitdiff
path: root/cesar/cl/test/src/cl_mme_recv.c
diff options
context:
space:
mode:
authorsave2008-04-07 14:17:42 +0000
committersave2008-04-07 14:17:42 +0000
commit3d58a62727346b7ac1a6cb36fed1a06ed72228dd (patch)
treed7788c3cf9f76426aef0286d0202e2097f0fa0eb /cesar/cl/test/src/cl_mme_recv.c
parent095dca4b0a8d4924093bab424f71f588fdd84613 (diff)
Moved the complete svn base into the cesar directory.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1769 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cl/test/src/cl_mme_recv.c')
-rw-r--r--cesar/cl/test/src/cl_mme_recv.c121
1 files changed, 121 insertions, 0 deletions
diff --git a/cesar/cl/test/src/cl_mme_recv.c b/cesar/cl/test/src/cl_mme_recv.c
new file mode 100644
index 0000000000..9a03afff2c
--- /dev/null
+++ b/cesar/cl/test/src/cl_mme_recv.c
@@ -0,0 +1,121 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cl/test/src/cl_mme_recv.c
+ * \brief <brief>
+ * \ingroup cl/test/src/
+ *
+ */
+
+#include "common/std.h"
+#include "lib/test.h"
+#include "lib/trace.h"
+
+#include "mac/common/store.h"
+#include "mac/common/ntb.h"
+#include "mac/pbproc/pbproc.h"
+#include "mac/sar/sar.h"
+
+#include "cl/cl.h"
+#include "cl/cl_mactotei.h"
+
+#include "cl/inc/trace.h"
+
+#include "hal/phy/phy.h"
+
+bool test_mme_recv;
+bool test_mme_send_done_to_cp;
+cl_t *cl;
+
+void cl_send_mme_to_cp (void *user, mfs_rx_t *mfs, u8 *buffer, uint length,
+ cl_mme_recv_t *mme_recv, bool encryption)
+{
+ test_mme_send_done_to_cp = true;
+
+ cl_mme_recv_done (cl, mme_recv);
+}
+
+void hle_mme_send_done (void *test, u8 *buffer)
+{
+ test_mme_recv = true;
+}
+
+int main (void)
+{
+ test_t test;
+ mac_store_t *mac_store;
+ sar_t *sar;
+ pbproc_t *pbproc;
+ mac_config_t *mac_config;
+ phy_t *phy;
+ mfs_rx_t *mfs;
+ bool added;
+ u8 buffer[2048];
+
+ test_init (test, 0, NULL);
+ trace_init ();
+
+ mac_store = mac_store_init ();
+ mac_config = blk_alloc ();
+ phy = blk_alloc ();
+ mac_ntb_init(phy, mac_config);
+ pbproc = pbproc_init (mac_config, mac_store);
+ sar = sar_init (mac_store, pbproc, NULL);
+ mac_config->tei = 10;
+ cl = cl_init (mac_store, sar, mac_config);
+
+ mfs = mac_store_mfs_add_rx (mac_store, false, false, 1, 1, &added);
+ dbg_assert (added);
+
+ cl_mme_recv_init (cl, cl_send_mme_to_cp, NULL);
+
+ // send a data to the CP
+ test_mme_send_done_to_cp = false;
+ cl_mme_sar_recv (cl, buffer, 1204, mfs, false);
+
+ test_begin(test, "Send done to CP from SAR")
+ {
+ test_fail_if (test_mme_send_done_to_cp == false, "data not send");
+ }
+ test_end;
+
+ mac_store_mfs_remove (mac_store, (mfs_t *) mfs);
+ blk_release (mfs);
+
+ test_mme_send_done_to_cp = false;
+ test_mme_recv = false;
+ cl_mme_ul_init_send_done(cl, hle_mme_send_done, NULL);
+ cl_mme_ul_send (cl, buffer, 1024);
+
+ test_begin(test, "Send done to CP from HLE")
+ {
+ test_fail_if (test_mme_send_done_to_cp == false, "data not send");
+ test_fail_if (test_mme_recv == false, "Hle not informed");
+ }
+ test_end;
+
+ added = mac_store_sta_remove (mac_store, 1);
+ dbg_check (added);
+ mac_store_uninit (mac_store);
+ blk_release (mac_config);
+ blk_release (phy);
+ pbproc_uninit (pbproc);
+ sar_uninit (sar);
+
+ cl_trace_print (cl);
+ cl_uninit(cl);
+
+ test_begin (test, "memory check")
+ {
+ test_fail_if (blk_check_memory == false, "momery not correctly freed");
+ }
+ test_end;
+
+ test_result (test);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+}