/* Cesar project {{{ * * Copyright (C) 2007 Spidcom * * <<>> * * }}} */ /** * \file cl/test/src/cl_mme_recv.c * \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; }