summaryrefslogtreecommitdiff
path: root/cleopatre/devkit/tests/plcdrv/utests/src
diff options
context:
space:
mode:
authorCyril Jourdan2011-12-09 14:52:11 +0100
committerNicolas Schodet2012-02-10 15:33:49 +0100
commit89328e8cc096f8c9f340a3eb8910d06748a3e572 (patch)
treebc38232bc82f639a80b917d739740b3d9608c03e /cleopatre/devkit/tests/plcdrv/utests/src
parentc0199c330baadc6a8089a1db26b3ec7f76734b2b (diff)
cleo/devkit/plcdrv: remove gidel and move arm dir content to plcdrv, refs #848
Diffstat (limited to 'cleopatre/devkit/tests/plcdrv/utests/src')
-rw-r--r--cleopatre/devkit/tests/plcdrv/utests/src/hal_utests.c380
-rw-r--r--cleopatre/devkit/tests/plcdrv/utests/src/linux_drv_utests.c94
-rw-r--r--cleopatre/devkit/tests/plcdrv/utests/src/mailbox_utests.c252
-rw-r--r--cleopatre/devkit/tests/plcdrv/utests/src/processing_utests.c230
4 files changed, 956 insertions, 0 deletions
diff --git a/cleopatre/devkit/tests/plcdrv/utests/src/hal_utests.c b/cleopatre/devkit/tests/plcdrv/utests/src/hal_utests.c
new file mode 100644
index 0000000000..57cd7db0b1
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/utests/src/hal_utests.c
@@ -0,0 +1,380 @@
+/* Cleopatre project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hal_utests.c
+ * \brief Unitary tests for HAL layer
+ * \ingroup Cleopatre - PlcDrv
+ *
+ * This file content all the unitary tests for the hal layer,
+ * this layer will provide all mechanisms to manage hardware.
+ */
+
+#include <check.h>
+#include <stdio.h>
+#include <string.h>
+#include "hal.h"
+#include "common.h"
+
+#include "inc/hal_utests.h"
+
+/** local defines */
+#define L2A_RING_BASE_ADDR ((uint32_t)&MBX_ring[A2L_RING_SIZE/4])
+#define A2L_RING_BASE_ADDR ((uint32_t)&MBX_ring[0])
+
+/** local variables */
+struct halctx *tstctx;
+
+struct init_info info = {
+ .ring_base_addr = (uint32_t)&MBX_ring[0],
+ .phys_ring_base_addr = (uint32_t)&MBX_ring[0],
+ .mbx_reg_base_addr = (uint32_t)&MBX_registers[0]
+};
+
+/** init test procedure */
+START_TEST (test_halmbx_init)
+{
+ //Check arguments
+ fail_if(halmbx_init(NULL) != NULL, "halmbx_init arguments error");
+
+ tstctx = halmbx_init(&info);
+
+ //Check mailbox pointer initialization
+ fail_if(tstctx->A2L_ptr != &MBX_ring[0], "A2L ring pointer not initialize");
+ fail_if(tstctx->L2A_ptr != &MBX_ring[A2L_RING_SIZE/4], "L2A ring pointer not initialize");
+ fail_if(tstctx->A2L_head != &MBX_registers[5], "A2L_tail pointer not initialize");
+ fail_if(tstctx->A2L_tail != &MBX_registers[4], "A2L_tail pointer not initialize");
+ fail_if(tstctx->L2A_head != &MBX_registers[7], "L2A_head pointer not initialize");
+ fail_if(tstctx->L2A_tail != &MBX_registers[6], "L2A_tail pointer not initialize");
+ fail_if(tstctx->A2L_it != &MBX_registers[0], "A2L it pointer not initialize");
+ fail_if(tstctx->L2A_it != &MBX_registers[2], "L2A it pointer not initialize");
+ fail_if(tstctx->L2A_it_mask != &MBX_registers[3], "L2A it mask pointer not initialize");
+
+ //Check mailbox head and tail pointers values
+ fail_if(*tstctx->A2L_tail != (uint32_t)&MBX_ring[0], "A2L tail not initialize");
+ fail_if(*tstctx->L2A_head != (uint32_t)&MBX_ring[A2L_RING_SIZE/4], "L2A head not initialize");
+}
+END_TEST
+
+START_TEST (test_set_A2Lt_interrupt)
+{
+ *tstctx->A2L_it = 0;
+ set_A2Lt_interrupt(tstctx);
+ fail_if(*tstctx->A2L_it != 0x01, "A2L trigger not set");
+ *tstctx->A2L_it = 3;
+ set_A2Lt_interrupt(tstctx);
+ fail_if(*tstctx->A2L_it != 0x03, "A2L trigger not set");
+}
+END_TEST
+
+START_TEST (test_set_L2Aa_interrupt)
+{
+ *tstctx->A2L_it = 0;
+ set_L2Aa_interrupt(tstctx);
+ fail_if(*tstctx->A2L_it != 0x02, "L2A acknowledge not set");
+ *tstctx->A2L_it = 3;
+ set_L2Aa_interrupt(tstctx);
+ fail_if(*tstctx->A2L_it != 0x03, "L2A acknowledge not set");
+}
+END_TEST
+
+START_TEST (test_clr_L2At_interrupt)
+{
+ *tstctx->L2A_it = 1;
+ clr_L2At_interrupt(tstctx);
+ fail_if(*tstctx->L2A_it != 0x01, "L2A trigger not clr");
+ *tstctx->L2A_it = 2;
+ clr_L2At_interrupt(tstctx);
+ fail_if(*tstctx->L2A_it != 0x01, "L2A trigger not clr");
+}
+END_TEST
+
+START_TEST (test_clr_A2La_interrupt)
+{
+ *tstctx->L2A_it = 2;
+ clr_A2La_interrupt(tstctx);
+ fail_if(*tstctx->L2A_it != 0x02, "A2L acknowledge not clr");
+ *tstctx->L2A_it = 1;
+ clr_A2La_interrupt(tstctx);
+ fail_if(*tstctx->L2A_it != 0x02, "A2L acknowledge not clr");
+}
+END_TEST
+
+START_TEST (test_A2La_it_enable)
+{
+ *tstctx->L2A_it_mask = 2;
+ A2La_it_enable(tstctx);
+ fail_if(*tstctx->L2A_it_mask != 0x00, "A2L acknowledge not enable");
+ *tstctx->L2A_it_mask = 1;
+ A2La_it_enable(tstctx);
+ fail_if(*tstctx->L2A_it_mask != 0x01, "A2L acknowledge not enable");
+}
+END_TEST
+
+START_TEST (test_L2At_it_enable)
+{
+ *tstctx->L2A_it_mask = 1;
+ L2At_it_enable(tstctx);
+ fail_if(*tstctx->L2A_it_mask != 0x00, "L2A trigger not enable");
+ *tstctx->L2A_it_mask = 2;
+ L2At_it_enable(tstctx);
+ fail_if(*tstctx->L2A_it_mask != 0x02, "L2A trigger not enable");
+}
+END_TEST
+
+START_TEST (test_A2La_it_disable)
+{
+ *tstctx->L2A_it_mask = 0;
+ A2La_it_disable(tstctx);
+ fail_if(*tstctx->L2A_it_mask != 0x02, "A2L acknowledge not disable");
+ *tstctx->L2A_it_mask = 3;
+ A2La_it_disable(tstctx);
+ fail_if(*tstctx->L2A_it_mask != 0x03, "A2L acknowledge not disable");
+}
+END_TEST
+
+START_TEST (test_L2At_it_disable)
+{
+ *tstctx->L2A_it_mask = 0;
+ L2At_it_disable(tstctx);
+ fail_if(*tstctx->L2A_it_mask != 0x01, "L2A trigger not disable");
+ *tstctx->L2A_it_mask = 3;
+ L2At_it_disable(tstctx);
+ fail_if(*tstctx->L2A_it_mask != 0x03, "L2A trigger not disable");
+}
+END_TEST
+
+START_TEST (test_halmbx_L2Amail_not_empty_queue)
+{
+ //The ring size for the test is 0x100
+ *tstctx->L2A_tail = 0x5;
+ *tstctx->L2A_head = 0x5;
+ fail_if(halmbx_L2Amail_not_empty_queue(tstctx) != 0, "Error checking L2A not empty queue");
+ *tstctx->L2A_tail = 0xA;
+ *tstctx->L2A_head = 0x7;
+ fail_if(halmbx_L2Amail_not_empty_queue(tstctx) == 0, "Error checking L2A not empty queue");
+ *tstctx->L2A_tail = 0x0;
+ *tstctx->L2A_head = 0xFE;
+ fail_if(halmbx_L2Amail_not_empty_queue(tstctx) == 0, "Error checking L2A not empty queue");
+}
+END_TEST
+
+START_TEST (test_halmbx_A2Lmail_status_queue)
+{
+ //The ring size for the test is 0x100
+ *tstctx->A2L_tail = A2L_RING_BASE_ADDR + 0x05;
+ *tstctx->A2L_head = A2L_RING_BASE_ADDR + 0x05;
+ fail_if(halmbx_A2Lmail_status_queue(tstctx) != NOT_FULL, "Error checking A2L status queue");
+ *tstctx->A2L_tail = A2L_RING_BASE_ADDR + 0x54;
+ *tstctx->A2L_head = A2L_RING_BASE_ADDR + 0x04;
+ fail_if(halmbx_A2Lmail_status_queue(tstctx) != NOT_FULL, "Error checking A2L status queue");
+ *tstctx->A2L_tail = A2L_RING_BASE_ADDR + 0x20;
+ *tstctx->A2L_head = A2L_RING_BASE_ADDR + 0xF0;
+ fail_if(halmbx_A2Lmail_status_queue(tstctx) != NOT_FULL, "Error checking A2L status queue");
+ *tstctx->A2L_tail = A2L_RING_BASE_ADDR + 0x18;
+ *tstctx->A2L_head = A2L_RING_BASE_ADDR + 0x1C;
+ fail_if(halmbx_A2Lmail_status_queue(tstctx) != FULL, "Error checking A2L status queue");
+ *tstctx->A2L_tail = A2L_RING_BASE_ADDR + 0xFC;
+ *tstctx->A2L_head = A2L_RING_BASE_ADDR + 0x04;
+ fail_if(halmbx_A2Lmail_status_queue(tstctx) != FULL, "Error checking A2L status queue");
+ *tstctx->A2L_tail = A2L_RING_BASE_ADDR + 0x08;
+ *tstctx->A2L_head = A2L_RING_BASE_ADDR + 0x14;
+ fail_if(halmbx_A2Lmail_status_queue(tstctx) != NEARLY_FULL, "Error checking A2L status queue");
+}
+END_TEST
+
+START_TEST (test_halmbx_L2Amail_status_queue)
+{
+ //The ring size for the test is 0x100
+ *tstctx->L2A_tail = L2A_RING_BASE_ADDR + 0x05;
+ *tstctx->L2A_head = L2A_RING_BASE_ADDR + 0x05;
+ fail_if(halmbx_L2Amail_status_queue(tstctx) != NOT_FULL, "Error checking L2A status queue");
+ *tstctx->L2A_tail = L2A_RING_BASE_ADDR + 0x54;
+ *tstctx->L2A_head = L2A_RING_BASE_ADDR + 0x04;
+ fail_if(halmbx_L2Amail_status_queue(tstctx) != NOT_FULL, "Error checking L2A status queue");
+ *tstctx->L2A_tail = L2A_RING_BASE_ADDR + 0x20;
+ *tstctx->L2A_head = L2A_RING_BASE_ADDR + 0xF0;
+ fail_if(halmbx_L2Amail_status_queue(tstctx) != NOT_FULL, "Error checking L2A status queue");
+ *tstctx->L2A_tail = L2A_RING_BASE_ADDR + 0x18;
+ *tstctx->L2A_head = L2A_RING_BASE_ADDR + 0x1C;
+ fail_if(halmbx_L2Amail_status_queue(tstctx) != FULL, "Error checking L2A status queue");
+ *tstctx->L2A_tail = L2A_RING_BASE_ADDR + 0xFC;
+ *tstctx->L2A_head = L2A_RING_BASE_ADDR + 0x04;
+ fail_if(halmbx_L2Amail_status_queue(tstctx) != FULL, "Error checking L2A status queue");
+ *tstctx->L2A_tail = L2A_RING_BASE_ADDR + 0x08;
+ *tstctx->L2A_head = L2A_RING_BASE_ADDR + 0x14;
+ fail_if(halmbx_L2Amail_status_queue(tstctx) != NEARLY_FULL, "Error checking L2A status queue");
+}
+END_TEST
+
+START_TEST (test_halmbx_copy_to_ring)
+{
+ uint32_t msg[] = {0x12345678, 0xFEDCBA98};
+ uint32_t *res;
+
+ //Check arguments
+ fail_if(halmbx_copy_to_ring(NULL,NULL,5) == 0, "Error with no context");
+ fail_if(halmbx_copy_to_ring(tstctx,NULL,MAX_MSG_SIZE+5) == 0, "Error with a too big size");
+ fail_if(halmbx_copy_to_ring(tstctx,NULL,0) == 0, "Error without size");
+ fail_if(halmbx_copy_to_ring(tstctx,NULL,3) == 0, "Error with size not align");
+ fail_if(halmbx_copy_to_ring(tstctx,NULL,4) == 0, "Error without pointer");
+ fail_if(halmbx_copy_to_ring(tstctx,(uint32_t*)0x67546421,4) == 0, "Error with pointer not align");
+
+ //Check function
+ *tstctx->A2L_tail = A2L_RING_BASE_ADDR + 0x4;
+ *tstctx->A2L_head = A2L_RING_BASE_ADDR + 0x4;
+ fail_if(halmbx_copy_to_ring(tstctx,(uint32_t*)msg, sizeof(msg)) != 0, "Error during copy");
+ res = (uint32_t*)(*tstctx->A2L_tail);
+ fail_if(*res++ != msg[0], "Error with copy");
+ fail_if(*res != msg[1], "Error with copy");
+
+ *tstctx->A2L_tail = A2L_RING_BASE_ADDR + 0xFC;
+ *tstctx->A2L_head = A2L_RING_BASE_ADDR + 0xFC;
+ fail_if(halmbx_copy_to_ring(tstctx,(uint32_t*)msg, sizeof(msg)) != 0, "Error before copy");
+ res = (uint32_t*)(*tstctx->A2L_tail);
+ fail_if(*res != msg[0], "Error with rollover copy"); //offset=FC to FF
+ res = (uint32_t*)A2L_RING_BASE_ADDR;
+ fail_if(*res != msg[1], "Error with rollover copy"); //offset=0 to 3
+}
+END_TEST
+
+START_TEST (test_halmbx_copy_from_ring)
+{
+ uint32_t msg_origin[] = {0x87654321, 0x89ABCDEF};
+ uint32_t msg[2];
+ uint32_t *res;
+
+ //Check arguments
+ fail_if(halmbx_copy_to_ring(NULL,NULL,5) == 0, "Error with no context");
+ fail_if(halmbx_copy_from_ring(tstctx,NULL,MAX_MSG_SIZE+5) == 0, "Error with a too big size");
+ fail_if(halmbx_copy_from_ring(tstctx,NULL,0) == 0, "Error without size");
+ fail_if(halmbx_copy_from_ring(tstctx,NULL,3) == 0, "Error with size not align");
+ fail_if(halmbx_copy_from_ring(tstctx,NULL,4) == 0, "Error without pointer");
+ fail_if(halmbx_copy_from_ring(tstctx,(uint32_t*)0x67546421,4) == 0, "Error with pointer not align");
+
+ //Check function
+ *tstctx->L2A_tail = L2A_RING_BASE_ADDR + 0x4;
+ *tstctx->L2A_head = L2A_RING_BASE_ADDR + 0x4;
+ res = (uint32_t*)(*tstctx->L2A_head);
+ *res = msg_origin[0];
+ *(res+1) = msg_origin[1];
+ fail_if(halmbx_copy_from_ring(tstctx,(uint32_t*)msg, sizeof(msg_origin)) != 0, "Error before copy");
+ fail_if(msg[0] != msg[0], "Error with copy");
+ fail_if(msg[1] != msg[1], "Error with copy");
+
+ memset((char*)tstctx->L2A_head, 0, 4);
+ *tstctx->L2A_tail = L2A_RING_BASE_ADDR + 0xFC;
+ *tstctx->L2A_head = L2A_RING_BASE_ADDR + 0xFC;
+ res = (uint32_t*)(*tstctx->L2A_head); //offset=FC to FF
+ *res = msg_origin[0];
+ res = (uint32_t*)L2A_RING_BASE_ADDR; //offset=0 to 3
+ *(res+1) = msg_origin[1];
+ fail_if(halmbx_copy_from_ring(tstctx,(uint32_t*)msg, sizeof(msg_origin)) != 0, "Error before copy");
+ fail_if(msg[0] != msg[0], "Error with rollover copy");
+ fail_if(msg[1] != msg[1], "Error with rollover copy");
+}
+END_TEST
+
+START_TEST (test_halmbx_A2Lmail_update)
+{
+ //Check arguments
+ fail_if(halmbx_A2Lmail_update(NULL,5) == 0, "Error with no context");
+ fail_if(halmbx_A2Lmail_update(tstctx,0) == 0, "Error without size");
+
+ //Check function
+ *tstctx->A2L_tail = A2L_RING_BASE_ADDR + 0x4;
+ *tstctx->A2L_head = A2L_RING_BASE_ADDR + 0x4;
+ fail_if(halmbx_A2Lmail_update(tstctx,8) != 0, "Error before update");
+ fail_if(*tstctx->A2L_tail != (A2L_RING_BASE_ADDR + 0xC), "Error with update");
+ *tstctx->A2L_tail = A2L_RING_BASE_ADDR + 0xFC;
+ *tstctx->A2L_head = A2L_RING_BASE_ADDR + 0xFC;
+ fail_if(halmbx_A2Lmail_update(tstctx,8) != 0, "Error before update");
+ fail_if(*tstctx->A2L_tail != (A2L_RING_BASE_ADDR + 0x4), "Error with rollover update");
+}
+END_TEST
+
+START_TEST (test_halmbx_L2Amail_update)
+{
+ //Check arguments
+ fail_if(halmbx_A2Lmail_update(NULL,5) == 0, "Error with no context");
+ fail_if(halmbx_L2Amail_update(tstctx,0) == 0, "Error without size");
+
+ //Check function
+ *tstctx->L2A_tail = L2A_RING_BASE_ADDR + 0x4;
+ *tstctx->L2A_head = L2A_RING_BASE_ADDR + 0x4;
+ fail_if(halmbx_L2Amail_update(tstctx,4) != 0, "Error before update");
+ fail_if(*tstctx->L2A_head != (L2A_RING_BASE_ADDR + 0x8), "Error with update");
+ *tstctx->L2A_tail = L2A_RING_BASE_ADDR + 0xFC;
+ *tstctx->L2A_head = L2A_RING_BASE_ADDR + 0xFC;
+ fail_if(halmbx_L2Amail_update(tstctx,0xC) != 0, "Error before update");
+ fail_if(*tstctx->L2A_head != (L2A_RING_BASE_ADDR + 0x8), "Error with rollover update");
+}
+END_TEST
+
+extern Suite* processing_suite(void)
+{
+ Suite *s = suite_create("HAL");
+ TCase *tc_core = tcase_create("Core");
+
+ //Test halmbx_init
+ tcase_add_test(tc_core, test_halmbx_init);
+
+ //Test set_A2Lt_interrupt
+ tcase_add_test(tc_core, test_set_A2Lt_interrupt);
+ //Test set_L2Aa_interrupt
+ tcase_add_test(tc_core, test_set_L2Aa_interrupt);
+ //Test clr_L2At_interrupt
+ tcase_add_test(tc_core, test_clr_L2At_interrupt);
+ //Test clr_A2La_interrupt
+ tcase_add_test(tc_core, test_clr_A2La_interrupt);
+
+ //Test en_A2La_interrupt
+ tcase_add_test(tc_core, test_A2La_it_enable);
+ //Test en_L2At_interrupt
+ tcase_add_test(tc_core, test_L2At_it_enable);
+ //Test dis_A2La_interrupt
+ tcase_add_test(tc_core, test_A2La_it_disable);
+ //Test dis_L2At_interrupt
+ tcase_add_test(tc_core, test_L2At_it_disable);
+
+ //Test halmbx_L2Amail_not_empty_queue
+ tcase_add_test(tc_core, test_halmbx_L2Amail_not_empty_queue);
+ //Test halmbx_A2Lmail_status_queue
+ tcase_add_test(tc_core, test_halmbx_A2Lmail_status_queue);
+ //Test halmbx_L2Amail_status_queue
+ tcase_add_test(tc_core, test_halmbx_L2Amail_status_queue);
+
+ //Test halmbx_copy_to_ring
+ tcase_add_test(tc_core, test_halmbx_copy_to_ring);
+ //Test halmbx_copy_from_ring
+ tcase_add_test(tc_core, test_halmbx_copy_from_ring);
+ //Test halmbx_A2Lmail_update
+ tcase_add_test(tc_core, test_halmbx_A2Lmail_update);
+ //Test halmbx_L2Amail_update
+ tcase_add_test(tc_core, test_halmbx_L2Amail_update);
+
+ suite_add_tcase(s, tc_core);
+ return s;
+}
+
+int main(void)
+{
+ int number_failed = 0;
+ Suite *s;
+
+ //Run Processing tests
+ s = processing_suite();
+
+ SRunner *sr = srunner_create(s);
+ srunner_set_fork_status (sr, CK_NOFORK);
+ srunner_run_all(sr, CK_NORMAL);
+ number_failed = srunner_ntests_failed(sr);
+ srunner_free(sr);
+
+ return (number_failed == 0) ? 0 : -1;
+}
+
diff --git a/cleopatre/devkit/tests/plcdrv/utests/src/linux_drv_utests.c b/cleopatre/devkit/tests/plcdrv/utests/src/linux_drv_utests.c
new file mode 100644
index 0000000000..ec341b9d35
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/utests/src/linux_drv_utests.c
@@ -0,0 +1,94 @@
+/* Cleopatre project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file linux_drv_utests.c
+ * \brief Unitary tests for Linux Driver layer
+ * \ingroup Cleopatre - PlcDrv
+ *
+ * This file content all the unitary tests for the Linux Driver layer,
+ * this layer correspond to the interface between
+ * the driver and Linux (it's a network Linux driver).
+ */
+
+#include <check.h>
+#include <stdio.h>
+#include <string.h>
+#include "linux_drv.h"
+
+/** local variables */
+static struct net_device dev;
+
+/** change mtu procedure */
+START_TEST (test_plc_drv_change_mtu)
+{
+ fail_if(plcdrv_change_mtu(NULL, 1234) != -1, "Error with arguments checking");
+ fail_if(plcdrv_change_mtu(&dev, 63) >= 0, "Error with too small mtu");
+ fail_if(plcdrv_change_mtu(&dev, 1510) >= 0, "Error with too big mtu");
+ fail_if(plcdrv_change_mtu(&dev, 1400) < 0, "Error with a correct mtu");
+}
+END_TEST
+
+/** set mac address procedure */
+START_TEST (test_plc_drv_set_mac_address)
+{
+ struct sockaddr addr;
+ int i;
+
+ fail_if(plcdrv_set_mac_address(NULL, NULL) != -1, "Error with first arguments checking");
+ fail_if(plcdrv_set_mac_address(&dev, NULL) != -1, "Error with second arguments checking");
+
+ for(i=0 ; i<sizeof(addr.sa_data) ; i++)
+ {
+ addr.sa_data[i] = i*11;
+ }
+
+ dev.addr_len = 0;
+ memset(dev.dev_addr, 0, sizeof(dev.dev_addr));
+ plcdrv_set_mac_address(&dev, &addr);
+ fail_if(memcmp(dev.dev_addr, addr.sa_data, dev.addr_len) != 0, "Error with mac address length=0");
+ dev.addr_len = 21;
+ memset(dev.dev_addr, 0, sizeof(dev.dev_addr));
+ plcdrv_set_mac_address(&dev, &addr);
+ fail_if(memcmp(dev.dev_addr, addr.sa_data, dev.addr_len) != 0, "Error with mac address length too big");
+ dev.addr_len = 6;
+ memset(dev.dev_addr, 0, sizeof(dev.dev_addr));
+ plcdrv_set_mac_address(&dev, &addr);
+ fail_if(memcmp(dev.dev_addr, addr.sa_data, dev.addr_len) != 0, "Error with mac address copy");
+}
+END_TEST
+
+extern Suite* plc_drv_suite(void)
+{
+ Suite *s = suite_create("PLC_DRV");
+ TCase *tc_core = tcase_create("Core");
+
+ //Test change mtu
+ tcase_add_test(tc_core, test_plc_drv_change_mtu);
+ //Test set mac address
+ tcase_add_test(tc_core, test_plc_drv_set_mac_address);
+
+ suite_add_tcase(s, tc_core);
+ return s;
+}
+
+int main(void)
+{
+ int number_failed = 0;
+ Suite *s;
+
+ //Run PLCDRV tests
+ s = plc_drv_suite();
+
+ SRunner *sr = srunner_create(s);
+ srunner_run_all(sr, CK_NORMAL);
+ number_failed = srunner_ntests_failed(sr);
+ srunner_free(sr);
+
+ return (number_failed == 0) ? 0 : -1;
+}
+
diff --git a/cleopatre/devkit/tests/plcdrv/utests/src/mailbox_utests.c b/cleopatre/devkit/tests/plcdrv/utests/src/mailbox_utests.c
new file mode 100644
index 0000000000..b9cc7299a0
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/utests/src/mailbox_utests.c
@@ -0,0 +1,252 @@
+/* Cleopatre project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file mailbox_utests.c
+ * \brief Unitary tests for Mailbox layer
+ * \ingroup Cleopatre - PlcDrv
+ *
+ * This file content all the unitary tests for the mailbox layer,
+ * this layer will provide all mechanisms to manage mailboxes.
+ */
+
+#include <check.h>
+#include <stdio.h>
+#include <string.h>
+#include "mailbox.h"
+
+/** local defines */
+
+/** local variables */
+struct init_info info;
+
+/** Test init */
+START_TEST (test_mailbox_init)
+{
+ fail_if(mailbox_init(NULL) != -1, "Error with argument checking");
+ fail_if(mailbox_init((struct init_info*)0x55555555) != -1, "Error with halmbx error");
+ fail_if(mailbox_init(&info) != 0, "Error with normal case");
+}
+END_TEST
+
+/** Test uninit */
+START_TEST (test_mailbox_uninit)
+{
+}
+END_TEST
+
+/** Test internal_send */
+START_TEST (test_internal_mailbox_send)
+{
+ mailbox_init(&info);
+ fail_if(internal_mailbox_send(NULL,4) != -1, "Error with argument checking");
+ fail_if(internal_mailbox_send((uint32_t*)0x12345678, 4) != NEARLY_FULL, "Error with status queue");
+ fail_if(internal_mailbox_send((uint32_t*)0x12345678, 4) != FULL, "Error with status queue");
+ fail_if(internal_mailbox_send((uint32_t*)0x55555555, 4) != -1, "Error with copy to ring process");
+ fail_if(internal_mailbox_send((uint32_t*)0x12345678, 0) != -1, "Error with A2Lmail_update");
+ fail_if(internal_mailbox_send((uint32_t*)0x12345678, 8) != NOT_FULL, "Error with normal process");
+}
+END_TEST
+
+/** Test buffer_add */
+START_TEST (test_mailbox_buffer_add)
+{
+ uint32_t eth_std[] = {0x11223344, 0x55667788, 0x99AABBCC};
+
+ mailbox_init(&info);
+
+ fail_if(mailbox_buffer_add(NULL,DATA) != -1, "Error with argument checking");
+ fail_if(mailbox_buffer_add((uint32_t*)0x12345678,(enum buffer_type)10) != -1, "Error with argument checking");
+
+ //WITH SEND TYPE DATA
+ //Clear the previous msg for a new test
+ mbx_buffer_add_result[0] = 0;
+ mbx_buffer_add_result[1] = 0;
+ //Add a data msg with eth_std pointer
+ fail_if(mailbox_buffer_add((uint32_t*)eth_std, DATA) != 0, "Error with buffer add data");
+ //Check msg header for buffer add type data
+ fail_if(mbx_buffer_add_result[0] != 0x00000101,"Error with buffer add data msg header construction");
+ //Check the if buffer_ptr is good
+ fail_if(mbx_buffer_add_result[1] != (uint32_t)&eth_std[0] ,"Error with buffer add msg construction");
+
+ //WITH SEND TYPE MME
+ //Clear the previous msg for a new test
+ mbx_buffer_add_result[0] = 0;
+ mbx_buffer_add_result[1] = 0;
+ //Add a mme msg with eth_std pointer
+ fail_if(mailbox_buffer_add((uint32_t*)eth_std, MME) != 0, "Error with buffer add mme");
+ //Check msg header for buffer add type mme
+ fail_if(mbx_buffer_add_result[0] != 0x00001101,"Error with buffer add mme msg header construction");
+ //Check the if buffer_ptr is good
+ fail_if(mbx_buffer_add_result[1] != (uint32_t)&eth_std[0] ,"Error with buffer add msg construction");
+
+ //WITH SEND TYPE INTERFACE
+ //Clear the previous msg for a new test
+ mbx_buffer_add_result[0] = 0;
+ mbx_buffer_add_result[1] = 0;
+ //Add a interface msg with eth_std pointer
+ fail_if(mailbox_buffer_add((uint32_t*)eth_std, INTERFACE) != 0, "Error with buffer add interface");
+ //Check msg header for buffer add type interface
+ fail_if(mbx_buffer_add_result[0] != 0x00002101,"Error with buffer add interface msg header construction");
+ //Check the if buffer_ptr is good
+ fail_if(mbx_buffer_add_result[1] != (uint32_t)&eth_std[0] ,"Error with buffer add msg construction");
+}
+END_TEST
+
+/** Test send */
+START_TEST (test_mailbox_send)
+{
+ uint32_t eth_std[] = {0x11223344, 0x55667788, 0x99AABBCC};
+
+ mailbox_init(&info);
+
+ fail_if(mailbox_send(NULL,4,DATA) != -1, "Error with argument checking");
+ fail_if(mailbox_send((uint32_t*)0x12345678,0,DATA) != -1, "Error with argument checking");
+ fail_if(mailbox_send((uint32_t*)0x12345678,4,(enum buffer_type)10) != -1, "Error with argument checking");
+
+ //WITH SEND TYPE DATA
+ //Clear the previous msg for a new test
+ mbx_send_result[0] = 0;
+ mbx_send_result[1] = 0;
+ //Send a data msg with eth_std pointer
+ fail_if(mailbox_send((uint32_t*)eth_std, sizeof(eth_std), DATA) != 0, "Error with send data");
+ //Check msg header for send type data
+ fail_if(mbx_send_result[0] != 0x00018100,"Error with send data msg header construction");
+ //Check the if buffer_ptr is good
+ fail_if(mbx_send_result[1] != (uint32_t)&eth_std[0] ,"Error with send msg construction");
+
+ //WITH SEND TYPE MME
+ //Clear the previous msg for a new test
+ mbx_send_result[0] = 0;
+ mbx_send_result[1] = 0;
+ //Send a mme msg with eth_std pointer
+ fail_if(mailbox_send((uint32_t*)eth_std, sizeof(eth_std), MME) != 0, "Error with send mme");
+ //Check msg header for send type mme
+ fail_if(mbx_send_result[0] != 0x00019100,"Error with send data msg header construction");
+ //Check the if buffer_ptr is good
+ fail_if(mbx_send_result[1] != (uint32_t)&eth_std[0] ,"Error with send msg construction");
+
+ //WITH SEND TYPE INTERFACE
+ //Clear the previous msg for a new test
+ mbx_send_result[0] = 0;
+ mbx_send_result[1] = 0;
+ //Send a interface msg with eth_std pointer
+ fail_if(mailbox_send((uint32_t*)eth_std, sizeof(eth_std), INTERFACE) != 0, "Error with send interface");
+ //Check msg header for send type mme
+ fail_if(mbx_send_result[0] != 0x00C02103,"Error with send data msg header construction");
+ //Check the if buffer_ptr is good
+ fail_if(mbx_send_result[1] != (uint32_t)&eth_std[0] ,"Error with send msg construction");
+}
+END_TEST
+
+/** Test receive */
+START_TEST (test_mailbox_receive)
+{
+ mailbox_init(&info);
+ //Check code the L2Amail_not_empty_queue
+ glbctx.num_tst=0; //num_tst=0 L2Amail_not_empty_queue returns empty
+ fail_if(mailbox_receive() != 0, "Error with not empty queue");
+ //Check code with copy_from_ring error
+ glbctx.num_tst=1; //num_tst=1 copy_from_ring returns an error
+ fail_if(mailbox_receive() != -2, "Error with copy from ring");
+ //Check code with update_ring_pointer error
+ glbctx.num_tst=2; //num_tst=2 update_ring_pointer returns an error
+ fail_if(mailbox_receive() != -3, "Error with update ring pointer");
+
+ //CHECK THE REAL FUNCTIONNALITY OF THE FUNCTION
+ //WITH SEND_DONE
+ //Check code with processing_buffer_free error
+ glbctx.num_tst=3; //num_tst=3 processing_buffer_free returns an error
+ fail_if(mailbox_receive() != -4, "Error with send done false");
+ //Check the real functionality of send_done
+ glbctx.num_tst=4; //num_tst=4 processing_buffer_free returns OK
+ fail_if(mailbox_receive() != 0, "Error with send done true");
+ //num_tst=5 by processing_buffer_free to break the RX loop
+ //Now check send_done message content (the addr pointer)
+ fail_if(mbx_rx_ptr_result != SEND_DONE_ADDRESS, "Error with RX send done");
+
+
+ //WITH INTERFACE
+ //Check code with processing_receive error
+ glbctx.num_tst=6; //num_tst=6 processing_receive returns an error
+ fail_if(mailbox_receive() != -5, "Error with interface false");
+ //Check the real functionality of interface
+ glbctx.num_tst=7; //num_tst=7 processing_receive returns OK
+ fail_if(mailbox_receive() != 0, "Error with interface true");
+ //num_tst=8 by processing_receive to break the RX loop
+ //Now check interface message content (the addr pointer)
+ fail_if(mbx_rx_ptr_result != INTERFACE_ADDRESS, "Error with RX interface");
+
+
+ //WITH MME
+ //Check code with processing_receive error
+ glbctx.num_tst=9; //num_tst=9 processing_receive returns an error
+ fail_if(mailbox_receive() != -6, "Error with mme false");
+ //Check the real functionality of mme
+ glbctx.num_tst=10; //num_tst=10 processing_receive returns OK
+ fail_if(mailbox_receive() != 0, "Error with mme true");
+ //num_tst=11 by processing_receive to break the RX loop
+ //Now check mme message content (the addr pointer)
+ fail_if(mbx_rx_ptr_result != DATAMME_ADDRESS, "Error with RX mme");
+
+ //WITH DATA
+ //Check code with processing_receive error
+ glbctx.num_tst=12; //num_tst=12 processing_receive returns an error
+ fail_if(mailbox_receive() != -7, "Error with data false");
+ //Check the real functionality of data
+ glbctx.num_tst=13; //num_tst=13 processing_receive returns OK
+ fail_if(mailbox_receive() != 0, "Error with data true");
+ //num_tst=14 by processing_receive to break the RX loop
+ //Now check data message content (the addr pointer)
+ fail_if(mbx_rx_ptr_result != DATADATA_ADDRESS, "Error with RX data");
+
+
+ //WITH ERROR TYPE
+// fail_if(mailbox_receive() != -1, "Error with message type");
+}
+END_TEST
+
+
+extern Suite* processing_suite(void)
+{
+ Suite *s = suite_create("MAILBOX");
+ TCase *tc_core = tcase_create("Core");
+
+ //Test init
+ tcase_add_test(tc_core, test_mailbox_init);
+ //Test uninit
+ tcase_add_test(tc_core, test_mailbox_uninit);
+ //Test internal_send
+ tcase_add_test(tc_core, test_internal_mailbox_send);
+ //Test buffer_add
+ tcase_add_test(tc_core, test_mailbox_buffer_add);
+ //Test send
+ tcase_add_test(tc_core, test_mailbox_send);
+ //Test receive
+ tcase_add_test(tc_core, test_mailbox_receive);
+
+ suite_add_tcase(s, tc_core);
+ return s;
+}
+
+int main(void)
+{
+ int number_failed = 0;
+ Suite *s;
+
+ //Run Processing tests
+ s = processing_suite();
+
+ SRunner *sr = srunner_create(s);
+ srunner_set_fork_status (sr, CK_NOFORK);
+ srunner_run_all(sr, CK_NORMAL);
+ number_failed = srunner_ntests_failed(sr);
+ srunner_free(sr);
+
+ return (number_failed == 0) ? 0 : -1;
+}
+
diff --git a/cleopatre/devkit/tests/plcdrv/utests/src/processing_utests.c b/cleopatre/devkit/tests/plcdrv/utests/src/processing_utests.c
new file mode 100644
index 0000000000..9035df1969
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/utests/src/processing_utests.c
@@ -0,0 +1,230 @@
+/* Cleopatre project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file processing_utests.c
+ * \brief Unitary tests for Porcessing layer
+ * \ingroup Cleopatre - PlcDrv
+ *
+ * This file content all the unitary tests for the processing layer,
+ * this layer will analyse all frames(TX ans RX) and decided to pass and drop it.
+ */
+
+#include <check.h>
+#include <stdio.h>
+#include <string.h>
+#include "processing.h"
+
+/** local defines */
+#define ETH_P_HPAV 0x88E1
+#define HPAV_MME_VERSION 0x01
+#define HPAV_MME_TYPE_FCALL 0xABCD
+#define HPAV_MME_FMI 0x2664
+
+/** local variables */
+static uint8_t eth_std[] = {
+ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, //src addr
+ 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, //dst addr
+ 0x34, 0x12, //eth type
+ 0x01, //eth raw
+ 0x88, 0x99,
+ 0x55, 0x66,
+ 0x99
+};
+static uint8_t eth_hpav[] = {
+ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, //src addr
+ 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, //dst addr
+ 0x88, 0xE1, //eth type=HPAV
+ 0x01, //mme version
+ 0x88, 0x99, //mme type=unknown
+ 0x55, 0x66, //mme fmi
+ 0x99
+};
+static uint8_t eth_hpav_fcall[] = {
+ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, //src addr
+ 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, //dst addr
+ 0x88, 0xE1, //eth type=HPAV
+ 0x01, //mme version
+ 0xAB, 0xCD, //mme type=fcall
+ 0x26, 0x64, //mme fmi
+ 0x99
+};
+
+/** Test init */
+START_TEST (test_processing_init)
+{
+ struct init_info info;
+ fail_if(processing_init(NULL) == 0, "Error checking arguments");
+ fail_if(processing_init((struct init_info*)0x55555555) == 0, "Error with mailbox layer error");
+ fail_if(processing_init(&info) != 0, "Error checking normal case");
+}
+END_TEST
+
+/** Test uninit */
+START_TEST (test_processing_uninit)
+{
+}
+END_TEST
+
+/** Test get_eth_src_addr */
+START_TEST (test_processing_get_eth_src_addr)
+{
+ uint8_t source[6];
+ int i;
+ get_eth_src_addr(eth_std, source);
+ for(i=0; i<6; i++)
+ {
+ fail_if(source[i] != eth_std[i+6], "Error with Eth src addr copy");
+ }
+}
+END_TEST
+
+/** Test get_eth_dst_addr */
+START_TEST (test_processing_get_eth_dst_addr)
+{
+ uint8_t dst[6];
+ int i;
+ get_eth_dst_addr(eth_std, dst);
+ for(i=0; i<6; i++)
+ {
+ fail_if(dst[i] != eth_std[i], "Error with Eth dst addr copy");
+ }
+}
+END_TEST
+
+/** Test get_eth_type */
+START_TEST (test_processing_get_eth_type)
+{
+ fail_if(get_eth_type(eth_hpav) != ETH_P_HPAV, "Error with Eth type search");
+}
+END_TEST
+
+/** Test get_eth_mme_version */
+START_TEST (test_processing_get_eth_mme_version)
+{
+ fail_if(get_eth_mme_version(eth_hpav) != HPAV_MME_VERSION, "Error with HPAV MME version search");
+}
+END_TEST
+
+/** Test get_eth_mme_type */
+START_TEST (test_processing_get_eth_mme_type)
+{
+ fail_if(get_eth_mme_type(eth_hpav_fcall) != HPAV_MME_TYPE_FCALL, "Error with HPAV MME type search");
+}
+END_TEST
+
+/** Test get_eth_mme_fmi */
+START_TEST (test_processing_get_eth_mme_fmi)
+{
+ fail_if(get_eth_mme_fmi(eth_hpav_fcall) != HPAV_MME_FMI, "Error with HPAV MME fmi search");
+}
+END_TEST
+
+/** Test processing_buffer_add */
+START_TEST (test_processing_buffer_add)
+{
+ fail_if(processing_buffer_add((void*)NULL, DATA) != -1, "Error with prepare_hw procedure");
+
+ fail_if(processing_buffer_add(eth_hpav_fcall, MME) != 0, "Error with sending a known frame");
+ fail_if(processing_buffer_add(eth_std, (enum buffer_type)10) != -1, "Error with sending an unknown type frame");
+}
+END_TEST
+
+/** Test processing_buffer_free */
+START_TEST (test_processing_buffer_free)
+{
+ fail_if(processing_buffer_free((void*)NULL) != -1, "Error with prepare_hw procedure");
+
+ fail_if(processing_buffer_free((void*)0x12345678) != 0, "Error with freeing a known frame");
+ fail_if(processing_buffer_free((void*)0x55555555) != -1, "Error with freeing an unknown type frame");
+}
+END_TEST
+
+/** Test processing_send */
+START_TEST (test_processing_send)
+{
+ fail_if(processing_send(NULL, 124) != -1, "Error with arguments checking");
+ fail_if(processing_send((void*)0x12345678, 0) != -1, "Error with arguments checking");
+ fail_if(processing_send((void*)0x12345678, 2000) != -1, "Error with arguments checking");
+
+ fail_if(processing_send((void*)eth_std, 100) != -1, "Error with prepare_hw procedure");
+
+ fail_if(processing_send(eth_hpav_fcall, 70) != 3, "Error with sending an Interface frame");
+ fail_if(processing_send(eth_hpav, 70) != 2, "Error with sending a Mme frame");
+ fail_if(processing_send(eth_std, 70) != 1, "Error with sending a Data frame");
+}
+END_TEST
+
+/** Test processing_receive */
+START_TEST (test_processing_receive)
+{
+ fail_if(processing_receive(NULL, 124, DATA) != -1, "Error with arguments checking");
+ fail_if(processing_receive((void*)0x12345678, 0, DATA) != -1, "Error with arguments checking");
+ fail_if(processing_receive((void*)0x12345678, 2000, DATA) != -1, "Error with arguments checking");
+
+ fail_if(processing_receive((void*)0x12345678, 100, DATA) != -1, "Error with prepare_hw procedure");
+
+ fail_if(processing_receive(eth_hpav_fcall, 70, INTERFACE) != 0, "Error with receiving an Interface frame");
+ fail_if(processing_receive(eth_hpav, 70, MME) != 0, "Error with receiving a Mme frame");
+ fail_if(processing_receive(eth_hpav, 70, DATA) != 0, "Error with receiving a Data frame");
+ fail_if(processing_receive(eth_hpav, 70, (enum buffer_type)10) != -1, "Error with receiving a unknown frame");
+
+ fail_if(processing_receive((void*)0x55555555, 70, DATA) != -1, "Error with plcdrv_rx procedure");
+}
+END_TEST
+
+
+extern Suite* processing_suite(void)
+{
+ Suite *s = suite_create("PROCESSING");
+ TCase *tc_core = tcase_create("Core");
+
+ //Test init
+ tcase_add_test(tc_core, test_processing_init);
+ //Test uninit
+ tcase_add_test(tc_core, test_processing_uninit);
+ //Test get_eth_src_addr
+ tcase_add_test(tc_core, test_processing_get_eth_src_addr);
+ //Test get_eth_dst_addr
+ tcase_add_test(tc_core, test_processing_get_eth_dst_addr);
+ //Test get_eth_type
+ tcase_add_test(tc_core, test_processing_get_eth_type);
+ //Test get_eth_mme_version
+ tcase_add_test(tc_core, test_processing_get_eth_mme_version);
+ //Test get_eth_mme_type
+ tcase_add_test(tc_core, test_processing_get_eth_mme_type);
+ //Test get_eth_mme_fmi
+ tcase_add_test(tc_core, test_processing_get_eth_mme_fmi);
+ //Test processing_buffer_add
+ tcase_add_test(tc_core, test_processing_buffer_add);
+ //Test processing_buffer_add
+ tcase_add_test(tc_core, test_processing_buffer_free);
+ //Test processing_send
+ tcase_add_test(tc_core, test_processing_send);
+ //Test processing_receive
+ tcase_add_test(tc_core, test_processing_receive);
+
+ suite_add_tcase(s, tc_core);
+ return s;
+}
+
+int main(void)
+{
+ int number_failed = 0;
+ Suite *s;
+
+ //Run Processing tests
+ s = processing_suite();
+
+ SRunner *sr = srunner_create(s);
+ srunner_run_all(sr, CK_NORMAL);
+ number_failed = srunner_ntests_failed(sr);
+ srunner_free(sr);
+
+ return (number_failed == 0) ? 0 : -1;
+}
+