/* Cesar project {{{; * * Copyright (C) 2007 Spidcom * * <<>> * * }}} */ /** * \file test/hle_recv.c * \brief unit test to test the hle when it sends a data to the CL. * \ingroup hle * * « long description » */ #include "common/std.h" #include #include #include #include "lib/test.h" #include "lib/blk.h" #include "lib/trace.h" #include "lib/bitstream.h" #include "cl/cl.h" #include "hle/hle.h" #include "lib/test.h" #include "hle/inc/trace.h" #include "mac/common/ntb.h" void interface_buffer_work_add (void *user_data, u8 *buffer) { } void interface_mme_recv (void *user_data, u8 *buffer) { } int main (void) { test_t test; bitstream_t bitstream; hle_t *hle; cl_t *cl; uint msgs [10]; u8 *buff_packet[2]; uint data; uint phy; mac_config_t mac_config; mac_ntb_init ((phy_t *) &phy, &mac_config); buff_packet[0] = malloc (2048 * sizeof(u8)); buff_packet[1] = malloc (2048 * sizeof(u8)); test_init (test, 0, NULL); trace_init(); // The function cl_init has been overided. cl = cl_init (NULL, NULL); hle = hle_init (cl); /** Data allocation */ bitstream_init (&bitstream, msgs, 32, BITSTREAM_WRITE); data = HLE_MSG_TYPE_BUFFER_ADD; bitstream_access (&bitstream, &data, 8); data = 1; bitstream_access (&bitstream, &data, 4); data = 1; bitstream_access (&bitstream, &data, 3); bitstream_finalise (&bitstream); memcpy (&msgs[1], &buff_packet[0], sizeof(uint)); memcpy (&msgs[2], &msgs[0], sizeof(uint)); memcpy (&msgs[3], &buff_packet[1], sizeof(uint)); hle_ipmbox_recv (hle, msgs, 4); /** MME allocation */ buff_packet[0] = malloc (2048 * sizeof(u8)); buff_packet[1] = malloc (2048 * sizeof(u8)); bitstream_init (&bitstream, msgs, 32, BITSTREAM_WRITE); data = HLE_MSG_TYPE_BUFFER_ADD; bitstream_access (&bitstream, &data, 8); data = 1; bitstream_access (&bitstream, &data, 4); data = 0; bitstream_access (&bitstream, &data, 3); bitstream_finalise (&bitstream); memcpy (&msgs[1], &buff_packet[0], sizeof(uint)); memcpy (&msgs[2], &msgs[0], sizeof(uint)); memcpy (&msgs[3], &buff_packet[1], sizeof(uint)); hle_ipmbox_recv (hle, msgs, 4); /** INTERFACE allocation */ hle_init_interface_cb (hle, interface_buffer_work_add, interface_mme_recv, NULL); buff_packet[0] = malloc (2048 * sizeof(u8)); buff_packet[1] = malloc (2048 * sizeof(u8)); bitstream_init (&bitstream, msgs, 32, BITSTREAM_WRITE); data = HLE_MSG_TYPE_BUFFER_ADD; bitstream_access (&bitstream, &data, 8); data = 1; bitstream_access (&bitstream, &data, 4); data = 2; bitstream_access (&bitstream, &data, 3); bitstream_finalise (&bitstream); memcpy (&msgs[1], &buff_packet[0], sizeof(uint)); memcpy (&msgs[2], &msgs[0], sizeof(uint)); memcpy (&msgs[3], &buff_packet[1], sizeof(uint)); hle_ipmbox_recv (hle, msgs, 4); hle_trace_print (hle); hle_uninit (hle); cl_uninit (cl); test_begin (test, "Memory test") { test_fail_if (blk_check_memory() == false, "Memory not freed"); } test_end; test_result (test); return test_nb_failed (test) == 0 ? 0 : 1; } u32 phy_date (phy_t *phy) { return 0; }