summaryrefslogtreecommitdiff
path: root/cleopatre/devkit
diff options
context:
space:
mode:
Diffstat (limited to 'cleopatre/devkit')
-rw-r--r--cleopatre/devkit/doc/cleopatre_mme_specs.odtbin199528 -> 199558 bytes
-rw-r--r--cleopatre/devkit/plcd/src/plcd_main.c15
-rw-r--r--cleopatre/devkit/plcdrv/arm/Module1
-rw-r--r--cleopatre/devkit/plcdrv/arm/inc/common.h4
-rw-r--r--cleopatre/devkit/plcdrv/arm/inc/hal.h6
-rw-r--r--cleopatre/devkit/plcdrv/arm/inc/linux_drv.h13
-rw-r--r--cleopatre/devkit/plcdrv/arm/inc/mailbox.h2
-rw-r--r--cleopatre/devkit/plcdrv/arm/inc/processing.h4
-rw-r--r--cleopatre/devkit/plcdrv/arm/src/boot_params.c41
-rw-r--r--cleopatre/devkit/plcdrv/arm/src/hal.c11
-rw-r--r--cleopatre/devkit/plcdrv/arm/src/linux_drv.c314
-rw-r--r--cleopatre/devkit/plcdrv/arm/src/mailbox.c17
-rw-r--r--cleopatre/devkit/plcdrv/arm/src/processing.c43
-rw-r--r--cleopatre/devkit/tests/common/Makefile46
-rw-r--r--cleopatre/devkit/tests/fw_wd/Makefile15
-rwxr-xr-xcleopatre/devkit/tests/fw_wd/run-test248
-rw-r--r--cleopatre/devkit/tests/hal/gidel/ftests/Makefile34
-rw-r--r--cleopatre/devkit/tests/hal/gidel/ftests/src/start.cpp139
-rw-r--r--cleopatre/devkit/tests/hal/gidel/ftests/src/start2.cpp117
-rw-r--r--cleopatre/devkit/tests/hal/gidel/ftests/src/start3.cpp137
-rw-r--r--cleopatre/devkit/tests/kernel/drivers/gpio/ftests/interrupt/Makefile35
-rw-r--r--cleopatre/devkit/tests/kernel/drivers/gpio/ftests/module/Kbuild4
-rw-r--r--cleopatre/devkit/tests/kernel/drivers/gpio/ftests/module/Makefile53
-rw-r--r--cleopatre/devkit/tests/kernel/drivers/gpio/ftests/user/Makefile35
-rw-r--r--cleopatre/devkit/tests/libmme/utests/Makefile22
-rw-r--r--cleopatre/devkit/tests/libmme/utests/src/mme_utests.c68
-rw-r--r--cleopatre/devkit/tests/libspid/ftests/Makefile38
-rw-r--r--cleopatre/devkit/tests/libspid/ftests/src/spidlib_ftests.c (renamed from cleopatre/devkit/tests/libspid/ftests/spidlib_ftests.c)0
-rw-r--r--cleopatre/devkit/tests/libspid/utests/Makefile46
-rw-r--r--cleopatre/devkit/tests/libspid/utests/inc/config_item_utests.h12
-rw-r--r--cleopatre/devkit/tests/libspid/utests/inc/config_line_utests.h5
-rw-r--r--cleopatre/devkit/tests/libspid/utests/inc/image_utests.h4
-rw-r--r--cleopatre/devkit/tests/libspid/utests/inc/network_utests.h6
-rw-r--r--cleopatre/devkit/tests/libspid/utests/inc/system_utests.h13
-rw-r--r--cleopatre/devkit/tests/libspid/utests/override/Module1
-rw-r--r--cleopatre/devkit/tests/libspid/utests/override/inc/eoc_utests.h (renamed from cleopatre/devkit/tests/libspid/utests/inc/eoc_utests.h)0
-rw-r--r--cleopatre/devkit/tests/libspid/utests/override/src/port_eoc_stub.c (renamed from cleopatre/devkit/tests/libspid/utests/stubs/port_eoc_stubs.c)0
-rw-r--r--cleopatre/devkit/tests/libspid/utests/override/src/service_eoc_stub.c (renamed from cleopatre/devkit/tests/libspid/utests/stubs/service_eoc_stubs.c)0
-rw-r--r--cleopatre/devkit/tests/libspid/utests/override/src/wl_eoc_stub.c (renamed from cleopatre/devkit/tests/libspid/utests/stubs/wl_eoc_stubs.c)0
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/analog_alarm_eoc_utests.c18
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/autoconf_eoc_utests.c209
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/config_item_utests.c6
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/config_line_utests.c42
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/current_alarm_eoc_utests.c14
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/discrete_alarm_eoc_utests.c20
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/hpav_info_utests.c3
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/image_utests.c9
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/master_config_eoc_utests.c16
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/misc_eoc_utests.c196
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/network_utests.c4
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/port_eoc_utests.c20
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/service_eoc_utests.c34
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/system_utests.c107
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/tonemap_snr_eoc_utests.c236
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/upgrade_eoc_utests.c258
-rw-r--r--cleopatre/devkit/tests/libspid/utests/src/wl_eoc_utests.c207
-rw-r--r--cleopatre/devkit/tests/managerd/ftests/Makefile32
-rw-r--r--cleopatre/devkit/tests/managerd/utests/Makefile102
-rw-r--r--cleopatre/devkit/tests/managerd/utests/override/Module1
-rw-r--r--cleopatre/devkit/tests/managerd/utests/override/inc/stub.h46
-rw-r--r--cleopatre/devkit/tests/managerd/utests/override/src/libmme_stub.c340
-rw-r--r--cleopatre/devkit/tests/managerd/utests/override/src/libspid_stub.c219
-rw-r--r--cleopatre/devkit/tests/managerd/utests/override/src/misc_stub.c43
-rw-r--r--cleopatre/devkit/tests/managerd/utests/src/vs_eoc_mme_utests.c42
-rw-r--r--cleopatre/devkit/tests/managerd/utests/src/vs_mme_utests.c105
-rw-r--r--cleopatre/devkit/tests/plcd/Makefile25
-rw-r--r--cleopatre/devkit/tests/plcd/inc/check_event.h24
-rwxr-xr-xcleopatre/devkit/tests/plcd/inc/eoc_utests.h32
-rw-r--r--cleopatre/devkit/tests/plcd/inc/hpav_utests.h43
-rw-r--r--cleopatre/devkit/tests/plcd/inc/plcd_utests.h43
-rw-r--r--cleopatre/devkit/tests/plcd/inc/stub.h20
-rwxr-xr-xcleopatre/devkit/tests/plcd/src/eoc_utests.c198
-rw-r--r--cleopatre/devkit/tests/plcd/src/event_utests.c777
-rw-r--r--cleopatre/devkit/tests/plcd/src/hpav_utests.c375
-rw-r--r--cleopatre/devkit/tests/plcd/src/plcd_utests.c132
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/ftests/lo_ecos/Makefile2
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/ftests/lo_ecos/src/loopback.c4
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/ftests/wd_leon/Makefile38
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/Makefile26
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/inc/linux_drv_utests.h176
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/inc/mailbox_utests.h5
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/src/hal_utests.c3
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/Module2
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/asm/arch/hardware/regbank.h13
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/asm/arch/nvram.h37
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/afe.h8
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/asm.h70
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/bitops.h6
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/capability.h14
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/cdev.h22
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/compiler.h8
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/delay.h6
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/device.h6
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/dma-mapping.h28
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/errno.h12
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/file.h6
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/fs.h125
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/gfp.h10
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/if.h8
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/if_ether.h17
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/if_vlan.h20
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/init.h11
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/interrupt.h38
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/irqreturn.h9
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/kdev_t.h11
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/kernel.h34
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/list.h71
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/module.h13
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/moduleparam.h6
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/mutex.h30
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/netdevice.h92
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/netlink.h84
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/path.h12
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/poll.h20
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/proc_fs.h29
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/rcupdate.h9
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/sched.h10
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/skbuff.h45
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/socket.h18
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/spinlock.h35
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/types.h23
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/wait.h32
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/net/net_namespace.h55
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/net/seq_check.h28
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/net/sock.h13
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/af_netlink.c24
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/afe.c6
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/bitops.c6
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/char_dev.c26
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/delay.c6
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/dma.c25
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/eth.c12
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/ioremap.c10
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/irq_manage.c12
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/mutex.c11
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/net_dev.c42
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/softirq.c15
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/uaccess.c32
-rw-r--r--cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/wait.c7
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/ftests/.exrc74
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/ftests/Makefile7
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/Config2
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/Makefile13
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/Makefile_debug30
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/common.h26
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/ecos.ecc.sh5
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/src/loopback.c117
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/htests/Makefile43
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/htests/src/hal_htests.cpp270
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/htests/src/mbx_htests.cpp109
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/utests/Makefile7
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/utests/inc/hal_stub.h507
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/utests/inc/hard_stub.h52
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/utests/inc/mailbox_stub.h60
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/utests/inc/plc_drv_stub.h38
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/utests/inc/processing_stub.h102
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/utests/src/hal_utests.cpp430
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/utests/src/mailbox_utests.c232
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/utests/src/plc_drv_utests.c122
-rw-r--r--cleopatre/devkit/tests/plcdrv/gidel/utests/src/processing_utests.c43
-rw-r--r--cleopatre/devkit/tests/utests_makerules70
161 files changed, 3008 insertions, 6532 deletions
diff --git a/cleopatre/devkit/doc/cleopatre_mme_specs.odt b/cleopatre/devkit/doc/cleopatre_mme_specs.odt
index 6cfeb3a977..805ce0e286 100644
--- a/cleopatre/devkit/doc/cleopatre_mme_specs.odt
+++ b/cleopatre/devkit/doc/cleopatre_mme_specs.odt
Binary files differ
diff --git a/cleopatre/devkit/plcd/src/plcd_main.c b/cleopatre/devkit/plcd/src/plcd_main.c
index 21cc043a50..153c40a09a 100644
--- a/cleopatre/devkit/plcd/src/plcd_main.c
+++ b/cleopatre/devkit/plcd/src/plcd_main.c
@@ -41,6 +41,7 @@ static spc300_nvram_t g_nvram;
volatile sig_atomic_t is_process_signal_needed;
+volatile sig_atomic_t exit_requested;
/******************************************************************************/
/* DEBUG FUNCTION */
@@ -74,11 +75,15 @@ plcd_print_usage (const char *cmd)
void
plcd_signal_handler (int signal_nb)
{
- /* check that we received a SIGHUP signal (other signals must be ignored) */
+ /* Check received signal. */
if (SIGHUP == signal_nb)
{
is_process_signal_needed = 1;
}
+ else if (SIGTERM == signal_nb)
+ {
+ exit_requested = 1;
+ }
}
@@ -314,8 +319,11 @@ main (int argc, char **argv)
exit (EXIT_FAILURE);
}
+ /* Catch SIGTERM. */
+ signal (SIGTERM, plcd_signal_handler);
+
/* now get all events from plcdrv (i.e. DRV MME-s) */
- while (1)
+ while (!exit_requested)
{
if (0 > plcd_stack_event_dispatch (&ctx))
{
@@ -323,6 +331,9 @@ main (int argc, char **argv)
}
}
+ libspid_system_file_update_unregister (pid, LIBSPID_HPAV_CONF_PATH);
+ libspid_system_file_update_unregister (pid, LIBSPID_HPAV_INFO_PATH);
+ libspid_system_file_update_unregister (pid, LIBSPID_MULTICAST_INFO_PATH);
plcd_uninit (&ctx);
exit (EXIT_SUCCESS);
}
diff --git a/cleopatre/devkit/plcdrv/arm/Module b/cleopatre/devkit/plcdrv/arm/Module
new file mode 100644
index 0000000000..d644569e21
--- /dev/null
+++ b/cleopatre/devkit/plcdrv/arm/Module
@@ -0,0 +1 @@
+SOURCES = hal.c linux_drv.c mailbox.c processing.c
diff --git a/cleopatre/devkit/plcdrv/arm/inc/common.h b/cleopatre/devkit/plcdrv/arm/inc/common.h
index bb6ba032d4..a9ca8cd850 100644
--- a/cleopatre/devkit/plcdrv/arm/inc/common.h
+++ b/cleopatre/devkit/plcdrv/arm/inc/common.h
@@ -20,7 +20,9 @@
#include <linux/kernel.h> //for printk...
#include <linux/string.h> //for memcpy, memset...
#include <linux/if_ether.h>//for ETH_ALEN
-#include <asm/bitops.h> //test_bit using on TRACE
+#else
+#include <linux/types.h>
+#include <linux/if_ether.h>
#endif
/** Define different trace levels */
diff --git a/cleopatre/devkit/plcdrv/arm/inc/hal.h b/cleopatre/devkit/plcdrv/arm/inc/hal.h
index 7d3bedf738..db99ef1479 100644
--- a/cleopatre/devkit/plcdrv/arm/inc/hal.h
+++ b/cleopatre/devkit/plcdrv/arm/inc/hal.h
@@ -17,9 +17,11 @@
*/
#ifdef __UTESTS__
-#include "hal_utests.h"
+# include "common.h"
+# include <linux/spinlock.h>
+#else
+# include <linux/spinlock.h>
#endif
-#include <linux/spinlock.h>
#define A2L_RING_MASK (A2L_RING_SIZE-1)
#define L2A_RING_MASK (L2A_RING_SIZE-1)
diff --git a/cleopatre/devkit/plcdrv/arm/inc/linux_drv.h b/cleopatre/devkit/plcdrv/arm/inc/linux_drv.h
index 0dc85eb7b6..75f09038ef 100644
--- a/cleopatre/devkit/plcdrv/arm/inc/linux_drv.h
+++ b/cleopatre/devkit/plcdrv/arm/inc/linux_drv.h
@@ -16,15 +16,20 @@
* linux_drv layer
*/
+#ifndef __UTESTS__
#include <linux/netdevice.h>
#include <net/seq_check.h>
+#else
+#include <linux/types.h>
+#include <linux/wait.h>
+#include <linux/interrupt.h>
+#include <linux/dma-mapping.h>
+#include <linux/netdevice.h>
+#endif
+
#include "common.h"
#include "hal.h"
-#ifdef __UTESTS__
-#include "linux_drv_utests.h"
-#endif
-
/** */
enum pkt_dest {
OTHER = 0,
diff --git a/cleopatre/devkit/plcdrv/arm/inc/mailbox.h b/cleopatre/devkit/plcdrv/arm/inc/mailbox.h
index 429e23bb79..c6cbfabd2c 100644
--- a/cleopatre/devkit/plcdrv/arm/inc/mailbox.h
+++ b/cleopatre/devkit/plcdrv/arm/inc/mailbox.h
@@ -19,7 +19,7 @@
#include "common.h"
#ifdef __UTESTS__
-#include "mailbox_utests.h"
+#include <linux/netdevice.h>
#endif
/**
diff --git a/cleopatre/devkit/plcdrv/arm/inc/processing.h b/cleopatre/devkit/plcdrv/arm/inc/processing.h
index 47297387ae..62c64c368e 100644
--- a/cleopatre/devkit/plcdrv/arm/inc/processing.h
+++ b/cleopatre/devkit/plcdrv/arm/inc/processing.h
@@ -18,10 +18,6 @@
#include "common.h"
-#ifdef __UTESTS__
-#include "processing_utests.h"
-#endif
-
/** Define HPAV Ethernet type */
#define ETH_P_HPAV 0x88E1
/** Define MME fcall type */
diff --git a/cleopatre/devkit/plcdrv/arm/src/boot_params.c b/cleopatre/devkit/plcdrv/arm/src/boot_params.c
index c57005bdf7..63ef4498b5 100644
--- a/cleopatre/devkit/plcdrv/arm/src/boot_params.c
+++ b/cleopatre/devkit/plcdrv/arm/src/boot_params.c
@@ -45,25 +45,44 @@ char custom_boot_params[BOOT_PARAMS_STR_SIZE] = "";
static int plcdrv_add_boot_param(char *params_str, const char *param_name,
const char *param_value)
{
- int ret;
+ size_t len;
BUG_ON(params_str == NULL);
BUG_ON(param_name == NULL);
- ret = snprintf(params_str, BOOT_PARAMS_STR_SIZE, "%s%s%s%s%s",
- params_str, param_name,
- (param_value != NULL) ? BOOT_PARAMS_KEY_VALUE_DELIMITER : "",
- (param_value != NULL) ? param_value: "",
- BOOT_PARAMS_DELIMITER);
+ len = strlen(params_str);
- if ((ret <= -1) || (ret >= BOOT_PARAMS_STR_SIZE))
+ /* If params_str is not empty, add a delimiter before adding the boot param. */
+ if (len > 0)
{
- printk (KERN_ERR
- "Boot parameters string too long (after adding default parameter)\n");
- return -1;
+ len += strlen(BOOT_PARAMS_DELIMITER);
+ if (len >= BOOT_PARAMS_STR_SIZE)
+ goto overflow;
+ strcat(params_str, BOOT_PARAMS_DELIMITER);
}
- return 0;
+ /* Add param_name. */
+ len += strlen(param_name);
+ if (len >= BOOT_PARAMS_STR_SIZE)
+ goto overflow;
+ strcat(params_str, param_name);
+
+ /* Add param_value, if any. */
+ if (param_value != NULL)
+ {
+ len += strlen(BOOT_PARAMS_KEY_VALUE_DELIMITER) + strlen(param_value);
+ if (len >= BOOT_PARAMS_STR_SIZE)
+ goto overflow;
+ strcat(params_str, BOOT_PARAMS_KEY_VALUE_DELIMITER);
+ strcat(params_str, param_value);
+ }
+
+ return 0;
+
+overflow:
+ printk (KERN_ERR
+ "Boot parameters string too long (while adding default parameter)\n");
+ return -1;
}
/**
diff --git a/cleopatre/devkit/plcdrv/arm/src/hal.c b/cleopatre/devkit/plcdrv/arm/src/hal.c
index de5fd68630..e8fd144774 100644
--- a/cleopatre/devkit/plcdrv/arm/src/hal.c
+++ b/cleopatre/devkit/plcdrv/arm/src/hal.c
@@ -15,15 +15,16 @@
*/
#ifndef __UTESTS__
-#include <linux/delay.h>
+# include <linux/delay.h>
+#else
+# include <linux/delay.h>
+# include <linux/bitops.h>
+# include <linux/kernel.h>
+#endif
#include "mailbox.h"
#include "hal.h"
#include "registers.h"
-#else
-#include <stdio.h>
#include "common.h"
-#include "hal.h"
-#endif
/** Define Debug/Trace Level */
#define TRACE(...) if(test_bit(TRACE_HAL, (const volatile unsigned long*)&trace)) printk(KERN_INFO "SPC300: HAL : " __VA_ARGS__)
diff --git a/cleopatre/devkit/plcdrv/arm/src/linux_drv.c b/cleopatre/devkit/plcdrv/arm/src/linux_drv.c
index 74f30707bd..faf050e289 100644
--- a/cleopatre/devkit/plcdrv/arm/src/linux_drv.c
+++ b/cleopatre/devkit/plcdrv/arm/src/linux_drv.c
@@ -20,31 +20,68 @@
#ifndef __UTESTS__
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-//#include <linux/version.h>
-#include <linux/afe.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <asm/semaphore.h>
-#include <linux/kdev_t.h>
-#include <linux/cdev.h>
-#include <linux/fs.h>
-#include <linux/proc_fs.h>
-#include <asm/uaccess.h>
-#include <linux/list.h>
-#include <linux/netlink.h>
-#include <linux/poll.h>
-#include <linux/wait.h>
-#include "net/seq_check.h"
-
-#include <asm/arch/nvram.h>
-#include <asm/arch/hardware/spi.h>
-#include <asm/arch/hardware/regbank.h>
-#include <asm-arm/arch-spc300/ioctl.h>
+# include <linux/types.h>
+# include <linux/kernel.h>
+# include <linux/module.h>
+# include <linux/afe.h>
+# include <linux/init.h>
+# include <linux/errno.h>
+# include <linux/netdevice.h>
+# include <linux/etherdevice.h>
+# include <asm/semaphore.h>
+# include <linux/kdev_t.h>
+# include <linux/cdev.h>
+# include <linux/fs.h>
+# include <linux/proc_fs.h>
+# include <asm/uaccess.h>
+# include <linux/list.h>
+# include <linux/netlink.h>
+# include <linux/poll.h>
+# include <linux/wait.h>
+# include "net/seq_check.h"
+
+# include <asm/arch/nvram.h>
+# include <asm/arch/hardware/spi.h>
+# include <asm/arch/hardware/regbank.h>
+# include <asm-arm/arch-spc300/ioctl.h>
+#else
+# include <linux/types.h>
+# include <linux/kernel.h>
+# include <linux/init.h>
+# include <linux/mutex.h>
+# include <linux/list.h>
+# include <linux/wait.h>
+# include <linux/afe.h>
+# include <linux/fs.h>
+# include <linux/poll.h>
+# include <linux/bitops.h> /* non present au-dessus, inclus par qqn ? */
+# include <linux/gfp.h> /* non present au-dessus, inclus par qqn ? */
+# include <linux/skbuff.h>
+# include <linux/netlink.h>
+# include <linux/interrupt.h>
+# include <linux/irqreturn.h>
+# include <linux/module.h>
+# include <linux/moduleparam.h>
+# include <linux/kdev_t.h>
+# include <linux/cdev.h>
+# include <linux/if_ether.h>
+# include <linux/errno.h>
+# include <linux/sched.h>
+# include <linux/dma-mapping.h>
+# include <net/net_namespace.h>
+# include <net/seq_check.h>
+
+# include <asm/arch/nvram.h>
+# include <asm/arch/hardware/regbank.h>
+
+/* TODO : move this ! */
+unsigned char plccode[124];
+#define VIRT_PLCCODE_BASE (&plccode[0])
+#define jiffies 1234
+struct net init_net;
+spc300_nvram_t spc300_nvram;
+
+#endif
#include "boot_params.h"
#include "common.h"
@@ -54,12 +91,6 @@
#include "hal.h"
#include "registers.h"
-
-#else
-#include "common.h"
-#include "linux_drv.h"
-#endif
-
MODULE_AUTHOR("SPiDCOM Technologies");
MODULE_DESCRIPTION("SPC300 PLC driver");
MODULE_LICENSE("SPiDCOM Technologies 2009");
@@ -111,6 +142,9 @@ static struct cdev plcdrv_char_dev;
/** Our trace character device. */
static struct cdev trace_cdev;
+/** Our plc directory in procfs. */
+static struct proc_dir_entry *proc_plc_dir;
+
/** Our mutex between firmware download and network driver start-up */
static uint8_t write_called = 0;
@@ -150,6 +184,9 @@ module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "Let's the user start PLC Processor by debugger");
module_param(trace, uint, 0644);
+void plcdrv_uninit(struct net_device *dev);
+
+
static const unsigned char __hexdigits[] = "0123456789ABCDEF";
static void sprintf_hex(unsigned char * str, const unsigned char * ptr, int len, unsigned char delim)
{
@@ -362,13 +399,50 @@ static int plcdrv_readproc_plc_stats(char *buf, char **start, off_t offset, int
*/
int plcdrv_reset_leon(int activate)
{
- RB_RST_GROUP_VA &= ~RST_LEONSS;
- if(RB_RST_GROUP_VA & RST_LEONSS)
- return -1;
+ if(activate)
+ {
+ RB_RST_GROUP_VA |= RST_LEONSS;
+ if(!(RB_RST_GROUP_VA & RST_LEONSS))
+ return -1;
- RB_RST_MODULE_VA &= ~RST_LCPU;
- if(RB_RST_MODULE_VA & RST_LCPU)
- return -1;
+ RB_RST_MODULE_VA |= RST_LCPU;
+ if(!(RB_RST_MODULE_VA & RST_LCPU))
+ return -1;
+ }
+ else
+ {
+ RB_RST_GROUP_VA &= ~RST_LEONSS;
+ if(RB_RST_GROUP_VA & RST_LEONSS)
+ return -1;
+
+ RB_RST_MODULE_VA &= ~RST_LCPU;
+ if(RB_RST_MODULE_VA & RST_LCPU)
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+ * Set/Unset Reset the DSP.
+ *
+ * \param activate 1 to activate reset.
+ * \return error code.
+ */
+int plcdrv_reset_dsp(int activate)
+{
+ if(activate)
+ {
+ RB_RST_GROUP_VA |= RST_DSP;
+ if(!(RB_RST_GROUP_VA & RST_DSP))
+ return -1;
+ }
+ else
+ {
+ RB_RST_GROUP_VA &= ~RST_DSP;
+ if(RB_RST_GROUP_VA & RST_DSP)
+ return -1;
+ }
return 0;
}
@@ -1625,11 +1699,18 @@ int plcdrv_open(struct net_device *dev)
return -EPERM;
}
+ //Prepare mutex
+ spin_lock_init(&priv->lock);
+
//Prepare sk_buff in used list
INIT_LIST_HEAD(&priv->list_head_skbs_tx);
INIT_LIST_HEAD(&priv->list_head_skbs_rx);
INIT_LIST_HEAD(&priv->list_head_skbs_rx_misc);
+ //Configure AFE with the default configuration
+ if (init_afe())
+ return -EFAULT;
+
//Allocate rings for each mailbox
if((priv->virt_ring_base_addr =
(uint32_t)dma_alloc_coherent(NULL,
@@ -1646,34 +1727,49 @@ int plcdrv_open(struct net_device *dev)
//Flush rings for each mailbox
memset((void*)priv->virt_ring_base_addr, 0, A2L_RING_SIZE+L2A_RING_SIZE);
- //Configure AFE with the default configuration
- if (init_afe())
- return -EFAULT;
+ //Request Receive IRQ
+ if(request_irq(priv->num_mbx_it, plcdrv_it_rx, 0, dev->name, dev) != 0)
+ {
+ printk(KERN_ERR DRV_NAME ": %s - interrupt %d request fail\n", dev->name, dev->irq);
+ result = -ENODEV;
+ goto err_open;
+ }
- //Prepare mutex
- spin_lock_init(&priv->lock);
+ //Request Transmit Acknowledge IRQ
+ if(request_irq(priv->num_mbx_it_ack, plcdrv_it_txdone, 0, dev->name, dev) != 0)
+ {
+ printk(KERN_ERR DRV_NAME ": %s - interrupt %d request fail\n", dev->name, dev->irq);
+ result = -ENODEV;
+ goto err_rq_ack;
+ }
- //Prepare init structure from lower layers
- info.ring_base_addr = priv->virt_ring_base_addr;
- info.phys_ring_base_addr = priv->phys_ring_base_addr;
- info.mbx_reg_base_addr = dev->base_addr;
- info.debug_mode = debug;
- info.launch_leon = &plcdrv_launch_leon;
- memcpy(info.mac_addr, dev->dev_addr, sizeof(info.mac_addr));
+ //Request Leon Watchdog IRQ
+ if(request_irq(priv->num_mbx_it_wd, plcdrv_it_wd, 0, dev->name, dev) != 0)
+ {
+ printk(KERN_ERR DRV_NAME ": %s - interrupt %d request fail\n", dev->name, dev->irq);
+ result = -ENODEV;
+ goto err_rq_wd;
+ }
//Unreset Leon Processor
if(plcdrv_reset_leon(0))
{
result = -1;
- goto err_open;
+ goto err_rq_wd;
}
//Start lower Layers
+ info.ring_base_addr = priv->virt_ring_base_addr;
+ info.phys_ring_base_addr = priv->phys_ring_base_addr;
+ info.mbx_reg_base_addr = dev->base_addr;
+ info.debug_mode = debug;
+ info.launch_leon = &plcdrv_launch_leon;
+ memcpy(info.mac_addr, dev->dev_addr, sizeof(info.mac_addr));
if(processing_init(&info, dev))
{
printk(KERN_ERR DRV_NAME ": %s: Error initializing hardware (firmware)\n", dev->name);
result = -1;
- goto err_open;
+ goto err_rq_wd;
}
//Allocate RX buffer pool to give to CESAR
@@ -1683,7 +1779,7 @@ int plcdrv_open(struct net_device *dev)
{
printk(KERN_ERR DRV_NAME ": %s: Error creating DATA buffer pool\n", dev->name);
result = -1;
- goto err_open;
+ goto err_rq_wd;
}
// update plc stats
priv->plc_stats.rx_pool++;
@@ -1694,7 +1790,7 @@ int plcdrv_open(struct net_device *dev)
{
printk(KERN_ERR DRV_NAME ": %s: Error creating MME buffer pool\n", dev->name);
result = -1;
- goto err_open;
+ goto err_rq_wd;
}
}
for(i=0 ; i<nb_rx_interface_buffers ; i++)
@@ -1703,40 +1799,12 @@ int plcdrv_open(struct net_device *dev)
{
printk(KERN_ERR DRV_NAME ": %s: Error creating INTERFACE buffer pool\n", dev->name);
result = -1;
- goto err_open;
+ goto err_rq_wd;
}
// update plc stats
priv->plc_stats.rx_pool++;
}
- //Prepare Linux as link up
- netif_carrier_on(dev);
- netif_start_queue(dev);
-
- //Request Receive IRQ
- if(request_irq(priv->num_mbx_it, plcdrv_it_rx, 0, dev->name, dev) != 0)
- {
- printk(KERN_ERR DRV_NAME ": %s - interrupt %d request fail\n", dev->name, dev->irq);
- result = -ENODEV;
- goto err_open;
- }
-
- //Request Transmit Acknowledge IRQ
- if(request_irq(priv->num_mbx_it_ack, plcdrv_it_txdone, 0, dev->name, dev) != 0)
- {
- printk(KERN_ERR DRV_NAME ": %s - interrupt %d request fail\n", dev->name, dev->irq);
- result = -ENODEV;
- goto err_rq_ack;
- }
-
- //Request Leon Watchdog IRQ
- if(request_irq(priv->num_mbx_it_wd, plcdrv_it_wd, 0, dev->name, dev) != 0)
- {
- printk(KERN_ERR DRV_NAME ": %s - interrupt %d request fail\n", dev->name, dev->irq);
- result = -ENODEV;
- goto err_rq_wd;
- }
-
//Enable tasklet for reception
tasklet_enable(&priv->tasklet_it_rx);
@@ -1744,6 +1812,10 @@ int plcdrv_open(struct net_device *dev)
priv->nl_drv_sock = netlink_kernel_create(&init_net, NETLINK_PLC_DRV, 0, plcdrv_netlink_drv_tx, NULL, THIS_MODULE);
priv->nl_mme_sock = netlink_kernel_create(&init_net, NETLINK_PLC_MME, 0, plcdrv_netlink_mme_tx, NULL, THIS_MODULE);
+ //Prepare Linux as link up
+ netif_carrier_on(dev);
+ netif_start_queue(dev);
+
return 0;
err_rq_wd:
@@ -1789,14 +1861,19 @@ int plcdrv_stop(struct net_device *dev)
//Stop tasklet for reception
tasklet_disable(&priv->tasklet_it_rx);
+ //Stop lower layers
+ processing_uninit();
+
+ //Reset LEON and DSP
+ plcdrv_reset_leon(1);
+ plcdrv_reset_dsp(1);
+ plcdrv_reset_dsp(0);
+
//Disconnect from IRQ
free_irq(priv->num_mbx_it, dev);
free_irq(priv->num_mbx_it_ack, dev);
free_irq(priv->num_mbx_it_wd, dev);
- //Stop lower layers
- processing_uninit();
-
//Free mailboxes ring
dma_free_coherent(NULL,
A2L_RING_SIZE+L2A_RING_SIZE,
@@ -1864,6 +1941,7 @@ int plcdrv_init(struct net_device *dev)
//Initialise device functions
ether_setup(dev);
+ dev->uninit = plcdrv_uninit;
dev->open = plcdrv_open;
dev->stop = plcdrv_stop;
dev->do_ioctl = plcdrv_ioctl;
@@ -1895,6 +1973,26 @@ int plcdrv_init(struct net_device *dev)
return 0;
}// plcdrv_init
+/**
+ * Uninitialise the network device.
+ *
+ * \param dev device structure.
+ */
+void plcdrv_uninit(struct net_device *dev)
+{
+ struct net_priv *priv;
+ BUG_ON(!dev);
+ priv = (struct net_priv *)dev->priv;
+ BUG_ON(!priv);
+
+ //Kill tasklet for reception
+ tasklet_kill(&priv->tasklet_it_rx);
+
+ //Unmap IP address
+ BUG_ON(!dev->base_addr);
+ iounmap((void*)dev->base_addr);
+}// plcdrv_uninit
+
/** Character device functions */
static struct file_operations plcdrv_char_fops = {
.owner = THIS_MODULE,
@@ -1921,7 +2019,6 @@ int __init plcdrv_module_init(void)
{
int result;
struct net_device *dev = NULL;
- struct proc_dir_entry *plc_dir;
struct proc_dir_entry *entry;
struct net_priv *priv;
@@ -1996,8 +2093,8 @@ int __init plcdrv_module_init(void)
}
//Create a proc entry for version
- plc_dir = proc_mkdir("plc", init_net.proc_net);
- entry = create_proc_entry("version", 0, plc_dir);
+ proc_plc_dir = proc_mkdir("plc", init_net.proc_net);
+ entry = create_proc_entry("version", 0, proc_plc_dir);
entry->read_proc = plcdrv_readproc_version;
entry->data = (int*)plcdrv_device;
@@ -2007,7 +2104,7 @@ int __init plcdrv_module_init(void)
entry->data = (int*)plcdrv_device;
// Create stats entries
- entry = create_proc_entry ("stats", 0, plc_dir);
+ entry = create_proc_entry ("stats", 0, proc_plc_dir);
entry->read_proc = plcdrv_readproc_plc_stats;
entry->data = (int*)plcdrv_device;
@@ -2025,7 +2122,7 @@ int __init plcdrv_module_init(void)
*/
void __exit plcdrv_module_exit(void)
{
- struct net_priv *priv = NULL;
+ BUG_ON(!plcdrv_device);
//Unregister character device
cdev_del(&plcdrv_char_dev);
@@ -2033,35 +2130,14 @@ void __exit plcdrv_module_exit(void)
unregister_chrdev_region(number, 2);
//Unregister network device
- if(plcdrv_device)
- {
- //Remove proc
- remove_proc_entry("plc/stats", init_net.proc_net);
- remove_proc_entry("plc/version", init_net.proc_net);
- remove_proc_entry("plc/regbank", init_net.proc_net);
- remove_proc_entry("plc", init_net.proc_net);
-
- //Unmap IP address
- if(plcdrv_device->base_addr)
- iounmap((void*)plcdrv_device->base_addr);
-
- priv = plcdrv_device->priv;
- if(priv)
- {
- //Kill tasklet for reception
- tasklet_kill(&priv->tasklet_it_rx);
-
- //Freeing private field of the net device structure
- kfree(priv);
- }
-
- //Unregister net device
- unregister_netdev(plcdrv_device);
-
- //Freeing network device
- free_netdev(plcdrv_device);
- }
-
+ unregister_netdev(plcdrv_device);
+ free_netdev(plcdrv_device);
+
+ //Remove proc
+ remove_proc_entry("stats", proc_plc_dir);
+ remove_proc_entry("version", proc_plc_dir);
+ remove_proc_entry("plc", init_net.proc_net);
+ remove_proc_entry("plc/regbank", init_net.proc_net);
}// plcdrv_module_exit
module_init(plcdrv_module_init);
diff --git a/cleopatre/devkit/plcdrv/arm/src/mailbox.c b/cleopatre/devkit/plcdrv/arm/src/mailbox.c
index b7fa76db5c..c7eab7a24d 100644
--- a/cleopatre/devkit/plcdrv/arm/src/mailbox.c
+++ b/cleopatre/devkit/plcdrv/arm/src/mailbox.c
@@ -14,15 +14,20 @@
* provide all mechanisms to manage mailboxes.
*/
-#ifndef __UTESTS__
#include "common.h"
#include "linux_drv.h"
#include "processing.h"
#include "mailbox.h"
#include "hal.h"
-#else
-#include "common.h"
-#include "mailbox.h"
+
+#include <linux/bitops.h>
+#include <linux/kernel.h>
+
+#ifdef __UTESTS__
+/* TODO : move this ! */
+uint32_t mbx_send_result[2];
+uint32_t mbx_buffer_add_result[2];
+uint32_t mbx_rx_ptr_result;
#endif
/** Define Debug/Trace Level */
@@ -152,7 +157,9 @@ int mailbox_init(struct init_info *info, struct net_device *dev)
L2At_it_disable(ctx);
L2Awd_it_disable(ctx);
- //Clear watchdog interrupt
+ //Clear interrupts
+ clr_A2La_interrupt(ctx);
+ clr_L2At_interrupt(ctx);
clr_L2Awd_interrupt(ctx);
//Unmask sending interrupts
diff --git a/cleopatre/devkit/plcdrv/arm/src/processing.c b/cleopatre/devkit/plcdrv/arm/src/processing.c
index cc37f5969c..c6276167a7 100644
--- a/cleopatre/devkit/plcdrv/arm/src/processing.c
+++ b/cleopatre/devkit/plcdrv/arm/src/processing.c
@@ -14,49 +14,22 @@
* (TX ans RX) and decided to pass and drop it.
*/
-#ifndef __UTESTS__
#include "common.h"
#include "linux_drv.h"
#include "processing.h"
#include "mailbox.h"
-#else
-#include "common.h"
-#include "processing.h"
-#endif
-#ifdef __LINUX__
+#ifndef __UTESTS__
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <asm/byteorder.h>
-#else // __LINUX__
-//Linux not define so we have to redefine all eth header structure and fields
-#define ETH_ALEN 6 //Octets in one Ethernet address
-#define ETH_HLEN 14 //Total octets in header
-#define VLAN_ETH_ALEN 6
-#define VLAN_ETH_HLEN 18
-struct ethhdr
-{
- unsigned char h_dest[ETH_ALEN]; //destination eth address
- unsigned char h_source[ETH_ALEN]; //source eth address
- unsigned short int h_proto; //packet type ID field
-} __attribute__((packed));
-
-struct vlan_ethhdr
-{
- unsigned char h_dest[ETH_ALEN];
- unsigned char h_source[ETH_ALEN];
- unsigned short int h_vlan_proto;
- unsigned short int h_vlan_TCI;
- unsigned short int h_vlan_encapsulated_proto;
-} __attribute__((packed));
-
-#define VLAN_VID_MASK 0x0fff
-
-static inline unsigned short int ntohs(unsigned short int x)
-{
- return x<<8 | x>>8;
-}
-#endif // __LINUX__
+#else //__UTESTS__
+#include <linux/types.h>
+#include <linux/bitops.h>
+#include <linux/kernel.h>
+#include <linux/if_ether.h>
+#include <linux/if_vlan.h>
+#endif // __UTESTS__
/** Define Debug/Trace Level */
#define TRACE(...) if(test_bit(TRACE_PROCESS, (const volatile unsigned long*)&trace)) printk(KERN_INFO "SPC300: PROC: " __VA_ARGS__)
diff --git a/cleopatre/devkit/tests/common/Makefile b/cleopatre/devkit/tests/common/Makefile
new file mode 100644
index 0000000000..5fd841ee8a
--- /dev/null
+++ b/cleopatre/devkit/tests/common/Makefile
@@ -0,0 +1,46 @@
+# Build target busybox for host machine.
+
+BUILDROOT_DIR = ../../../buildroot
+BUILDROOT_TARGET = spk300g_eoc_master
+BUILDROOT_BUSYBOX_DIR = $(BUILDROOT_DIR)/project_build_$(BR2_ARCH)/$(BUILDROOT_TARGET)/busybox-$(BR2_BUSYBOX_VERSION)
+BUILDROOT_BUSYBOX_CONFIG = $(BUILDROOT_DIR)/$(subst ",,$(BR2_PACKAGE_BUSYBOX_CONFIG)) #")
+
+.PHONY: all busybox busybox-config busybox-unpacked \
+ buildroot-config clean
+
+all:
+
+-include $(BUILDROOT_DIR)/.config
+
+ifdef BR2_PROJECT
+ ifneq ($(BR2_PROJECT),"$(BUILDROOT_TARGET)")
+ ifndef FORCE
+ $(error Should clean buildroot project $(BR2_PROJECT) != $(BUILDROOT_TARGET))
+ endif
+ endif
+endif
+
+busybox: busybox-config
+ $(MAKE) -C busybox
+
+busybox-config: busybox/.config
+
+busybox/.config: $(BUILDROOT_BUSYBOX_CONFIG) busybox-unpacked
+ test -n '$(BR2_PACKAGE_BUSYBOX_CONFIG)'
+ mkdir -p busybox
+ cp $< $@
+ sed -i 's/CONFIG_HALT=y/# CONFIG_HALT is not set/' $@
+ $(MAKE) -C $(BUILDROOT_BUSYBOX_DIR) O=$(CURDIR)/busybox oldconfig
+
+busybox-unpacked: buildroot-config
+ $(MAKE) -C $(BUILDROOT_DIR) dirs busybox-unpacked
+
+buildroot-config: $(BUILDROOT_DIR)/.config
+
+$(BUILDROOT_DIR)/.config:
+ $(MAKE) -C $(BUILDROOT_DIR) $(BUILDROOT_TARGET)_defconfig
+
+clean:
+ if test -f busybox/Makefile; then \
+ $(MAKE) -C busybox clean; \
+ fi
diff --git a/cleopatre/devkit/tests/fw_wd/Makefile b/cleopatre/devkit/tests/fw_wd/Makefile
new file mode 100644
index 0000000000..de2cfaefcd
--- /dev/null
+++ b/cleopatre/devkit/tests/fw_wd/Makefile
@@ -0,0 +1,15 @@
+BUSYBOX = ../common/busybox/busybox
+
+.PHONY: all busybox tests clean
+
+all: busybox
+
+busybox:
+ $(MAKE) -C ../common busybox
+
+tests: busybox
+ ./run-test
+
+clean:
+ $(MAKE) -C ../common clean
+ rm -rf root
diff --git a/cleopatre/devkit/tests/fw_wd/run-test b/cleopatre/devkit/tests/fw_wd/run-test
new file mode 100755
index 0000000000..ce1d77218e
--- /dev/null
+++ b/cleopatre/devkit/tests/fw_wd/run-test
@@ -0,0 +1,248 @@
+#!/usr/bin/python
+"""Test FW watch daemon."""
+from shutil import copy, rmtree
+from os import symlink, mkdir, chmod
+import sys
+import subprocess
+import gzip
+import time
+
+busybox_path = '../common/busybox/busybox'
+fw_wd_path = '../../../application/fw_wd'
+
+trace_content = """\
+Test trace line 1
+Test trace line 2
+Test trace line 3
+Test trace line 4
+Test trace line 5
+"""
+
+trace_files_content = {
+'/etc/hpav.info': """\
+hpav.info file line 1
+hpav.info file line 2
+""",
+'/proc/uptime': """\
+uptime line 1
+""",
+}
+
+fw_wd_stub = """\
+#!/bin/sh
+test -f /tmp/fw_wd_run && echo "fw_wd stop test" && exit 1
+touch /tmp/fw_wd_run
+echo "fw_wd run"
+exit %(retcode)s
+"""
+
+fw_wd_wait_stub = """\
+#!/bin/sh
+echo "fw_wd run"
+trap : TERM
+sleep 100 &
+pid=$!
+wait $pid
+kill $pid
+"""
+
+reboot_stub = """\
+#!/bin/sh
+echo "reboot run"
+exit %(retcode)s
+"""
+
+default_content = """\
+REBOOT=%(reboot)s
+TRACE_ENABLED=%(trace_enabled)s
+TRACE_FOLDER="/usr/local/trace/"
+TRACE_FILES="%(trace_files)s"
+TRACE_CMDS="%(trace_cmds)s"
+"""
+
+chroot_env = {
+ 'PATH': '/bin:/sbin:/usr/bin:/usr/sbin',
+ 'USER': 'testuser',
+ 'SHELL': '/bin/sh',
+ }
+
+trace_cmds = [ [ ], [ 'echo choucroute' ] ]
+trace_cmds_result = [ [ ], [ 'choucroute\n' ] ]
+
+class TestParams:
+ def __init__(self, test_name, **kw):
+ self.test_name = test_name
+ self.fw_wd_retcode = 0
+ self.reboot = True
+ self.reboot_retcode = 0
+ self.trace_enabled = True
+ self.trace_present = True
+ self.trace_files = [ '/proc/uptime', '/etc/hpav.info' ]
+ self.trace_cmds_test = False
+ self.trace_dir = True
+ self.old_traces = [ ]
+ self.kill = False
+ self.__dict__.update(kw)
+
+def chroot_call(root_path, command):
+ """Call a command in the chrooted environment, raise error on any
+ problem."""
+ subprocess.check_call([ 'fakechroot', '/usr/sbin/chroot', root_path ] +
+ command)
+
+def create_file(root_path, filename, content, executable=False):
+ """Create a text file in rootfs with given content. Give execution
+ permissions if requested."""
+ f = open(root_path + filename, 'w')
+ f.write(content)
+ f.close()
+ if executable:
+ chmod(root_path + filename, 0755)
+
+def create_rootfs(root_path, test_params):
+ """Create a full rootfs from given test parameters. Clean up if rootfs is
+ existent."""
+ # Create basic rootfs.
+ rmtree(root_path, ignore_errors=True)
+ mkdir(root_path)
+ for p in [ '/bin', '/sbin', '/usr', '/usr/bin', '/usr/sbin', '/usr/local',
+ '/proc', '/proc/self', '/dev', '/etc', '/etc/default', '/tmp' ]:
+ mkdir(root_path + p)
+ copy(busybox_path, root_path + '/bin')
+ symlink('/bin/busybox', root_path + '/proc/self/exe')
+ chroot_call(root_path, [ '/bin/busybox', '--install', '-s' ])
+ copy(fw_wd_path + '/fwwatchd', root_path + '/usr/bin')
+ create_file(root_path, '/dev/null', '')
+ # Create test stubs.
+ if not test_params.kill:
+ create_file(root_path, '/usr/bin/fw_wd',
+ fw_wd_stub % { 'retcode': test_params.fw_wd_retcode },
+ executable=True)
+ else:
+ create_file(root_path, '/usr/bin/fw_wd', fw_wd_wait_stub,
+ executable=True)
+ create_file(root_path, '/sbin/reboot',
+ reboot_stub % { 'retcode': test_params.reboot_retcode },
+ executable=True)
+ if test_params.trace_present:
+ create_file(root_path, '/dev/trace', trace_content)
+ for f in test_params.trace_files:
+ create_file(root_path, f, trace_files_content[f])
+ if test_params.trace_dir:
+ mkdir(root_path + '/usr/local/trace')
+ for i in test_params.old_traces:
+ create_file(root_path, '/usr/local/trace/trace_%d.gz' % i,
+ 'Old trace %d' % i)
+ # Create default file.
+ def bool_value(b):
+ return 'true' if b else 'false'
+ def list_value(l):
+ return ':'.join(l)
+ create_file(root_path, '/etc/default/fwwatchd', default_content % {
+ 'reboot': bool_value(test_params.reboot),
+ 'trace_enabled': bool_value(test_params.trace_enabled),
+ 'trace_files': list_value(test_params.trace_files),
+ 'trace_cmds': list_value(trace_cmds[test_params.trace_cmds_test]),
+ })
+
+def check(root_path, test_params, stdout):
+ """Check test result."""
+ # Check stdout.
+ if not test_params.trace_enabled:
+ expected_stdout = ''
+ else:
+ expected_stdout = 'fw_wd run\n'
+ if test_params.fw_wd_retcode == 0 and not test_params.kill:
+ if test_params.reboot:
+ expected_stdout += 'reboot run\n'
+ if test_params.reboot_retcode == 0:
+ expected_stdout += 'fw_wd stop test\n'
+ if expected_stdout != stdout:
+ print test_params.test_name, "failed (%s != %s)" % (repr(stdout),
+ repr(expected_stdout))
+ return False
+ # Check trace file.
+ expected_trace = ''
+ expected_last_head_trace = ''
+ if test_params.trace_enabled and test_params.fw_wd_retcode == 0 \
+ and not test_params.kill:
+ if test_params.trace_present:
+ expected_last_head_trace = \
+ '\n'.join(trace_content.split('\n')[0:3]) + '\n'
+ expected_trace += expected_last_head_trace + trace_content
+ for f in test_params.trace_files:
+ expected_trace += "==== %s ====\n" % f
+ expected_trace += trace_files_content[f]
+ expected_trace += "\n"
+ for cmd, result in zip(trace_cmds[test_params.trace_cmds_test],
+ trace_cmds_result[test_params.trace_cmds_test]):
+ expected_trace += "==== %s ====\n" % cmd
+ expected_trace += result
+ expected_trace += "\n"
+ expected_trace_nb = max(test_params.old_traces + [ 0 ] ) + 1
+ expected_file_name = '/usr/local/trace/trace_%d.gz' % expected_trace_nb
+ try:
+ f = gzip.open(root_path + expected_file_name)
+ if not expected_trace:
+ print test_params.test_name, \
+ "failed (%s exists)" % expected_file_name
+ return False
+ else:
+ trace = f.read()
+ if expected_trace != trace:
+ print test_params.test_name, "failed"
+ print "expected trace:\n", expected_trace
+ print "trace:\n", trace
+ return False
+ f.close()
+ except IOError:
+ if expected_trace:
+ print test_params.test_name, \
+ "failed (can not open %s)" % expected_file_name
+ return False
+ return True
+
+def run_test(root_path, test_params):
+ """Run FW watch daemon in a chrooted environment and check result. Return
+ a number of failed test."""
+ create_rootfs('root', test_params)
+ proc = subprocess.Popen([ 'fakechroot', '/usr/sbin/chroot', root_path,
+ '/usr/bin/fwwatchd' ], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ env=chroot_env)
+ if test_params.kill:
+ time.sleep(0.1)
+ proc.terminate()
+ stdout = proc.communicate()[0]
+ result = check('root', test_params, stdout)
+ return 0 if result else 1
+
+if __name__ == '__main__':
+ failed = 0
+ tp = TestParams("default params")
+ failed += run_test('root', tp)
+ # Watchdog test.
+ tp = TestParams("fw_wd fail", fw_wd_retcode=1)
+ failed += run_test('root', tp)
+ tp = TestParams("kill script", kill=True)
+ failed += run_test('root', tp)
+ # Trace tests.
+ tp = TestParams("trace disabled", trace_enabled=False)
+ failed += run_test('root', tp)
+ tp = TestParams("trace not available", trace_present=False)
+ failed += run_test('root', tp)
+ tp = TestParams("no trace files", trace_files=[ ])
+ failed += run_test('root', tp)
+ tp = TestParams("trace commands", trace_cmds_test=True)
+ failed += run_test('root', tp)
+ tp = TestParams("no trace dir", trace_dir=False)
+ failed += run_test('root', tp)
+ tp = TestParams("old traces", old_traces=[ 1, 2, 8 ])
+ failed += run_test('root', tp)
+ # Reboot tests.
+ tp = TestParams("no reboot", reboot=False)
+ failed += run_test('root', tp)
+ tp = TestParams("reboot fail", reboot_retcode=1)
+ failed += run_test('root', tp)
+ # Bye.
+ print "failed %d tests" % failed
+ sys.exit (1 if failed else 0)
diff --git a/cleopatre/devkit/tests/hal/gidel/ftests/Makefile b/cleopatre/devkit/tests/hal/gidel/ftests/Makefile
deleted file mode 100644
index a3224c5321..0000000000
--- a/cleopatre/devkit/tests/hal/gidel/ftests/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-BASE := $(CURDIR)/../../../../..
-OBJPATH := ./obj
-SRCPATH := ./src
-PRJPATH := $(BASE)/devkit/hal/gidel
-INC_PRJPATH := $(PRJPATH)
-###################################################
-
-# Common stuff
-CC := g++
-CFLAGS := -Wall -g3 -DLINUX -I. -I$(INC_PRJPATH)
-LIBS := -L$(PRJPATH) -lgidel -lgidelproc
-export LD_LIBRARY_PATH=\$$LD_LIBRARY_PATH:$(PRJPATH)
-
-SRCS=$(subst $(SRCPATH)/,,$(wildcard $(SRCPATH)/*.cpp))
-BINS=$(addprefix $(OBJPATH)/,$(SRCS:.cpp=.elf))
-
-
-# Rules
-all: $(PRJPATH)/libgidel.so $(OBJPATH) $(BINS)
-
-$(PRJPATH)/libgidel.so:
- $(MAKE) -C $(PRJPATH)
-
-$(OBJPATH)/%.elf: $(OBJPATH)/%.o
- $(CC) -shared -o $@ $^ $(LIBS)
-
-$(OBJPATH)/%.o : $(SRCPATH)/%.cpp
- $(CC) $(CFLAGS) -c -o $@ $<
-
-$(OBJPATH):
- mkdir -p $@
-
-clean :
- rm -rf $(OBJPATH)
diff --git a/cleopatre/devkit/tests/hal/gidel/ftests/src/start.cpp b/cleopatre/devkit/tests/hal/gidel/ftests/src/start.cpp
deleted file mode 100644
index bf7acf4975..0000000000
--- a/cleopatre/devkit/tests/hal/gidel/ftests/src/start.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test.cpp
- * \brief simple loader and basic test program
- * \ingroup
- *
- * this program load an rbf file into the gidel's FPGA
- * and start some tests
- */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <signal.h>
-#include "AHBMemory.h"
-#include "AHBRegister.h"
-#include "Gidel.h"
-
-#define FPGA_NUM 1
-#define RBF "/home/spidcom/Maria_proto/projects/Maria_Proto_11/modules/maria_proto/board/hardware/proto_maria_ddr/fpga.rbf"
-
-CGidel *m_gidel = NULL;
-char rbf[_MAX_PATH];
-
-static void catch_sigint(int sig)
-{
- if(m_gidel != NULL)
- {
- printf("freeing memory...\n");
- delete m_gidel;
- }
- exit(0);
-}
-
-void test_irq(LPVOID pData)
-{
- printf("Oh What a pretty IRQ !\n");
-}
-
-int main(int argc, char* argv[])
-{
- unsigned char user;
-
- signal(SIGINT, catch_sigint);
-
- memset(rbf, 0, sizeof(rbf));
- strcpy(rbf, RBF);
-
- //download .rbf into the FPGA
- printf("\nLoading FPGA under GIDEL..........");
- try
- {
- m_gidel = new CGidel(rbf, FPGA_NUM, 0);
- }
- catch(const ProcException& e)
- {
- e.ErrorMsg();
- exit(-1);
- }
- catch(...)
- {
- printf("failed\nUnable to Load FPGA under Gidel\n");
- exit(-1);
- }
- //print rbf version
- printf("done (V%d)\n", m_gidel->GetRBFVersion());
- //start processor and ahb
- printf("Starting processor and AHB........");
- m_gidel->f_rst_ahb = 0;
- m_gidel->f_rst_proc = 0;
-
- if(!m_gidel->f_rst_ahb && !m_gidel->f_rst_proc)
- printf("done\n");
- else
- printf("failed\nUnable to UnReset processor and AHB\n");
-
- unsigned int test;
- AHBRegister leon_cfg_reg(m_gidel, 0x80000024);
- test = leon_cfg_reg;
- printf("leon_cfg_reg=%x\n",test);
- printf("leon_cfg_reg=%x\n",(unsigned int)leon_cfg_reg);
-
- unsigned int test1;
- AHBRegister myreg(m_gidel, 0xB5000010);
- test1 = myreg;
- printf("test1=%x\n",test1);
- myreg = 0x12345678;
- printf("myreg=%x\n",(unsigned int)myreg);
-
- unsigned int test2, test3, val[4] = {0x11111111, 0x22222222, 0x33333333, 0x44444444};
- AHBMemoryPtr<DWORD> memory(m_gidel, 0x00000030, 4);
- for(int i=0 ; i<4 ; i++)
- {
- *memory = val[i];
- test2 = *memory;
- test3 = memory.GetAddr();
- printf("memory 0x%08x=%08x\n", test3, test2);
- memory = memory + 1;
-// memory += 1;
-// memory++;
- }
-
- //set interrupt handler (interrupt from LEON)
- m_gidel->SetUserInterruptHandler(&test_irq);
- m_gidel->EnableInterrupt(true);
-
- //config interrupt to LEON
- //active interrupt 5 with GPIO14 on positive edge
- printf("Waiting debuggueur..."); scanf("%c",&user);
- unsigned int cfg;
- AHBRegister gpio_int_cfg(m_gidel, 0x800000A8);
- cfg = gpio_int_cfg;
- printf("GPIO int cfg before : %x\n",cfg);
- gpio_int_cfg = (cfg & 0xFFFF00FF) | 0xEE00; //active interrupt on GPIO 14 on positive edge
- printf("GPIO int cfg after : %x\n",(unsigned int)gpio_int_cfg);
-
- do {
- //start interrupt to LEON
- printf("Start Interrupt to LEON (%x) ? (y/n): ", (unsigned int)m_gidel->r_Pciit);
- scanf("%c",&user);
-
- if(user == 'y')
- {
- printf("Interrupt sending\n");
- if(m_gidel->f_pciit_to_leon == 1)
- m_gidel->f_pciit_to_leon = 0;
- else
- m_gidel->f_pciit_to_leon = 1;
- }
- } while(1); //wait Ctrl+C
-
- return 0;
-}
-
diff --git a/cleopatre/devkit/tests/hal/gidel/ftests/src/start2.cpp b/cleopatre/devkit/tests/hal/gidel/ftests/src/start2.cpp
deleted file mode 100644
index a5d2c1a08b..0000000000
--- a/cleopatre/devkit/tests/hal/gidel/ftests/src/start2.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test.cpp
- * \brief simple loader and basic test program
- * \ingroup
- *
- * this program load an rbf file into the gidel's FPGA
- * and start some tests
- */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <signal.h>
-#include "AHBMemory.h"
-#include "AHBRegister.h"
-#include "Gidel.h"
-
-#define FPGA_NUM 1
-#define RBF "/home/spidcom/Maria_proto/projects/Maria_Proto_11/modules/maria_proto/board/hardware/proto_maria_ddr/fpga.rbf"
-
-CGidel *m_gidel = NULL;
-char rbf[_MAX_PATH];
-
-static void catch_sigint(int sig)
-{
- if(m_gidel != NULL)
- {
- printf("freeing memory...\n");
- delete m_gidel;
- }
- exit(0);
-}
-
-void test_irq(LPVOID pData)
-{
- printf("Oh What a pretty IRQ !\n");
-}
-
-int main(int argc, char* argv[])
-{
- signal(SIGINT, catch_sigint);
-
- memset(rbf, 0, sizeof(rbf));
- strcpy(rbf, RBF);
-
- //download .rbf into the FPGA
- printf("\nLoading FPGA under GIDEL..........");
- try
- {
- m_gidel = new CGidel(rbf, FPGA_NUM, 0);
- }
- catch(const ProcException& e)
- {
- e.ErrorMsg();
- exit(-1);
- }
- catch(...)
- {
- printf("failed\nUnable to Load FPGA under Gidel\n");
- exit(-1);
- }
- //print rbf version
- printf("done (V%d)\n", m_gidel->GetRBFVersion());
- //start processor and ahb
- printf("Starting processor and AHB........");
- m_gidel->f_rst_ahb = 0;
- m_gidel->f_rst_proc = 0;
-
- if(!m_gidel->f_rst_ahb && !m_gidel->f_rst_proc)
- printf("done\n");
- else
- printf("failed\nUnable to UnReset processor and AHB\n");
-
- //set interrupt handler (interrupt from LEON)
- m_gidel->SetUserInterruptHandler(&test_irq);
- m_gidel->EnableInterrupt(true);
-
- AHBRegister L2A_head(m_gidel, 0xB500001C);
-
- unsigned int error = 0;
- unsigned int result;
- printf("Read/Write test starting... ");
-
- for(unsigned int i=0;;i++)
- {
- L2A_head = i;
- result = L2A_head;
- if(result != i)
- {
- printf("i=0x%08x ; result=0x%08x\n",i,result);
- printf("PCI latency Last=%d ; PCI latency Max=%d\n", (unsigned int)m_gidel->r_PCILatencyLast, (unsigned int)m_gidel->r_PCILatencyMax);
- error++;
- }
- if((!(i%100000)) && (i!=0))
- {
- if(error)
- {
- printf("%d on %d Errors\n", error, i);
- i = 0;
- error = 0;
- }
- else
- {
- i = 0;
- printf("No Errors\n");
- }
- }
- }
- return 0;
-}
-
diff --git a/cleopatre/devkit/tests/hal/gidel/ftests/src/start3.cpp b/cleopatre/devkit/tests/hal/gidel/ftests/src/start3.cpp
deleted file mode 100644
index a5953dd508..0000000000
--- a/cleopatre/devkit/tests/hal/gidel/ftests/src/start3.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test.cpp
- * \brief simple loader and basic test program
- * \ingroup
- *
- * this program load an rbf file into the gidel's FPGA
- * and start some tests
- */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <signal.h>
-#include "AHBMemory.h"
-#include "AHBRegister.h"
-#include "Gidel.h"
-
-#define FPGA_NUM 1
-#define RBF "/home/spidcom/Maria_proto/projects/Maria_Proto_11/modules/maria_proto/board/hardware/proto_maria_ddr/fpga.rbf"
-
-CGidel *m_gidel = NULL;
-char rbf[_MAX_PATH];
-
-static void catch_sigint(int sig)
-{
- if(m_gidel != NULL)
- {
- printf("freeing memory...\n");
- delete m_gidel;
- }
- exit(0);
-}
-
-void test_irq(LPVOID pData)
-{
- printf("Oh What a pretty IRQ !\n");
-}
-
-int main(int argc, char* argv[])
-{
- signal(SIGINT, catch_sigint);
-
- memset(rbf, 0, sizeof(rbf));
- strcpy(rbf, RBF);
-
- //download .rbf into the FPGA
- printf("\nLoading FPGA under GIDEL..........");
- try
- {
- m_gidel = new CGidel(rbf, FPGA_NUM, 0);
- }
- catch(const ProcException& e)
- {
- e.ErrorMsg();
- exit(-1);
- }
- catch(...)
- {
- printf("failed\nUnable to Load FPGA under Gidel\n");
- exit(-1);
- }
- //print rbf version
- printf("done (V%d)\n", m_gidel->GetRBFVersion());
- //start processor and ahb
- printf("Starting processor and AHB........");
- m_gidel->f_rst_ahb = 0;
- m_gidel->f_rst_proc = 0;
-
- if(!m_gidel->f_rst_ahb && !m_gidel->f_rst_proc)
- printf("done\n");
- else
- printf("failed\nUnable to UnReset processor and AHB\n");
-
- //set interrupt handler (interrupt from LEON)
- m_gidel->SetUserInterruptHandler(&test_irq);
- m_gidel->EnableInterrupt(true);
-
- AHBMemoryPtr<uint32_t> ddr2(m_gidel, 0x50000, 4);
-
- unsigned int error = 0;
- unsigned int result[4];
- printf("Read/Write test starting... \n");
-
- for(unsigned int i=0;;i++)
- {
- *ddr2 = i;
- *(ddr2+1) = i+1;
- *(ddr2+2) = i+2;
- *(ddr2+3) = i+3;
- result[0] = *ddr2;
- result[1] = *(ddr2+1);
- result[2] = *(ddr2+2);
- result[3] = *(ddr2+3);
- if(result[0] != i)
- {
- printf("00000 i=0x%08x ; result=0x%08x\n",i,result[0]);
- error++;
- }
- if(result[1] != i+1)
- {
- printf("11111 i=0x%08x ; result=0x%08x\n",i+1,result[1]);
- error++;
- }
- if(result[2] != i+2)
- {
- printf("22222 i=0x%08x ; result=0x%08x\n",i+2,result[2]);
- error++;
- }
- if(result[3] != i+3)
- {
- printf("44444 i=0x%08x ; result=0x%08x\n",i+3,result[3]);
- error++;
- }
- if((!(i%25000)) && (i!=0))
- {
- if(error)
- {
- printf("%d on %d Errors\n", error, i);
- i = 0;
- error = 0;
- }
- else
- {
- i = 0;
- printf("No Errors\n");
- }
- }
- }
- return 0;
-}
-
diff --git a/cleopatre/devkit/tests/kernel/drivers/gpio/ftests/interrupt/Makefile b/cleopatre/devkit/tests/kernel/drivers/gpio/ftests/interrupt/Makefile
index 4328624292..ffa0511e7d 100644
--- a/cleopatre/devkit/tests/kernel/drivers/gpio/ftests/interrupt/Makefile
+++ b/cleopatre/devkit/tests/kernel/drivers/gpio/ftests/interrupt/Makefile
@@ -1,33 +1,16 @@
-BIN=gpio_interrupt
-OBJPATH=./obj
-SRCPATH=./src
-INCPATH=./inc
+BASE = ../../../../../../../../cesar
+CLEO_BASE = ../cleopatre
-CC=arm-linux-gcc
-CC_WITH_CFLAGS=$(CC) -I/opt/spidcom/spc300/usr/include -g -Os
-CC_WITHOUT_CFLAGS=$(CC)
-LINUX_DIR=../../../../../../../linux-2.6.25.10-spc300
-EXTRA_CFLAGS=-I$(INCPATH) -I$(LINUX_DIR)/include -MMD
+LINUX_PATH = $(CLEO_BASE)/linux-2.6.25.10-spc300
-SRCS=$(subst $(SRCPATH)/,,$(wildcard $(SRCPATH)/*.c))
-OBJS=$(addprefix $(OBJPATH)/,$(SRCS:.c=.o))
-DEPS=$(patsubst %o,%d,$(OBJS))
+INCLUDES = $(LINUX_PATH)/include/
-all: $(BIN)
+EXTRA_TARGET_CFLAGS = -I/opt/spidcom/spc300/usr/include
-$(BIN): $(OBJPATH) $(OBJS)
- $(CC_WITHOUT_CFLAGS) -o $@ $(OBJS)
+TARGET_PROGRAMS = gpio_interrupt
-$(OBJPATH)/%.o: $(SRCPATH)/%.c
- $(CC_WITH_CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<
+TARGET = arm
-$(OBJPATH):
- mkdir -p $(OBJPATH)
-
--include $(DEPS)
-
-.PHONY: all clean
-
-clean:
- rm -f $(OBJS) $(DEPS) $(BIN)
+gpio_interrupt_SOURCES = gpio_interrupt.c
+include $(BASE)/common/make/top.mk
diff --git a/cleopatre/devkit/tests/kernel/drivers/gpio/ftests/module/Kbuild b/cleopatre/devkit/tests/kernel/drivers/gpio/ftests/module/Kbuild
new file mode 100644
index 0000000000..e1b0e05f31
--- /dev/null
+++ b/cleopatre/devkit/tests/kernel/drivers/gpio/ftests/module/Kbuild
@@ -0,0 +1,4 @@
+obj-m := testgpio.o
+testgpio-objs := src/gpio_kernel.o
+
+EXTRA_CFLAGS += -I$(M)/inc
diff --git a/cleopatre/devkit/tests/kernel/drivers/gpio/ftests/module/Makefile b/cleopatre/devkit/tests/kernel/drivers/gpio/ftests/module/Makefile
index ef8c67ab26..2f302c9c7d 100644
--- a/cleopatre/devkit/tests/kernel/drivers/gpio/ftests/module/Makefile
+++ b/cleopatre/devkit/tests/kernel/drivers/gpio/ftests/module/Makefile
@@ -1,47 +1,12 @@
-BASEPATH=../../../../../../..
-TESTSUBPATH=devkit/tests/kernel/drivers/gpio/ftests/module
-TESTPATH=$(BASEPATH)/$(TESTSUBPATH)
-KRNPATH=$(BASEPATH)/linux-2.6.25.10-spc300
-DEBUG = n
+KERNELDIR := ../../../../../../../linux-2.6.25.10-spc300
-# Add our debugging flag to CFLAGS
-ifeq ($(DEBUG),y)
- DEBFLAGS = -O -g
-else
- DEBFLAGS = -Os
-endif
+# all rules is buggy for external modules, default to modules rule
+all:
+ $(MAKE) -C $(KERNELDIR) M=`pwd` ARCH=arm CROSS_COMPILE=arm-linux- modules
-#We cannot modify CFLAGS but we have to methods to add CFLAGS
-#1st for all files
-EXTRA_CFLAGS += $(DEBFLAGS) -D__LINUX__
-EXTRA_CFLAGS += -I../$(TESTSUBPATH)/inc
-#2nd for each file
-#CFLAGS_gpio_kernel.o := $(DEBFLAGS) -D__LINUX__ -I../$(TESTSUBPATH)/inc
+%::
+ $(MAKE) -C $(KERNELDIR) M=`pwd` ARCH=arm CROSS_COMPILE=arm-linux- $@
-ifneq ($(KERNELRELEASE),)
-# call from kernel build system
-
-testgpio-objs := src/gpio_kernel.o
-obj-m := testgpio.o
-
-else
-
-KERNELDIR ?= $(KRNPATH)
-PWD := $(CURDIR)
-
-modules:
- $(MAKE) -C $(KERNELDIR) ARCH=arm CROSS_COMPILE=arm-linux- M=$(PWD) modules
-endif
-
-
-clean:
- rm -f $(TESTPATH)/src/*.o
- rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c *.mod.o .tmp_versions modules.order Module.symvers
-
-depend .depend dep:
- $(CC) $(CFLAGS) -M *.c > .depend
-
-
-ifeq (.depend,$(wildcard .depend))
-include .depend
-endif
+clean::
+ $(MAKE) -C $(KERNELDIR) M=`pwd` ARCH=arm CROSS_COMPILE=arm-linux- $@
+ rm -f $(CURDIR)/modules.order
diff --git a/cleopatre/devkit/tests/kernel/drivers/gpio/ftests/user/Makefile b/cleopatre/devkit/tests/kernel/drivers/gpio/ftests/user/Makefile
index 4a4646eec4..3d4924c1ad 100644
--- a/cleopatre/devkit/tests/kernel/drivers/gpio/ftests/user/Makefile
+++ b/cleopatre/devkit/tests/kernel/drivers/gpio/ftests/user/Makefile
@@ -1,33 +1,16 @@
-BIN=gpio_user
-OBJPATH=./obj
-SRCPATH=./src
-INCPATH=./inc
+BASE = ../../../../../../../../cesar
+CLEO_BASE = ../cleopatre
-CC=arm-linux-gcc
-CC_WITH_CFLAGS=$(CC) -I/opt/spidcom/spc300/usr/include -g -Os
-CC_WITHOUT_CFLAGS=$(CC)
-LINUX_DIR=../../../../../../../linux-2.6.25.10-spc300
-EXTRA_CFLAGS=-I$(INCPATH) -I$(LINUX_DIR)/include -MMD
+LINUX_PATH = $(CLEO_BASE)/linux-2.6.25.10-spc300
-SRCS=$(subst $(SRCPATH)/,,$(wildcard $(SRCPATH)/*.c))
-OBJS=$(addprefix $(OBJPATH)/,$(SRCS:.c=.o))
-DEPS=$(patsubst %o,%d,$(OBJS))
+INCLUDES = $(LINUX_PATH)/include/
-all: $(BIN)
+EXTRA_TARGET_CFLAGS = -I/opt/spidcom/spc300/usr/include
-$(BIN): $(OBJPATH) $(OBJS)
- $(CC_WITHOUT_CFLAGS) -o $@ $(OBJS)
+TARGET_PROGRAMS = gpio_user
-$(OBJPATH)/%.o: $(SRCPATH)/%.c
- $(CC_WITH_CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<
+TARGET = arm
-$(OBJPATH):
- mkdir -p $(OBJPATH)
-
--include $(DEPS)
-
-.PHONY: all clean
-
-clean:
- rm -f $(OBJS) $(DEPS) $(BIN)
+gpio_user_SOURCES = gpio_user.c
+include $(BASE)/common/make/top.mk
diff --git a/cleopatre/devkit/tests/libmme/utests/Makefile b/cleopatre/devkit/tests/libmme/utests/Makefile
index 2d2cc67eb2..740ad756b8 100644
--- a/cleopatre/devkit/tests/libmme/utests/Makefile
+++ b/cleopatre/devkit/tests/libmme/utests/Makefile
@@ -1,8 +1,18 @@
-BASE = ../../../..
-PRJ_BASE = $(BASE)/application/libmme
-LINUX_DIR = $(BASE)/linux-2.6.25.10-spc300/include
-EXTRA_CFLAGS = -I$(LINUX_DIR)
-FILES = mme
+BASE = ../../../../../cesar
+CLEO_BASE = ../cleopatre
-include ../../utests_makerules
+LINUX_PATH = $(CLEO_BASE)/linux-2.6.25.10-spc300
+# We test libmme.
+PROJECT_DIR = $(CLEO_BASE)/application/libmme
+
+INCLUDES = $(PROJECT_DIR)/inc $(LINUX_PATH)/include
+
+EXTRA_HOST_LDLIBS = -lcheck -lpthread
+
+HOST_PROGRAMS = mme_utests
+
+mme_utests_SOURCES = mme_utests.c
+mme_utests_MODULES = $(PROJECT_DIR)
+
+include $(BASE)/common/make/top.mk
diff --git a/cleopatre/devkit/tests/libmme/utests/src/mme_utests.c b/cleopatre/devkit/tests/libmme/utests/src/mme_utests.c
index 73a31771ea..17772c72a9 100644
--- a/cleopatre/devkit/tests/libmme/utests/src/mme_utests.c
+++ b/cleopatre/devkit/tests/libmme/utests/src/mme_utests.c
@@ -182,8 +182,8 @@ static int send_message()
MME_t *mh = &hdr;
int nbpkt;
unsigned short hfmi;
- int fo; /* current fragment offset */
- int fs; /* current fragment size */
+ unsigned int fo; /* current fragment offset */
+ unsigned int fs; /* current fragment size */
int i;
unsigned char *pkt = NULL;
int pkt_len;
@@ -279,6 +279,25 @@ static void* thread_sender(void *unused)
TRACE("Thread 'sender' starting...\n");
+ /* form the thread MME context */
+ thr_ctx->buffer = thr_buff;
+ thr_ctx->mmtype = mmtype; /* type of MME that server thread will be sending */
+ thr_ctx->length = sizeof(thr_buff);
+ thr_ctx->head = HEAD;
+ thr_ctx->tail = HEAD + MSG_LEN;
+ thr_ctx->status = MME_STATUS_OK;
+
+ /* clean temporary buffer */
+ memset(thr_buff, 0x0, sizeof(thr_buff));
+
+ /* write in it server thread message */
+ /* we will form test payload like this :
+ * |MME_HEADER|00...00|cc...ccee...ee|00..00|
+ * head tail
+ */
+ memset(thr_buff + HEAD, 0xcc, MSG_LEN/2);
+ memset(thr_buff+ HEAD + MSG_LEN/2, 0xee, MSG_LEN/2);
+
while (1)
{
/*
@@ -292,28 +311,6 @@ static void* thread_sender(void *unused)
if (end)
break;
- /*
- * Now you can do the work
- */
- /* form the thread MME context */
- thr_ctx->buffer = thr_buff;
- thr_ctx->mmtype = mmtype; /* type of MME that server thread will be sending */
- thr_ctx->length = sizeof(thr_buff);
- thr_ctx->head = HEAD;
- thr_ctx->tail = HEAD + MSG_LEN;
- thr_ctx->status = MME_STATUS_OK;
-
- /* clean temporary buffer */
- memset(thr_buff, 0x0, sizeof(thr_buff));
-
- /* write in it server thread message */
- /* we will form test payload like this :
- * |MME_HEADER|00...00|cc...ccee...ee|00..00|
- * head tail
- */
- memset(thr_buff + HEAD, 0xcc, MSG_LEN/2);
- memset(thr_buff+ HEAD + MSG_LEN/2, 0xee, MSG_LEN/2);
-
/* send the payload */
send_message();
} /* while */
@@ -425,7 +422,7 @@ static void* thread_receiver(void *unused)
mh = (MME_t *)frame_tx;
if ( (rcv_len > 0) &&
- (rcv_len >= sizeof(MME_t)) &&
+ (rcv_len >= (int)sizeof(MME_t)) &&
(memcmp(mh->mme_dest, dst_addr, 6) == 0) &&
(mh->mmtype == mmtype)
) /* if packet was ment for us and mmetype is expected*/
@@ -569,7 +566,7 @@ END_TEST
START_TEST (test_mme_push)
{
mme_error_t ret;
- int i;
+ unsigned int i;
unsigned int size;
unsigned int res;
@@ -616,7 +613,7 @@ END_TEST
START_TEST (test_mme_put)
{
mme_error_t ret;
- int i;
+ unsigned int i;
unsigned int size;
unsigned int res;
@@ -631,7 +628,7 @@ START_TEST (test_mme_put)
*/
/* initialize data array to some value, for example 0, 1, 2, ... */
- for (i=0; i<sizeof(data_put); i--)
+ for (i=0; i<sizeof(data_put); i++)
{
data_put[i] = i;
}
@@ -639,7 +636,7 @@ START_TEST (test_mme_put)
/* make space in the begining */
ctx->head = 512; /* move head on the right to 512 */
- ctx->head = 768; /* it was already here after mme_push, but just to be sure */
+ ctx->tail = 768; /* it was already here after mme_push, but just to be sure */
memset(ctx->buffer, 0x0, 512); /* zero-out the begining, so we can observe payload shift */
/*
* state of buffer :
@@ -650,21 +647,20 @@ START_TEST (test_mme_put)
*/
//Check arguments
- /* firs put a little chun k, to check if it works */
+ /* first put a little chunk, to check if it works */
size = sizeof(data_put) / 4;
ret = mme_put(ctx, (void *)data_put, size, &res);
fail_if(ret != MME_SUCCESS, "mme_put fail");
-
- fail_if ( memcmp( ctx->buffer + ctx->tail - sizeof(data_put), data_put, sizeof(data_put) / 4 ) != 0, "wrong data put");
+ fail_if ( memcmp( ctx->buffer + ctx->tail - size, data_put, size) != 0, "wrong data put");
/* this leaves us with 512 (before head) + 128 (after tail) bytes of free space */
size = sizeof(data_put); /* bigger size of trailing 128 bytes that will provoke shifting payload left */
ret = mme_put(ctx, (void *)data_put, size, &res);
fail_if(ret != MME_SUCCESS, "mme_put fail");
- if (sizeof(data_put) > BUFF_LEN - ctx->tail) /* in this case we have shift */
+ if (size > BUFF_LEN - ctx->tail) /* in this case we have shift */
{
- fail_if ( memcmp( ctx->buffer + ctx->tail - sizeof(data_put), data_put, sizeof(data_put)) != 0, "wrong data shift");
- if ( sizeof(data_put) < ctx->head + (BUFF_LEN - ctx->tail) - 3 ) /* if we have at least 3 bytes of free space left */
+ fail_if ( memcmp( ctx->buffer + ctx->tail - size, data_put, size) != 0, "wrong data shift");
+ if ( size < ctx->head + (BUFF_LEN - ctx->tail) - 3 ) /* if we have at least 3 bytes of free space left */
{
fail_if ( memcmp( ctx->buffer + ctx->head - 3, "\x00\x00\x00", 3) != 0, "wrong data shift");
}
@@ -850,7 +846,7 @@ START_TEST (test_mme_send)
}
END_TEST
-mme_error_t listen_cb (mme_ctx_t *ctx, unsigned char *iface, unsigned char *source)
+mme_error_t listen_cb (mme_ctx_t *ctx, char *iface, unsigned char *source)
{
TRACE("Inside callback function.\n");
listen_var = 1;
diff --git a/cleopatre/devkit/tests/libspid/ftests/Makefile b/cleopatre/devkit/tests/libspid/ftests/Makefile
index 30746afdca..74db15cd9e 100644
--- a/cleopatre/devkit/tests/libspid/ftests/Makefile
+++ b/cleopatre/devkit/tests/libspid/ftests/Makefile
@@ -1,33 +1,21 @@
-BASE := $(CURDIR)/../../../..
-OBJPATH := ./obj
-PRJPATH := $(BASE)/application/libspid
-INC_PRJPATH := $(PRJPATH)/inc
-LINUX_PATH := $(BASE)/linux-2.6.25.10-spc300
-###################################################
+BASE = ../../../../../cesar
+CLEO_BASE = ../cleopatre
-# Common stuff
-CC := arm-linux-gcc
-CFLAGS := -Wall -g3 -DLINUX -I. -I./inc -I$(INC_PRJPATH) -I$(LINUX_PATH)/include/asm-arm/arch-spc300
-LIBS := -L$(PRJPATH) -lspid
+# We test libspid.
+PROJECT_DIR = $(CLEO_BASE)/application/libspid
-SRCS=$(wildcard *.c)
-OBJS=$(addprefix $(OBJPATH)/,$(SRCS:.c=.o))
+LINUX_PATH = $(CLEO_BASE)/linux-2.6.25.10-spc300
+INCLUDES = $(PROJECT_DIR)/inc $(CLEO_BASE)/include
-# Rules
-all: $(PRJPATH)/libspid.a
- mkdir -p $(OBJPATH)
- $(MAKE) $(OBJPATH)/libspid_ftests
+TARGET_PROGRAMS = libspid_ftest
-$(LIBPATH)/libspid.a:
- $(MAKE) -C $(LIBPATH) libspid.a
+TARGET = arm
-$(OBJPATH)/libspid_ftests : $(OBJS)
- $(CC) $(CFLAGS) -static -o $@ $^ $(LIBS)
+libspid_ftest_SOURCES = spidlib_ftests.c
+libspid_ftest_MODULES = $(CLEO_BASE)/application/libspid
-$(OBJPATH)/%.o : %.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-clean :
- rm -rf $(OBJPATH)
+EXTRA_TARGET_LDFLAGS = -static
+DEFS = -DLINUX
+include $(BASE)/common/make/top.mk
diff --git a/cleopatre/devkit/tests/libspid/ftests/spidlib_ftests.c b/cleopatre/devkit/tests/libspid/ftests/src/spidlib_ftests.c
index 9ff0eb4d30..9ff0eb4d30 100644
--- a/cleopatre/devkit/tests/libspid/ftests/spidlib_ftests.c
+++ b/cleopatre/devkit/tests/libspid/ftests/src/spidlib_ftests.c
diff --git a/cleopatre/devkit/tests/libspid/utests/Makefile b/cleopatre/devkit/tests/libspid/utests/Makefile
index bc07c52447..756c8f43da 100644
--- a/cleopatre/devkit/tests/libspid/utests/Makefile
+++ b/cleopatre/devkit/tests/libspid/utests/Makefile
@@ -1,11 +1,41 @@
-PRJ_BASE = ../../../../application/libspid
-FILES = system network config_item config_line image hpav_info misc misc_eoc upgrade_eoc wl_eoc service_eoc port_eoc autoconf_eoc master_config_eoc discrete_alarm_eoc analog_alarm_eoc current_alarm_eoc tonemap_snr_eoc
-OBJ_FILES = $(PRJ_OBJPATH)/openssl_md5.o $(PRJ_OBJPATH)/misc.o $(PRJ_OBJPATH)/config_line.o $(PRJ_OBJPATH)/config_item.o $(PRJ_OBJPATH)/system.o $(PRJ_OBJPATH)/image.o $(PRJ_OBJPATH)/network.o $(PRJ_OBJPATH)/wl_eoc.o $(PRJ_OBJPATH)/service_eoc.o $(PRJ_OBJPATH)/port_eoc.o $(TEST_OBJPATH)/wl_eoc_stubs.o $(TEST_OBJPATH)/service_eoc_stubs.o $(TEST_OBJPATH)/port_eoc_stubs.o
+BASE = ../../../../../cesar
+CLEO_BASE = ../cleopatre
-LIBSPID_DIR=../../../../application/libspid
-LIBMME_DIR=../../../../application/libmme
-LINUX_DIR=../../../../linux-2.6.25.10-spc300
+# We test libspid.
+PROJECT_DIR = $(CLEO_BASE)/application/libspid
+LIBMME_DIR = $(CLEO_BASE)/application/libmme
+LINUX_DIR = $(CLEO_BASE)/linux-2.6.25.10-spc300
+UTESTS_DIR = $(CLEO_BASE)/devkit/tests/libspid/utests/
+OVERRIDE_DIR = $(UTESTS_DIR)/override
+LIBMME_OVERRIDE_DIR = $(CLEO_BASE)/devkit/tests/managerd/utests/override
-EXTRA_CFLAGS = -I$(LIBSPID_DIR)/inc -I$(LIBMME_DIR)/inc -I$(LINUX_DIR)/include/asm-arm/arch-spc300 -MMD
+INCLUDES = $(PROJECT_DIR)/inc $(CLEO_BASE)/include $(LIBMME_DIR)/inc \
+ $(LINUX_DIR)/include/asm-arm/arch-spc300 $(LIBMME_OVERRIDE_DIR)/inc \
+ $(OVERRIDE_DIR)/inc $(UTESTS_DIR)/inc
-include ../../utests_makerules
+DEFS = -D__UTESTS__
+
+EXTRA_HOST_LDLIBS = -lcheck
+
+EXTRA_CFLAGS = -MMD
+
+# Templates to define list of sources & module to use.
+# Parameter: $1 is executabe & source name (without .c).
+define utest_libspid
+$(1)_SOURCES = $(1).c
+$(1)_MODULES = $(PROJECT_DIR) $(LIBMME_OVERRIDE_DIR) $(OVERRIDE_DIR)
+endef
+
+HOST_PROGRAMS = system_utests network_utests config_item_utests \
+ config_line_utests hpav_info_utests image_utests \
+ misc_utests misc_eoc_utests upgrade_eoc_utests wl_eoc_utests \
+ service_eoc_utests port_eoc_utests autoconf_eoc_utests \
+ master_config_eoc_utests discrete_alarm_eoc_utests analog_alarm_eoc_utests \
+ current_alarm_eoc_utests tonemap_snr_eoc_utests
+
+.._cleopatre_devkit_tests_managerd_utests_override_MODULE_SOURCES = libmme_stub.c
+
+# Generate sources & module list for each host programs.
+$(foreach prog,$(HOST_PROGRAMS),$(eval $(call utest_libspid,$(prog))))
+
+include $(BASE)/common/make/top.mk
diff --git a/cleopatre/devkit/tests/libspid/utests/inc/config_item_utests.h b/cleopatre/devkit/tests/libspid/utests/inc/config_item_utests.h
index 501d65fe8b..cb682c1869 100644
--- a/cleopatre/devkit/tests/libspid/utests/inc/config_item_utests.h
+++ b/cleopatre/devkit/tests/libspid/utests/inc/config_item_utests.h
@@ -22,18 +22,6 @@
/* VARIABLE STUB */
/* none */
/* FUNCTION STUB */
-/* true if character is a blank (space or tab). C99. */
-#undef isblank
-/*
-static int isblank(int c)
-{
- return (c == ' ') || (c == '\t');
-}
-*/
/* none */
-/* PLCD FUNCTION DECLARATIONS */
-/* system.c */
-libspid_error_t libspid_config_read_item (const char *filename, const char *label, char *value, int buffer_len);
-libspid_error_t libspid_config_write_item(const char *filename, const char *label, const char *value);
#endif /* system_utests_h */
diff --git a/cleopatre/devkit/tests/libspid/utests/inc/config_line_utests.h b/cleopatre/devkit/tests/libspid/utests/inc/config_line_utests.h
index b217a1c021..cb682c1869 100644
--- a/cleopatre/devkit/tests/libspid/utests/inc/config_line_utests.h
+++ b/cleopatre/devkit/tests/libspid/utests/inc/config_line_utests.h
@@ -24,9 +24,4 @@
/* FUNCTION STUB */
/* none */
-/* PLCD FUNCTION DECLARATIONS */
-/* system.c */
-libspid_error_t libspid_config_read_line (const char *filename, const char *label, char *value, int buffer_len);
-libspid_error_t libspid_config_write_line(const char *filename, const char *label, const char *value);
-pidlib_error_t libspid_config_remove_line(const char *filename, const char *delimiters, const char *key);
#endif /* system_utests_h */
diff --git a/cleopatre/devkit/tests/libspid/utests/inc/image_utests.h b/cleopatre/devkit/tests/libspid/utests/inc/image_utests.h
index 2492f52931..bab1572d36 100644
--- a/cleopatre/devkit/tests/libspid/utests/inc/image_utests.h
+++ b/cleopatre/devkit/tests/libspid/utests/inc/image_utests.h
@@ -24,8 +24,4 @@
/* FUNCTION STUB */
/* none */
-/* PLCD FUNCTION DECLARATIONS */
-/* image.c */
-/* system.c */
-
#endif /* image_utests_h */
diff --git a/cleopatre/devkit/tests/libspid/utests/inc/network_utests.h b/cleopatre/devkit/tests/libspid/utests/inc/network_utests.h
index 85a00727c3..c3f9eadd79 100644
--- a/cleopatre/devkit/tests/libspid/utests/inc/network_utests.h
+++ b/cleopatre/devkit/tests/libspid/utests/inc/network_utests.h
@@ -24,10 +24,4 @@
/* FUNCTION STUB */
/* none */
-/* PLCD FUNCTION DECLARATIONS */
-/* system.c */
-libspid_error_t libspid_network_get_ip (const char *interface, libspid_ip_t *ip);
-libspid_error_t libspid_network_set_ip (const char *interface, const libspid_ip_t *ip);
-libspid_error_t libspid_network_get_mac (const char *interface, unsigned char *mac);
-
#endif /* system_utests_h */
diff --git a/cleopatre/devkit/tests/libspid/utests/inc/system_utests.h b/cleopatre/devkit/tests/libspid/utests/inc/system_utests.h
index 7e3117edc3..c3f9eadd79 100644
--- a/cleopatre/devkit/tests/libspid/utests/inc/system_utests.h
+++ b/cleopatre/devkit/tests/libspid/utests/inc/system_utests.h
@@ -24,17 +24,4 @@
/* FUNCTION STUB */
/* none */
-/* PLCD FUNCTION DECLARATIONS */
-/* system.c */
-libspid_error_t libspid_system_get_kernel_version(char *buffer, int buffer_len);
-libspid_error_t libspid_system_get_plc_version (char *buffer, const int buffer_len);
-libspid_error_t libspid_system_get_av_version (char *buffer, const int buffer_len);
-libspid_error_t libspid_system_get_uptime(unsigned int *total_s, unsigned int *idle_s);
-libspid_error_t libspid_system_get_meminfo(char *buffer, int buffer_len);
-libspid_error_t libspid_system_save(void);
-libspid_error_t libspid_system_factory(void);
-libspid_error_t libspid_system_get_nvram(spc300_nvram_t *nvram);
-libspid_error_t libspid_system_set_nvram(spc300_nvram_t *nvram);
-libspid_error_t libspid_system_get_date (char *buffer, const int buffer_len);
-
#endif /* system_utests_h */
diff --git a/cleopatre/devkit/tests/libspid/utests/override/Module b/cleopatre/devkit/tests/libspid/utests/override/Module
new file mode 100644
index 0000000000..f70b890893
--- /dev/null
+++ b/cleopatre/devkit/tests/libspid/utests/override/Module
@@ -0,0 +1 @@
+SOURCES := port_eoc_stub.c service_eoc_stub.c wl_eoc_stub.c
diff --git a/cleopatre/devkit/tests/libspid/utests/inc/eoc_utests.h b/cleopatre/devkit/tests/libspid/utests/override/inc/eoc_utests.h
index 8e855d9ec2..8e855d9ec2 100644
--- a/cleopatre/devkit/tests/libspid/utests/inc/eoc_utests.h
+++ b/cleopatre/devkit/tests/libspid/utests/override/inc/eoc_utests.h
diff --git a/cleopatre/devkit/tests/libspid/utests/stubs/port_eoc_stubs.c b/cleopatre/devkit/tests/libspid/utests/override/src/port_eoc_stub.c
index 3893777ab1..3893777ab1 100644
--- a/cleopatre/devkit/tests/libspid/utests/stubs/port_eoc_stubs.c
+++ b/cleopatre/devkit/tests/libspid/utests/override/src/port_eoc_stub.c
diff --git a/cleopatre/devkit/tests/libspid/utests/stubs/service_eoc_stubs.c b/cleopatre/devkit/tests/libspid/utests/override/src/service_eoc_stub.c
index 049d8b8ad1..049d8b8ad1 100644
--- a/cleopatre/devkit/tests/libspid/utests/stubs/service_eoc_stubs.c
+++ b/cleopatre/devkit/tests/libspid/utests/override/src/service_eoc_stub.c
diff --git a/cleopatre/devkit/tests/libspid/utests/stubs/wl_eoc_stubs.c b/cleopatre/devkit/tests/libspid/utests/override/src/wl_eoc_stub.c
index 835c49295d..835c49295d 100644
--- a/cleopatre/devkit/tests/libspid/utests/stubs/wl_eoc_stubs.c
+++ b/cleopatre/devkit/tests/libspid/utests/override/src/wl_eoc_stub.c
diff --git a/cleopatre/devkit/tests/libspid/utests/src/analog_alarm_eoc_utests.c b/cleopatre/devkit/tests/libspid/utests/src/analog_alarm_eoc_utests.c
index 30afcd739a..abcf328633 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/analog_alarm_eoc_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/analog_alarm_eoc_utests.c
@@ -49,14 +49,14 @@
void
setup (void)
{
- int ret, rc;
+ int ret;
struct stat st;
char buf[256];
/* initialize - delete testing dir if it exists */
if ((stat (UTESTS_TMP_DIR, &st) == 0))
{
- rc = system ("rm -r " UTESTS_TMP_DIR);
+ system ("rm -r " UTESTS_TMP_DIR);
}
ret = mkdir (UTESTS_TMP_DIR, 0770);
if (ret < 0 && errno != EEXIST)
@@ -111,7 +111,7 @@ tc_param (void)
START_TEST (test_libspid_eoc_analog_alarm_set)
{
- int ret, rc;
+ int ret;
char oid[LIBSPID_OID_MAX_LEN];
libspid_eoc_analog_alarm_entry_t entry;
@@ -131,7 +131,7 @@ START_TEST (test_libspid_eoc_analog_alarm_set)
entry.lolo = 5;
entry.deadband = 6;
- rc = system ("cp " ANALOG_ALARM_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " ANALOG_ALARM_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_analog_alarm_set (oid, &entry);
fail_if (ret != LIBSPID_SUCCESS, "libspid_eoc_analog_alarm_set fail");
}
@@ -139,7 +139,7 @@ END_TEST
START_TEST (test_libspid_eoc_analog_alarm_get)
{
- int ret, rc;
+ int ret;
char oid[LIBSPID_OID_MAX_LEN];
libspid_eoc_analog_alarm_entry_t entry;
@@ -148,7 +148,7 @@ START_TEST (test_libspid_eoc_analog_alarm_get)
strcpy (oid, ".1.3.6.1.4.1.22764.3.1.5.2.4.1.10");
- rc = system ("cp " ANALOG_ALARM_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " ANALOG_ALARM_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_analog_alarm_get (oid, &entry);
@@ -168,7 +168,7 @@ END_TEST
START_TEST (test_libspid_eoc_analog_alarm_get_list)
{
- int ret, rc;
+ int ret;
libspid_eoc_analog_alarm_entry_t entries[ANALOG_ALARM_ENTRY_NUM];
int i;
int count;
@@ -185,7 +185,7 @@ START_TEST (test_libspid_eoc_analog_alarm_get_list)
memset (entries, 0, ANALOG_ALARM_ENTRY_NUM * sizeof (libspid_eoc_analog_alarm_entry_t));
- rc = system ("cp " ANALOG_ALARM_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " ANALOG_ALARM_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_analog_alarm_get_list (entries, &count);
@@ -201,7 +201,7 @@ START_TEST (test_libspid_eoc_analog_alarm_get_list)
"libspid_eoc_analog_alarm_get_list corrupts alarm OID");
fail_if (entries[i].enable.LOLO_alarm_enable != atoi (enable[i]),
"libspid_eoc_analog_alarm_get_list corrupts alarm enable");
- fail_if (entries[i].state != atoi (state[i]),
+ fail_if ((int) entries[i].state != atoi (state[i]),
"libspid_eoc_analog_alarm_get_list corrupts alarm state");
fail_if (entries[i].hihi != atoi (hihi[i]),
"libspid_eoc_analog_alarm_get_list corrupts alarm HIHI threshold");
diff --git a/cleopatre/devkit/tests/libspid/utests/src/autoconf_eoc_utests.c b/cleopatre/devkit/tests/libspid/utests/src/autoconf_eoc_utests.c
index a35867b6fa..fd93da9532 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/autoconf_eoc_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/autoconf_eoc_utests.c
@@ -46,216 +46,17 @@
#define CONFIG_TAR_FILE "config.tar"
#define CONFIG_GZIP_FILE "config.tar.gz"
-static unsigned int seq_cnt = 1;
-
-/**
- * Pull (get) data from beginning of MME payload. MME data head and length are updated
- * If there is not enough data to pull, an error is returned and the remaining payload length is returned.
- *
- * \param ctx MME context where to get data
- * \param data buffer where to get data from the beginning of MME payload
- * \param length length of data to pull
- * \param result_length length of data pulled; if there is not enough data into the MME to fit the length, the remaining data length is returned
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- */
-mme_error_t mme_pull (mme_ctx_t *ctx, void *data, unsigned int length, unsigned int *result_length)
-{
- /* protect from null pointers */
- if (ctx == NULL || data == NULL || result_length == NULL)
- return MME_ERROR_GEN;
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT)
- return MME_ERROR_NOT_INIT;
-
- /* check if it is demanded more data than we have in payload */
- if (length > ctx->tail - ctx->head)
- {
- *result_length = ctx->tail - ctx->head;
- return MME_ERROR_ENOUGH;
- }
-
- *result_length = length;
-
- memcpy(data, (unsigned char *)(ctx->buffer + ctx->head), length);
-
- ctx->head += length;
-
- return MME_SUCCESS;
-}
-
-/**
- * Create a MME message context. This context is used to build the MME message step by step.
- * The provided buffer must be enough large to contain all the final payload.
- * The MME payload can be bigger than an ethernet payload, as the fragmentation is managed by the 'send' function.
- *
- * \param ctx MME context to fill with init value
- * \param mmtype type of MME message (must be in official type list)
- * \param buffer the buffer to put the payload
- * \param length the buffer length
- * \return error type (MME_SUCCESS if success)
- */
-mme_error_t mme_init (mme_ctx_t *ctx, const mme_type_t mmtype, unsigned char *buffer, const unsigned int length)
-{
- /* protect from null pointers */
- if (ctx == NULL || buffer == NULL)
- return MME_ERROR_GEN;
-
- ctx->buffer = buffer;
- ctx->mmtype = mmtype;
- ctx->length = length;
- ctx->head = 0;
- ctx->tail = 0;
-
- ctx->status = MME_STATUS_OK;
-
- return MME_SUCCESS;
-}
-
-/**
- * Put data at the end of MME payload. MME data tail and length are updated<br>
- * If there is not enough free place to put data, an error is returned and the remaining free space length is returned.
- *
- * \param ctx MME context where to put data
- * \param data data to put at the end of MME payload
- * \param length length of data to put
- * \param result_length length of data really put
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- * \return MME_ERROR_SPACE: not enough available space
- */
-mme_error_t mme_put (mme_ctx_t *ctx, const void *data, unsigned int length, unsigned int *result_length)
-{
- int free = 0;
- int delta = 0;
-
- /* protect from null pointers */
- if (ctx == NULL || data == NULL || result_length == NULL)
- return MME_ERROR_GEN;
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT)
- return MME_ERROR_NOT_INIT;
-
- free = ctx->length - (ctx->tail - ctx->head);
- if (length > free)
- {
- *result_length = free;
- return MME_ERROR_SPACE;
- }
-
- *result_length = length;
-
- /* make place after payload, if needed */
- if (length > ctx->length - ctx->tail)
- {
- /*
- * *length
- * .---------------^-----------------.
- * |-----------|------------|xxxxxxx|-------------------------|
- * buff head tail ctx->length
- * \________ ________/
- * \/
- * payload
- *
- * we have to shift left our payload for this difference delta marked with 'x'
- * in order for *length bytes to fit in from beginning of the buffer
- */
- delta = length - (ctx->length - ctx->tail);
- memmove( (unsigned char *)(ctx->buffer + ctx->head - delta), (unsigned char *)(ctx->buffer + ctx->head), ctx->tail - ctx->head );
-
- /* update head and tail pointers (offsets) */
- ctx->head -= delta;
- ctx->tail -= delta;
- }
-
- memcpy( (unsigned char *)(ctx->buffer + ctx->tail), (unsigned char *)data, length );
- ctx->tail += length;
-
- return MME_SUCCESS;
-}
-
-/**
- * Send fake MME by filling buffer: confirm_ctx->buffer
- *
- * \param ctx MME context to send
- * \param type transaction type
- * \param iface selected communication interface
- * \param dest destination MAC address in binary format (6 bytes)
- * \param confirm_ctx MME context given to put the received MME answer packet. A adapted buffer must have been provided.
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- */
-mme_error_t mme_send (mme_ctx_t *ctx, mme_send_type_t type, char *iface, unsigned char *dest, mme_ctx_t *confirm_ctx)
-{
- /* protect from null pointers */
- if (ctx == NULL || confirm_ctx == NULL || iface == NULL || dest == NULL)
- return MME_ERROR_GEN;
-
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT)
- return MME_ERROR_NOT_INIT;
-
- confirm_ctx->buffer[0] = 0x00;
- if ((ctx->mmtype >> 12) == 0xA)
- {
- confirm_ctx->buffer[1] = 0x13;
- confirm_ctx->buffer[2] = 0xD7;
-
- if (ctx->mmtype == (MME_TYPE_VS_EOC_AUTOCONF_START | MME_TYPE_REQ))
- {
- seq_cnt = 0;
- if (memcmp(dest, "\x00\x11\x22\x33\x44\x66", LIBSPID_MAC_BIN_LEN) == 0)
- confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_START_MODEM_BUSY;
- else if (memcmp(dest, "\x00\x11\x22\x33\x44\x77", LIBSPID_MAC_BIN_LEN) == 0)
- confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_START_BAD_PROTOCOL;
- else if (memcmp(dest, "\x00\x11\x22\x33\x44\x88", LIBSPID_MAC_BIN_LEN) == 0)
- confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_START_FAILED;
- else if (memcmp(dest, "\x00\x11\x22\x33\x44\xcc", LIBSPID_MAC_BIN_LEN) == 0)
- confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_START_CONFIG_EXIST;
- else
- confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_START_SUCCESS;
- }
- if (ctx->mmtype == (MME_TYPE_VS_EOC_AUTOCONF_TRANSFER | MME_TYPE_REQ))
- {
- seq_cnt++;
- if (memcmp (dest, "\x00\x11\x22\x33\x44\x99", LIBSPID_MAC_BIN_LEN) == 0)
- confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_TRANSFER_FAILED;
- else
- {
- confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_TRANSFER_SUCCESS;
- confirm_ctx->buffer[4] = (seq_cnt >> 0) & 0xFF;
- confirm_ctx->buffer[5] = (seq_cnt >> 8) & 0xFF;
- confirm_ctx->buffer[6] = (seq_cnt >> 16) & 0xFF;
- confirm_ctx->buffer[7] = (seq_cnt >> 24) & 0xFF;
- }
- }
- if (ctx->mmtype == (MME_TYPE_VS_EOC_AUTOCONF_END | MME_TYPE_REQ))
- {
- if (memcmp (dest, "\x00\x11\x22\x33\x44\xbb", LIBSPID_MAC_BIN_LEN) == 0)
- confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_END_MD5_ERROR;
- else if (memcmp (dest, "\x00\x11\x22\x33\x44\xaa", LIBSPID_MAC_BIN_LEN) == 0)
- confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_END_FAILED;
- else
- confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_END_SUCCESS;
- }
- }
-
- confirm_ctx->tail = ETH_DATA_LEN;
-
- return MME_SUCCESS;
-}
-
/* fixtures - run before and after each unit test */
void setup(void)
{
- int ret, rc;
+ int ret;
struct stat st;
char buf[256];
/* initialize - delete testing dir if it exists */
if ( (stat (UTESTS_TMP_DIR, &st) == 0) )
{
- rc = system ("rm -r " UTESTS_TMP_DIR);
+ system ("rm -r " UTESTS_TMP_DIR);
}
ret = mkdir (UTESTS_TMP_DIR, 0770);
if (ret < 0 && errno != EEXIST)
@@ -299,7 +100,7 @@ END_TEST
START_TEST (test_libspid_eoc_configure)
{
- int ret, i, rc;
+ int ret, i;
char tar_file[] = UTESTS_TMP_DIR "/" CONFIG_TAR_FILE;
char gzip_file[] = UTESTS_TMP_DIR "/" CONFIG_GZIP_FILE;
int exp_ret[8] = {
@@ -312,7 +113,7 @@ START_TEST (test_libspid_eoc_configure)
"00:11:22:33:44:99", "00:11:22:33:44:aa", "00:11:22:33:44:bb", "00:11:22:33:44:cc"
};
- rc = system ("cp " LOCAL_CONFIG_TAR_FILE " " UTESTS_TMP_DIR);
+ system ("cp " LOCAL_CONFIG_TAR_FILE " " UTESTS_TMP_DIR);
/* Check for NULL parameters */
ret = libspid_eoc_configure (NULL, tar_file);
@@ -326,7 +127,7 @@ START_TEST (test_libspid_eoc_configure)
fail_if (ret != exp_ret[i], "[MAC %s] libspid_eoc_configure return is incorrect", mac_addr[i]);
}
- rc = system ("mv " UTESTS_TMP_DIR "/" CONFIG_TAR_FILE " " UTESTS_TMP_DIR "/" CONFIG_GZIP_FILE);
+ system ("mv " UTESTS_TMP_DIR "/" CONFIG_TAR_FILE " " UTESTS_TMP_DIR "/" CONFIG_GZIP_FILE);
/* Check wrong archive */
ret = libspid_eoc_configure ("00:11:22:33:44:55", tar_file);
diff --git a/cleopatre/devkit/tests/libspid/utests/src/config_item_utests.c b/cleopatre/devkit/tests/libspid/utests/src/config_item_utests.c
index 722964a1ae..a8175aa610 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/config_item_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/config_item_utests.c
@@ -34,7 +34,7 @@
#include <net/if.h>
#include <libgen.h> /* for basename() */
-#include "config_item_utests.h"
+#include "inc/config_item_utests.h"
//#define DEBUG 1
@@ -376,8 +376,8 @@ int main(void)
s = libspid_config_item_suite();
SRunner *sr = srunner_create(s);
- srunner_set_fork_status (sr, CK_NOFORK);
- //srunner_set_fork_status (sr, CK_FORK);
+ //srunner_set_fork_status (sr, CK_NOFORK);
+ srunner_set_fork_status (sr, CK_FORK);
srunner_run_all(sr, CK_NORMAL);
number_failed = srunner_ntests_failed(sr);
srunner_free(sr);
diff --git a/cleopatre/devkit/tests/libspid/utests/src/config_line_utests.c b/cleopatre/devkit/tests/libspid/utests/src/config_line_utests.c
index 09269769ba..d7742b8512 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/config_line_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/config_line_utests.c
@@ -34,7 +34,7 @@
#include <net/if.h>
#include <libgen.h> /* for basename() */
-#include "config_item_utests.h"
+#include "inc/config_item_utests.h"
//#define DEBUG 1
@@ -86,9 +86,9 @@ START_TEST (test_read_param)
int ret = 7;
char delimiters[32] = " :";
char buffer[LIBSPID_CONFIG_LINE_MAX_LEN] = {0};
- char *elt[10];
+ char *elt[9];
unsigned int elt_nb = 2;
- char key[32] = "key";
+ char key[LIBSPID_CONFIG_KEY_MAX_LEN + 1] = "key";
char filename[128];
@@ -154,7 +154,7 @@ START_TEST (test_read_param)
/* get a big element with a shorter buffer */
strcpy(key, "key3");
elt_nb = 10;
- fail_unless(((libspid_config_read_line(filename, " ", key, &elt_nb, elt, buffer, 32) >= 0)
+ fail_unless(((libspid_config_read_line(filename, " ", key, &elt_nb, elt, buffer, 32) == 0)
&& (elt_nb == 3)
&& !strcmp(elt[2], "very_very_very")),
"get limited size element: key=%s, elt_nb=%d, elt[2]='%s'\n", key, elt_nb, elt[2]);
@@ -162,7 +162,7 @@ START_TEST (test_read_param)
/* ask for no element */
strcpy(key, "key2");
elt_nb = 0;
- fail_unless(((libspid_config_read_line(filename, " ", key, &elt_nb, elt, buffer, LIBSPID_CONFIG_LINE_MAX_LEN) >= 0)
+ fail_unless(((libspid_config_read_line(filename, " ", key, &elt_nb, elt, buffer, LIBSPID_CONFIG_LINE_MAX_LEN) == 0)
&& !strcmp(key, "key3")
&& (elt_nb == 0)),
"get 0 element");
@@ -170,7 +170,7 @@ START_TEST (test_read_param)
/* other delimiter */
strcpy(key, "key4");
elt_nb = 10;
- fail_unless(((libspid_config_read_line(filename, ":", key, &elt_nb, elt, buffer, LIBSPID_CONFIG_LINE_MAX_LEN) >= 0)
+ fail_unless(((libspid_config_read_line(filename, ":", key, &elt_nb, elt, buffer, LIBSPID_CONFIG_LINE_MAX_LEN) == 0)
&& (elt_nb == 8)
&& !strcmp(elt[3], "elt54 elt")),
"other delimiter");
@@ -178,7 +178,7 @@ START_TEST (test_read_param)
/* 2 delimiters */
strcpy(key, "key4");
elt_nb = 10;
- fail_unless(((libspid_config_read_line(filename, " :", key, &elt_nb, elt, buffer, LIBSPID_CONFIG_LINE_MAX_LEN) >= 0)
+ fail_unless(((libspid_config_read_line(filename, " :", key, &elt_nb, elt, buffer, LIBSPID_CONFIG_LINE_MAX_LEN) == 0)
&& !strcmp(key, "key5")
&& (elt_nb == 9)
&& !strcmp(elt[3], "elt54")
@@ -188,7 +188,7 @@ START_TEST (test_read_param)
/* long comment line */
strcpy(key, "key1");
elt_nb = 10;
- fail_unless(((libspid_config_read_line(filename, " ", key, &elt_nb, elt, buffer, LIBSPID_CONFIG_LINE_MAX_LEN) >= 0)
+ fail_unless(((libspid_config_read_line(filename, " ", key, &elt_nb, elt, buffer, LIBSPID_CONFIG_LINE_MAX_LEN) == 0)
&& !strcmp(key, "key2")),
"long comment line");
@@ -201,7 +201,8 @@ START_TEST (test_write_param)
char delimiter = 'a';
char *elt[8];
unsigned int elt_nb = 2;
- char key[128] = "key";
+ char key[LIBSPID_CONFIG_KEY_MAX_LEN + 1] = "key";
+ char key_too_long[LIBSPID_CONFIG_KEY_MAX_LEN * 2] = "key_too_long";
char filename[128];
system("cp " LINE_CNF " " UTESTS_TMP_DIR);
@@ -238,8 +239,8 @@ START_TEST (test_write_param)
fail_unless( ret == LIBSPID_ERROR_PARAM, "elt = NULL");
/* key too long */
- strcpy(key, "very_very_very_very_very_very_very_very_very_very_very_very_very_long_key");
- ret = libspid_config_write_line(filename, delimiter, key, elt_nb, elt);
+ strcpy(key_too_long, "very_very_very_very_very_very_very_very_very_very_very_very_very_long_key");
+ ret = libspid_config_write_line(filename, delimiter, key_too_long, elt_nb, elt);
fail_unless( ret == LIBSPID_ERROR_PARAM, "key too long");
/* key = "" */
@@ -259,7 +260,8 @@ START_TEST (test_remove_param)
{
int ret;
char delimiters[32] = " :";
- char key[128] = "key";
+ char key[LIBSPID_CONFIG_KEY_MAX_LEN + 1] = "key";
+ char key_too_long[LIBSPID_CONFIG_KEY_MAX_LEN * 2] = "key_too_long";
char filename[128];
system("cp " LINE_CNF " " UTESTS_TMP_DIR);
@@ -284,8 +286,8 @@ START_TEST (test_remove_param)
fail_unless( ret == LIBSPID_ERROR_PARAM, "key = NULL");
/* key too long */
- strcpy(key, "very_very_very_very_very_very_very_very_very_very_very_very_very_long_key");
- ret = libspid_config_remove_line(filename, delimiters, key);
+ strcpy(key_too_long, "very_very_very_very_very_very_very_very_very_very_very_very_very_long_key");
+ ret = libspid_config_remove_line(filename, delimiters, key_too_long);
fail_unless( ret == LIBSPID_ERROR_PARAM, "key too long");
/* key = "" */
@@ -320,7 +322,7 @@ START_TEST (test_libspid_config_read_line)
char buffer[LIBSPID_CONFIG_LINE_MAX_LEN] = {0};
char *elt[8];
unsigned int elt_nb;
- char key[32];
+ char key[LIBSPID_CONFIG_KEY_MAX_LEN + 1];
system ("cp " LINE_CNF " " UTESTS_TMP_DIR);
sprintf (filename, "%s/%s", UTESTS_TMP_DIR, basename (LINE_CNF));
@@ -391,7 +393,7 @@ START_TEST (test_libspid_config_write_line)
char delimiter = ' ';
char *elt[2];
unsigned int elt_nb;
- char key[32];
+ char key[LIBSPID_CONFIG_KEY_MAX_LEN + 1];
FILE *fp;
char line[LIBSPID_CONFIG_LINE_MAX_LEN];
char el0[32] = {0};
@@ -445,14 +447,12 @@ START_TEST (test_libspid_config_remove_line)
int ret;
char filename[128];
char delimiters[32] = " ";
- unsigned int elt_nb;
- char key[32];
+ char key[LIBSPID_CONFIG_KEY_MAX_LEN + 1];
char cmd[256];
struct stat file_stat;
system ("cp " LINE_CNF " " UTESTS_TMP_DIR);
sprintf (filename, "%s/%s", UTESTS_TMP_DIR, basename (LINE_CNF));
- elt_nb = 3;
strcpy (key, "00:13:D7:d0:a0:b2");
ret = libspid_config_remove_line (filename, delimiters, key);
fail_if (ret != LIBSPID_SUCCESS, "libspid_config_remove_line fail");
@@ -490,8 +490,8 @@ int main(void)
s = libspid_config_line_suite();
SRunner *sr = srunner_create(s);
- srunner_set_fork_status (sr, CK_NOFORK);
- //srunner_set_fork_status (sr, CK_FORK);
+ //srunner_set_fork_status (sr, CK_NOFORK);
+ srunner_set_fork_status (sr, CK_FORK);
srunner_run_all(sr, CK_NORMAL);
number_failed = srunner_ntests_failed(sr);
srunner_free(sr);
diff --git a/cleopatre/devkit/tests/libspid/utests/src/current_alarm_eoc_utests.c b/cleopatre/devkit/tests/libspid/utests/src/current_alarm_eoc_utests.c
index e6f25670fe..f42d5ee6a0 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/current_alarm_eoc_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/current_alarm_eoc_utests.c
@@ -48,14 +48,14 @@
/* fixtures - run before and after each unit test */
void setup(void)
{
- int ret, rc;
+ int ret;
struct stat st;
char buf[256];
/* initialize - delete testing dir if it exists */
if ( (stat (UTESTS_TMP_DIR, &st) == 0) )
{
- rc = system ("rm -r " UTESTS_TMP_DIR);
+ system ("rm -r " UTESTS_TMP_DIR);
}
ret = mkdir (UTESTS_TMP_DIR, 0770);
if (ret < 0 && errno != EEXIST)
@@ -109,7 +109,7 @@ tc_param (void)
START_TEST (test_libspid_eoc_current_alarm_get)
{
- int ret, rc;
+ int ret;
char oid[LIBSPID_OID_MAX_LEN];
libspid_eoc_current_alarm_entry_t entry;
@@ -117,7 +117,7 @@ START_TEST (test_libspid_eoc_current_alarm_get)
strcpy (oid, ".1.3.6.1.4.1.22764.3.1.5.1.6.1.6");
- rc = system ("cp " ALARM_INFO " " UTESTS_TMP_DIR "/etc");
+ system ("cp " ALARM_INFO " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_current_alarm_get (oid, &entry);
fail_if (ret != LIBSPID_SUCCESS, "libspid_eoc_current_alarm_get return unsuccessful");
@@ -130,7 +130,7 @@ END_TEST
/* TODO */
START_TEST (test_libspid_eoc_current_alarm_get_list)
{
- int ret, rc;
+ int ret;
libspid_eoc_current_alarm_entry_t entries[CURRENT_ALARM_ENTRY_NUM];
int i;
int count;
@@ -143,7 +143,7 @@ START_TEST (test_libspid_eoc_current_alarm_get_list)
memset (entries, 0, CURRENT_ALARM_ENTRY_NUM * sizeof (libspid_eoc_current_alarm_entry_t));
- rc = system ("cp " ALARM_INFO " " UTESTS_TMP_DIR "/etc");
+ system ("cp " ALARM_INFO " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_current_alarm_get_list (entries, &count);
@@ -154,7 +154,7 @@ START_TEST (test_libspid_eoc_current_alarm_get_list)
fail_if (ret != LIBSPID_SUCCESS, "libspid_eoc_current_alarm_get_list return is unsuccessful");
fail_if (strcmp (entries[i].oid, oid[i]) != 0, "libspid_eoc_current_alarm_get_list corrupts alarm OID");
- fail_if (entries[i].state != atoi (state[i]), "libspid_eoc_current_alarm_get_list corrupts alarm state");
+ fail_if ((int) entries[i].state != atoi (state[i]), "libspid_eoc_current_alarm_get_list corrupts alarm state");
fail_if (entries[i].value != atoi (value[i]), "libspid_eoc_current_alarm_get_list corrupts alarm value");
}
}
diff --git a/cleopatre/devkit/tests/libspid/utests/src/discrete_alarm_eoc_utests.c b/cleopatre/devkit/tests/libspid/utests/src/discrete_alarm_eoc_utests.c
index fa0f4c4efd..fa1730071f 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/discrete_alarm_eoc_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/discrete_alarm_eoc_utests.c
@@ -49,14 +49,14 @@
void
setup(void)
{
- int ret, rc;
+ int ret;
struct stat st;
char buf[256];
/* initialize - delete testing dir if it exists */
if ( (stat (UTESTS_TMP_DIR, &st) == 0) )
{
- rc = system ("rm -r " UTESTS_TMP_DIR);
+ system ("rm -r " UTESTS_TMP_DIR);
}
ret = mkdir (UTESTS_TMP_DIR, 0770);
if (ret < 0 && errno != EEXIST)
@@ -110,7 +110,7 @@ tc_param (void)
START_TEST (test_libspid_eoc_discrete_alarm_set)
{
- int ret, rc;
+ int ret;
char oid[LIBSPID_OID_MAX_LEN];
libspid_eoc_discrete_alarm_entry_t entry;
@@ -122,7 +122,7 @@ START_TEST (test_libspid_eoc_discrete_alarm_set)
entry.enable = 2;
entry.state = 1;
- rc = system ("cp " DISCRETE_ALARM_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " DISCRETE_ALARM_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_discrete_alarm_set (oid, &entry);
fail_if (ret != LIBSPID_SUCCESS, "libspid_eoc_discrete_alarm_set fail");
}
@@ -130,7 +130,7 @@ END_TEST
START_TEST (test_libspid_eoc_discrete_alarm_get)
{
- int ret, rc;
+ int ret;
char oid[LIBSPID_OID_MAX_LEN];
libspid_eoc_discrete_alarm_entry_t entry;
@@ -138,7 +138,7 @@ START_TEST (test_libspid_eoc_discrete_alarm_get)
strcpy (oid, ".1.3.6.1.4.1.22764.3.1.5.1.6.1.6");
- rc = system ("cp " DISCRETE_ALARM_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " DISCRETE_ALARM_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_discrete_alarm_get (oid, &entry);
fail_if (ret != LIBSPID_SUCCESS, "libspid_eoc_discrete_alarm_get return unsuccessful");
@@ -151,7 +151,7 @@ END_TEST
START_TEST (test_libspid_eoc_discrete_alarm_get_list)
{
- int ret, rc;
+ int ret;
libspid_eoc_discrete_alarm_entry_t entries[DISCRETE_ALARM_ENTRY_NUM];
int i;
int count;
@@ -164,7 +164,7 @@ START_TEST (test_libspid_eoc_discrete_alarm_get_list)
memset (entries, 0, DISCRETE_ALARM_ENTRY_NUM * sizeof (libspid_eoc_discrete_alarm_entry_t));
- rc = system ("cp " DISCRETE_ALARM_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " DISCRETE_ALARM_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_discrete_alarm_get_list (entries, &count);
@@ -176,8 +176,8 @@ START_TEST (test_libspid_eoc_discrete_alarm_get_list)
fail_if (strcmp (entries[i].oid, oid[i]) != 0, "libspid_eoc_discrete_alarm_get_list corrupts alarm OID");
fail_if (entries[i].trigger != atoi (trigger[i]), "libspid_eoc_discrete_alarm_get_list corrupts alarm trigger");
- fail_if (entries[i].enable != atoi (enable[i]), "libspid_eoc_discrete_alarm_get_list corrupts alarm enable");
- fail_if (entries[i].state != atoi (state[i]), "libspid_eoc_discrete_alarm_get_list corrupts alarm state");
+ fail_if ((int) entries[i].enable != atoi (enable[i]), "libspid_eoc_discrete_alarm_get_list corrupts alarm enable");
+ fail_if ((int) entries[i].state != atoi (state[i]), "libspid_eoc_discrete_alarm_get_list corrupts alarm state");
}
}
END_TEST
diff --git a/cleopatre/devkit/tests/libspid/utests/src/hpav_info_utests.c b/cleopatre/devkit/tests/libspid/utests/src/hpav_info_utests.c
index 506df36a2d..36e16d9fe7 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/hpav_info_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/hpav_info_utests.c
@@ -106,7 +106,8 @@ main (void)
{
Suite *s = libspid_hpav_info_suite ();
SRunner *sr = srunner_create (s);
- srunner_set_fork_status (sr, CK_NOFORK);
+ //srunner_set_fork_status (sr, CK_NOFORK);
+ srunner_set_fork_status (sr, CK_FORK);
srunner_run_all (sr, CK_NORMAL);
int number_failed = srunner_ntests_failed (sr);
srunner_free (sr);
diff --git a/cleopatre/devkit/tests/libspid/utests/src/image_utests.c b/cleopatre/devkit/tests/libspid/utests/src/image_utests.c
index 86b17f3085..1553bda0eb 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/image_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/image_utests.c
@@ -29,7 +29,7 @@
#include <dirent.h>
#include <sys/stat.h>
-#include "image_utests.h"
+#include "inc/image_utests.h"
//#define DEBUG 1
@@ -52,7 +52,6 @@
/** stub functions */
-
/* fixtures - run before and after each unit test */
void setup(void)
{
@@ -406,7 +405,7 @@ extern Suite* libspid_image_suite(void)
tcase_add_test(tc_core, test_libspid_image_select);
suite_add_tcase(s, tc_core);
- //suite_add_tcase(s, tc_param());
+ suite_add_tcase(s, tc_param());
return s;
}
@@ -419,8 +418,8 @@ int main(void)
s = libspid_image_suite();
SRunner *sr = srunner_create(s);
- srunner_set_fork_status (sr, CK_NOFORK);
- //srunner_set_fork_status (sr, CK_FORK);
+ //srunner_set_fork_status (sr, CK_NOFORK);
+ srunner_set_fork_status (sr, CK_FORK);
srunner_run_all(sr, CK_NORMAL);
number_failed = srunner_ntests_failed(sr);
srunner_free(sr);
diff --git a/cleopatre/devkit/tests/libspid/utests/src/master_config_eoc_utests.c b/cleopatre/devkit/tests/libspid/utests/src/master_config_eoc_utests.c
index 2dc2cf1a6e..4fbc75a8a9 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/master_config_eoc_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/master_config_eoc_utests.c
@@ -53,7 +53,7 @@
/* fixtures - run before and after each unit test */
void setup(void)
{
- int ret, rc;
+ int ret;
struct stat st;
char buf[256];
@@ -79,7 +79,7 @@ void setup(void)
/* initialize - delete testing dir if it exists */
if ( (stat (UTESTS_TMP_DIR, &st) == 0) )
{
- rc = system ("rm -r " UTESTS_TMP_DIR);
+ system ("rm -r " UTESTS_TMP_DIR);
}
ret = mkdir(UTESTS_TMP_DIR, 0770);
if (ret < 0 && errno != EEXIST)
@@ -114,11 +114,11 @@ void teardown(void)
/* --- TEST PROCEDURES --- */
START_TEST (test_libspid_eoc_master_vlan_action)
{
- int rc, ret;
+ int ret;
/* prepare configuration files */
- rc = system("cp " NETWORK_BR_TST " " LIBSPID_NETWORK_CONF_PATH );
- rc = system("cp " MASTER_CONF " " UTESTS_TMP_DIR "/etc");
+ system("cp " NETWORK_BR_TST " " LIBSPID_NETWORK_CONF_PATH );
+ system("cp " MASTER_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_master_vlan_action();
@@ -128,11 +128,11 @@ END_TEST
START_TEST (test_libspid_eoc_master_disable_vlan_action)
{
- int rc, ret;
+ int ret;
/* prepare configuration files */
- rc = system("cp " NETWORK_BR_TST " " LIBSPID_NETWORK_CONF_PATH );
- rc = system("cp " MASTER_CONF " " UTESTS_TMP_DIR "/etc");
+ system("cp " NETWORK_BR_TST " " LIBSPID_NETWORK_CONF_PATH );
+ system("cp " MASTER_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_master_disable_vlan_action();
diff --git a/cleopatre/devkit/tests/libspid/utests/src/misc_eoc_utests.c b/cleopatre/devkit/tests/libspid/utests/src/misc_eoc_utests.c
index 39095bb2c7..ed26a1c762 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/misc_eoc_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/misc_eoc_utests.c
@@ -49,191 +49,17 @@
typedef char mac_t[6];
typedef char mac_string_t[18];
-/**
- * Pull (get) data from beginning of MME payload. MME data head and length are updated
- * If there is not enough data to pull, an error is returned and the remaining payload length is returned.
- *
- * \param ctx MME context where to get data
- * \param data buffer where to get data from the beginning of MME payload
- * \param length length of data to pull
- * \param result_length length of data pulled; if there is not enough data into the MME to fit the length, the remaining data length is returned
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- */
-mme_error_t mme_pull (mme_ctx_t *ctx, void *data, unsigned int length, unsigned int *result_length)
-{
- /* protect from null pointers */
- if (ctx == NULL || data == NULL || result_length == NULL)
- return MME_ERROR_GEN;
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT)
- return MME_ERROR_NOT_INIT;
-
- /* check if it is demanded more data than we have in payload */
- if (length > ctx->tail - ctx->head)
- {
- *result_length = ctx->tail - ctx->head;
- return MME_ERROR_ENOUGH;
- }
-
- *result_length = length;
-
- memcpy(data, (unsigned char *)(ctx->buffer + ctx->head), length);
-
- ctx->head += length;
-
- return MME_SUCCESS;
-}
-
-/**
- * Create a MME message context. This context is used to build the MME message step by step.
- * The provided buffer must be enough large to contain all the final payload.
- * The MME payload can be bigger than an ethernet payload, as the fragmentation is managed by the 'send' function.
- *
- * \param ctx MME context to fill with init value
- * \param mmtype type of MME message (must be in official type list)
- * \param buffer the buffer to put the payload
- * \param length the buffer length
- * \return error type (MME_SUCCESS if success)
- */
-mme_error_t mme_init (mme_ctx_t *ctx, const mme_type_t mmtype, unsigned char *buffer, const unsigned int length)
-{
- /* protect from null pointers */
- if (ctx == NULL || buffer == NULL)
- return MME_ERROR_GEN;
-
- ctx->buffer = buffer;
- ctx->mmtype = mmtype;
- ctx->length = length;
- ctx->head = 0;
- ctx->tail = 0;
-
- ctx->status = MME_STATUS_OK;
-
- return MME_SUCCESS;
-}
-
-/**
- * Put data at the end of MME payload. MME data tail and length are updated<br>
- * If there is not enough free place to put data, an error is returned and the remaining free space length is returned.
- *
- * \param ctx MME context where to put data
- * \param data data to put at the end of MME payload
- * \param length length of data to put
- * \param result_length length of data really put
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- * \return MME_ERROR_SPACE: not enough available space
- */
-mme_error_t mme_put (mme_ctx_t *ctx, const void *data, unsigned int length, unsigned int *result_length)
-{
- int free = 0;
- int delta = 0;
-
- /* protect from null pointers */
- if (ctx == NULL || data == NULL || result_length == NULL)
- return MME_ERROR_GEN;
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT)
- return MME_ERROR_NOT_INIT;
-
- free = ctx->length - (ctx->tail - ctx->head);
- if (length > free)
- {
- *result_length = free;
- return MME_ERROR_SPACE;
- }
-
- *result_length = length;
-
- /* make place after payload, if needed */
- if (length > ctx->length - ctx->tail)
- {
- /*
- * *length
- * .---------------^-----------------.
- * |-----------|------------|xxxxxxx|-------------------------|
- * buff head tail ctx->length
- * \________ ________/
- * \/
- * payload
- *
- * we have to shift left our payload for this difference delta marked with 'x'
- * in order for *length bytes to fit in from beginning of the buffer
- */
- delta = length - (ctx->length - ctx->tail);
- memmove( (unsigned char *)(ctx->buffer + ctx->head - delta), (unsigned char *)(ctx->buffer + ctx->head), ctx->tail - ctx->head );
-
- /* update head and tail pointers (offsets) */
- ctx->head -= delta;
- ctx->tail -= delta;
- }
-
- memcpy( (unsigned char *)(ctx->buffer + ctx->tail), (unsigned char *)data, length );
- ctx->tail += length;
-
- return MME_SUCCESS;
-}
-
-/**
- * Send fake MME by filling buffer: confirm_ctx->buffer
- *
- * \param ctx MME context to send
- * \param type transaction type
- * \param iface selected communication interface
- * \param dest destination MAC address in binary format (6 bytes)
- * \param confirm_ctx MME context given to put the received MME answer packet. A adapted buffer must have been provided.
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- */
-mme_error_t mme_send (mme_ctx_t *ctx, mme_send_type_t type, char *iface, unsigned char *dest, mme_ctx_t *confirm_ctx)
-{
- /* protect from null pointers */
- if (ctx == NULL || confirm_ctx == NULL || dest == NULL)
- return MME_ERROR_GEN;
-
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT)
- return MME_ERROR_NOT_INIT;
-
- confirm_ctx->buffer[0] = 0x00;
- confirm_ctx->buffer[1] = 0x13;
- confirm_ctx->buffer[2] = 0xD7;
- confirm_ctx->buffer[3] = 0x00;
-
- if (ctx->mmtype == (MME_TYPE_VS_EOC_REAL_TIME_STATISTICS | MME_TYPE_REQ))
- {
- if (memcmp (dest, "\x00\x11\x22\x33\x44\xaa", LIBSPID_MAC_BIN_LEN) == 0)
- confirm_ctx->buffer[3] = 0;
- if (memcmp (dest, "\x00\x11\x22\x33\x44\xbb", LIBSPID_MAC_BIN_LEN) == 0)
- confirm_ctx->buffer[3] = 1;
- if (memcmp (dest, "\x00\x11\x22\x33\x44\xcc", LIBSPID_MAC_BIN_LEN) == 0)
- return MME_ERROR_GEN;
- if (memcmp (dest, "\x00\x11\x22\x33\x44\xdd", LIBSPID_MAC_BIN_LEN) == 0)
- {
- confirm_ctx->buffer[4] = 0x0;
- confirm_ctx->buffer[5] = 0x3;
- confirm_ctx->buffer[6] = 0x55;
- confirm_ctx->buffer[7] = 0x17;
- }
- }
-
- confirm_ctx->tail = ETH_DATA_LEN;
-
- return MME_SUCCESS;
-}
-
/* fixtures - run before and after each unit test */
void setup(void)
{
- int ret, rc;
+ int ret;
struct stat st;
char buf[256];
/* initialize - delete testing dir if it exists */
if ( (stat (UTESTS_TMP_DIR, &st) == 0) )
{
- rc = system ("rm -r " UTESTS_TMP_DIR);
+ system ("rm -r " UTESTS_TMP_DIR);
}
ret = mkdir(UTESTS_TMP_DIR, 0770);
if (ret < 0 && errno != EEXIST)
@@ -319,11 +145,11 @@ END_TEST
START_TEST (test_libspid_eoc_get_topo)
{
- int ret, rc;
+ int ret;
mac_t mac_address_list[5];
int mac_address_count = 0;
- rc = system("cp " ONLINE_INFO " " UTESTS_TMP_DIR "/etc");
+ system("cp " ONLINE_INFO " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_get_topo(mac_address_list[0], &mac_address_count);
fail_if(ret != LIBSPID_SUCCESS, "libspid_eoc_get_topo fail");
fail_if(strcmp(mac_address_list[0], "\x00\xd7\x20\x00\x00\x01") != 0, "libspid_eoc_get_topo gets wrong mac address 1");
@@ -340,13 +166,13 @@ START_TEST (test_libspid_eoc_get_device_info)
mac_string_t mac_address;
libspid_eoc_dev_info_t eoc_dev_info;
libspid_error_t ret;
- int rc;
- rc = system("cp " ONLINE_INFO " " UTESTS_TMP_DIR "/etc");
+ system("cp " ONLINE_INFO " " UTESTS_TMP_DIR "/etc");
strcpy(mac_address, "00:d7:20:00:00:03");
ret = libspid_eoc_get_device_info(mac_address, &eoc_dev_info);
+ fail_if (ret != LIBSPID_SUCCESS, "libspid_eoc_get_device_info fail");
fail_if(strcmp(eoc_dev_info.sw_version, "software3") != 0, "libspid_eoc_get_device_info gets wrong software version");
fail_if(eoc_dev_info.eth_port_nb != 1, "libspid_eoc_get_device_info gets wrong ethernet port number");
fail_if(strcmp(eoc_dev_info.model_no, "model3") != 0, "libspid_eoc_get_device_info gets wrong model string");
@@ -359,13 +185,13 @@ START_TEST (test_libspid_eoc_get_link)
mac_string_t mac_address;
libspid_eoc_link_quality_t eoc_link_quality;
libspid_error_t ret;
- int rc;
- rc = system("cp " ONLINE_INFO " " UTESTS_TMP_DIR "/etc");
+ system("cp " ONLINE_INFO " " UTESTS_TMP_DIR "/etc");
strcpy(mac_address, "00:d7:20:00:00:03");
ret = libspid_eoc_get_link(mac_address, &eoc_link_quality);
+ fail_if (ret != LIBSPID_SUCCESS, "libspid_eoc_get_link fail");
fail_if(eoc_link_quality.down_att != 30, "libspid_eoc_get_link gets wrong downstream attenuation");
fail_if(eoc_link_quality.up_att != 103, "libspid_eoc_get_link gets wrong upstream attenuation ");
fail_if(eoc_link_quality.down_quality != 100, "libspid_eoc_get_link gets wrong downstream quality");
@@ -384,13 +210,13 @@ START_TEST (test_libspid_eoc_get_stat)
int ret = 0;
ret = libspid_eoc_get_stat (mac_addr[0], &eoc_rt_stat);
- fail_if (ret != exp_ret[0], "libspid_eoc_get_stat failed");
+ fail_if (ret != exp_ret[0], "libspid_eoc_get_stat 1 failed");
ret = libspid_eoc_get_stat (mac_addr[1], &eoc_rt_stat);
- fail_if (ret != exp_ret[1], "libspid_eoc_get_stat failed");
+ fail_if (ret != exp_ret[1], "libspid_eoc_get_stat 2 failed");
ret = libspid_eoc_get_stat (mac_addr[2], &eoc_rt_stat);
- fail_if (ret != exp_ret[2], "libspid_eoc_get_stat failed");
+ fail_if (ret != exp_ret[2], "libspid_eoc_get_stat 3 failed");
ret = libspid_eoc_get_stat (mac_addr[3], &eoc_rt_stat);
fail_if (eoc_rt_stat.rx_pkt != data_exp, "libspid_eoc_get_stat data error");
diff --git a/cleopatre/devkit/tests/libspid/utests/src/network_utests.c b/cleopatre/devkit/tests/libspid/utests/src/network_utests.c
index 9fb31b2be7..143bb5acdf 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/network_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/network_utests.c
@@ -32,7 +32,7 @@
#include <fcntl.h>
#include <net/if.h>
-#include "network_utests.h"
+#include "inc/network_utests.h"
//#define DEBUG 1
@@ -232,7 +232,7 @@ START_TEST (test_libspid_network_get_mac)
if((error = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0)
{
close(fd);
- if (error == EPERM)
+ if (error == -EPERM)
printf("TUN/TAP creation error.\nYou need to be root to create an network interface.\n");
else
printf("TUN/TAP creation error(%d).\n",error);
diff --git a/cleopatre/devkit/tests/libspid/utests/src/port_eoc_utests.c b/cleopatre/devkit/tests/libspid/utests/src/port_eoc_utests.c
index 0ebb671d13..b12de7106c 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/port_eoc_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/port_eoc_utests.c
@@ -53,14 +53,14 @@
void
setup (void)
{
- int ret, rc;
+ int ret;
struct stat st;
char buf[256];
/* initialize - delete testing dir if it exists */
if ( (stat (UTESTS_TMP_DIR, &st) == 0) )
{
- rc = system ("rm -r " UTESTS_TMP_DIR);
+ system ("rm -r " UTESTS_TMP_DIR);
}
ret = mkdir (UTESTS_TMP_DIR, 0770);
if (ret < 0 && errno != EEXIST)
@@ -119,7 +119,7 @@ tc_param (void)
START_TEST (test_libspid_eoc_port_set)
{
- int ret, rc;
+ int ret;
char mac_address[LIBSPID_MAC_STR_LEN];
char index[2];
libspid_eoc_port_entry_t entry;
@@ -134,7 +134,7 @@ START_TEST (test_libspid_eoc_port_set)
strcpy (entry.vlan_tag_en, "1");
strcpy (entry.vlan_mark_id, "5");
- rc = system ("cp " PORT_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " PORT_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_port_set (mac_address, index, &entry);
fail_if (ret != LIBSPID_SUCCESS, "libspid_eoc_port_set fail");
}
@@ -142,7 +142,7 @@ END_TEST
START_TEST (test_libspid_eoc_port_get)
{
- int ret, rc;
+ int ret;
char mac_address[LIBSPID_MAC_STR_LEN];
char index[2];
libspid_eoc_port_entry_t entry;
@@ -152,7 +152,7 @@ START_TEST (test_libspid_eoc_port_get)
strcpy (mac_address, "00:13:D7:00:00:01");
strcpy (index, "4");
- rc = system ("cp " PORT_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " PORT_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_port_get (mac_address, index, &entry);
fail_if (ret != LIBSPID_SUCCESS, "libspid_eoc_port_get return unsuccessful");
@@ -167,7 +167,7 @@ END_TEST
START_TEST (test_libspid_eoc_port_get_list)
{
- int ret, rc;
+ int ret;
libspid_eoc_port_entry_t entries[PORT_ENTRY_NUM];
int i;
int count;
@@ -202,7 +202,7 @@ START_TEST (test_libspid_eoc_port_get_list)
memset (entries, 0, PORT_ENTRY_NUM * sizeof (libspid_eoc_port_entry_t));
- rc = system ("cp " PORT_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " PORT_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_port_get_list (entries, &count);
@@ -254,9 +254,9 @@ END_TEST
START_TEST (test_libspid_eoc_port_sync)
{
- int ret, rc;
+ int ret;
- rc = system ("cp " PORT_SYNC_CONF " " UTESTS_TMP_DIR PORT_CONF_SYSTEM);
+ system ("cp " PORT_SYNC_CONF " " UTESTS_TMP_DIR PORT_CONF_SYSTEM);
ret = libspid_eoc_port_sync ();
diff --git a/cleopatre/devkit/tests/libspid/utests/src/service_eoc_utests.c b/cleopatre/devkit/tests/libspid/utests/src/service_eoc_utests.c
index 669056292c..ab9b45525a 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/service_eoc_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/service_eoc_utests.c
@@ -55,14 +55,14 @@
void
setup (void)
{
- int ret, rc;
+ int ret;
struct stat st;
char buf[256];
/* initialize - delete testing dir if it exists */
if ( (stat (UTESTS_TMP_DIR, &st) == 0) )
{
- rc = system ("rm -r " UTESTS_TMP_DIR);
+ system ("rm -r " UTESTS_TMP_DIR);
}
ret = mkdir (UTESTS_TMP_DIR, 0770);
if (ret < 0 && errno != EEXIST)
@@ -119,7 +119,7 @@ tc_param (void)
START_TEST (test_libspid_eoc_service_set)
{
- int ret, rc;
+ int ret;
char index[4];
libspid_eoc_service_entry_t entry;
@@ -138,7 +138,7 @@ START_TEST (test_libspid_eoc_service_set)
strcpy (entry.max_jitter, "0");
strcpy (entry.acs_en, "0");
- rc = system ("cp " SERVICE_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " SERVICE_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_service_set (index, &entry);
fail_if (ret != LIBSPID_SUCCESS, "libspid_eoc_service_set fail");
}
@@ -146,15 +146,15 @@ END_TEST
START_TEST (test_libspid_eoc_service_get)
{
- int ret, rc;
+ int ret;
char index[4];
libspid_eoc_service_entry_t entry;
memset (&entry, 0, sizeof (entry));
strcpy (index, "8");
- rc = system ("cp " SERVICE_CONF " " UTESTS_TMP_DIR "/etc");
- rc = system ("cp " EOC_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " SERVICE_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " EOC_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_service_get (index, &entry);
fail_if (ret != LIBSPID_SUCCESS, "libspid_eoc_service_get return unsuccessful");
@@ -176,7 +176,7 @@ END_TEST
START_TEST (test_libspid_eoc_service_get_list)
{
- int ret, rc;
+ int ret;
libspid_eoc_service_entry_t entries[SERVICE_ENTRY_NUM];
int i;
int count;
@@ -198,8 +198,8 @@ START_TEST (test_libspid_eoc_service_get_list)
memset (entries, 0, SERVICE_ENTRY_NUM * sizeof (libspid_eoc_service_entry_t));
- rc = system ("cp " SERVICE_CONF " " UTESTS_TMP_DIR "/etc");
- rc = system ("cp " EOC_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " SERVICE_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " EOC_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_service_get_list(entries, &count);
@@ -229,9 +229,9 @@ END_TEST
START_TEST (test_libspid_eoc_service_remove)
{
char index[4];
- int ret, rc;
+ int ret;
- rc = system ("cp " SERVICE_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " SERVICE_CONF " " UTESTS_TMP_DIR "/etc");
strcpy (index, "7");
@@ -243,9 +243,9 @@ END_TEST
START_TEST (test_libspid_eoc_service_flush)
{
- int ret, rc;
+ int ret;
- rc = system ("cp " SERVICE_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " SERVICE_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_service_flush ();
@@ -305,10 +305,10 @@ END_TEST
START_TEST (test_libspid_eoc_service_sync)
{
- int ret, rc;
+ int ret;
- rc = system ("cp " SERVICE_SYNC_CONF " " UTESTS_TMP_DIR SERVICE_CONF_SYSTEM);
- rc = system ("cp " EOC_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " SERVICE_SYNC_CONF " " UTESTS_TMP_DIR SERVICE_CONF_SYSTEM);
+ system ("cp " EOC_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_service_sync ();
diff --git a/cleopatre/devkit/tests/libspid/utests/src/system_utests.c b/cleopatre/devkit/tests/libspid/utests/src/system_utests.c
index 0d066fe80d..778d5f6242 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/system_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/system_utests.c
@@ -24,11 +24,13 @@
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
+#include <sys/wait.h>
#include <dirent.h>
#include <sys/stat.h>
#include <time.h>
-#include "system_utests.h"
+#include "inc/system_utests.h"
+#include "path.h"
//#define DEBUG 1
@@ -98,6 +100,14 @@ void setup(void)
exit(EXIT_FAILURE);
}
+ sprintf(buf, "%s/factory", UTESTS_TMP_DIR);
+ ret = mkdir(buf, 0770);
+ if (ret < 0 && errno != EEXIST)
+ {
+ perror("mkdir(UTESTS_TMP_DIR, 0770)");
+ exit(EXIT_FAILURE);
+ }
+
sprintf(buf, "%s/dev", UTESTS_TMP_DIR);
ret = mkdir(buf, 0770);
if (ret < 0 && errno != EEXIST)
@@ -387,60 +397,24 @@ START_TEST (test_libspid_system_factory)
char tst_file[128] = {0};
struct stat st;
-#ifdef DEBUG
- struct dirent *d;
- DIR *dir;
-#endif /* DEBUG */
-
- sprintf (tst_file, "%s/test_F1", LIBSPID_CONF_SAVE_PATH);
- mknod(tst_file, 0770, S_IFREG);
- sprintf (tst_file, "%s/test_F2", LIBSPID_CONF_SAVE_PATH);
- mknod(tst_file, 0770, S_IFREG);
- sprintf (tst_file, "%s/test_F3.conf", LIBSPID_CONF_SAVE_PATH);
- mknod(tst_file, 0770, S_IFREG);
+ sprintf (tst_file, "%s/test1", LIBSPID_CONF_SAVE_PATH);
+ fail_if ( stat(tst_file,&st) != 0, "missing file before test" );
+ sprintf (tst_file, "%s/test2", LIBSPID_CONF_SAVE_PATH);
+ fail_if ( stat(tst_file,&st) != 0, "missing file before test" );
+ sprintf (tst_file, "%s/test3.conf", LIBSPID_CONF_SAVE_PATH);
+ fail_if ( stat(tst_file,&st) != 0, "missing file before test" );
ret = libspid_system_factory();
fail_if(ret != LIBSPID_SUCCESS, "libspid_system_factory fail");
/* test if files have been deleted */
- sprintf (tst_file, "%s/test_F1", LIBSPID_CONF_SAVE_PATH);
- fail_if ( stat(tst_file,&st) == 0, "libspid_system_factory did not delete F1 file" );
- sprintf (tst_file, "%s/test_F2", LIBSPID_CONF_SAVE_PATH);
- fail_if ( stat(tst_file,&st) == 0, "libspid_system_factory did not delete F2 file" );
- sprintf (tst_file, "%s/test_F3.conf", LIBSPID_CONF_SAVE_PATH);
- fail_if ( stat(tst_file,&st) == 0, "libspid_system_factory did not delete F3 file" );
-
-#ifdef DEBUG
- /* print contents for debug */
- dir = opendir (LIBSPID_CONF_SAVE_PATH);
- if (dir == NULL)
- {
- perror("opendir()");
- exit(1);
- }
- TRACE ("Listing LIBSPID_CONF_SAVE_PATH, %s:\n", LIBSPID_CONF_SAVE_PATH);
- while( (d = readdir(dir)) != NULL )
- {
- TRACE("%s\n",d->d_name);
- }
-
- sprintf (tst_file, "%s/test_F1", LIBSPID_CONF_SAVE_PATH);
- if ( stat(tst_file,&st) == 0 )
- {
- printf("%s is present\n", tst_file);
- }
-
- sprintf (tst_file, "%s/test_NON_EXISTANT", LIBSPID_CONF_SAVE_PATH);
- if ( stat(tst_file,&st) == 0 )
- {
- printf("%s is present\n", tst_file);
- }
- else
- {
- printf("%s is *NOT* present\n", tst_file);
- }
-#endif /* DEBUG */
+ sprintf (tst_file, "%s/test1", LIBSPID_CONF_SAVE_PATH);
+ fail_if ( stat(tst_file,&st) == 0, "file not removed" );
+ sprintf (tst_file, "%s/test2", LIBSPID_CONF_SAVE_PATH);
+ fail_if ( stat(tst_file,&st) == 0, "file not removed" );
+ sprintf (tst_file, "%s/test3.conf", LIBSPID_CONF_SAVE_PATH);
+ fail_if ( stat(tst_file,&st) == 0, "file not removed" );
}
END_TEST
@@ -530,7 +504,7 @@ START_TEST (test_libspid_system_set_nvram)
perror("Cannot open NVRAM path for reading");
exit(EXIT_FAILURE);
}
- fread(&ret_nvram, sizeof(spc300_nvram_t), 1, fp);
+ fail_if (fread (&ret_nvram, sizeof (spc300_nvram_t), 1, fp) != 1);
fclose(fp);
ret = memcmp(&ret_nvram, &nvram, sizeof(spc300_nvram_t));
@@ -566,15 +540,15 @@ void callback (int signal_nb)
START_TEST (test_libspid_system_file_update_register)
{
pid_t rx_pid = 1;
- char filename[LIBSPID_CONFIG_KEY_MAX_LEN];
+ char filename[LIBSPID_CONFIG_KEY_MAX_LEN + 1];
char filename_too_long[LIBSPID_CONFIG_KEY_MAX_LEN + 2];
libspid_boolean_t is_registered = LIBSPID_FALSE;
unsigned int elt_number = LIBSPID_CONFIG_ELT_MAX_NB;
char *elt[LIBSPID_CONFIG_ELT_MAX_NB] = { NULL };
char buffer[LIBSPID_CONFIG_LINE_MAX_LEN] = {0};
- char key[LIBSPID_CONFIG_KEY_MAX_LEN];
- memset (filename, 'f', LIBSPID_CONFIG_KEY_MAX_LEN-1);
- filename[LIBSPID_CONFIG_KEY_MAX_LEN-1] = '\0';
+ char key[LIBSPID_CONFIG_KEY_MAX_LEN + 1];
+ memset (filename, 'f', LIBSPID_CONFIG_KEY_MAX_LEN);
+ filename[LIBSPID_CONFIG_KEY_MAX_LEN] = '\0';
memset (filename_too_long, 'l', LIBSPID_CONFIG_KEY_MAX_LEN + 1);
filename_too_long[LIBSPID_CONFIG_KEY_MAX_LEN + 1] = '\0';
strcpy (key, filename);
@@ -819,8 +793,29 @@ START_TEST (test_libspid_system_file_update_warn)
fail_if (LIBSPID_SUCCESS != libspid_system_file_update_is_registered (getpid(),
filename, &is_registered));
fail_if (LIBSPID_TRUE != is_registered);
+ fail_if (LIBSPID_SUCCESS != libspid_system_file_update_warn (getpid(), filename));
+ fail_if (handler_called);
fail_if (LIBSPID_SUCCESS != libspid_system_file_update_warn (tx_pid, filename));
fail_if (!handler_called);
+ fail_if (LIBSPID_SUCCESS != libspid_system_file_update_unregister (getpid(), filename));
+ handler_called = 0;
+
+ /* Test with a registered process that no longer exists. */
+ pid_t child_pid = fork ();
+ fail_if (child_pid == -1);
+ if (child_pid)
+ {
+ fail_if (waitpid (child_pid, NULL, 0) != child_pid);
+ fail_if (LIBSPID_SUCCESS != libspid_system_file_update_register (child_pid, filename,
+ callback));
+ fail_if (LIBSPID_SUCCESS != libspid_system_file_update_warn (tx_pid, filename));
+ fail_if (handler_called);
+ fail_if (LIBSPID_SUCCESS != libspid_system_file_update_unregister (child_pid, filename));
+ }
+ else
+ {
+ exit (0);
+ }
}
END_TEST
@@ -860,8 +855,8 @@ int main(void)
s = libspid_system_suite();
SRunner *sr = srunner_create(s);
- //srunner_set_fork_status (sr, CK_NOFORK);
- srunner_set_fork_status (sr, CK_FORK);
+ srunner_set_fork_status (sr, CK_NOFORK);
+ //srunner_set_fork_status (sr, CK_FORK);
srunner_run_all(sr, CK_NORMAL);
number_failed = srunner_ntests_failed(sr);
srunner_free(sr);
diff --git a/cleopatre/devkit/tests/libspid/utests/src/tonemap_snr_eoc_utests.c b/cleopatre/devkit/tests/libspid/utests/src/tonemap_snr_eoc_utests.c
index ada26d86f2..11b0b7d8ad 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/tonemap_snr_eoc_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/tonemap_snr_eoc_utests.c
@@ -43,242 +43,6 @@
#define TRACE(...)
#endif
-
-/**
- * Pull (get) data from beginning of MME payload. MME data head and length are updated
- * If there is not enough data to pull, an error is returned and the remaining payload length is returned.
- *
- * \param ctx MME context where to get data
- * \param data buffer where to get data from the beginning of MME payload
- * \param length length of data to pull
- * \param result_length length of data pulled; if there is not enough data into the MME to fit the length, the remaining data length is returned
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- */
-mme_error_t mme_pull (mme_ctx_t *ctx, void *data, unsigned int length, unsigned int *result_length)
-{
- /* protect from null pointers */
- if (ctx == NULL || data == NULL || result_length == NULL)
- return MME_ERROR_GEN;
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT)
- return MME_ERROR_NOT_INIT;
-
- /* check if it is demanded more data than we have in payload */
- if (length > ctx->tail - ctx->head)
- {
- *result_length = ctx->tail - ctx->head;
- return MME_ERROR_ENOUGH;
- }
-
- *result_length = length;
-
- memcpy (data, (unsigned char *)(ctx->buffer + ctx->head), length);
-
- ctx->head += length;
-
- return MME_SUCCESS;
-}
-
-/**
- * Create a MME message context. This context is used to build the MME message step by step.
- * The provided buffer must be enough large to contain all the final payload.
- * The MME payload can be bigger than an ethernet payload, as the fragmentation is managed by the 'send' function.
- *
- * \param ctx MME context to fill with init value
- * \param mmtype type of MME message (must be in official type list)
- * \param buffer the buffer to put the payload
- * \param length the buffer length
- * \return error type (MME_SUCCESS if success)
- */
-mme_error_t mme_init (mme_ctx_t *ctx, const mme_type_t mmtype, unsigned char *buffer, const unsigned int length)
-{
- /* protect from null pointers */
- if (ctx == NULL || buffer == NULL)
- return MME_ERROR_GEN;
-
- ctx->buffer = buffer;
- ctx->mmtype = mmtype;
- ctx->length = length;
- ctx->head = 0;
- ctx->tail = 0;
-
- ctx->status = MME_STATUS_OK;
-
- return MME_SUCCESS;
-}
-
-/**
- * Put data at the end of MME payload. MME data tail and length are updated<br>
- * If there is not enough free place to put data, an error is returned and the remaining free space length is returned.
- *
- * \param ctx MME context where to put data
- * \param data data to put at the end of MME payload
- * \param length length of data to put
- * \param result_length length of data really put
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- * \return MME_ERROR_SPACE: not enough available space
- */
-mme_error_t mme_put (mme_ctx_t *ctx, const void *data, unsigned int length, unsigned int *result_length)
-{
- int free = 0;
- int delta = 0;
-
- /* protect from null pointers */
- if (ctx == NULL || data == NULL || result_length == NULL)
- return MME_ERROR_GEN;
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT)
- return MME_ERROR_NOT_INIT;
-
- free = ctx->length - (ctx->tail - ctx->head);
- if (length > free)
- {
- *result_length = free;
- return MME_ERROR_SPACE;
- }
-
- *result_length = length;
-
- /* make place after payload, if needed */
- if (length > ctx->length - ctx->tail)
- {
- /*
- * *length
- * .---------------^-----------------.
- * |-----------|------------|xxxxxxx|-------------------------|
- * buff head tail ctx->length
- * \________ ________/
- * \/
- * payload
- *
- * we have to shift left our payload for this difference delta marked with 'x'
- * in order for *length bytes to fit in from beginning of the buffer
- */
- delta = length - (ctx->length - ctx->tail);
- memmove( (unsigned char *)(ctx->buffer + ctx->head - delta), (unsigned char *)(ctx->buffer + ctx->head), ctx->tail - ctx->head );
-
- /* update head and tail pointers (offsets) */
- ctx->head -= delta;
- ctx->tail -= delta;
- }
-
- memcpy( (unsigned char *)(ctx->buffer + ctx->tail), (unsigned char *)data, length );
- ctx->tail += length;
-
- return MME_SUCCESS;
-}
-
-/**
- * Send fake MME by filling buffer: confirm_ctx->buffer
- *
- * \param ctx MME context to send
- * \param type transaction type
- * \param iface selected communication interface
- * \param dest destination MAC address in binary format (6 bytes)
- * \param confirm_ctx MME context given to put the received MME answer packet. A adapted buffer must have been provided.
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- */
-mme_error_t mme_send (mme_ctx_t *ctx, mme_send_type_t type, char *iface, unsigned char *dest, mme_ctx_t *confirm_ctx)
-{
- libspid_eoc_snr_entry_t snr;
- libspid_eoc_tonemap_entry_t tonemap;
-
- snr.int_id = 0;
- snr.int_length = 1;
- snr.tm_ber = 789;
-
- /* result */
- unsigned char result = 0;
-
- /* protect from null pointers */
- if (ctx == NULL || confirm_ctx == NULL || dest == NULL)
- return MME_ERROR_GEN;
-
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT)
- return MME_ERROR_NOT_INIT;
-
- if (ctx->mmtype == (MME_TYPE_VS_GET_SNR | MME_TYPE_REQ))
- {
- snr.carrier_group = ctx->buffer[11];
-
- confirm_ctx->buffer[0] = 0x00;
- confirm_ctx->buffer[1] = 0x13;
- confirm_ctx->buffer[2] = 0xD7;
-
- confirm_ctx->buffer[3] = result;
- confirm_ctx->buffer[4] = snr.int_id;
- confirm_ctx->buffer[5] = snr.int_length;
- snr.int_et[0] = 537;
- memcpy(&confirm_ctx->buffer[6], &snr.int_et[0], 2);
- memcpy(&confirm_ctx->buffer[8], &snr.tm_ber, 2);
-
- confirm_ctx->buffer[10] = snr.carrier_group;
-
- snr.snr_list[5] = 203;
- memcpy(&confirm_ctx->buffer[11], snr.snr_list, LIBSPID_EOC_SNR_LIST_MAX_SIZE);
-
- }
- if (ctx->mmtype == (MME_TYPE_VS_GET_TONEMAP | MME_TYPE_REQ))
- {
- confirm_ctx->buffer[0] = 0x00;
- confirm_ctx->buffer[1] = 0x13;
- confirm_ctx->buffer[2] = 0xD7;
-
- if (ctx->buffer[9] == 255)
- {
- confirm_ctx->buffer[3] = result;
- tonemap.int_id = 35;
- confirm_ctx->buffer[8] = tonemap.int_id;
- }
- else
- {
- confirm_ctx->buffer[3] = result;
-
- tonemap.int_id = 35;
- confirm_ctx->buffer[8] = tonemap.int_id;
-
- tonemap.tmi_default = 3;
- confirm_ctx->buffer[9] = tonemap.tmi_default;
-
- tonemap.tmi_length = 1;
- confirm_ctx->buffer[10] = tonemap.tmi_length;
-
- tonemap.tmi_data[0] = 67;
- confirm_ctx->buffer[11] = tonemap.tmi_data[0];
-
- tonemap.int_length = 1;
- confirm_ctx->buffer[12] = tonemap.int_length;
-
- tonemap.int_et[0] = 633;
- memcpy(&confirm_ctx->buffer[13], &tonemap.int_et[0], 2);
-
- tonemap.int_tmi[0] = 56;
- confirm_ctx->buffer[15] = tonemap.int_tmi[0];
-
- tonemap.tmi = 3;
- confirm_ctx->buffer[16] = tonemap.tmi;
-
- tonemap.tm_fec = 7;
- confirm_ctx->buffer[17] = tonemap.tm_fec;
-
- tonemap.tm_gi = 5;
- confirm_ctx->buffer[18] = tonemap.tm_gi;
-
- tonemap.modulation_list[3] = 31;
- memcpy(&confirm_ctx->buffer[19], tonemap.modulation_list, LIBSPID_EOC_MODULATION_LIST_MAX_SIZE);
- }
-
- }
-
- confirm_ctx->tail = ETH_DATA_LEN;
-
- return MME_SUCCESS;
-}
-
START_TEST (test_libspid_eoc_get_tonemap)
{
int ret = 0;
diff --git a/cleopatre/devkit/tests/libspid/utests/src/upgrade_eoc_utests.c b/cleopatre/devkit/tests/libspid/utests/src/upgrade_eoc_utests.c
index a0794259ec..f2db459b9f 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/upgrade_eoc_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/upgrade_eoc_utests.c
@@ -50,263 +50,17 @@
typedef char mac_t[6];
typedef char mac_string_t[18];
-static unsigned int seq_cnt = 1;
-
-/**
- * Pull (get) data from beginning of MME payload. MME data head and length are updated
- * If there is not enough data to pull, an error is returned and the remaining payload length is returned.
- *
- * \param ctx MME context where to get data
- * \param data buffer where to get data from the beginning of MME payload
- * \param length length of data to pull
- * \param result_length length of data pulled; if there is not enough data into the MME to fit the length, the remaining data length is returned
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- */
-mme_error_t mme_pull (mme_ctx_t *ctx, void *data, unsigned int length, unsigned int *result_length)
-{
- /* protect from null pointers */
- if (ctx == NULL || data == NULL || result_length == NULL)
- return MME_ERROR_GEN;
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT)
- return MME_ERROR_NOT_INIT;
-
- /* check if it is demanded more data than we have in payload */
- if (length > ctx->tail - ctx->head)
- {
- *result_length = ctx->tail - ctx->head;
- return MME_ERROR_ENOUGH;
- }
-
- *result_length = length;
-
- memcpy(data, (unsigned char *)(ctx->buffer + ctx->head), length);
-
- ctx->head += length;
-
- return MME_SUCCESS;
-}
-
-/**
- * Create a MME message context. This context is used to build the MME message step by step.
- * The provided buffer must be enough large to contain all the final payload.
- * The MME payload can be bigger than an ethernet payload, as the fragmentation is managed by the 'send' function.
- *
- * \param ctx MME context to fill with init value
- * \param mmtype type of MME message (must be in official type list)
- * \param buffer the buffer to put the payload
- * \param length the buffer length
- * \return error type (MME_SUCCESS if success)
- */
-mme_error_t mme_init (mme_ctx_t *ctx, const mme_type_t mmtype, unsigned char *buffer, const unsigned int length)
-{
- /* protect from null pointers */
- if (ctx == NULL || buffer == NULL)
- return MME_ERROR_GEN;
-
- ctx->buffer = buffer;
- ctx->mmtype = mmtype;
- ctx->length = length;
- ctx->head = 0;
- ctx->tail = 0;
-
- ctx->status = MME_STATUS_OK;
-
- return MME_SUCCESS;
-}
-
-/**
- * Put data at the end of MME payload. MME data tail and length are updated<br>
- * If there is not enough free place to put data, an error is returned and the remaining free space length is returned.
- *
- * \param ctx MME context where to put data
- * \param data data to put at the end of MME payload
- * \param length length of data to put
- * \param result_length length of data really put
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- * \return MME_ERROR_SPACE: not enough available space
- */
-mme_error_t mme_put (mme_ctx_t *ctx, const void *data, unsigned int length, unsigned int *result_length)
-{
- int free = 0;
- int delta = 0;
-
- /* protect from null pointers */
- if (ctx == NULL || data == NULL || result_length == NULL)
- return MME_ERROR_GEN;
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT)
- return MME_ERROR_NOT_INIT;
-
- free = ctx->length - (ctx->tail - ctx->head);
- if (length > free)
- {
- *result_length = free;
- return MME_ERROR_SPACE;
- }
-
- *result_length = length;
-
- /* make place after payload, if needed */
- if (length > ctx->length - ctx->tail)
- {
- /*
- * *length
- * .---------------^-----------------.
- * |-----------|------------|xxxxxxx|-------------------------|
- * buff head tail ctx->length
- * \________ ________/
- * \/
- * payload
- *
- * we have to shift left our payload for this difference delta marked with 'x'
- * in order for *length bytes to fit in from beginning of the buffer
- */
- delta = length - (ctx->length - ctx->tail);
- memmove( (unsigned char *)(ctx->buffer + ctx->head - delta), (unsigned char *)(ctx->buffer + ctx->head), ctx->tail - ctx->head );
-
- /* update head and tail pointers (offsets) */
- ctx->head -= delta;
- ctx->tail -= delta;
- }
-
- memcpy( (unsigned char *)(ctx->buffer + ctx->tail), (unsigned char *)data, length );
- ctx->tail += length;
-
- return MME_SUCCESS;
-}
-
-/**
- * Send fake MME by filling buffer: confirm_ctx->buffer
- *
- * \param ctx MME context to send
- * \param type transaction type
- * \param iface selected communication interface
- * \param dest destination MAC address in binary format (6 bytes)
- * \param confirm_ctx MME context given to put the received MME answer packet. A adapted buffer must have been provided.
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- */
-mme_error_t mme_send (mme_ctx_t *ctx, mme_send_type_t type, char *iface, unsigned char *dest, mme_ctx_t *confirm_ctx)
-{
- /* protect from null pointers */
- if (ctx == NULL || confirm_ctx == NULL ||iface == NULL || dest == NULL)
- return MME_ERROR_GEN;
-
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT)
- return MME_ERROR_NOT_INIT;
-
- confirm_ctx->buffer[0] = 0x00;
- if ((ctx->mmtype >> 12) == 0xA)
- {
- confirm_ctx->buffer[1] = 0x13;
- confirm_ctx->buffer[2] = 0xD7;
-
- if (ctx->mmtype == (MME_TYPE_VS_UPDATE_START | MME_TYPE_REQ))
- {
- seq_cnt = 0;
- if (memcmp(dest, "\x00\x11\x22\x33\x44\x66", LIBSPID_MAC_BIN_LEN) == 0)
- confirm_ctx->buffer[3] = LIBSPID_UPDATE_START_VERSION_OK;
- else if(memcmp(dest, "\x00\x11\x22\x33\x44\x77", LIBSPID_MAC_BIN_LEN) == 0)
- confirm_ctx->buffer[3] = LIBSPID_UPDATE_START_BAD_ARCH;
- else if(memcmp(dest, "\x00\x11\x22\x33\x44\x88", LIBSPID_MAC_BIN_LEN) == 0)
- confirm_ctx->buffer[3] = LIBSPID_UPDATE_START_BAD_TYPE;
- else if(memcmp(dest, "\x00\x11\x22\x33\x44\x99", LIBSPID_MAC_BIN_LEN) == 0)
- confirm_ctx->buffer[3] = LIBSPID_UPDATE_START_MODEM_BUSY;
- else
- confirm_ctx->buffer[3] = LIBSPID_UPDATE_START_SUCCESS;
- }
- if (ctx->mmtype == (MME_TYPE_VS_UPDATE_TRANSFER | MME_TYPE_REQ))
- {
- seq_cnt++;
- if (memcmp(dest, "\x00\x11\x22\x33\x44\xbb", LIBSPID_MAC_BIN_LEN) == 0)
- confirm_ctx->buffer[3] = LIBSPID_UPDATE_TRANSFER_FAILED;
- else
- {
- confirm_ctx->buffer[3] = LIBSPID_UPDATE_TRANSFER_SUCCESS;
- confirm_ctx->buffer[4] = (seq_cnt >> 0) & 0xFF;
- confirm_ctx->buffer[5] = (seq_cnt >> 8) & 0xFF;
- confirm_ctx->buffer[6] = (seq_cnt >> 16) & 0xFF;
- confirm_ctx->buffer[7] = (seq_cnt >> 24) & 0xFF;
- }
- }
- if (ctx->mmtype == (MME_TYPE_VS_UPDATE_END | MME_TYPE_REQ))
- {
- if (memcmp(dest, "\x00\x11\x22\x33\x44\xdd", LIBSPID_MAC_BIN_LEN) == 0)
- confirm_ctx->buffer[3] = LIBSPID_UPDATE_END_MD5_ERROR;
- else
- confirm_ctx->buffer[3] = LIBSPID_UPDATE_END_SUCCESS;
- }
- }
-
- confirm_ctx->tail = ETH_DATA_LEN;
-
- return MME_SUCCESS;
-}
-
-/**
- * Wait for an MME request and call an user function to build and send the answer.<br>
- * As MME are level 2 and IP routing does not apply, the network interface where to listen to data packet must be selected inside
- * iface paramater. For instance : "eth0", "br0", ...<br>
- * If a received MME is fragmented, the receive process re-assemble it before delivering.<br>
- * When received MME has been processed and put into a MME context, the user function is called with the context in parameter.
- *
- * \param ctx context to receive the MME data
- * \param iface interface where to listen to the MME
- * \param source buffer where is filled the source MAC address of received MMA
- * \param listen_cb callback function used when MME packet is received.
- * \param tout timeout in seconds after which listening expires.
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- */
-mme_error_t mme_listen (mme_ctx_t *ctx, char *iface, unsigned char *source, mme_listen_cb_t listen_cb, unsigned int tout)
-{
- unsigned int result_len;
- char data[4];
-
- /* protect from null pointers */
- if (ctx == NULL || iface == NULL || source == NULL) return MME_ERROR_GEN;
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT) return MME_ERROR_NOT_INIT;
-
- data[0] = 0x00;
- data[1] = 0x13;
- data[2] = 0xD7;
-
- if (ctx->mmtype == (MME_TYPE_VS_UPDATE_END | MME_TYPE_IND))
- {
- if (memcmp(source, "\x00\x11\x22\x33\x44\xee", LIBSPID_MAC_BIN_LEN) == 0)
- data[3] = LIBSPID_UPDATE_END_FLASH_ERROR;
- else
- data[3] = LIBSPID_UPDATE_END_SUCCESS;
- }
- else if (ctx->mmtype == (MME_TYPE_VS_UPDATE_TRANSFER | MME_TYPE_IND))
- {
- if (memcmp(source, "\x00\x11\x22\x33\x44\xee", LIBSPID_MAC_BIN_LEN) == 0)
- data[3] = LIBSPID_UPDATE_TRANSFER_FAILED;
- else
- data[3] = LIBSPID_UPDATE_TRANSFER_SUCCESS;
- }
-
- mme_put(ctx, data, 4, &result_len);
-
- return MME_SUCCESS;
-}
-
/* fixtures - run before and after each unit test */
void setup(void)
{
- int ret, rc;
+ int ret;
struct stat st;
char buf[256];
/* initialize - delete testing dir if it exists */
if ( (stat (UTESTS_TMP_DIR, &st) == 0) )
{
- rc = system ("rm -r " UTESTS_TMP_DIR);
+ system ("rm -r " UTESTS_TMP_DIR);
}
ret = mkdir(UTESTS_TMP_DIR, 0770);
if (ret < 0 && errno != EEXIST)
@@ -359,7 +113,7 @@ END_TEST
START_TEST (test_libspid_eoc_upgrade_remote_image)
{
int exp_ret[10] = { 0, 4, 4, 4, 4, 0, 4, 0, 4, 4 };
- int ret, i, rc;
+ int ret, i;
char mac_addr[10][LIBSPID_MAC_STR_LEN] = {
"00:11:22:33:44:55", "00:11:22:33:44:66", "00:11:22:33:44:77",
"00:11:22:33:44:88", "00:11:22:33:44:99", "00:11:22:33:44:aa",
@@ -368,7 +122,7 @@ START_TEST (test_libspid_eoc_upgrade_remote_image)
};
char file[] = UTESTS_TMP_DIR "/" IMAGE_FILE;
- rc = system("cp " LOCAL_IMAGE_FILE " " UTESTS_TMP_DIR);
+ system("cp " LOCAL_IMAGE_FILE " " UTESTS_TMP_DIR);
for (i=0; i<10; i++) {
ret = libspid_eoc_upgrade_remote_image(mac_addr[i], file);
@@ -383,7 +137,7 @@ END_TEST
START_TEST (test_libspid_eoc_tftp_upgrade_remote_image)
{
- int ret, rc, i;
+ int ret, i;
int exp_ret[10] = { 0, 4, 4, 4, 4, 0, 0, 0, 4, 4 };
char mac_addr[10][LIBSPID_MAC_STR_LEN] = {
"00:11:22:33:44:55", "00:11:22:33:44:66", "00:11:22:33:44:77",
@@ -393,7 +147,7 @@ START_TEST (test_libspid_eoc_tftp_upgrade_remote_image)
};
char file[] = UTESTS_TMP_DIR "/" IMAGE_FILE;
- rc = system("cp " LOCAL_IMAGE_FILE " " UTESTS_TMP_DIR);
+ system("cp " LOCAL_IMAGE_FILE " " UTESTS_TMP_DIR);
for (i=0; i<10; i++) {
ret = libspid_eoc_tftp_upgrade_remote_image (mac_addr[i], file);
diff --git a/cleopatre/devkit/tests/libspid/utests/src/wl_eoc_utests.c b/cleopatre/devkit/tests/libspid/utests/src/wl_eoc_utests.c
index ea47c9809a..4fb9bc85c7 100644
--- a/cleopatre/devkit/tests/libspid/utests/src/wl_eoc_utests.c
+++ b/cleopatre/devkit/tests/libspid/utests/src/wl_eoc_utests.c
@@ -90,181 +90,18 @@ itoa (int n, char* s, int b)
reverse(s);
}
-/* stub functions */
-
-/**
- * Pull (get) data from beginning of MME payload. MME data head and length are updated
- * If there is not enough data to pull, an error is returned and the remaining payload length is returned.
- *
- * \param ctx MME context where to get data
- * \param data buffer where to get data from the beginning of MME payload
- * \param length length of data to pull
- * \param result_length length of data pulled; if there is not enough data into the MME to fit the length, the remaining data length is returned
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- */
-mme_error_t
-mme_pull (mme_ctx_t *ctx, void *data, unsigned int length, unsigned int *result_length)
-{
- /* protect from null pointers */
- if (ctx == NULL || data == NULL || result_length == NULL)
- return MME_ERROR_GEN;
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT)
- return MME_ERROR_NOT_INIT;
-
- /* check if it is demanded more data than we have in payload */
- if (length > ctx->tail - ctx->head)
- {
- *result_length = ctx->tail - ctx->head;
- return MME_ERROR_ENOUGH;
- }
-
- *result_length = length;
-
- memcpy (data, (unsigned char *)(ctx->buffer + ctx->head), length);
-
- ctx->head += length;
-
- return MME_SUCCESS;
-}
-
-/**
- * Create a MME message context. This context is used to build the MME message step by step.
- * The provided buffer must be enough large to contain all the final payload.
- * The MME payload can be bigger than an ethernet payload, as the fragmentation is managed by the 'send' function.
- *
- * \param ctx MME context to fill with init value
- * \param mmtype type of MME message (must be in official type list)
- * \param buffer the buffer to put the payload
- * \param length the buffer length
- * \return error type (MME_SUCCESS if success)
- */
-mme_error_t
-mme_init (mme_ctx_t *ctx, const mme_type_t mmtype, unsigned char *buffer, const unsigned int length)
-{
- /* protect from null pointers */
- if (ctx == NULL || buffer == NULL)
- return MME_ERROR_GEN;
-
- ctx->buffer = buffer;
- ctx->mmtype = mmtype;
- ctx->length = length;
- ctx->head = 0;
- ctx->tail = 0;
-
- ctx->status = MME_STATUS_OK;
-
- return MME_SUCCESS;
-}
-
-/**
- * Put data at the end of MME payload. MME data tail and length are updated<br>
- * If there is not enough free place to put data, an error is returned and the remaining free space length is returned.
- *
- * \param ctx MME context where to put data
- * \param data data to put at the end of MME payload
- * \param length length of data to put
- * \param result_length length of data really put
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- * \return MME_ERROR_SPACE: not enough available space
- */
-mme_error_t
-mme_put (mme_ctx_t *ctx, const void *data, unsigned int length, unsigned int *result_length)
-{
- int free = 0;
- int delta = 0;
-
- /* protect from null pointers */
- if (ctx == NULL || data == NULL || result_length == NULL)
- return MME_ERROR_GEN;
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT)
- return MME_ERROR_NOT_INIT;
-
- free = ctx->length - (ctx->tail - ctx->head);
- if (length > free)
- {
- *result_length = free;
- return MME_ERROR_SPACE;
- }
-
- *result_length = length;
-
- /* make place after payload, if needed */
- if (length > ctx->length - ctx->tail)
- {
- /*
- * *length
- * .---------------^-----------------.
- * |-----------|------------|xxxxxxx|-------------------------|
- * buff head tail ctx->length
- * \________ ________/
- * \/
- * payload
- *
- * we have to shift left our payload for this difference delta marked with 'x'
- * in order for *length bytes to fit in from beginning of the buffer
- */
- delta = length - (ctx->length - ctx->tail);
- memmove ( (unsigned char *)(ctx->buffer + ctx->head - delta), (unsigned char *)(ctx->buffer + ctx->head), ctx->tail - ctx->head );
-
- /* update head and tail pointers (offsets) */
- ctx->head -= delta;
- ctx->tail -= delta;
- }
-
- memcpy ( (unsigned char *)(ctx->buffer + ctx->tail), (unsigned char *)data, length );
- ctx->tail += length;
-
- return MME_SUCCESS;
-}
-
-/**
- * Send fake MME by filling buffer: confirm_ctx->buffer
- *
- * \param ctx MME context to send
- * \param type transaction type
- * \param iface selected communication interface
- * \param dest destination MAC address in binary format (6 bytes)
- * \param confirm_ctx MME context given to put the received MME answer packet. A adapted buffer must have been provided.
- * \return error type (MME_SUCCESS if success)
- * \return MME_ERROR_NOT_INIT: context not initialized
- */
-mme_error_t
-mme_send (mme_ctx_t *ctx, mme_send_type_t type, char *iface, unsigned char *dest, mme_ctx_t *confirm_ctx)
-{
- /* protect from null pointers */
- if (ctx == NULL || confirm_ctx == NULL ||iface == NULL || dest == NULL)
- return MME_ERROR_GEN;
-
- /* check if ctx has been inititalized */
- if (ctx->status == MME_STATUS_INIT)
- return MME_ERROR_NOT_INIT;
-
- confirm_ctx->buffer[0] = 0x00;
- confirm_ctx->buffer[1] = 0x13;
- confirm_ctx->buffer[2] = 0xD7;
- confirm_ctx->buffer[3] = 0x00;
-
- confirm_ctx->tail = ETH_DATA_LEN;
-
- return MME_SUCCESS;
-}
-
/* fixtures - run before and after each unit test */
void
setup (void)
{
- int ret, rc;
+ int ret;
struct stat st;
char buf[256];
/* initialize - delete testing dir if it exists */
if ( (stat (UTESTS_TMP_DIR, &st) == 0) )
{
- rc = system ("rm -r " UTESTS_TMP_DIR);
+ system ("rm -r " UTESTS_TMP_DIR);
}
ret = mkdir (UTESTS_TMP_DIR, 0770);
if (ret < 0 && errno != EEXIST)
@@ -313,7 +150,7 @@ END_TEST
START_TEST (test_libspid_eoc_wl_set)
{
- int ret, rc;
+ int ret;
mac_string_t mac_address;
libspid_eoc_wl_entry_t entry;
@@ -328,8 +165,8 @@ START_TEST (test_libspid_eoc_wl_set)
strcpy (entry.end_time, "20:00");
strcpy (entry.dpw, "MALIKA-2");
- rc = system ("cp " WHITE_LIST_CONF " " UTESTS_TMP_DIR "/etc");
- rc = system ("cp " PORT_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " WHITE_LIST_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " PORT_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_wl_set (mac_address, &entry);
fail_if (ret != LIBSPID_SUCCESS, "libspid_eoc_wl_set fail");
}
@@ -337,14 +174,14 @@ END_TEST
START_TEST (test_libspid_eoc_wl_get)
{
- int ret, rc;
+ int ret;
mac_string_t mac_address;
libspid_eoc_wl_entry_t entry;
memset (&entry, 0, sizeof (entry));
strcpy (mac_address, "00:13:D7:00:00:02");
- rc = system ("cp " WHITE_LIST_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " WHITE_LIST_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_wl_get (mac_address, &entry);
fail_if (ret != LIBSPID_SUCCESS, "libspid_eoc_wl_get return unsuccessful");
@@ -360,7 +197,7 @@ END_TEST
START_TEST (test_libspid_eoc_wl_get_list)
{
- int ret, rc;
+ int ret;
libspid_eoc_wl_entry_t entries[WL_ENTRY_NUM];
int idx;
int count;
@@ -376,7 +213,7 @@ START_TEST (test_libspid_eoc_wl_get_list)
memset (entries, 0, WL_ENTRY_NUM * sizeof (libspid_eoc_wl_entry_t));
- rc = system ("cp " WHITE_LIST_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " WHITE_LIST_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_wl_get_list (entries, &count);
@@ -399,10 +236,10 @@ END_TEST
START_TEST (test_libspid_eoc_wl_remove)
{
mac_string_t mac_address;
- int ret, rc;
+ int ret;
- rc = system ("cp " WHITE_LIST_CONF " " UTESTS_TMP_DIR "/etc");
- rc = system ("cp " PORT_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " WHITE_LIST_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " PORT_CONF " " UTESTS_TMP_DIR "/etc");
strcpy (mac_address, "00:13:D7:00:00:02");
@@ -414,10 +251,10 @@ END_TEST
START_TEST (test_libspid_eoc_wl_flush)
{
- int ret, rc;
+ int ret;
- rc = system ("cp " WHITE_LIST_CONF " " UTESTS_TMP_DIR "/etc");
- rc = system ("cp " PORT_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " WHITE_LIST_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " PORT_CONF " " UTESTS_TMP_DIR "/etc");
ret = libspid_eoc_wl_flush ();
@@ -427,9 +264,9 @@ END_TEST
START_TEST (test_libspid_eoc_wl_sync)
{
- int ret, rc;
+ int ret;
- rc = system ("cp " WHITE_LIST_INFO " " UTESTS_TMP_DIR WHITE_LIST_CONF_SYSTEM);
+ system ("cp " WHITE_LIST_INFO " " UTESTS_TMP_DIR WHITE_LIST_CONF_SYSTEM);
ret = libspid_eoc_wl_sync ();
fail_if (ret != LIBSPID_SUCCESS, "libspid_eoc_wl_sync return is unsuccessful");
@@ -478,9 +315,9 @@ START_TEST (test_libspid_eoc_wl_set_output_level)
char expected_output_level[] = "95";
libspid_eoc_wl_entry_t entries[WL_ENTRY_NUM];
int count = 0;
- int ret, rc, idx;
+ int ret, idx;
- rc = system ("cp " WHITE_LIST_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " WHITE_LIST_CONF " " UTESTS_TMP_DIR "/etc");
libspid_eoc_wl_set_output_level (expected_output_level);
@@ -496,7 +333,7 @@ END_TEST
START_TEST (test_libspid_eoc_wl_mac_change)
{
- int rc = 0, ret = 0, i = 0;
+ int ret = 0, i = 0;
libspid_eoc_wl_entry_t entry;
char index[2];
libspid_eoc_port_entry_t port_entry;
@@ -518,8 +355,8 @@ START_TEST (test_libspid_eoc_wl_mac_change)
char vlan_tag_en[LIBSPID_PORT_PER_SLAVE_MAX][2] = {"1", "0", "1", "0", "1"};
char vlan_mark_id[LIBSPID_PORT_PER_SLAVE_MAX][2] = {"1", "3", "4", "1", "2"};
- rc = system ("cp " WHITE_LIST_CONF " " UTESTS_TMP_DIR "/etc");
- rc = system ("cp " PORT_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " WHITE_LIST_CONF " " UTESTS_TMP_DIR "/etc");
+ system ("cp " PORT_CONF " " UTESTS_TMP_DIR "/etc");
/* change mac_addr[1] to mac_addr[2] */
ret = libspid_eoc_wl_mac_change (mac_addr[0], mac_addr[1]);
diff --git a/cleopatre/devkit/tests/managerd/ftests/Makefile b/cleopatre/devkit/tests/managerd/ftests/Makefile
deleted file mode 100644
index 28399e20d3..0000000000
--- a/cleopatre/devkit/tests/managerd/ftests/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-BASE = ../../../..
-
-TEST_DIR = devkit/tests/managerd/ftests
-PRJ_DIR = $(BASE)/application/managerd
-LIBMME_DIR = $(BASE)/application/libmme
-LIBSPID_DIR = $(BASE)/application/libspid
-
-SRCPATH = src
-INCPATH = inc
-OBJPATH = obj
-BOARD_OBJPATH = $(OBJPATH)/board
-
-CC_FOR_BOARD = arm-linux-gcc
-AR_FOR_BOARD = arm-linux-ar
-
-INC = -I$(INCPATH) -I$(PRJ_DIR)/$(INCPATH) -I$(LIBMME_DIR)/$(INCPATH) -I$(LIBSPID_DIR)/$(INCPATH)
-CFLAGS_FOR_BOARD = -D__FTEST_PC__ -Wall $(INC)
-
-all: preall board
-
-preall:
- mkdir -p $(BOARD_OBJPATH)
-
-board: board-prj
-
-clean:
- rm -rf $(OBJPATH)
- $(MAKE) clean -C $(PRJ_DIR)
-
-board-prj:
- $(MAKE) -C $(PRJ_DIR) TEST=y CC_FOR_TEST=$(CC_FOR_BOARD) CFLAGS_FOR_TEST=$(CFLAGS_FOR_BOARD) AR_FOR_TEST=$(AR_FOR_BOARD) OBJPATH_FOR_TEST=$(TEST_DIR)/$(BOARD_OBJPATH)
-
diff --git a/cleopatre/devkit/tests/managerd/utests/Makefile b/cleopatre/devkit/tests/managerd/utests/Makefile
index a0a9aaf64e..8e02157bab 100644
--- a/cleopatre/devkit/tests/managerd/utests/Makefile
+++ b/cleopatre/devkit/tests/managerd/utests/Makefile
@@ -1,94 +1,36 @@
-TEST_NAME = utests
+BASE = ../../../../../cesar
+CLEO_BASE = ../cleopatre
-OBJPATH = obj
-PRJ_OBJPATH = $(OBJPATH)/prj
-TEST_OBJPATH = $(OBJPATH)/test
-LIBSPID_OBJPATH = $(OBJPATH)/libspid
-STUB_OBJPATH = $(OBJPATH)/stub
-LIBMME_STUB_OBJPATH = $(STUB_OBJPATH)/libmme
-LIBSPID_STUB_OBJPATH = $(STUB_OBJPATH)/libspid
+LINUX_PATH = $(CLEO_BASE)/linux-2.6.25.10-spc300
-BASE = ../../../..
+# We test managerd.
+PROJECT_DIR = $(CLEO_BASE)/application/managerd
-PRJ_DIR = $(BASE)/application/managerd
-LIBMME_DIR = $(BASE)/application/libmme
-LIBSPID_DIR = $(BASE)/application/libspid
-STUB_DIR = $(BASE)/devkit/tests/stub
-LIBMME_STUB_DIR = $(STUB_DIR)/libmme
-LIBSPID_STUB_DIR = $(STUB_DIR)/libspid
-LINUX_DIR = $(BASE)/linux-2.6.25.10-spc300
+LIBMME_BASE = $(CLEO_BASE)/application/libmme
+LIBSPID_BASE = $(CLEO_BASE)/application/libspid
+OVERRIDE_BASE = $(CLEO_BASE)/devkit/tests/managerd/utests/override
-SRCPATH = ./src
-INCPATH = ./inc
+INCLUDES = $(PROJECT_DIR)/inc $(LINUX_PATH)/include/asm-arm/arch-spc300 \
+ $(LIBMME_BASE)/inc $(LIBSPID_BASE)/inc $(LINUX_PATH)/include \
+ $(OVERRIDE_BASE)/inc
-FILES = vs_eoc_mme vs_mme
-
-INCLUDES = -I$(LINUX_DIR)/include -I$(LINUX_DIR)/include/asm-arm/arch-spc300 -I$(INCPATH) -I$(PRJ_DIR)/$(INCPATH) \
--I$(LIBMME_DIR)/$(INCPATH) -I$(LIBSPID_DIR)/$(INCPATH) -I$(LIBSPID_STUB_DIR)/$(INCPATH) \
--I$(LIBMME_STUB_DIR)/$(INCPATH)
-
-BINS = $(foreach file, $(FILES), $(OBJPATH)/$(file).elf)
+EXTRA_HOST_LDLIBS = -lcheck -lpthread
EXTRA_CFLAGS = -MMD
-CC = gcc
-CFLAGS = -Wall -g -D__UTESTS__ -D__MANAGERD__ $(EXTRA_CFLAGS) $(INCLUDES)
-LDFLAGS =
-LIBS = -lcheck -lpthread
-
-all: preall $(BINS)
-
-clean:
- rm -rf $(TEST_OBJPATH)
- rm -rf $(PRJ_OBJPATH)
- rm -rf $(LIB_STUB_OBJPATH)
- rm -rf $(OBJPATH)
-
-preall:
- mkdir -p $(PRJ_OBJPATH)
- mkdir -p $(TEST_OBJPATH)
- mkdir -p $(LIBSPID_OBJPATH)
- mkdir -p $(LIBMME_STUB_OBJPATH)
- mkdir -p $(LIBSPID_STUB_OBJPATH)
-
-.PHONY: all clean
-.PRECIOUS: $(PRJ_OBJPATH)/%.o $(TEST_OBJPATH)/%.o $(LIBSPID_OBJPATH)/%.o \
-$(LIBMME_STUB_OBJPATH)/mme.o $(LIBSPID_STUB_OBJPATH)/system.o $(LIBSPID_STUB_OBJPATH)/image.o $(LIBSPID_STUB_OBJPATH)/upgrade_eoc.o \
-$(LIBSPID_OBJPATH)/misc.o $(LIBSPID_OBJPATH)/config_item.o $(LIBSPID_OBJPATH)/network.o $(LIBSPID_OBJPATH)/config_line.o $(LIBSPID_OBJPATH)/openssl_md5.o
-
-$(OBJPATH)/%.elf: $(PRJ_OBJPATH)/%.o $(TEST_OBJPATH)/%_$(TEST_NAME).o \
-$(LIBMME_STUB_OBJPATH)/mme.o $(LIBSPID_STUB_OBJPATH)/system.o $(LIBSPID_STUB_OBJPATH)/image.o $(LIBSPID_STUB_OBJPATH)/upgrade_eoc.o \
-$(LIBSPID_OBJPATH)/misc.o $(LIBSPID_OBJPATH)/config_item.o $(LIBSPID_OBJPATH)/network.o $(LIBSPID_OBJPATH)/config_line.o $(LIBSPID_OBJPATH)/openssl_md5.o
- $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
-
-$(TEST_OBJPATH)/%.o: $(SRCPATH)/%.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-$(PRJ_OBJPATH)/%.o: $(PRJ_DIR)/$(SRCPATH)/%.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-$(LIBMME_STUB_OBJPATH)/mme.o: $(LIBMME_STUB_DIR)/$(SRCPATH)/mme.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-$(LIBSPID_OBJPATH)/network.o: $(LIBSPID_DIR)/$(SRCPATH)/network.c
- $(CC) $(CFLAGS) -c -o $@ $<
-$(LIBSPID_STUB_OBJPATH)/system.o: $(LIBSPID_STUB_DIR)/$(SRCPATH)/system.c
- $(CC) $(CFLAGS) -c -o $@ $<
+MANAGERD_MODE = 0
+DEFS = -D__UTESTS__ -DMANAGERD_MODE=$(MANAGERD_MODE)
-$(LIBSPID_STUB_OBJPATH)/image.o: $(LIBSPID_STUB_DIR)/$(SRCPATH)/image.c
- $(CC) $(CFLAGS) -c -o $@ $<
+HOST_PROGRAMS = vs_mme_utests vs_eoc_mme_utests
-$(LIBSPID_STUB_OBJPATH)/upgrade_eoc.o: $(LIBSPID_STUB_DIR)/$(SRCPATH)/upgrade_eoc.c
- $(CC) $(CFLAGS) -c -o $@ $<
+vs_mme_utests_SOURCES = vs_mme_utests.c
+vs_mme_utests_MODULES = $(PROJECT_DIR) $(OVERRIDE_BASE)
-$(LIBSPID_OBJPATH)/config_item.o: $(LIBSPID_DIR)/$(SRCPATH)/config_item.c
- $(CC) $(CFLAGS) -c -o $@ $<
+vs_eoc_mme_utests_SOURCES = vs_eoc_mme_utests.c
+vs_eoc_mme_utests_MODULES = $(PROJECT_DIR) $(OVERRIDE_BASE)
-$(LIBSPID_OBJPATH)/config_line.o: $(LIBSPID_DIR)/$(SRCPATH)/config_line.c
- $(CC) $(CFLAGS) -c -o $@ $<
+.._cleopatre_application_managerd_MODULE_SOURCES = bridge.c mme_nl.c vs_mme.c \
+ vs_eoc_mme.c js_eoc_mme.c
-$(LIBSPID_OBJPATH)/misc.o: $(LIBSPID_DIR)/$(SRCPATH)/misc.c
- $(CC) $(CFLAGS) -c -o $@ $<
+include $(BASE)/common/make/top.mk
-$(LIBSPID_OBJPATH)/openssl_md5.o: $(LIBSPID_DIR)/$(SRCPATH)/openssl_md5.c
- $(CC) $(CFLAGS) -c -o $@ $<
diff --git a/cleopatre/devkit/tests/managerd/utests/override/Module b/cleopatre/devkit/tests/managerd/utests/override/Module
new file mode 100644
index 0000000000..8b45b59efe
--- /dev/null
+++ b/cleopatre/devkit/tests/managerd/utests/override/Module
@@ -0,0 +1 @@
+SOURCES := libspid_stub.c libmme_stub.c misc_stub.c
diff --git a/cleopatre/devkit/tests/managerd/utests/override/inc/stub.h b/cleopatre/devkit/tests/managerd/utests/override/inc/stub.h
new file mode 100644
index 0000000000..5066b2d254
--- /dev/null
+++ b/cleopatre/devkit/tests/managerd/utests/override/inc/stub.h
@@ -0,0 +1,46 @@
+#ifndef override_inc_stub_h
+#define override_inc_stub_h
+/* Cleopatre project {{{
+ *
+ * Copyright (C) 2011 SPiDCOM Technologies
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file override/inc/stub.h
+ * \brief datas for stub and tests sources
+ * \ingroup Cleopatre - managerd
+ */
+
+#include <setjmp.h>
+
+#define IMAGE_DESC_VERSION "utest_mme"
+#define PLC_FIRMWARE_VERSION "0.1-rc3-1-unit_test"
+
+#define PLC_VERSION_FILE "testfiles/plc_version"
+#define NET_DEV_FILE "testfiles/net_dev"
+
+#define BR_MAC_ADDR "\x00\x13\xd7\x00\x00\x10"
+
+#define MAX_ITEM_NB 8
+#define CONF_TABLE_INDEX 0
+#define INFO_TABLE_INDEX 1
+
+enum test_id_en {
+ TEST_GET_VERSION = 0,
+ TEST_ETH_STATS,
+ TEST_GET_DEVICE_INFO,
+ TEST_NB
+};
+extern enum test_id_en test_id;
+
+struct check_ctx_st {
+ int assert_id;
+ int test_id;
+ jmp_buf jmp_env;
+
+};
+extern struct check_ctx_st check_ctx;
+
+#endif /* override_inc_stub_h */
diff --git a/cleopatre/devkit/tests/managerd/utests/override/src/libmme_stub.c b/cleopatre/devkit/tests/managerd/utests/override/src/libmme_stub.c
new file mode 100644
index 0000000000..fc7cb96302
--- /dev/null
+++ b/cleopatre/devkit/tests/managerd/utests/override/src/libmme_stub.c
@@ -0,0 +1,340 @@
+/* Cleopatre project {{{
+ *
+ * Copyright (C) 2011 SPiDCOM Technologies
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file override/src/libmme_stub.c
+ * \brief Stub for some libmme functions used in libspid
+ * \ingroup Cleopatre - managerd
+ */
+
+#include <string.h>
+#include "libmme.h"
+#include "libspid.h"
+
+static unsigned int seq_cnt = 1;
+
+mme_error_t mme_init (mme_ctx_t *ctx, const mme_type_t mmtype, unsigned char *buffer, const unsigned int length)
+{
+ /* protect from null pointers */
+ if (ctx == NULL || buffer == NULL)
+ return MME_ERROR_GEN;
+
+ ctx->buffer = buffer;
+ ctx->mmtype = mmtype;
+ ctx->length = length;
+ ctx->head = 0;
+ ctx->tail = 0;
+ ctx->status = MME_STATUS_OK;
+ return MME_SUCCESS;
+}
+
+mme_error_t mme_push (mme_ctx_t *ctx, const void *data, unsigned int length, unsigned int *result_length)
+{
+ return MME_SUCCESS;
+}
+
+mme_error_t mme_pull (mme_ctx_t *ctx, void *data, unsigned int length, unsigned int *result_length)
+{
+ /* protect from null pointers */
+ if (ctx == NULL || data == NULL || result_length == NULL)
+ return MME_ERROR_GEN;
+ /* check if ctx has been inititalized */
+ if (ctx->status == MME_STATUS_INIT)
+ return MME_ERROR_NOT_INIT;
+
+ /* check if it is demanded more data than we have in payload */
+ if (length > ctx->tail - ctx->head)
+ {
+ *result_length = ctx->tail - ctx->head;
+ return MME_ERROR_ENOUGH;
+ }
+
+ *result_length = length;
+ memcpy(data, (unsigned char *)(ctx->buffer + ctx->head), length);
+ ctx->head += length;
+ return MME_SUCCESS;
+}
+
+mme_error_t mme_put (mme_ctx_t *ctx, const void *data, unsigned int length, unsigned int *result_length)
+{
+ unsigned int free = 0;
+ int delta = 0;
+
+ /* protect from null pointers */
+ if (ctx == NULL || data == NULL || result_length == NULL)
+ return MME_ERROR_GEN;
+ /* check if ctx has been inititalized */
+ if (ctx->status == MME_STATUS_INIT)
+ return MME_ERROR_NOT_INIT;
+
+ free = ctx->length - (ctx->tail - ctx->head);
+ if (length > free)
+ {
+ *result_length = free;
+ return MME_ERROR_SPACE;
+ }
+
+ /* make place after payload, if needed */
+ if (length > ctx->length - ctx->tail)
+ {
+ /*
+ * *length
+ * .---------------^-----------------.
+ * |-----------|------------|xxxxxxx|-------------------------|
+ * buff head tail ctx->length
+ * \________ ________/
+ * \/
+ * payload
+ *
+ * we have to shift left our payload for this difference delta marked with 'x'
+ * in order for *length bytes to fit in from beginning of the buffer
+ */
+ delta = length - (ctx->length - ctx->tail);
+ memmove ( (unsigned char *)(ctx->buffer + ctx->head - delta), (unsigned char *)(ctx->buffer + ctx->head), ctx->tail - ctx->head );
+
+ /* update head and tail pointers (offsets) */
+ ctx->head -= delta;
+ ctx->tail -= delta;
+ }
+
+ *result_length = length;
+ memcpy( (unsigned char *)(ctx->buffer + ctx->tail), (unsigned char *)data, length );
+ ctx->tail += length;
+ return MME_SUCCESS;
+}
+
+mme_error_t
+mme_send (mme_ctx_t *ctx, mme_send_type_t type, char *iface, unsigned char *dest,
+ mme_ctx_t *confirm_ctx)
+{
+ libspid_eoc_snr_entry_t snr;
+ libspid_eoc_tonemap_entry_t tonemap;
+
+ snr.int_id = 0;
+ snr.int_length = 1;
+ snr.tm_ber = 789;
+
+ /* result */
+ unsigned char result = 0;
+
+ /* protect from null pointers */
+ if (ctx == NULL || confirm_ctx == NULL || dest == NULL)
+ return MME_ERROR_GEN;
+
+ /* check if ctx has been inititalized */
+ if (ctx->status == MME_STATUS_INIT)
+ return MME_ERROR_NOT_INIT;
+
+ confirm_ctx->buffer[0] = 0x00;
+ if ((ctx->mmtype >> 12) == 0xA)
+ {
+ confirm_ctx->buffer[1] = 0x13;
+ confirm_ctx->buffer[2] = 0xD7;
+ confirm_ctx->buffer[3] = 0x00;
+ }
+
+ if (ctx->mmtype == (MME_TYPE_VS_EOC_REAL_TIME_STATISTICS | MME_TYPE_REQ))
+ {
+ if (memcmp (dest, "\x00\x11\x22\x33\x44\xaa", LIBSPID_MAC_BIN_LEN) == 0)
+ confirm_ctx->buffer[3] = 0;
+ if (memcmp (dest, "\x00\x11\x22\x33\x44\xbb", LIBSPID_MAC_BIN_LEN) == 0)
+ confirm_ctx->buffer[3] = 1;
+ if (memcmp (dest, "\x00\x11\x22\x33\x44\xcc", LIBSPID_MAC_BIN_LEN) == 0)
+ return MME_ERROR_GEN;
+ if (memcmp (dest, "\x00\x11\x22\x33\x44\xdd", LIBSPID_MAC_BIN_LEN) == 0)
+ {
+ confirm_ctx->buffer[4] = 0x0;
+ confirm_ctx->buffer[5] = 0x3;
+ confirm_ctx->buffer[6] = 0x55;
+ confirm_ctx->buffer[7] = 0x17;
+ }
+ }
+ if (ctx->mmtype == (MME_TYPE_VS_UPDATE_START | MME_TYPE_REQ))
+ {
+ seq_cnt = 0;
+ if (memcmp(dest, "\x00\x11\x22\x33\x44\x66", LIBSPID_MAC_BIN_LEN) == 0)
+ confirm_ctx->buffer[3] = LIBSPID_UPDATE_START_VERSION_OK;
+ else if(memcmp(dest, "\x00\x11\x22\x33\x44\x77", LIBSPID_MAC_BIN_LEN) == 0)
+ confirm_ctx->buffer[3] = LIBSPID_UPDATE_START_BAD_ARCH;
+ else if(memcmp(dest, "\x00\x11\x22\x33\x44\x88", LIBSPID_MAC_BIN_LEN) == 0)
+ confirm_ctx->buffer[3] = LIBSPID_UPDATE_START_BAD_TYPE;
+ else if(memcmp(dest, "\x00\x11\x22\x33\x44\x99", LIBSPID_MAC_BIN_LEN) == 0)
+ confirm_ctx->buffer[3] = LIBSPID_UPDATE_START_MODEM_BUSY;
+ else
+ confirm_ctx->buffer[3] = LIBSPID_UPDATE_START_SUCCESS;
+ }
+ if (ctx->mmtype == (MME_TYPE_VS_UPDATE_TRANSFER | MME_TYPE_REQ))
+ {
+ seq_cnt++;
+ if (memcmp(dest, "\x00\x11\x22\x33\x44\xbb", LIBSPID_MAC_BIN_LEN) == 0)
+ confirm_ctx->buffer[3] = LIBSPID_UPDATE_TRANSFER_FAILED;
+ else
+ {
+ confirm_ctx->buffer[3] = LIBSPID_UPDATE_TRANSFER_SUCCESS;
+ confirm_ctx->buffer[4] = (seq_cnt >> 0) & 0xFF;
+ confirm_ctx->buffer[5] = (seq_cnt >> 8) & 0xFF;
+ confirm_ctx->buffer[6] = (seq_cnt >> 16) & 0xFF;
+ confirm_ctx->buffer[7] = (seq_cnt >> 24) & 0xFF;
+ }
+ }
+ if (ctx->mmtype == (MME_TYPE_VS_UPDATE_END | MME_TYPE_REQ))
+ {
+ if (memcmp(dest, "\x00\x11\x22\x33\x44\xdd", LIBSPID_MAC_BIN_LEN) == 0)
+ confirm_ctx->buffer[3] = LIBSPID_UPDATE_END_MD5_ERROR;
+ else
+ confirm_ctx->buffer[3] = LIBSPID_UPDATE_END_SUCCESS;
+ }
+ if (ctx->mmtype == (MME_TYPE_VS_EOC_AUTOCONF_START | MME_TYPE_REQ))
+ {
+ seq_cnt = 0;
+ if (memcmp(dest, "\x00\x11\x22\x33\x44\x66", LIBSPID_MAC_BIN_LEN) == 0)
+ confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_START_MODEM_BUSY;
+ else if (memcmp(dest, "\x00\x11\x22\x33\x44\x77", LIBSPID_MAC_BIN_LEN) == 0)
+ confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_START_BAD_PROTOCOL;
+ else if (memcmp(dest, "\x00\x11\x22\x33\x44\x88", LIBSPID_MAC_BIN_LEN) == 0)
+ confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_START_FAILED;
+ else if (memcmp(dest, "\x00\x11\x22\x33\x44\xcc", LIBSPID_MAC_BIN_LEN) == 0)
+ confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_START_CONFIG_EXIST;
+ else
+ confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_START_SUCCESS;
+ }
+ if (ctx->mmtype == (MME_TYPE_VS_EOC_AUTOCONF_TRANSFER | MME_TYPE_REQ))
+ {
+ seq_cnt++;
+ if (memcmp (dest, "\x00\x11\x22\x33\x44\x99", LIBSPID_MAC_BIN_LEN) == 0)
+ confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_TRANSFER_FAILED;
+ else
+ {
+ confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_TRANSFER_SUCCESS;
+ confirm_ctx->buffer[4] = (seq_cnt >> 0) & 0xFF;
+ confirm_ctx->buffer[5] = (seq_cnt >> 8) & 0xFF;
+ confirm_ctx->buffer[6] = (seq_cnt >> 16) & 0xFF;
+ confirm_ctx->buffer[7] = (seq_cnt >> 24) & 0xFF;
+ }
+ }
+ if (ctx->mmtype == (MME_TYPE_VS_EOC_AUTOCONF_END | MME_TYPE_REQ))
+ {
+ if (memcmp (dest, "\x00\x11\x22\x33\x44\xbb", LIBSPID_MAC_BIN_LEN) == 0)
+ confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_END_MD5_ERROR;
+ else if (memcmp (dest, "\x00\x11\x22\x33\x44\xaa", LIBSPID_MAC_BIN_LEN) == 0)
+ confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_END_FAILED;
+ else
+ confirm_ctx->buffer[3] = LIBSPID_EOC_AUTOCONF_END_SUCCESS;
+ }
+ if (ctx->mmtype == (MME_TYPE_VS_GET_SNR | MME_TYPE_REQ))
+ {
+ snr.carrier_group = ctx->buffer[11];
+
+ confirm_ctx->buffer[0] = 0x00;
+ confirm_ctx->buffer[1] = 0x13;
+ confirm_ctx->buffer[2] = 0xD7;
+
+ confirm_ctx->buffer[3] = result;
+ confirm_ctx->buffer[4] = snr.int_id;
+ confirm_ctx->buffer[5] = snr.int_length;
+ snr.int_et[0] = 537;
+ memcpy(&confirm_ctx->buffer[6], &snr.int_et[0], 2);
+ memcpy(&confirm_ctx->buffer[8], &snr.tm_ber, 2);
+
+ confirm_ctx->buffer[10] = snr.carrier_group;
+
+ snr.snr_list[5] = 203;
+ memcpy(&confirm_ctx->buffer[11], snr.snr_list, LIBSPID_EOC_SNR_LIST_MAX_SIZE);
+
+ }
+ if (ctx->mmtype == (MME_TYPE_VS_GET_TONEMAP | MME_TYPE_REQ))
+ {
+ confirm_ctx->buffer[0] = 0x00;
+ confirm_ctx->buffer[1] = 0x13;
+ confirm_ctx->buffer[2] = 0xD7;
+
+ if (ctx->buffer[9] == 255)
+ {
+ confirm_ctx->buffer[3] = result;
+ tonemap.int_id = 35;
+ confirm_ctx->buffer[8] = tonemap.int_id;
+ }
+ else
+ {
+ confirm_ctx->buffer[3] = result;
+
+ tonemap.int_id = 35;
+ confirm_ctx->buffer[8] = tonemap.int_id;
+
+ tonemap.tmi_default = 3;
+ confirm_ctx->buffer[9] = tonemap.tmi_default;
+
+ tonemap.tmi_length = 1;
+ confirm_ctx->buffer[10] = tonemap.tmi_length;
+
+ tonemap.tmi_data[0] = 67;
+ confirm_ctx->buffer[11] = tonemap.tmi_data[0];
+
+ tonemap.int_length = 1;
+ confirm_ctx->buffer[12] = tonemap.int_length;
+
+ tonemap.int_et[0] = 633;
+ memcpy(&confirm_ctx->buffer[13], &tonemap.int_et[0], 2);
+
+ tonemap.int_tmi[0] = 56;
+ confirm_ctx->buffer[15] = tonemap.int_tmi[0];
+
+ tonemap.tmi = 3;
+ confirm_ctx->buffer[16] = tonemap.tmi;
+
+ tonemap.tm_fec = 7;
+ confirm_ctx->buffer[17] = tonemap.tm_fec;
+
+ tonemap.tm_gi = 5;
+ confirm_ctx->buffer[18] = tonemap.tm_gi;
+
+ tonemap.modulation_list[3] = 31;
+ memcpy(&confirm_ctx->buffer[19], tonemap.modulation_list, LIBSPID_EOC_MODULATION_LIST_MAX_SIZE);
+ }
+ }
+
+ confirm_ctx->tail = ETH_DATA_LEN;
+
+ return MME_SUCCESS;
+}
+
+mme_error_t
+mme_listen (mme_ctx_t *ctx, char *iface, unsigned char *source,
+ mme_listen_cb_t listen_cb, unsigned int tout)
+{
+ unsigned int result_len;
+ char data[4];
+
+ /* protect from null pointers */
+ if (ctx == NULL || iface == NULL || source == NULL) return MME_ERROR_GEN;
+ /* check if ctx has been inititalized */
+ if (ctx->status == MME_STATUS_INIT) return MME_ERROR_NOT_INIT;
+
+ data[0] = 0x00;
+ data[1] = 0x13;
+ data[2] = 0xD7;
+
+ if (ctx->mmtype == (MME_TYPE_VS_UPDATE_END | MME_TYPE_IND))
+ {
+ if (memcmp(source, "\x00\x11\x22\x33\x44\xee", LIBSPID_MAC_BIN_LEN) == 0)
+ data[3] = LIBSPID_UPDATE_END_FLASH_ERROR;
+ else
+ data[3] = LIBSPID_UPDATE_END_SUCCESS;
+ }
+ else if (ctx->mmtype == (MME_TYPE_VS_UPDATE_TRANSFER | MME_TYPE_IND))
+ {
+ if (memcmp(source, "\x00\x11\x22\x33\x44\xee", LIBSPID_MAC_BIN_LEN) == 0)
+ data[3] = LIBSPID_UPDATE_TRANSFER_FAILED;
+ else
+ data[3] = LIBSPID_UPDATE_TRANSFER_SUCCESS;
+ }
+
+ mme_put(ctx, data, 4, &result_len);
+
+ return MME_SUCCESS;
+}
+
diff --git a/cleopatre/devkit/tests/managerd/utests/override/src/libspid_stub.c b/cleopatre/devkit/tests/managerd/utests/override/src/libspid_stub.c
new file mode 100644
index 0000000000..5c695777ca
--- /dev/null
+++ b/cleopatre/devkit/tests/managerd/utests/override/src/libspid_stub.c
@@ -0,0 +1,219 @@
+/* SPC300-eoc bundle {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file devkit/tests/onlined/utests/override/src/libspid_stub.c
+ * \brief Stub functions for some libspid functions used in onlined daemon
+ * \ingroup onlined
+ *
+ * Functions definition
+ */
+#include <check.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <linux/if_ether.h>
+#include <fcntl.h>
+#include "path.h"
+#include "libspid.h"
+
+#include "stub.h"
+
+static int test_nr;
+
+static char label_table[2][MAX_ITEM_NB][64];
+static char value_table[2][MAX_ITEM_NB][64];
+
+/**
+ * Get the NVRAM content.
+ *
+ * \return error type (LIBSPID_SUCCESS if success)
+ * \return LIBSPID_ERROR_PARAM: bad input parameters
+ * \return LIBSPID_ERROR_NOT_FOUND: key not found or no more
+ * line to read
+ * \return LIBSPID_ERROR_SYSTEM: system error, see errno
+ */
+libspid_error_t libspid_system_get_nvram(spc300_nvram_t *nvram)
+{
+ if (nvram == NULL)
+ return LIBSPID_ERROR_PARAM;
+
+ // correct response
+ if ((test_nr == 0) || (test_nr == 2))
+ {
+ strcpy(nvram->product_name, "SPiDCOMmodem1Test");
+ nvram->img_0_offset = 4;
+ nvram->eth_port_nb = 4;
+ }
+ // returns LIBSPID_ERROR_SYSTEM
+ else if (test_nr == 1)
+ {
+ test_nr++;
+ return LIBSPID_ERROR_SYSTEM;
+ }
+ else{}
+
+ return LIBSPID_SUCCESS;
+}
+
+void libspid_system_reboot(void)
+{
+}
+
+libspid_error_t
+libspid_image_get_index (const char *mtd_path, int *index)
+{
+ *index = 0;
+ return LIBSPID_SUCCESS;
+}
+
+libspid_error_t libspid_config_read_item (const char *filename, const char *label, char *value, int buffer_len)
+{
+ int i, conf;
+ conf = (!strcmp (filename, "conf") ? CONF_TABLE_INDEX : INFO_TABLE_INDEX);
+ for(i = 0; i < MAX_ITEM_NB; i++)
+ {
+ if(!strcmp (label, label_table[conf][i]))
+ {
+ strcpy (value, value_table[conf][i]);
+ return LIBSPID_SUCCESS;
+ }
+ }
+ return LIBSPID_ERROR_NOT_FOUND;
+}
+
+libspid_error_t libspid_config_write_item(const char *filename, const char *label, const char *value)
+{
+ int i, conf;
+ conf = (!strcmp (filename, "conf") ? CONF_TABLE_INDEX : INFO_TABLE_INDEX);
+ for (i = 0; i < MAX_ITEM_NB; i++)
+ {
+ if(label_table[conf][i][0] == '\0')
+ break;
+ if(!strcmp (label_table[conf][i], label))
+ {
+ strcpy (value_table[conf][i], value);
+ return LIBSPID_SUCCESS;
+ }
+ }
+ if(i >= MAX_ITEM_NB)
+ return LIBSPID_ERROR_NO_SPACE;
+ strcpy (label_table[conf][i], label);
+ strcpy (value_table[conf][i], value);
+ return LIBSPID_SUCCESS;
+}
+
+libspid_error_t libspid_system_save_file(const char *filename)
+{
+ return LIBSPID_SUCCESS;
+}
+
+libspid_error_t libspid_image_get_desc(libspid_image_desc_type_t type, spidcom_image_desc_t *image_desc, char *mtd_name)
+{
+ memset (image_desc, '\0', sizeof(spidcom_image_desc_t));
+ strcpy (image_desc->version, IMAGE_DESC_VERSION);
+
+ return LIBSPID_SUCCESS;
+}
+
+libspid_error_t
+libspid_eoc_upgrade_local_image (char *file)
+{
+ return LIBSPID_SUCCESS;
+}
+
+libspid_error_t
+libspid_image_select (libspid_image_select_t select)
+{
+ return LIBSPID_SUCCESS;
+}
+
+libspid_error_t
+libspid_image_get_running_version (char *image_version)
+{
+ memset (image_version, '\0', LIBSPID_IMAGE_VERSION_STR_MAX_LEN);
+ strcpy (image_version, IMAGE_DESC_VERSION);
+
+ return LIBSPID_SUCCESS;
+}
+
+libspid_error_t
+libspid_mac_bin_to_str (const unsigned char *bin, char *str)
+{
+ return LIBSPID_SUCCESS;
+}
+
+libspid_error_t
+libspid_system_file_update_warn (pid_t tx_pid, const char *filename)
+{
+ return LIBSPID_SUCCESS;
+}
+
+int
+MD5_Init (MD5_CTX *c)
+{
+ return 0;
+}
+
+int
+MD5_Update (MD5_CTX *c, const void *data, size_t len)
+{
+ return 0;
+}
+
+int
+MD5_Final (unsigned char *md, MD5_CTX *c)
+{
+ return 0;
+}
+
+libspid_error_t
+libspid_config_read_line (const char *filename, const char* delimiters,
+ char *key, unsigned int *elt_number, char *elt[],
+ char *buffer, unsigned int buffer_len)
+{
+ return LIBSPID_SUCCESS;
+}
+
+libspid_error_t
+libspid_config_write_line (const char *filename, const char delimiter,
+ const char *key, unsigned int elt_number, char *elt[])
+{
+ return LIBSPID_SUCCESS;
+}
+
+libspid_error_t
+libspid_network_get_ip (const char *interface, libspid_ip_t *ip)
+{
+ return LIBSPID_SUCCESS;
+}
+
+libspid_error_t
+libspid_ip_str_to_bin (const char *str, unsigned char *bin)
+{
+ return LIBSPID_SUCCESS;
+}
+
+libspid_error_t
+libspid_ip_bin_to_str (const unsigned char *bin, char *str)
+{
+ return LIBSPID_SUCCESS;
+}
+
+libspid_error_t
+libspid_network_set_ip (const char *interface, const libspid_ip_t *ip)
+{
+ return LIBSPID_SUCCESS;
+}
+
+/* as each unit test is independant, you should not have a common
+ * test_nb variable between all test files but stub this function for
+ * each test file
+ */
diff --git a/cleopatre/devkit/tests/managerd/utests/override/src/misc_stub.c b/cleopatre/devkit/tests/managerd/utests/override/src/misc_stub.c
new file mode 100644
index 0000000000..dfae7cdea0
--- /dev/null
+++ b/cleopatre/devkit/tests/managerd/utests/override/src/misc_stub.c
@@ -0,0 +1,43 @@
+/* Cleopatre project {{{
+ *
+ * Copyright (C) 2011 SPiDCOM Technologies
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file override/src/misc_stub.c
+ * \brief Stub for some Linux functions
+ * \ingroup Cleopatre - managerd
+ */
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <setjmp.h>
+#include "stub.h"
+
+static int test_fd;
+
+void __assert_fail (__const char *__assertion, __const char *__file,
+ unsigned int __line, __const char *__function)
+{
+ check_ctx.assert_id = check_ctx.test_id;
+ longjmp (check_ctx.jmp_env, check_ctx.assert_id);
+}
+
+FILE *fopen (const char *path, const char *mode)
+{
+ switch(test_id)
+ {
+ case TEST_GET_VERSION:
+ test_fd = open (PLC_VERSION_FILE, O_RDONLY);
+ break;
+ case TEST_ETH_STATS:
+ test_fd = open (NET_DEV_FILE, O_RDONLY);
+ break;
+ default:
+ return NULL;
+ }
+ return fdopen (test_fd, "r");
+}
+
diff --git a/cleopatre/devkit/tests/managerd/utests/src/vs_eoc_mme_utests.c b/cleopatre/devkit/tests/managerd/utests/src/vs_eoc_mme_utests.c
index 4402a524ff..e312049011 100644
--- a/cleopatre/devkit/tests/managerd/utests/src/vs_eoc_mme_utests.c
+++ b/cleopatre/devkit/tests/managerd/utests/src/vs_eoc_mme_utests.c
@@ -27,21 +27,14 @@
#include "vs_eoc_mme.h"
#include "vs_mme.h"
+#include "stub.h"
+
#define BR_MAC_ADDR "\x00\x13\xd7\x00\x00\x10"
#define LOCAL_SLAVE_CONF_FILE "testfiles/slave.conf"
-static struct check_ctx {
- int assert_id;
- int test_id;
- jmp_buf jmp_env;
-
-} check_ctx;
-
-enum test_id {
- TEST_GET_DEVICE_INFO = 0
-};
+struct check_ctx_st check_ctx;
-enum test_id test_id;
+enum test_id_en test_id;
struct managerd_ctx ctx;
struct managerd_ctx *pctx = &ctx;
@@ -53,25 +46,6 @@ static char confirm_buffer[1518];
static MME_t *request = (MME_t *)request_buffer;
static MME_t *confirm = (MME_t *)confirm_buffer;
-
-/*
-######################################
-# FUNCTION STUB
-# (redefinition of libc functions)
-######################################
-*/
-void __assert_fail (__const char *__assertion, __const char *__file,
- unsigned int __line, __const char *__function)
-{
- check_ctx.assert_id = check_ctx.test_id;
- longjmp (check_ctx.jmp_env, check_ctx.assert_id);
-}
-
-int bridge_send(struct managerd_ctx *ctx, uint8_t *buffer, int len)
-{
- return 0;
-}
-
/* fixtures - run before and after each unit test */
void setup(void)
{
@@ -144,14 +118,12 @@ START_TEST (test_get_device_info_success)
vs_eoc_get_device_info_cnf_t *get_device_info_cnf;
char model_no[64] = "SPiDCOMmodem1Test";
unsigned int eth_port_nb = 4;
- char sw_version[16] = "eoc-alpha0-test";
char downstream_attenuation = 0;
- int rc;
test_id = TEST_GET_DEVICE_INFO;
- rc = system ("mkdir -p /tmp/utests/etc");
- rc = system ("cp " LOCAL_SLAVE_CONF_FILE " " LIBSPID_CONF_ROOT_PATH);
+ system ("mkdir -p /tmp/utests/etc");
+ system ("cp " LOCAL_SLAVE_CONF_FILE " " LIBSPID_CONF_ROOT_PATH);
get_device_info_cnf = (vs_eoc_get_device_info_cnf_t *)((unsigned char*)confirm + sizeof(MME_t));
/* fill request */
@@ -171,7 +143,7 @@ START_TEST (test_get_device_info_success)
fail_if ((get_device_info_cnf->result != 0), "vs_mme_eoc_get_device_info success (7)");
fail_if (memcmp(get_device_info_cnf->model_no, model_no, sizeof(model_no)), "vs_mme_eoc_get_device_info success (8)");
fail_if ((get_device_info_cnf->eth_port_nb != eth_port_nb), "vs_mme_eoc_get_device_info success (9)");
- fail_if (memcmp (get_device_info_cnf->sw_version, sw_version, sizeof(sw_version)), "vs_mme_eoc_get_device_info success (10)");
+ fail_if (memcmp (get_device_info_cnf->sw_version, IMAGE_DESC_VERSION, strlen (IMAGE_DESC_VERSION)), "vs_mme_eoc_get_device_info success (10)");
fail_if ((get_device_info_cnf->downstream_attenuation != downstream_attenuation), "vs_mme_eoc_get_device_info success (11)");
}
diff --git a/cleopatre/devkit/tests/managerd/utests/src/vs_mme_utests.c b/cleopatre/devkit/tests/managerd/utests/src/vs_mme_utests.c
index b71d47500d..54d3471f69 100644
--- a/cleopatre/devkit/tests/managerd/utests/src/vs_mme_utests.c
+++ b/cleopatre/devkit/tests/managerd/utests/src/vs_mme_utests.c
@@ -15,21 +15,13 @@
*/
#include <check.h>
-#include <stdio.h>
#include <string.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <sys/time.h> /* for select() */
#include <linux/if_ether.h> /* for ETH_ALEN */
-#include <unistd.h>
-#include <setjmp.h>
-#include <assert.h>
-#include <errno.h>
#include "libmme.h"
-#include "libspid.h"
-#include "bridge.h"
#include "vs_mme.h"
+#include "stub.h"
+
#define DEBUG 1
#ifdef DEBUG
@@ -38,32 +30,9 @@
#define TRACE(...)
#endif
-#define IMAGE_DESC_VERSION "eoc-alpha0-test"
-#define PLC_FIRMWARE_VERSION "0.1-rc3-1-unit_test"
-
-#define PLC_VERSION_FILE "testfiles/plc_version"
-#define NET_DEV_FILE "testfiles/net_dev"
-
-#define BR_MAC_ADDR "\x00\x13\xd7\x00\x00\x10"
-
-#define MAX_ITEM_NB 8
-#define CONF_TABLE_INDEX 0
-#define INFO_TABLE_INDEX 1
-
-static struct check_ctx {
- int assert_id;
- int test_id;
- jmp_buf jmp_env;
-
-} check_ctx;
-
-enum test_id {
- TEST_GET_VERSION = 0,
- TEST_ETH_STATS,
- TEST_NB
-};
+struct check_ctx_st check_ctx;
-enum test_id test_id;
+enum test_id_en test_id;
/** local variables */
static struct managerd_ctx managerd_ctx;
@@ -72,56 +41,6 @@ static char request_buffer[1518];
static char confirm_buffer[1518];
static MME_t *request = (MME_t *)request_buffer;
static MME_t *confirm = (MME_t *)confirm_buffer;
-int test_fd;
-
-unsigned char label_table[2][MAX_ITEM_NB][64];
-unsigned char value_table[2][MAX_ITEM_NB][64];
-unsigned char msg_buf[ETH_FRAME_LEN]; /* local buffer to store netlink messages */
-
-/*
- ######################################
- # FUNCTION STUB
- # (redefinition of libc functions)
- ######################################
-*/
-void __assert_fail (__const char *__assertion, __const char *__file,
- unsigned int __line, __const char *__function)
-{
- check_ctx.assert_id = check_ctx.test_id;
- longjmp (check_ctx.jmp_env, check_ctx.assert_id);
-}
-
-FILE *fopen (const char *path, const char *mode)
-{
- switch(test_id)
- {
- case TEST_GET_VERSION:
- test_fd = open (PLC_VERSION_FILE, O_RDONLY);
- break;
- case TEST_ETH_STATS:
- test_fd = open (NET_DEV_FILE, O_RDONLY);
- break;
- default:
- return NULL;
- }
- return fdopen (test_fd, "r");
-}
-
-
-void dump_table (unsigned char table[MAX_ITEM_NB][64])
-{
- int i;
- for (i = 0; i < MAX_ITEM_NB; i++)
- printf ("%s-", table[i]);
- printf ("\n");
-}
-
-
-
-int bridge_send (struct managerd_ctx *ctx, uint8_t *buffer, int len)
-{
- return 0;
-}
/* fixtures - run before and after each unit test */
void setup(void)
@@ -129,7 +48,7 @@ void setup(void)
check_ctx.test_id = 0;
check_ctx.assert_id = 0;
memcpy (ctx->br_mac_addr, BR_MAC_ADDR, ETH_ALEN);
- }
+}
void teardown(void)
{
@@ -327,8 +246,7 @@ START_TEST (test_eth_stats_get_success)
&& (eth_stats_cnf->tx_dropped == 1010)
&& (eth_stats_cnf->tx_fifo == 1111)
&& (eth_stats_cnf->tx_collisions == 1212)
- && (eth_stats_cnf->tx_carrier == 1313)
- ,
+ && (eth_stats_cnf->tx_carrier == 1313),
"vs_eth_stats_get success");
}
END_TEST
@@ -346,9 +264,9 @@ TCase *vs_eth_stats_tcase (void)
return tc;
}
-Suite* managerd_mme_suite(void)
+Suite* vs_mme_suite(void)
{
- Suite *s = suite_create ("MANAGERD_MME");
+ Suite *s = suite_create ("vs_mme");
suite_add_tcase (s, vs_get_version_tcase ());
suite_add_tcase (s, vs_eth_stats_tcase ());
return s;
@@ -356,13 +274,10 @@ Suite* managerd_mme_suite(void)
int main(void)
{
+ Suite *s = suite_create ("vs_mme");
int number_failed = 0;
- Suite *s;
-
- s = managerd_mme_suite ();
-
SRunner *sr = srunner_create (s);
-
+ srunner_add_suite (sr, vs_mme_suite ());
//srunner_set_fork_status (sr, CK_NOFORK);
srunner_set_fork_status (sr, CK_FORK);
srunner_run_all (sr, CK_NORMAL);
diff --git a/cleopatre/devkit/tests/plcd/Makefile b/cleopatre/devkit/tests/plcd/Makefile
deleted file mode 100644
index d355d358fe..0000000000
--- a/cleopatre/devkit/tests/plcd/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-PRJ_BASE = ../../plcd
-FILES = eoc
-
-LIBMME_DIR = ../../../application/libmme
-LIBSPID_DIR=../../../application/libspid
-LIBMME_TEST_DIR = ../libmme/utests
-LIBSPID_TEST_DIR = ../libspid/utests
-LIBMME_TEST_OBJ = $(wildcard $(LIBMME_TEST_DIR)/obj/prj/*.o)
-LIBSPID_TEST_OBJ = $(wildcard $(LIBSPID_TEST_DIR)/obj/prj/*.o)
-
-EXTRA_CFLAGS = -I$(LIBMME_DIR)/inc -I$(LIBSPID_DIR)/inc -I../../../include
-EXTRA_LIBS =
-
-PREBINS =
-
-include ../../tests/utests_makerules
-
-make_libs:
- $(MAKE) -C $(LIBMME_TEST_DIR)
- $(MAKE) -C $(LIBSPID_TEST_DIR)
-
-#OVERRIDE_VARS = CC=gcc AR=ar
-
-.PHONY: all clean make_libs
-
diff --git a/cleopatre/devkit/tests/plcd/inc/check_event.h b/cleopatre/devkit/tests/plcd/inc/check_event.h
deleted file mode 100644
index 4d502c7e8c..0000000000
--- a/cleopatre/devkit/tests/plcd/inc/check_event.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef _check_event_h
-#define _check_event_h
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file devkit/tests/plcd/utests/inc/check_event.h
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-
-typedef enum {
- EVENT_NONE = 0,
- EVENT_REFRESH_STATUS_1,
-} check_event_t;
-
-
-#endif /* _check_event_h */
diff --git a/cleopatre/devkit/tests/plcd/inc/eoc_utests.h b/cleopatre/devkit/tests/plcd/inc/eoc_utests.h
deleted file mode 100755
index 6225b7b565..0000000000
--- a/cleopatre/devkit/tests/plcd/inc/eoc_utests.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef eoc_utests_h
-#define eoc_utests_h
-/* Cleopatre project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file eoc_utests.h
- * \brief interfaces for unitary tests of functions bellonging to module eoc.c
- * \ingroup plcd
- *
- * this file content interfaces and exported macros, variables... For the
- * unitary tests of functions bellonging to module eoc.c
- */
-
-#include <sys/types.h>
-#include "libmme.h"
-#include "libspid.h"
-#include "plcd.h"
-
-/* FUNCTION STUB */
-ssize_t sendmsg (int socket, const struct msghdr *message, int flags);
-int recvmsg (int s, struct msghdr *message, int flags);
-int hpav_compute_dak (const char *dpw, unsigned char *dak);
-
-/* PLCD FUNCTION DECLARATIONS */
-int hpav_send_white_list (const plcd_ctx_t *plcd_ctx);
-
-#endif /* mme_utests_h */
diff --git a/cleopatre/devkit/tests/plcd/inc/hpav_utests.h b/cleopatre/devkit/tests/plcd/inc/hpav_utests.h
deleted file mode 100644
index 68c158d386..0000000000
--- a/cleopatre/devkit/tests/plcd/inc/hpav_utests.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef hpav_utests_h
-#define hpav_utests_h
-/* Cleopatre project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hpav_utests.h
- * \brief interfaces for unitary tests of libMME
- * \ingroup Cleopatre - LibMME
- *
- * this file content interfaces and exported macros, variables... For the
- * unitary tests of libMME
- */
-
-#include <sys/types.h>
-#include "libmme.h"
-#include "libspid.h"
-#include "plcd.h"
-
-/* FUNCTION STUB */
-ssize_t sendmsg (int socket, const struct msghdr *message, int flags);
-int recvmsg(int s, struct msghdr *message, int flags);
-
-/* PLCD FUNCTION DECLARATIONS */
-int hpav_send_mac_address (const plcd_ctx_t *plcd_ctx, const unsigned char *mac_addr);
-int hpav_send_cco_preferred (const plcd_ctx_t *plcd_ctx, const int is_cco_preferred);
-int hpav_send_was_cco (const plcd_ctx_t *plcd_ctx, const int is_was_cco);
-int hpav_compute_nmk (const char *npw, unsigned char *nmk);
-int hpav_compute_dak (const char *dpw, unsigned char *dak);
-int hpav_send_key (const plcd_ctx_t *plcd_ctx, const unsigned char *nmk, const unsigned char *nid, const char *sl);
-int hpav_send_dak (const plcd_ctx_t *plcd_ctx, const unsigned char *dak);
-int hpav_send_mfg_hfid (const plcd_ctx_t *plcd_ctx, const char *mfg_hfid);
-int hpav_send_user_hfid (const plcd_ctx_t *plcd_ctx, const char *user_hfid);
-int hpav_send_avln_hfid (const plcd_ctx_t *plcd_ctx, const char *avln_hfid);
-int hpav_send_tonemask (const plcd_ctx_t *plcd_ctx, const unsigned char *tonemask);
-int hpav_send_start (const plcd_ctx_t *plcd_ctx);
-
-#endif /* mme_utests_h */
-
diff --git a/cleopatre/devkit/tests/plcd/inc/plcd_utests.h b/cleopatre/devkit/tests/plcd/inc/plcd_utests.h
deleted file mode 100644
index 283eff559f..0000000000
--- a/cleopatre/devkit/tests/plcd/inc/plcd_utests.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef mme_utests_h
-#define mme_utests_h
-/* Cleopatre project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file mme_utests.h
- * \brief interfaces for unitary tests of libMME
- * \ingroup Cleopatre - LibMME
- *
- * this file content interfaces and exported macros, variables... For the
- * unitary tests of libMME
- */
-
-#include <sys/types.h>
-#include "libmme.h"
-#include "libspid.h"
-#include "plcd.h"
-
-/* VARIABLE STUB */
-#define NETLINK_PLC NETLINK_ROUTE /* to enable a compilation on X86 */
-
-/* FUNCTION STUB */
-inline static int hpav_init (plcd_ctx_t *plcd_ctx)
-{
- return 0;
-}
-
-static inline libspid_error_t utests_libspid_system_get_nvram(spc300_nvram_t *nvram)
-{
- return LIBSPID_SUCCESS;
-}
-
-/* PLCD FUNCTION DECLARATIONS */
-/* plcd.c*/
-int plcd_init (plcd_ctx_t *ctx);
-void plcd_uninit (plcd_ctx_t *ctx);
-
-#endif /* mme_utests_h */
diff --git a/cleopatre/devkit/tests/plcd/inc/stub.h b/cleopatre/devkit/tests/plcd/inc/stub.h
deleted file mode 100644
index 67fb3079cb..0000000000
--- a/cleopatre/devkit/tests/plcd/inc/stub.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _stub_h
-#define _stub_h
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file /home/lefranc/Dev/git/cleopatre/devkit/tests/plcd/utests/inc/stub.h
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-
-
-
-#endif /* _stub_h */
diff --git a/cleopatre/devkit/tests/plcd/src/eoc_utests.c b/cleopatre/devkit/tests/plcd/src/eoc_utests.c
deleted file mode 100755
index 84c371e1c1..0000000000
--- a/cleopatre/devkit/tests/plcd/src/eoc_utests.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/* Cleopatre project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file eoc_utests.c
- * \brief Unitary tests for plcd
- * \ingroup Cleopatre - plcd
- *
- * This file content all the unitary tests for eoc, part of plcd
- * (the interface between the PLC driver and the Linux filesystem).
- */
-
-#include <check.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/time.h> /* for select() */
-#include <linux/if_ether.h> /* for ETH_ALEN */
-#include <unistd.h>
-#include <errno.h>
-#include "plcd.h"
-#include "eoc_utests.h"
-
-#define DEBUG 1
-
-#ifdef DEBUG
-#define TRACE(...) printf("HPAV UTESTS: " __VA_ARGS__)
-#else
-#define TRACE(...)
-#endif
-
-/** local defines */
-#define MAC_ADDR "00:11:22:33:44:55" /* mac addr that will be used for testing */
-#define PLC_ADDR "FF:EE:DD:98:76:54" /* mac addr that will be used for testing */
-
-/** local variables */
-plcd_ctx_t plcd_ctx;
-plcd_ctx_t *ctx = &plcd_ctx;
-
-unsigned char msg_buf[ETH_FRAME_LEN]; /* local buffer to store netlink messages */
-
-/*
-######################################
-# FUNCTION STUB
-# (redefinition of glibc functions)
-######################################
-*/
-ssize_t sendmsg (int socket, const struct msghdr *message, int flags)
-{
- struct nlmsghdr *nlh;
-
- nlh = (struct nlmsghdr *)(message->msg_iov->iov_base);
-
- /* store message to local buffer */
- memcpy(msg_buf, nlh, message->msg_iov->iov_len);
-
- return 1;
-}
-
-int recvmsg(int s, struct msghdr *message, int flags)
-{
- struct nlmsghdr *nlh;
- MME_t *mme_hdr;
-
- nlh = (struct nlmsghdr *)(message->msg_iov->iov_base);
- mme_hdr = (MME_t *)NLMSG_DATA(msg_buf);
-
- /* change mme type to CNF */
- mme_hdr->mmtype = (mme_hdr->mmtype & ~MME_TYPE_MASK) | MME_TYPE_CNF;
-
- /* copy local buffer to response message */
- memcpy(nlh, msg_buf, message->msg_iov->iov_len);
-
- return 1;
-}
-
-int select(int nfds, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout)
-{
- return 1;
-}
-
-int hpav_send_single_value (const plcd_ctx_t *plcd_ctx, unsigned int mmtype, const void *value, unsigned int length)
-{
- unsigned char sta_num = 0x01;
- unsigned char mac1[ETH_ALEN] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55};
- unsigned char tei1 = 0x20;
- unsigned char authorisation1 = 0x01;
- unsigned char rfol1 = 0x03;
- unsigned char stime1[4] = {0x12, 0x34, 0x56, 0x78};
- unsigned char etime1[4] = {0xaa, 0xbb, 0xcc, 0xdd};
- unsigned char dak1[8] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88};
- unsigned char action1 = 0x01;
-
- fail_if( memcmp(value, &sta_num, 1) != 0, "fail: wrong number of STAs" );
- fail_if( memcmp(value + 1, mac1, ETH_ALEN) != 0, "fail: wrong MAC1 address" );
- fail_if( memcmp(value + 7, &tei1, 1) != 0, "fail: wrong TEI1" );
- fail_if( memcmp(value + 8, &authorisation1, 1) != 0, "fail: wrong authorisation1" );
- fail_if( memcmp(value + 9, &rfol1, 1) != 0, "fail: wrong RF output value 1 (rfol1)" );
- fail_if( memcmp(value + 10, stime1, 4) != 0, "fail: wrong start of time limitation (stime1)" );
- fail_if( memcmp(value + 14, etime1, 4) != 0, "fail: wrong end of time limitation (etime1)" );
- fail_if( memcmp(value + 18, dak1, 8) != 0, "fail: wrong dak1" );
- fail_if( memcmp(value, &action1, 1) != 0, "fail: wrong action1" );
-
- return 0;
-}
-
-int hpav_compute_dak (const char *dpw, unsigned char *dak)
-{
- dak[0] = 0x11;
- dak[1] = 0x22;
- dak[2] = 0x33;
- dak[3] = 0x44;
- dak[4] = 0x55;
- dak[5] = 0x66;
- dak[6] = 0x77;
- dak[7] = 0x88;
-
- return 0;
-}
-
-/* fixtures - run before and after each unit test */
-void setup(void)
-{
- int i;
- char pa[] = PLC_ADDR;
- char *s, *e;
-
- ctx->hardware_info_path = (char *)malloc(64);
- ctx->hpav_info_path = (char *)malloc(64);
- ctx->hpav_conf_path = (char *)malloc(64);
-
- /* initialize plcd context */
- strcpy(ctx->hardware_info_path, LIBSPID_HARDWARE_INFO_PATH);
- strcpy(ctx->hpav_info_path, LIBSPID_HPAV_INFO_PATH);
- strcpy(ctx->hpav_conf_path, LIBSPID_HPAV_CONF_PATH);
- ctx->plc_sock = 0;
- ctx->nvram = (spc300_nvram_t *) malloc(sizeof(spc300_nvram_t));
- s = pa;
- for (i = 0; i < 6; ++i)
- {
- ctx->nvram->plc_address[i] = s ? strtoul (s, &e, 16) : 0;
- if (s)
- s = (*e) ? e + 1 : e;
- }
-}
-
-void teardown(void)
-{
-}
-
-/* --- TEST PROCEDURES --- */
-/** test procedures */
-START_TEST (test_hpav_send_white_list)
-{
- int ret;
-
- ret = hpav_send_white_list(ctx);
- fail_if( ret != 0, "hpav_send_white_list fail" );
-}
-END_TEST
-
-extern Suite* hpav_suite(void)
-{
- Suite *s = suite_create("EOC");
- TCase *tc_core = tcase_create("Core");
-
- tcase_add_checked_fixture (tc_core, setup, teardown);
-
- //Test hpav_send_white_list
- tcase_add_test(tc_core, test_hpav_send_white_list);
-
- suite_add_tcase(s, tc_core);
- return s;
-}
-
-int main(void)
-{
- int number_failed = 0;
- Suite *s;
-
- //Run hpav tests
- s = hpav_suite();
-
- SRunner *sr = srunner_create(s);
- //srunner_set_fork_status (sr, CK_NOFORK);
- srunner_set_fork_status (sr, CK_FORK);
- 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/plcd/src/event_utests.c b/cleopatre/devkit/tests/plcd/src/event_utests.c
deleted file mode 100644
index 48b0dccf58..0000000000
--- a/cleopatre/devkit/tests/plcd/src/event_utests.c
+++ /dev/null
@@ -1,777 +0,0 @@
-/* Cleopatre project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file check_event.c
- * \brief Unitary tests for plcd
- * \ingroup Cleopatre - plcd
- *
- * This file content all the unitary tests for event, part of plcd
- * (the interface between the PLC driver and the Linux filesystem).
- */
-
-#include <check.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/time.h> /* for select() */
-#include <linux/if_ether.h> /* for ETH_ALEN */
-#include <unistd.h>
-#include <setjmp.h>
-#include <assert.h>
-#include <errno.h>
-#include "plcd.h"
-#include "stub.h"
-#include "libmme.h"
-#include "libspid.h"
-
-#define DEBUG 1
-
-#ifdef DEBUG
-#define TRACE(...) printf("EVENT UTESTS: " __VA_ARGS__)
-#else
-#define TRACE(...)
-#endif
-
-#define HPAV_CONF_TMP_PATH "hpav_tmp.conf"
-#define HPAV_INFO_TMP_PATH "hpav_tmp.info"
-
-#define HPAV_CONF_FILE_BAD_STATUS "../testfiles/hpav_bad_status.conf"
-#define HPAV_CONF_FILE_BAD_CCO "../testfiles/hpav_bad_cco.conf"
-#define HPAV_CONF_FILE_3 "../testfiles/hpav_3.conf"
-#define HPAV_CONF_FILE_4 "../testfiles/hpav_4.conf"
-
-#define HPAV_INFO_FILE_1 "../testfiles/hpav_1.info"
-
-static struct check_ctx {
- int assert_id;
- int test_id;
- jmp_buf jmp_env;
-
-} check_ctx;
-
-#define CHECK_ASSERT(result, id, jmpbuf) if(0 == (result = setjmp (jmpbuf)))
-
-/** local defines */
-#define MAC_ADDR "AA:BB:CC:12:34:56" /* mac addr that will be used for testing */
-#define PLC_ADDR "FF:EE:DD:98:76:54" /* mac addr that will be used for testing */
-#define MAX_ITEM_NB 8
-#define CONF_TABLE_INDEX 0
-#define INFO_TABLE_INDEX 1
-
-/** local variables */
-static plcd_ctx_t plcd_ctx;
-static plcd_ctx_t *ctx = &plcd_ctx;
-static int is_info_manager_needed, is_save_conf_needed;
-static mme_ctx_t mme_ctx;
-static char mme_buffer[256];
-unsigned char label_table[2][MAX_ITEM_NB][64];
-unsigned char value_table[2][MAX_ITEM_NB][64];
-unsigned char msg_buf[ETH_FRAME_LEN]; /* local buffer to store netlink messages */
-
-extern int check_sc_start (plcd_ctx_t *ctx);
-extern int refresh_status (plcd_ctx_t *ctx, mme_ctx_t *status_ctx, int *is_save_conf_needed, int *is_info_manager_needed);
-
-
-/*
- ######################################
- # FUNCTION STUB
- # (redefinition of libc functions)
- ######################################
-*/
-void __assert_fail (__const char *__assertion, __const char *__file,
- unsigned int __line, __const char *__function)
-{
- check_ctx.assert_id = check_ctx.test_id;
- longjmp (check_ctx.jmp_env, check_ctx.assert_id);
-}
-
-ssize_t sendmsg (int socket, const struct msghdr *message, int flags)
-{
- struct nlmsghdr *nlh;
-
- nlh = (struct nlmsghdr *)(message->msg_iov->iov_base);
-
- /* store message to local buffer */
- memcpy(msg_buf, nlh, message->msg_iov->iov_len);
-
- return 1;
-}
-
-int recvmsg(int s, struct msghdr *message, int flags)
-{
- struct nlmsghdr *nlh;
- MME_t *mme_hdr;
-
- nlh = (struct nlmsghdr *)(message->msg_iov->iov_base);
- mme_hdr = (MME_t *)NLMSG_DATA(msg_buf);
-
- /* change mme type to CNF */
- mme_hdr->mmtype = (mme_hdr->mmtype & ~MME_TYPE_MASK) | MME_TYPE_CNF;
-
- /* copy local buffer to response message */
- memcpy(nlh, msg_buf, message->msg_iov->iov_len);
-
- return 1;
-}
-
-int select(int nfds, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout)
-{
- return 1;
-}
-
-void syslog(int priority, const char *format, ...)
-{
- return;
-}
-
-int hpav_send_single_value (const plcd_ctx_t *plcd_ctx, unsigned int mmtype, const void *value, unsigned int length)
-{
- int len;
- mme_init (&mme_ctx, mmtype, mme_buffer, sizeof(mme_buffer));
- mme_put (&mme_ctx, value, length, &len);
- return 0;
-}
-
-mme_error_t mme_init (mme_ctx_t *ctx, const mme_type_t mmtype, unsigned char *buffer, const unsigned int length)
-{
- ctx->buffer = buffer;
- ctx->mmtype = mmtype;
- ctx->length = length;
- ctx->head = 0;
- ctx->tail = 0;
- return MME_SUCCESS;
-}
-
-mme_error_t mme_push (mme_ctx_t *ctx, const void *data, unsigned int length, unsigned int *result_length)
-{
- return MME_SUCCESS;
-}
-
-mme_error_t mme_pull (mme_ctx_t *ctx, void *data, unsigned int length, unsigned int *result_length)
-{
- *result_length = length;
- memcpy(data, (unsigned char *)(ctx->buffer + ctx->head), length);
- ctx->head += length;
- //printf ("head=%d, data=%02x\n", ctx->head, *((unsigned char *)data));
- return MME_SUCCESS;
-}
-
-mme_error_t mme_put (mme_ctx_t *ctx, const void *data, unsigned int length, unsigned int *result_length)
-{
- *result_length = length;
- memcpy( (unsigned char *)(ctx->buffer + ctx->tail), (unsigned char *)data, length );
- ctx->tail += length;
- return MME_SUCCESS;
-}
-
-void dump_table (unsigned char table[MAX_ITEM_NB][64])
-{
- int i;
- for (i = 0; i < MAX_ITEM_NB; i++)
- printf ("%s-", table[i]);
- printf ("\n");
-}
-
-libspid_error_t libspid_config_read_item (const char *filename, const char *label, char *value, int buffer_len)
-{
- int i, conf;
- conf = (!strcmp (filename, "conf") ? CONF_TABLE_INDEX : INFO_TABLE_INDEX);
- for(i = 0; i < MAX_ITEM_NB; i++)
- {
- if(!strcmp (label, label_table[conf][i]))
- {
- strcpy (value, value_table[conf][i]);
- return LIBSPID_SUCCESS;
- }
- }
- return LIBSPID_ERROR_NOT_FOUND;
-}
-
-libspid_error_t libspid_config_write_item(const char *filename, const char *label, const char *value)
-{
- int i, conf;
- conf = (!strcmp (filename, "conf") ? CONF_TABLE_INDEX : INFO_TABLE_INDEX);
- for (i = 0; i < MAX_ITEM_NB; i++)
- {
- if(label_table[conf][i][0] == '\0')
- break;
- if(!strcmp (label_table[conf][i], label))
- {
- strcpy (value_table[conf][i], value);
- return LIBSPID_SUCCESS;
- }
- }
- if(i >= MAX_ITEM_NB)
- return LIBSPID_ERROR_NO_SPACE;
- strcpy (label_table[conf][i], label);
- strcpy (value_table[conf][i], value);
- return LIBSPID_SUCCESS;
-}
-
-extern libspid_error_t libspid_system_save_file(const char *filename)
-{
- return LIBSPID_SUCCESS;
-}
-
-/* fixtures - run before and after each unit test */
-void setup(void)
-{
- plcd_ctx.hpav_conf_path = HPAV_CONF_TMP_PATH;
- plcd_ctx.hpav_info_path = HPAV_INFO_TMP_PATH;
- mme_init (&mme_ctx, MME_TYPE_DRV_STA_STATUS | MME_TYPE_IND, mme_buffer, sizeof(mme_buffer));
- is_info_manager_needed = LIBSPID_FALSE;
- is_save_conf_needed = LIBSPID_FALSE;
- check_ctx.test_id = 0;
- check_ctx.assert_id = 0;
- memset (label_table, '\0', sizeof(label_table));
- memset (value_table, '\0', sizeof(value_table));
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_STATUS, "unassociated");
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_CCO, "station");
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_BACKUP_CCO, "no");
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_SC, "no");
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_SC_BUTTON, "no");
-
-}
-
-void teardown(void)
-{
-}
-
-/***********************************************************
- *
- * check_sc_start() test cases
- *
- *******************************************************/
-
-/* check when plcd_ctx = NULL */
-START_TEST (test_check_sc_start_param_1)
-{
- check_ctx.test_id = 1;
- if(0 == setjmp (check_ctx.jmp_env))
- {
- check_sc_start (NULL);
- fail ("check_sc_start plcd_ctx = NULL (1)");
- }
- fail_unless ((check_ctx.test_id == check_ctx.assert_id),
- "check_sc_start plcd_ctx = NULL (2)");
-}
-END_TEST
-
-/* check if no MME is sent if SC_BUTTON!=yes or SC!=no */
-START_TEST (test_check_sc_start_cond_1)
-{
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_SC_BUTTON, "yes");
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_SC, "yes");
- check_sc_start (&plcd_ctx);
- fail_unless ((mme_ctx.head == mme_ctx.tail),
- "check_sc_start SC_BUTTON=yes, SC=yes");
-
-}
-END_TEST
-
-/* check if no MME is sent if SC_BUTTON!=no or SC!=no */
-START_TEST (test_check_sc_start_cond_2)
-{
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_SC_BUTTON, "no");
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_SC, "no");
- check_sc_start (&plcd_ctx);
- fail_unless ((mme_ctx.head == mme_ctx.tail),
- "check_sc_start SC_BUTTON=no, SC=no");
-
-}
-END_TEST
-
-/* check if MME is sent with SC_JOIN */
-START_TEST (test_check_sc_start_assoc_1)
-{
- unsigned char sc;
- unsigned int length;
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_SC_BUTTON, "yes");
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_SC, "no");
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_STATUS, "unassociated");
-
- check_sc_start (&plcd_ctx);
- mme_pull (&mme_ctx, &sc, 1, &length);
- fail_unless ((MME_DRV_SC_JOIN == sc)
- && (1 == length),
- "check_sc_start SC_JOIN");
-}
-END_TEST
-
-/* check if MME is sent with SC_ADD */
-START_TEST (test_check_sc_start_assoc_2)
-{
- unsigned char sc;
- unsigned int length;
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_SC_BUTTON, "yes");
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_SC, "no");
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_STATUS, "authenticated");
-
- check_sc_start (&plcd_ctx);
- mme_pull (&mme_ctx, &sc, 1, &length);
- fail_unless ((MME_DRV_SC_ADD == sc)
- && (1 == length),
- "check_sc_start SC_ADD");
-}
-END_TEST
-
-TCase *event_refresh_check_sc_start_tcase (void)
-{
- TCase *tc = tcase_create ("check_sc_start");
- tcase_add_checked_fixture (tc, setup, teardown);
- // check STATUS field
- tcase_add_test (tc, test_check_sc_start_param_1);
- tcase_add_test (tc, test_check_sc_start_cond_1);
- tcase_add_test (tc, test_check_sc_start_cond_2);
- tcase_add_test (tc, test_check_sc_start_assoc_1);
- tcase_add_test (tc, test_check_sc_start_assoc_2);
- return (tc);
-}
-
-/***********************************************************
- *
- * refresh_status() test cases
- *
- *******************************************************/
-
-/* check when plcd_ctx = NULL */
-START_TEST (test_refresh_status_param_1)
-{
- check_ctx.test_id = 1;
- if(0 == setjmp (check_ctx.jmp_env))
- {
- refresh_status (NULL, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- fail ("refresh_status plcd_ctx = NULL (1)");
- }
- fail_unless ((check_ctx.test_id == check_ctx.assert_id),
- "refresh status plcd_ctx = NULL (2)");
-}
-END_TEST
-
-/* check when mme_ctx = NULL */
-START_TEST (test_refresh_status_param_2)
-{
- check_ctx.test_id = 2;
- if(0 == setjmp (check_ctx.jmp_env))
- {
- refresh_status (&plcd_ctx, NULL, &is_save_conf_needed, &is_info_manager_needed);
- fail ("refresh_status mme_ctx = NULL (1)");
- }
- fail_unless ((check_ctx.test_id == check_ctx.assert_id),
- "refresh status mme_ctx = NULL (2)");
-}
-END_TEST
-
-/* check when mme_ctx.mmtype has wrong value */
-START_TEST (test_refresh_status_param_3)
-{
- mme_ctx.mmtype = MME_TYPE_DRV_STA_STATUS | MME_TYPE_CNF;
- check_ctx.test_id = 3;
- if(0 == setjmp (check_ctx.jmp_env))
- {
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- fail ("refresh_status mme_ctx.mmtype (1)");
- }
- fail_unless ((check_ctx.test_id == check_ctx.assert_id),
- "refresh status mme_ctx.mmtype (2)");
-}
-END_TEST
-
-/* check when is_save_conf_needed = NULL */
-START_TEST (test_refresh_status_param_4)
-{
- check_ctx.test_id = 4;
- if(0 == setjmp (check_ctx.jmp_env))
- {
- refresh_status (&plcd_ctx, &mme_ctx, NULL, &is_info_manager_needed);
- fail ("refresh_status is_save_conf_needed (1)");
- }
- fail_unless ((check_ctx.test_id == check_ctx.assert_id),
- "refresh status is_save_conf_needed (2)");
-}
-END_TEST
-
-/* check when is_info_manager_needed = NULL */
-START_TEST (test_refresh_status_param_5)
-{
- check_ctx.test_id = 5;
- if(0 == setjmp (check_ctx.jmp_env))
- {
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, NULL);
- fail ("refresh_status is_info_manager_needed (1)");
- }
- fail_unless ((check_ctx.test_id == check_ctx.assert_id),
- "refresh status is_info_manager_needed (2)");
-}
-END_TEST
-
-TCase *event_refresh_status_param_tcase (void)
-{
- TCase *tc = tcase_create ("refresh_status_param");
- tcase_add_checked_fixture (tc, setup, teardown);
- // check params plcd_ctx = NULL
- tcase_add_test (tc, test_refresh_status_param_1);
- // check param mme_ctx = NULL
- tcase_add_test (tc, test_refresh_status_param_2);
- // check param mme_ctx.mmtype has wrong value
- tcase_add_test (tc, test_refresh_status_param_3);
- // check param is_save_conf_needed = NULL
- tcase_add_test (tc, test_refresh_status_param_4);
- // check param is_info_manager_needed = NULL
- tcase_add_test (tc, test_refresh_status_param_5);
- return tc;
-}
-
-/* check assoc status switch to unassociated */
-START_TEST (test_refresh_status_assoc_1)
-{
- unsigned int length;
- char buffer[1024];
-
- mme_put (&mme_ctx, "\x00\x00\x00\x00\x00", 5, &length);
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_STATUS, "unassociated");
-
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- libspid_config_read_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_STATUS, buffer, sizeof(buffer));
-
- fail_unless (!strcmp (buffer, "unassociated")
- && (LIBSPID_FALSE == is_info_manager_needed),
- "STATUS = unassociated");
-}
-END_TEST
-
-/* check assoc status switch to associated */
-START_TEST (test_refresh_status_assoc_2)
-{
- unsigned int length;
- char buffer[1024];
-
- mme_put (&mme_ctx, "\x01\x00\x00\x00\x00", 5, &length);
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_STATUS, "unassociated");
-
-// dump_table (label_table[INFO_TABLE_INDEX]);
-// dump_table (value_table[INFO_TABLE_INDEX]);
-
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- libspid_config_read_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_STATUS, buffer, sizeof(buffer));
-
-// dump_table (label_table[INFO_TABLE_INDEX]);
-// dump_table (value_table[INFO_TABLE_INDEX]);
-
- fail_unless (!strcmp (buffer, "associated")
- && (LIBSPID_TRUE == is_info_manager_needed),
- "STATUS = associated");
-}
-END_TEST
-
-/* check assoc status switch to associated */
-START_TEST (test_refresh_status_assoc_3)
-{
- unsigned int length;
- char buffer[1024];
-
- mme_put (&mme_ctx, "\x02\x00\x00\x00\x00", 5, &length);
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_STATUS, "unassociated");
-
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- libspid_config_read_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_STATUS, buffer, sizeof(buffer));
-
- fail_unless (!strcmp (buffer, "authenticated")
- && (LIBSPID_TRUE == is_info_manager_needed),
- "STATUS = authenticated");
-}
-END_TEST
-
-/* check assoc status wrong value */
-START_TEST (test_refresh_status_assoc_4)
-{
- unsigned int length;
- char buffer[1024];
-
- mme_put (&mme_ctx, "\x03\x00\x00\x00\x00", 5, &length);
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_STATUS, "associated");
-
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- libspid_config_read_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_STATUS, buffer, sizeof(buffer));
-
- fail_unless (!strcmp (buffer, "associated")
- && (LIBSPID_FALSE == is_info_manager_needed),
- "wrong STATUS value");
-}
-END_TEST
-
-TCase *event_refresh_status_assoc_tcase (void)
-{
- TCase *tc = tcase_create ("refresh_status_assoc");
- tcase_add_checked_fixture (tc, setup, teardown);
- // check STATUS field
- tcase_add_test (tc, test_refresh_status_assoc_1);
- tcase_add_test (tc, test_refresh_status_assoc_2);
- tcase_add_test (tc, test_refresh_status_assoc_3);
- tcase_add_test (tc, test_refresh_status_assoc_4);
-
- return tc;
-}
-
-/* check cco switch to proxy */
-START_TEST (test_refresh_status_cco_1)
-{
- unsigned int length;
- char buffer[1024];
-
- mme_put (&mme_ctx, "\x00\x01\x00\x00\x00", 5, &length);
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_CCO, "station");
-
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- libspid_config_read_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_CCO, buffer, sizeof(buffer));
-
- fail_unless (!strcmp (buffer, "proxy")
- && (LIBSPID_TRUE == is_info_manager_needed),
- "CCO = proxy");
-}
-END_TEST
-
-/* check cco switch to station */
-START_TEST (test_refresh_status_cco_2)
-{
- unsigned int length;
- char buffer[1024];
-
- mme_put (&mme_ctx, "\x00\x00\x00\x00\x00", 5, &length);
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_CCO, "proxy");
-
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- libspid_config_read_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_CCO, buffer, sizeof(buffer));
-
- fail_unless (!strcmp (buffer, "station")
- && (LIBSPID_TRUE == is_info_manager_needed),
- "CCO = station");
-}
-END_TEST
-
-/* check cco switch to main with WAS_CCO=no update */
-START_TEST (test_refresh_status_cco_3)
-{
- unsigned int length;
- char buffer1[256], buffer2[256];
-
- mme_put (&mme_ctx, "\x02\x02\x00\x00\x00", 5, &length);
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_CCO, "station");
- libspid_config_write_item (plcd_ctx.hpav_conf_path, LIBSPID_HPAV_CONF_LABEL_WAS_CCO, "no");
-
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- libspid_config_read_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_CCO, buffer1, sizeof(buffer1));
- libspid_config_read_item (plcd_ctx.hpav_conf_path, LIBSPID_HPAV_CONF_LABEL_WAS_CCO, buffer2, sizeof(buffer2));
-
- fail_unless (!strcmp (buffer1, "main")
- && !strcmp (buffer2, "yes")
- && (LIBSPID_TRUE == is_info_manager_needed)
- && (LIBSPID_TRUE == is_save_conf_needed),
- "CCO = main with WAS_CCO = no (status=%s, was_cco=%s)", buffer1, buffer2);
-}
-END_TEST
-
-/* check cco switch to station with WAS_CCO=yes update */
-START_TEST (test_refresh_status_cco_4)
-{
- unsigned int length;
- char buffer1[256], buffer2[256];
-
- mme_put (&mme_ctx, "\x02\x00\x00\x00\x00", 5, &length);
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_CCO, "main");
- libspid_config_write_item (plcd_ctx.hpav_conf_path, LIBSPID_HPAV_CONF_LABEL_WAS_CCO, "yes");
-
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- libspid_config_read_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_CCO, buffer1, sizeof(buffer1));
- libspid_config_read_item (plcd_ctx.hpav_conf_path, LIBSPID_HPAV_CONF_LABEL_WAS_CCO, buffer2, sizeof(buffer2));
-
- fail_unless (!strcmp (buffer1, "station")
- && !strcmp (buffer2, "no")
- && (LIBSPID_TRUE == is_info_manager_needed)
- && (LIBSPID_TRUE == is_save_conf_needed),
- "CCO = station with WAS_CCO = yes (status=%s, was_cco=%s)", buffer1, buffer2);
-}
-END_TEST
-
-TCase *event_refresh_status_cco_tcase (void)
-{
- TCase *tc = tcase_create ("refresh_status_cco");
- tcase_add_checked_fixture (tc, setup, teardown);
- // check STATUS field
- tcase_add_test (tc, test_refresh_status_cco_1);
- tcase_add_test (tc, test_refresh_status_cco_2);
- tcase_add_test (tc, test_refresh_status_cco_3);
- tcase_add_test (tc, test_refresh_status_cco_4);
- return tc;
-}
-
-/* check cco preferred from no to yes*/
-START_TEST (test_refresh_status_cco_preferred_1)
-{
- unsigned int length;
- char buffer[256];
-
- mme_put (&mme_ctx, "\x00\x00\x01\x00\x00", 5, &length);
- libspid_config_write_item (plcd_ctx.hpav_conf_path, LIBSPID_HPAV_CONF_LABEL_CCO_PREFERRED, "no");
-
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- libspid_config_read_item (plcd_ctx.hpav_conf_path, LIBSPID_HPAV_CONF_LABEL_CCO_PREFERRED, buffer, sizeof(buffer));
-
- fail_unless (!strcmp (buffer, "yes")
- && (LIBSPID_TRUE == is_save_conf_needed),
- "CCO_PREFERRED = yes");
-}
-END_TEST
-
-/* check cco preferred from yes to no */
-START_TEST (test_refresh_status_cco_preferred_2)
-{
- unsigned int length;
- char buffer[256];
-
- mme_put (&mme_ctx, "\x00\x00\x00\x00\x00", 5, &length);
- libspid_config_write_item (plcd_ctx.hpav_conf_path, LIBSPID_HPAV_CONF_LABEL_CCO_PREFERRED, "yes");
-
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- libspid_config_read_item (plcd_ctx.hpav_conf_path, LIBSPID_HPAV_CONF_LABEL_CCO_PREFERRED, buffer, sizeof(buffer));
-
- fail_unless (!strcmp (buffer, "no")
- && (LIBSPID_TRUE == is_save_conf_needed),
- "CCO_PREFERRED = no");
-}
-END_TEST
-
-TCase *event_refresh_status_cco_preferred_tcase (void)
-{
- TCase *tc = tcase_create ("refresh_status_cco_preferred");
- tcase_add_checked_fixture (tc, setup, teardown);
- tcase_add_test (tc, test_refresh_status_cco_preferred_1);
- tcase_add_test (tc, test_refresh_status_cco_preferred_2);
- return tc;
-}
-
-/* check cco backup from no to yes */
-START_TEST (test_refresh_status_cco_backup_1)
-{
- unsigned int length;
- char buffer[256];
-
- mme_put (&mme_ctx, "\x00\x00\x00\x01\x00", 5, &length);
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_BACKUP_CCO, "no");
-
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- libspid_config_read_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_BACKUP_CCO, buffer, sizeof(buffer));
-
- fail_unless (!strcmp (buffer, "yes")
- && (LIBSPID_TRUE == is_info_manager_needed),
- "BACKUP_CCO = yes");
-}
-END_TEST
-
-/* check cco backup from yes to no */
-START_TEST (test_refresh_status_cco_backup_2)
-{
- unsigned int length;
- char buffer[256];
-
- mme_put (&mme_ctx, "\x00\x00\x00\x00\x00", 5, &length);
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_BACKUP_CCO, "yes");
-
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- libspid_config_read_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_BACKUP_CCO, buffer, sizeof(buffer));
-
- fail_unless (!strcmp (buffer, "no")
- && (LIBSPID_TRUE == is_info_manager_needed),
- "BACKUP_CCO = no");
-}
-END_TEST
-
-TCase *event_refresh_status_cco_backup_tcase (void)
-{
- TCase *tc = tcase_create ("refresh_status_cco_backup");
- tcase_add_checked_fixture (tc, setup, teardown);
- tcase_add_test (tc, test_refresh_status_cco_backup_1);
- tcase_add_test (tc, test_refresh_status_cco_backup_2);
- return tc;
-}
-
-/* check SC from no to yes */
-START_TEST (test_refresh_status_sc_1)
-{
- unsigned int length;
- char buffer[256];
-
- mme_put (&mme_ctx, "\x00\x00\x00\x00\x01", 5, &length);
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_SC, "no");
-
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- libspid_config_read_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_SC, buffer, sizeof(buffer));
-
- fail_unless (!strcmp (buffer, "yes")
- && (LIBSPID_TRUE == is_info_manager_needed),
- "SC = yes");
-}
-END_TEST
-
-/* check sc from yes to no */
-START_TEST (test_refresh_status_sc_2)
-{
- unsigned int length;
- char buffer[256];
-
- mme_put (&mme_ctx, "\x00\x00\x00\x00\x00", 5, &length);
- libspid_config_write_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_SC, "yes");
-
- refresh_status (&plcd_ctx, &mme_ctx, &is_save_conf_needed, &is_info_manager_needed);
- libspid_config_read_item (plcd_ctx.hpav_info_path, LIBSPID_HPAV_INFO_LABEL_SC, buffer, sizeof(buffer));
-
- fail_unless (!strcmp (buffer, "no")
- && (LIBSPID_TRUE == is_info_manager_needed),
- "BACKUP_SC = no");
-}
-END_TEST
-
-TCase *event_refresh_status_sc_tcase (void)
-{
- TCase *tc = tcase_create ("refresh_status_sc");
- tcase_add_checked_fixture (tc, setup, teardown);
- tcase_add_test (tc, test_refresh_status_sc_1);
- tcase_add_test (tc, test_refresh_status_sc_2);
- return tc;
-}
-
-
-Suite* event_suite(void)
-{
- Suite *s = suite_create ("event");
- suite_add_tcase (s, event_refresh_status_param_tcase ());
- suite_add_tcase (s, event_refresh_status_assoc_tcase());
- suite_add_tcase (s, event_refresh_status_cco_tcase());
- suite_add_tcase (s, event_refresh_status_cco_preferred_tcase());
- suite_add_tcase (s, event_refresh_status_cco_backup_tcase());
- suite_add_tcase (s, event_refresh_status_sc_tcase());
- suite_add_tcase (s, event_refresh_check_sc_start_tcase ());
- return s;
-}
-
-int main(void)
-{
- Suite *s = suite_create ("event");
- int number_failed = 0;
- SRunner *sr = srunner_create(s);
- srunner_add_suite (sr, event_suite ());
- //srunner_set_fork_status (sr, CK_NOFORK);
- srunner_set_fork_status (sr, CK_FORK);
- 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/plcd/src/hpav_utests.c b/cleopatre/devkit/tests/plcd/src/hpav_utests.c
deleted file mode 100644
index 5e6c2d2f3d..0000000000
--- a/cleopatre/devkit/tests/plcd/src/hpav_utests.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/* Cleopatre project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hpav_utests.c
- * \brief Unitary tests for plcd
- * \ingroup Cleopatre - plcd
- *
- * This file content all the unitary tests for hpav, part of plcd
- * (the interface between the PLC driver and the Linux filesystem).
- */
-
-#include <check.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/time.h> /* for select() */
-#include <linux/if_ether.h> /* for ETH_ALEN */
-#include <unistd.h>
-#include <errno.h>
-#include "plcd.h"
-#include "hpav_utests.h"
-
-#define DEBUG 1
-
-#ifdef DEBUG
-#define TRACE(...) printf("HPAV UTESTS: " __VA_ARGS__)
-#else
-#define TRACE(...)
-#endif
-
-/** local defines */
-#define MAC_ADDR "AA:BB:CC:12:34:56" /* mac addr that will be used for testing */
-#define PLC_ADDR "FF:EE:DD:98:76:54" /* mac addr that will be used for testing */
-
-/** local variables */
-plcd_ctx_t plcd_ctx;
-plcd_ctx_t *ctx = &plcd_ctx;
-
-unsigned char msg_buf[ETH_FRAME_LEN]; /* local buffer to store netlink messages */
-
-/*
- ######################################
- # FUNCTION STUB
- # (redefinition of glibc functions)
- ######################################
-*/
-ssize_t sendmsg (int socket, const struct msghdr *message, int flags)
-{
- struct nlmsghdr *nlh;
-
- nlh = (struct nlmsghdr *)(message->msg_iov->iov_base);
-
- /* store message to local buffer */
- memcpy(msg_buf, nlh, message->msg_iov->iov_len);
-
- return 1;
-}
-
-int recvmsg(int s, struct msghdr *message, int flags)
-{
- struct nlmsghdr *nlh;
- MME_t *mme_hdr;
-
- nlh = (struct nlmsghdr *)(message->msg_iov->iov_base);
- mme_hdr = (MME_t *)NLMSG_DATA(msg_buf);
-
- /* change mme type to CNF */
- mme_hdr->mmtype = (mme_hdr->mmtype & ~MME_TYPE_MASK) | MME_TYPE_CNF;
-
- /* copy local buffer to response message */
- memcpy(nlh, msg_buf, message->msg_iov->iov_len);
-
- return 1;
-}
-
-int select(int nfds, fd_set *readfds, fd_set *writefds,
- fd_set *exceptfds, struct timeval *timeout)
-{
- return 1;
-}
-
-
-
-/* fixtures - run before and after each unit test */
-void setup(void)
-{
- int i;
- char pa[] = PLC_ADDR;
- char *s, *e;
-
- ctx->hardware_info_path = (char *)malloc(64);
- ctx->hpav_info_path = (char *)malloc(64);
- ctx->hpav_conf_path = (char *)malloc(64);
-
- /* initialize plcd context */
- strcpy(ctx->hardware_info_path, LIBSPID_HARDWARE_INFO_PATH);
- strcpy(ctx->hpav_info_path, LIBSPID_HPAV_INFO_PATH);
- strcpy(ctx->hpav_conf_path, LIBSPID_HPAV_CONF_PATH);
- ctx->plc_sock = 0;
- ctx->nvram = (spc300_nvram_t *) malloc(sizeof(spc300_nvram_t));
- s = pa;
- for (i = 0; i < 6; ++i)
- {
- ctx->nvram->plc_address[i] = s ? strtoul (s, &e, 16) : 0;
- if (s)
- s = (*e) ? e + 1 : e;
- }
-
-}
-
-void teardown(void)
-{
-}
-
-/* --- TEST PROCEDURES --- */
-
-/** test procedures */
-START_TEST (test_hpav_send_mac_address)
-{
- int ret;
- struct nlmsghdr *nlh;
- unsigned char *payload= NLMSG_DATA(msg_buf) + sizeof(MME_t);
-
- //Check arguments
- ret = hpav_send_mac_address(ctx, MAC_ADDR);
- fail_if( ret != 0, "hpav_send_mac_address fail" );
- fail_if( memcmp(payload, MAC_ADDR, ETH_ALEN) != 0, "hpav_send_mac_address sends wrong payload" );
-
-}
-END_TEST
-
-
-START_TEST (test_hpav_send_cco_preferred)
-{
- int ret;
- struct nlmsghdr *nlh;
- unsigned char *payload= NLMSG_DATA(msg_buf) + sizeof(MME_t);
- const unsigned char is_cco_preferred = 5;
-
- ret = hpav_send_cco_preferred (ctx, is_cco_preferred);
- fail_if( ret != 0, "hpav_send_cco_preferred fail" );
- fail_if( memcmp(payload, &is_cco_preferred, 1) != 0, "hpav_send_cco_preferred sends wrong payload" );
-}
-END_TEST
-
-START_TEST (test_hpav_send_was_cco)
-{
- int ret;
- struct nlmsghdr *nlh;
- unsigned char *payload= NLMSG_DATA(msg_buf) + sizeof(MME_t);
- const unsigned char was_cco = 6;
-
- ret = hpav_send_was_cco(ctx, was_cco);
- fail_if( ret != 0, " fail" );
- fail_if( memcmp(payload, &was_cco, 1) != 0, "hpav_send_was_cco sends wrong payload" );
-}
-END_TEST
-
-START_TEST (test_hpav_compute_nmk)
-{
- /* XXX: TBD */
-}
-END_TEST
-
-START_TEST (test_hpav_send_key)
-{
- int ret;
- int i;
- struct nlmsghdr *nlh;
- unsigned char *payload= NLMSG_DATA(msg_buf) + sizeof(MME_t);
- unsigned char nmk[16];
- unsigned char nid[7];
- char sl[16];
- char c;
-
- for (i=0; i<16; i++)
- nmk[i] = 0xA;
- for (i=0; i<7; i++)
- nid[i] = 0xE;
- strcpy(sl, LIBSPID_HPAV_CONF_VALUE_SL_HS);
- ret = hpav_send_key(ctx, nmk, nid, sl);
- fail_if( ret != 0, " fail" );
-
- fail_if( memcmp(payload, nmk, 16) != 0, "hpav_send_key sends wrong nmk" );
- i = 0x1;
- fail_if( memcmp(payload + 16, &i, 1) != 0, "hpav_send_key sends wrong payload" );
- fail_if( memcmp(payload + 16 + 8, &i, 1) != 0, "hpav_send_key sends wrong payload" );
- for (i=0; i<8; i++)
- sl[i] = '\0';
- fail_if( memcmp(payload + 16 + 1, sl, 7) != 0, "hpav_send_key sends wrong payload" );
-
- ret = hpav_send_key(ctx, nmk, nid, NULL);
- fail_if( ret != 0, " fail" );
-
- fail_if( memcmp(payload, nmk, 16) != 0, "hpav_send_key sends wrong nmk" );
- c = '\0';
- fail_if( memcmp(payload + 16, &c, 1) != 0, "hpav_send_key sends wrong payload" );
- fail_if( memcmp(payload + 16 + 1, nid, 7) != 0, "hpav_send_key sends wrong payload" );
- fail_if( memcmp(payload + 16 + 1 + 7, &c, 1) != 0, "hpav_send_key sends wrong payload" );
-}
-END_TEST
-
-START_TEST (test_hpav_compute_dak)
-{
- /* XXX: TBD */
-}
-END_TEST
-
-START_TEST (test_hpav_send_dak)
-{
- int ret;
- int i;
- struct nlmsghdr *nlh;
- unsigned char *payload= NLMSG_DATA(msg_buf) + sizeof(MME_t);
- unsigned char dak[16];
-
- for (i=0; i<16; i++)
- dak[i] = i;
-
- ret = hpav_send_dak(ctx, &dak);
- fail_if( ret != 0, "hpav_send_dak fail" );
- fail_if( memcmp(payload, &dak, 16) != 0, "hpav_send_dak sends wrong payload" );
-}
-END_TEST
-
-START_TEST (test_hpav_send_mfg_hfid)
-{
- int ret;
- int i;
- struct nlmsghdr *nlh;
- unsigned char *payload= NLMSG_DATA(msg_buf) + sizeof(MME_t);
- char mfg_hfid[64];
-
- for (i=0; i<64; i++)
- mfg_hfid[i] = i;
-
- ret = hpav_send_mfg_hfid (ctx, &mfg_hfid);
- fail_if( ret != 0, "hpav_send_mfg_hfid fail" );
- fail_if( memcmp(payload, &mfg_hfid, 64) != 0, "hpav_send_mfg_hfid sends wrong payload" );
-}
-END_TEST
-
-START_TEST (test_hpav_send_user_hfid)
-{
- int ret;
- int i;
- struct nlmsghdr *nlh;
- unsigned char *payload= NLMSG_DATA(msg_buf) + sizeof(MME_t);
- char user_hfid[64];
-
- for (i=0; i<64; i++)
- user_hfid[i] = i;
-
- ret = hpav_send_user_hfid(ctx, &user_hfid);
- fail_if( ret != 0, "hpav_send_user_hfid fail" );
- fail_if( memcmp(payload, &user_hfid, 64) != 0, "hpav_send_user_hfid sends wrong payload" );
-}
-END_TEST
-
-START_TEST (test_hpav_send_avln_hfid)
-{
- int ret;
- int i;
- struct nlmsghdr *nlh;
- unsigned char *payload= NLMSG_DATA(msg_buf) + sizeof(MME_t);
- char avln_hfid[64];
-
- for (i=0; i<64; i++)
- avln_hfid[i] = i;
-
- ret = hpav_send_avln_hfid(ctx, &avln_hfid);
- fail_if( ret != 0, "hpav_send_avln_hfid fail" );
- fail_if( memcmp(payload, &avln_hfid, 64) != 0, "hpav_send_avln_hfid sends wrong payload" );
-}
-END_TEST
-
-
-START_TEST (test_hpav_send_tonemask)
-{
- int ret;
- int i;
- struct nlmsghdr *nlh;
- unsigned char *payload= NLMSG_DATA(msg_buf) + sizeof(MME_t);
- char tonemask[192];
-
- for (i=0; i<192; i++)
- tonemask[i] = i;
-
- ret = hpav_send_tonemask(ctx, &tonemask);
- fail_if( ret != 0, "hpav_send_tonemask fail" );
- fail_if( memcmp(payload, &tonemask, 192) != 0, "hpav_send_tonemask sends wrong payload" );
-}
-END_TEST
-
-START_TEST (test_hpav_send_start)
-{
- int ret;
- struct nlmsghdr *nlh;
- unsigned char *payload= NLMSG_DATA(msg_buf) + sizeof(MME_t);
-
- ret = hpav_send_start(ctx);
- fail_if( ret != 0, "hpav_send_start fail" );
-}
-END_TEST
-
-extern Suite* hpav_suite(void)
-{
- Suite *s = suite_create("HPAV");
- TCase *tc_core = tcase_create("Core");
-
- tcase_add_checked_fixture (tc_core, setup, teardown);
-
- //Test hpav_send_mac_address
- tcase_add_test(tc_core, test_hpav_send_mac_address);
-
- //Test hpav_send_cco_preferred
- tcase_add_test(tc_core, test_hpav_send_cco_preferred);
-
- //Test hpav_send_was_cco
- tcase_add_test(tc_core, test_hpav_send_was_cco);
-
- //Test hpav_compute_nmk
- tcase_add_test(tc_core, test_hpav_compute_nmk);
-
- //Test hpav_send_key
- tcase_add_test(tc_core, test_hpav_send_key);
-
- //Test hpav_compute_dak
- tcase_add_test(tc_core, test_hpav_compute_dak);
-
- //Test hpav_send_dak
- tcase_add_test(tc_core, test_hpav_send_dak);
-
- //Test hpav_send_mfg_hfid
- tcase_add_test(tc_core, test_hpav_send_mfg_hfid);
-
- //Test hpav_send_user_hfid
- tcase_add_test(tc_core, test_hpav_send_user_hfid);
-
- //Test hpav_send_avln_hfid
- tcase_add_test(tc_core, test_hpav_send_avln_hfid);
-
- //Test hpav_send_tonemask
- tcase_add_test(tc_core, test_hpav_send_tonemask);
-
- //Test hpav_send_start
- tcase_add_test(tc_core, test_hpav_send_start);
-
- suite_add_tcase(s, tc_core);
- return s;
-}
-
-int main(void)
-{
- int number_failed = 0;
- Suite *s;
-
- //Run hpav tests
- s = hpav_suite();
-
- SRunner *sr = srunner_create(s);
- //srunner_set_fork_status (sr, CK_NOFORK);
- srunner_set_fork_status (sr, CK_FORK);
- 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/plcd/src/plcd_utests.c b/cleopatre/devkit/tests/plcd/src/plcd_utests.c
deleted file mode 100644
index 3e999f20e9..0000000000
--- a/cleopatre/devkit/tests/plcd/src/plcd_utests.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/* Cleopatre project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hpav_utests.c
- * \brief Unitary tests for plcd
- * \ingroup Cleopatre - plcd
- *
- * This file content all the unitary tests for plcd,
- * (interface between the PLC driver and the Linux filesystem).
- */
-
-#include <check.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <stdlib.h>
-#include <sys/time.h>
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <unistd.h>
-#include <errno.h>
-#include <linux/if_packet.h>
-#include <linux/if_ether.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-#include <net/ethernet.h>
-#include <netinet/ether.h>
-
-#include <inttypes.h>
-#include <fcntl.h>
-#include <signal.h>
-
-#include <unistd.h>
-#include <pthread.h>
-#include <linux/if_tun.h>
-
-#include "plcd.h"
-#include "plcd_utests.h"
-
-#define DEBUG 1
-
-
-#ifdef DEBUG
-#define TRACE(...) printf("PLCD UTESTS: " __VA_ARGS__)
-#else
-#define TRACE(...)
-#endif
-
-/** local variables */
-plcd_ctx_t plcd_ctx;
-plcd_ctx_t *ctx = &plcd_ctx;
-
-#if 0
-/* fixtures - run before and after each unit test */
-void setup(void)
-{
-}
-
-void teardown(void)
-{
-}
-#endif
-
-/* --- TEST PROCEDURES --- */
-
-/** test procedures */
-START_TEST (test_plcd_init)
-{
- int ret;
-
- /* zero-out plcd ctx */
- memset(ctx, 0x0, sizeof(plcd_ctx_t));
-
- //Check arguments
- ret = plcd_init(ctx);
- fail_if( 0 != ret, "plcd_init fail");
-
- TRACE("ctx->hardware_info_path=%s\n", ctx->hardware_info_path);
- TRACE("ctx->hpav_info_path=%s\n", ctx->hpav_info_path);
- TRACE("ctx->hpav_conf_path=%s\n", ctx->hpav_conf_path);
-
- fail_if( strcmp(ctx->hardware_info_path, LIBSPID_HARDWARE_INFO_PATH) != 0,
- "hardware_info_path was not correctly initialized" );
- fail_if( strcmp(ctx->hpav_info_path, LIBSPID_HPAV_INFO_PATH) != 0,
- "hpav_info_path was not correctly initialized" );
- fail_if( strcmp(ctx->hpav_conf_path, LIBSPID_HPAV_CONF_PATH) != 0,
- "hpav_conf_path was not correctly initialized" );
-
- /* close netlink fd opened in plcd_init() */
- plcd_uninit (ctx);
-}
-END_TEST
-
-extern Suite* plcd_suite(void)
-{
- Suite *s = suite_create("PLCD");
- TCase *tc_core = tcase_create("Core");
-
- //Test plcd_init
- tcase_add_test(tc_core, test_plcd_init);
-
- suite_add_tcase(s, tc_core);
- return s;
-}
-
-int main(void)
-{
- int number_failed = 0;
- Suite *s;
-
- //Run plcd tests
- s = plcd_suite();
-
- SRunner *sr = srunner_create(s);
- //srunner_set_fork_status (sr, CK_NOFORK);
- srunner_set_fork_status (sr, CK_FORK);
- 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/arm/ftests/lo_ecos/Makefile b/cleopatre/devkit/tests/plcdrv/arm/ftests/lo_ecos/Makefile
index 286f3cb463..7e7acd5606 100644
--- a/cleopatre/devkit/tests/plcdrv/arm/ftests/lo_ecos/Makefile
+++ b/cleopatre/devkit/tests/plcdrv/arm/ftests/lo_ecos/Makefile
@@ -8,6 +8,6 @@ DEFS = -DLOOPBACK_DEBUG
TARGET_PROGRAMS = loopback
loopback_SOURCES = loopback.c
-loopback_MODULES = lib hal/hle
+loopback_MODULES = lib hal/hle hal/arch
include $(BASE)/common/make/top.mk
diff --git a/cleopatre/devkit/tests/plcdrv/arm/ftests/lo_ecos/src/loopback.c b/cleopatre/devkit/tests/plcdrv/arm/ftests/lo_ecos/src/loopback.c
index 3f9c843b25..87a62a0a0e 100644
--- a/cleopatre/devkit/tests/plcdrv/arm/ftests/lo_ecos/src/loopback.c
+++ b/cleopatre/devkit/tests/plcdrv/arm/ftests/lo_ecos/src/loopback.c
@@ -21,7 +21,6 @@
#include "hal/hle/ipmbox.h"
#include "hal/hle/defs.h"
#include "lib/utils.h"
-#include "hal/hle/inc/trace.h"
/** Debug mode */
#ifdef LOOPBACK_DEBUG
@@ -47,9 +46,6 @@ void mail_thread(cyg_addrword_t index)
while(1)
{
cyg_thread_delay(300);
-// diag_printf("ct=%d\n",my_counter);
- if(!my_counter)
- ipmbox_trace_print(ipmbox_ctx);
my_counter++;
}
}
diff --git a/cleopatre/devkit/tests/plcdrv/arm/ftests/wd_leon/Makefile b/cleopatre/devkit/tests/plcdrv/arm/ftests/wd_leon/Makefile
index 5a416e8f72..53347893d1 100644
--- a/cleopatre/devkit/tests/plcdrv/arm/ftests/wd_leon/Makefile
+++ b/cleopatre/devkit/tests/plcdrv/arm/ftests/wd_leon/Makefile
@@ -1,37 +1,7 @@
-BIN = wd_leon
-OBJPATH = obj
-SRCPATH = src
+BASE = ../../../../../../../cesar
-ifeq ($(CC_FOR_TARGET),) # direct compile
-CC = arm-linux-gcc
-CC_WITH_CFLAGS = $(CC) -I/opt/spidcom/spc300/usr/include -g -Os
-CC_WITHOUT_CFLAGS = $(CC)
-LINUX_DIR = ../../../../../../linux-2.6.25.10-spc300
-else # compile from buildroot
-CC_WITH_CFLAGS = $(CC)
-CC_WITHOUT_CFLAGS = $(CC_FOR_TARGET)
-endif
-EXTRA_CFLAGS = -I$(LINUX_DIR)/include/asm-arm/arch-spc300 -MMD
-LIBS =
+HOST_PROGRAMS = wd_leon
-SRCS = $(subst $(SRCPATH)/,,$(wildcard $(SRCPATH)/*.c))
-OBJS = $(addprefix $(OBJPATH)/,$(SRCS:.c=.o))
-DEPS = $(patsubst %o,%d,$(OBJS))
+wd_leon_SOURCES = wd_leon.c
-all: $(BIN)
-
-$(BIN): $(OBJPATH) $(OBJS)
- $(CC_WITHOUT_CFLAGS) -static -o $@ $(OBJS) $(LIBS)
-
-$(OBJPATH)/%.o: $(SRCPATH)/%.c
- $(CC_WITH_CFLAGS) $(EXTRA_CFLAGS) -o $@ -c $<
-
-$(OBJPATH):
- mkdir -p $(OBJPATH)
-
--include $(DEPS)
-
-.PHONY: all clean
-
-clean:
- rm -f $(OBJS) $(DEPS) $(BIN)
+include $(BASE)/common/make/top.mk
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/Makefile b/cleopatre/devkit/tests/plcdrv/arm/utests/Makefile
index 6042aa45ed..5367a5264b 100644
--- a/cleopatre/devkit/tests/plcdrv/arm/utests/Makefile
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/Makefile
@@ -1,7 +1,21 @@
-PRJ_BASE = ../../../../plcdrv/arm
-FILES = hal
-FILES += mailbox
-FILES += processing
-#FILES += linux_drv
+BASE = ../../../../../../cesar
+CLEO_BASE = ../cleopatre
-include ../../../utests_makerules
+# We test PLCDrv.
+PROJECT_DIR = $(CLEO_BASE)/devkit/plcdrv/arm/
+
+LINUX_STUB_BASE = $(CLEO_BASE)/devkit/tests/plcdrv/arm/utests/stub/linux
+
+INCLUDES = $(PROJECT_DIR)/inc $(LINUX_STUB_BASE)/inc
+
+EXTRA_HOST_LDLIBS = -lcheck
+
+DEFS = -D__UTESTS__ -DDRV_VERSION=\"test\"
+
+#Do not compile linux_drv_utests, mailbox_utests and processing_utests
+HOST_PROGRAMS = hal_utests
+
+hal_utests_SOURCES = hal_utests.c
+hal_utests_MODULES = $(PROJECT_DIR) $(LINUX_STUB_BASE)
+
+include $(BASE)/common/make/top.mk
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/inc/linux_drv_utests.h b/cleopatre/devkit/tests/plcdrv/arm/utests/inc/linux_drv_utests.h
index d113446741..f58f615ce1 100644
--- a/cleopatre/devkit/tests/plcdrv/arm/utests/inc/linux_drv_utests.h
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/inc/linux_drv_utests.h
@@ -21,187 +21,15 @@
#include <stdint.h>
#include <string.h>
+#include "registers.h"
+
/****************************************************/
/***** SPECIFIC STUB *****/
/****************************************************/
-unsigned char plccode[124];
-#define VIRT_PLCCODE_BASE (&plccode[0])
-#define MBX_BASE_ADDR 0x1234567
-#define NB_MBX_REGISTERS 8
-#define INT_MBX 12
-#define INT_MBX_ACK 13
-static inline int processing_init(struct init_info *info){return 0;}
-static inline int processing_uninit(void){return 0;}
-static inline int processing_send(void *pointer, int length){return 0;}
-static inline int processing_buffer_add(void *pointer, enum buffer_type type){return 0;}
-
-static inline int mailbox_buffer_add(void *pointer, enum buffer_type type){return 0;}
-static inline int mailbox_receive(void){return 0;}
-static inline int mailbox_txdone(void){return 0;}
/****************************************************/
/***** LINUX STUB *****/
/****************************************************/
-#define kfree free
-#define printk(...)
-#define irqreturn_t int
-#define jiffies 1234
-#define IRQ_HANDLED 1
-#define IRQ_NONE 0
-#define EOPNOTSUPP 1
-#define EINVAL 1
-#define ENODEV 1
-#define ENOMEM 1
-#define EFAULT 1
-#define EPERM 1
-#define KERN_ERR
-#define __init
-#define __exit
-#define __devinitdata
-#define __user
-#define MODULE_AUTHOR(a)
-#define MODULE_DESCRIPTION(a)
-#define MODULE_LICENSE(a)
-#define MODULE_PARM_DESC(a,b)
-#define module_param(a,b,c)
-#define module_init(a)
-#define module_exit(a)
-#define DMA_BIDIRECTIONAL 1
-#define GFP_KERNEL 1
-#define GFP_DMA 1
-#define DMA_FROM_DEVICE 1
-#define DMA_TO_DEVICE 1
-#define CHECKSUM_UNNECESSARY 1
-#define TASK_INTERRUPTIBLE 1
-#define HZ 100
-
-typedef irqreturn_t (*irq_handler_t)(int, void *);
-
-struct file {
- unsigned int not_used;
-};
-struct list_head {
- struct list_head *next, *prev;
-};
-struct sk_buff {
- unsigned char *data;
- struct net_device *dev;
- unsigned int len;
- unsigned short protocol;
- unsigned char ip_summed;
-};
-struct net_device_stats {
- unsigned long rx_packets;
- unsigned long tx_packets;
- unsigned long rx_bytes;
- unsigned long tx_bytes;
- unsigned long rx_dropped;
- unsigned long tx_dropped;
- unsigned long tx_fifo_errors;
-};
-struct ifreq {
- char dummy;
-};
-#define ETH_ALEN 6
-struct ethhdr {
- unsigned char h_dest[ETH_ALEN];
- unsigned char h_source[ETH_ALEN];
- unsigned short h_proto;
-};
-struct sockaddr {
- char sa_data[14];
-};
-struct net_device {
- char name[16];
- unsigned long base_addr;
- void *priv;
- unsigned char dev_addr[32];
- unsigned char addr_len;
- unsigned int irq;
- unsigned int mtu;
- unsigned long trans_start;
- int (*init)(struct net_device *dev);
- int (*hard_start_xmit)(struct sk_buff *skb, struct net_device *dev);
- int (*open)(struct net_device *dev);
- int (*stop)(struct net_device *dev);
- int (*set_mac_address)(struct net_device *dev, void *addr);
- struct net_device_stats* (*get_stats)(struct net_device *dev);
- int (*do_ioctl)(struct net_device *dev, struct ifreq *ifr, int cmd);
- int (*change_mtu)(struct net_device *dev, int new_mtu);
-};
-
-static inline void set_current_state(int state){}
-static inline void schedule_timeout(int timeout){}
-static inline void *ioremap(unsigned long phys_addr, unsigned int size){return (void*)phys_addr;}
-static inline void iounmap(void* addr){}
-static inline void ether_setup(struct net_device *dev){}
-static inline unsigned short eth_type_trans(struct sk_buff *skb, struct net_device *dev){return 5;}
-static inline void netif_carrier_on(struct net_device *dev){}
-static inline void netif_start_queue(struct net_device *dev){}
-static inline void netif_carrier_off(struct net_device *dev){}
-static inline void netif_stop_queue(struct net_device *dev){}
-static inline void netif_wake_queue(struct net_device *dev){}
-static inline int netif_rx(struct sk_buff *skb){return 0;}
-static inline int netif_queue_stopped(const struct net_device *dev){return 0;}
-static inline int register_netdev(struct net_device *dev){return 0;}
-static inline void unregister_netdev(struct net_device *dev){}
-static inline int request_irq(unsigned int irq, irq_handler_t handler, unsigned long irqflags, const char *devname, void *dev_id){return 0;}
-static inline void free_irq(unsigned int irq, void *dev_id){}
-static inline unsigned int virt_to_dma(void* dev, unsigned int addr){return addr;}
-static inline unsigned int dma_to_virt(void* dev, unsigned int addr){return addr;}
-static inline unsigned int dma_map_single(void *dev, void *ptr, unsigned int size, int dir){return (unsigned int)ptr;}
-static inline void dma_unmap_single(void *dev, unsigned int dma_addr, unsigned int size, int dir){}
-static inline void* dma_alloc_coherent(int *dummy, unsigned int size, unsigned int *handle, int gfp){return (void*)handle;}
-static inline void dma_free_coherent(int *dummy, unsigned int size, void *cpu_addr, unsigned int handle){}
-static inline struct sk_buff *alloc_skb(unsigned int size, int priority)
-{
- struct sk_buff* skb;
- skb = (struct sk_buff*)malloc((unsigned int)(sizeof(struct sk_buff)));
- return skb;
-}
-static inline void kfree_skb(struct sk_buff *skb)
-{
- if(skb)
- free(skb);
-}
-static inline struct net_device *alloc_netdev(int sizeof_priv, const char *name, void (*setup)(struct net_device *))
-{
- struct net_device* dev;
- dev = (struct net_device*)malloc((unsigned int)(sizeof(struct net_device)));
- dev->priv = malloc((unsigned int)(sizeof_priv));
- return dev;
-}
-static inline void free_netdev(struct net_device* dev)
-{
- if(dev->priv)
- free(dev->priv);
- free((void*)(dev));
-}
-static inline int copy_to_user(void *to, const void *from, unsigned long n)
-{
- if(n)
- {
- memcpy(to, from, sizeof(plccode));
- return 0;
- }
- else
- {
- return -1;
- }
-}
-static inline int copy_from_user(void *to, const void *from, unsigned long n)
-{
- if(n)
- {
- memcpy(to, from, sizeof(plccode));
- return 0;
- }
- else
- {
- return -1;
- }
-}
-
/****************************************************/
/***** STATIC FUNCTION PROTOTYPES *****/
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/inc/mailbox_utests.h b/cleopatre/devkit/tests/plcdrv/arm/utests/inc/mailbox_utests.h
index 3bb12a70b6..4d161d65fb 100644
--- a/cleopatre/devkit/tests/plcdrv/arm/utests/inc/mailbox_utests.h
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/inc/mailbox_utests.h
@@ -32,11 +32,6 @@
/****************************************************/
/***** SPECIFICS VARIABLES *****/
/****************************************************/
-static int nbtests_A2L_status_queue = 0;
-static int nbtests_L2A_status_queue = 0;
-uint32_t mbx_send_result[2];
-uint32_t mbx_buffer_add_result[2];
-uint32_t mbx_rx_ptr_result;
/****************************************************/
/***** LOWER STUB *****/
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/src/hal_utests.c b/cleopatre/devkit/tests/plcdrv/arm/utests/src/hal_utests.c
index 0a4dfc9638..57cd7db0b1 100644
--- a/cleopatre/devkit/tests/plcdrv/arm/utests/src/hal_utests.c
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/src/hal_utests.c
@@ -18,6 +18,9 @@
#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])
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/Module b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/Module
new file mode 100644
index 0000000000..c0143da23f
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/Module
@@ -0,0 +1,2 @@
+SOURCES := af_netlink.c afe.c bitops.c char_dev.c delay.c dma.c eth.c \
+ ioremap.c irq_manage.c mutex.c net_dev.c softirq.c uaccess.c wait.c
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/asm/arch/hardware/regbank.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/asm/arch/hardware/regbank.h
new file mode 100644
index 0000000000..bbcc8e4de8
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/asm/arch/hardware/regbank.h
@@ -0,0 +1,13 @@
+#ifndef stub_linux_inc_linux_asm_arch_hardware_regbank_h
+#define stub_linux_inc_linux_asm_arch_hardware_regbank_h
+
+#include <linux/types.h>
+
+#define RB_LEON_ADD_START (0x120)
+#define RB_RST_GROUP_VA (*(volatile uint32_t *)0x12345678)
+#define RB_RST_MODULE_VA (*(volatile uint32_t *)0x87654321)
+#define RB_RST_GLOBAL_VA (*(volatile uint32_t *)0x55555555)
+#define RST_LEONSS (0x8)
+#define RST_LCPU (0x800)
+
+#endif /* stub_linux_inc_linux_asm_arch_hardware_regbank_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/asm/arch/nvram.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/asm/arch/nvram.h
new file mode 100644
index 0000000000..180868a766
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/asm/arch/nvram.h
@@ -0,0 +1,37 @@
+#ifndef stub_linux_inc_linux_asm_arch_nvram_h
+#define stub_linux_inc_linux_asm_arch_nvram_h
+
+typedef struct
+{
+ char magic[8]; // Magic number "NVRAM\0\0\0"
+ uint32_t pkg_cfg; // SPC300 package configuration register
+ uint32_t gpio_0_7_cfg; // SPC300 GPIO 0 to 7 configuration register
+ uint32_t gpio_8_15_cfg; // SPC300 GPIO 8 to 15 configuration register
+ uint32_t gpio_allow_dir; // SPC300 GPIO allowed directions 0:none 1:in 2:out 3:bi
+ uint32_t sdram_config; // SPC300 SDRAM configuration register
+ uint32_t sdram_timing0; // SPC300 SDRAM timing register 0
+ uint32_t sdram_timing1; // SPC300 SDRAM timing register 1
+ uint32_t sdram_refresh; // SPC300 SDRAM refresh register
+ uint32_t flash_org; // Flash organization
+ uint32_t img_0_offset; // Offset of first image address
+ uint32_t nb_images; // Max Number of Images present in flash
+ char product_name[64]; // Product short name in string format
+ char product_partnb[64]; // Product part number in string format
+ char product_desc[128]; // Product long description in string format
+ char serial_number[64]; // Product serial number in string format
+ uint32_t eth_phy_addr; // Address of Ethernet PHY
+ unsigned char eth_address[6]; // Ethernet MAC address
+ unsigned char reserved1[2];
+ unsigned char plc_address[6]; // PowerLine MAC address
+ unsigned char reserved2[2];
+ char device_password[32]; // HomePlugAV device unique password (DPW)
+ char oem_info[64]; // Additional information for OEM
+ unsigned char tonemask[192]; // HomePlugAV tonemask
+ char manufactory_info[64]; // Name of the product manufacturer
+ uint32_t img_max_size; // Max size of an image in flash
+ uint32_t cpu_partnb; // SPC3x0 partnb
+} spc300_nvram_t; //Currently __attribute__((packed)) not needed
+
+extern spc300_nvram_t spc300_nvram;
+
+#endif /* stub_linux_inc_linux_asm_arch_nvram_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/afe.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/afe.h
new file mode 100644
index 0000000000..641ca36b66
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/afe.h
@@ -0,0 +1,8 @@
+#ifndef stub_linux_inc_linux_afe_h
+#define stub_linux_inc_linux_afe_h
+
+#include <linux/types.h>
+
+extern int afe_write_reg(uint8_t reg, uint8_t val);
+
+#endif /* stub_linux_inc_linux_afe_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/asm.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/asm.h
new file mode 100644
index 0000000000..20254883f1
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/asm.h
@@ -0,0 +1,70 @@
+#ifndef stub_linux_inc_linux_asm_h
+#define stub_linux_inc_linux_asm_h
+
+/** All stubs from linux/asm directory. */
+
+#include <linux/compiler.h>
+
+/* types.h */
+typedef unsigned char __u8;
+typedef unsigned short __u16;
+typedef unsigned int __u32;
+typedef unsigned short umode_t;
+typedef int ssize_t;
+
+/* atomic.h */
+typedef struct { volatile int counter; } atomic_t;
+#define ATOMIC_INIT(i) { (i) }
+#define atomic_read(v) ((v)->counter)
+#define atomic_set(v,i) (((v)->counter) = (i))
+
+/* rwsem.h */
+struct rw_semaphore {};
+
+/* poll.h */
+#define POLLPRI 0x0002
+#define POLLERR 0x0008
+
+/* bug.h */
+#define BUG_ON(condition) do { if (condition) {} } while(0)
+
+/* processor.h */
+static inline void prefetch(const void *ptr)
+{
+}
+
+#include <stdlib.h> /* for malloc & free */
+#include <string.h> /* for memset */
+#include <stdio.h> /* for sprintf */
+/* did not find these... */
+static inline void * kmalloc(int size, int flags)
+{
+ return NULL;
+}
+static inline void kfree(void * ptr)
+{
+}
+/* arch-spc300/irqs.h */
+#define INT_MBX 12
+#define INT_MBX_ACK 13
+#define INT_MBX_WD 13
+
+/* arch/param.h */
+#define HZ 100
+
+/* io.h */
+#define MT_DEVICE 0
+extern void * __arm_ioremap(unsigned long phys_addr, size_t size, unsigned int mtype);
+#define ioremap(cookie,size) __arm_ioremap(cookie, size, MT_DEVICE)
+extern void __iounmap(volatile void *addr);
+#define iounmap(cookie) __iounmap(cookie)
+
+/* memory.h */
+#define virt_to_dma(dev, addr) ((int) addr)
+#define dma_to_virt(dev, addr) ((int) addr)
+
+/* uaccess.h */
+extern unsigned long copy_from_user(void *to, const void __user *from, unsigned long n);
+extern unsigned long copy_to_user(void __user *to, const void *from, unsigned long n);
+
+#endif /* stub_linux_inc_linux_asm_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/bitops.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/bitops.h
new file mode 100644
index 0000000000..83a16882b6
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/bitops.h
@@ -0,0 +1,6 @@
+#ifndef inc_linux_asm_bitops_h
+#define inc_linux_asm_bitops_h
+
+extern inline int test_bit(int nr, const volatile unsigned long *addr);
+
+#endif /* inc_linux_asm_bitops_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/capability.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/capability.h
new file mode 100644
index 0000000000..7fbd3051c6
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/capability.h
@@ -0,0 +1,14 @@
+#ifndef stub_linux_inc_linux_capability_h
+#define stub_linux_inc_linux_capability_h
+
+#include <linux/types.h>
+
+#define _LINUX_CAPABILITY_U32S_3 2
+
+#define _KERNEL_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_3
+
+typedef struct kernel_cap_struct {
+ __u32 cap[_KERNEL_CAPABILITY_U32S];
+} kernel_cap_t;
+
+#endif /* stub_linux_inc_linux_capability_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/cdev.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/cdev.h
new file mode 100644
index 0000000000..168a437b50
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/cdev.h
@@ -0,0 +1,22 @@
+#ifndef stub_linux_inc_linux_cdev_h
+#define stub_linux_inc_linux_cdev_h
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/list.h>
+
+struct cdev {
+ struct module *owner;
+ const struct file_operations *ops;
+ struct list_head list;
+ dev_t dev;
+ unsigned int count;
+};
+
+extern void cdev_init(struct cdev *, const struct file_operations *);
+
+extern int cdev_add(struct cdev *, dev_t, unsigned);
+
+extern void cdev_del(struct cdev *);
+
+#endif /* stub_linux_inc_linux_cdev_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/compiler.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/compiler.h
new file mode 100644
index 0000000000..bbe302a179
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/compiler.h
@@ -0,0 +1,8 @@
+#ifndef stub_linux_inc_linux_compiler_h
+#define stub_linux_inc_linux_compiler_h
+
+#define unlikely(x) x
+
+#define __user
+
+#endif /* stub_linux_inc_linux_compiler_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/delay.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/delay.h
new file mode 100644
index 0000000000..25860b2565
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/delay.h
@@ -0,0 +1,6 @@
+#ifndef inc_linux_delay_h
+#define inc_linux_delay_h
+
+extern unsigned long msleep_interruptible(unsigned int msecs);
+
+#endif /* inc_linux_delay_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/device.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/device.h
new file mode 100644
index 0000000000..309238757a
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/device.h
@@ -0,0 +1,6 @@
+#ifndef stub_linux_inc_linux_device_h
+#define stub_linux_inc_linux_device_h
+
+struct device;
+
+#endif /* stub_linux_inc_linux_device_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/dma-mapping.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/dma-mapping.h
new file mode 100644
index 0000000000..327c7d0773
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/dma-mapping.h
@@ -0,0 +1,28 @@
+#ifndef stub_linux_inc_linux_dma_mapping_h
+#define stub_linux_inc_linux_dma_mapping_h
+
+#include <linux/types.h>
+#include <linux/device.h>
+
+enum dma_data_direction {
+ DMA_BIDIRECTIONAL = 0,
+ DMA_TO_DEVICE = 1,
+ DMA_FROM_DEVICE = 2,
+ DMA_NONE = 3,
+};
+
+/* Actually in asm/dma-mapping.h... */
+extern void *
+dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp);
+
+extern void
+dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
+ dma_addr_t handle);
+
+extern dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
+ enum dma_data_direction dir);
+
+extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
+ size_t size, enum dma_data_direction dir);
+
+#endif /* stub_linux_inc_linux_dma_mapping_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/errno.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/errno.h
new file mode 100644
index 0000000000..7e8a432ba4
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/errno.h
@@ -0,0 +1,12 @@
+#ifndef stub_linux_inc_linux_errno_h
+#define stub_linux_inc_linux_errno_h
+
+#define EOPNOTSUPP 1
+#define EINVAL 1
+#define ENODEV 1
+#define ENOMEM 1
+#define EFAULT 1
+#define EPERM 1
+#define EBUSY 1
+
+#endif /* stub_linux_inc_linux_errno_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/file.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/file.h
new file mode 100644
index 0000000000..9e68db0e87
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/file.h
@@ -0,0 +1,6 @@
+#ifndef stub_linux_inc_linux_file_h
+#define stub_linux_inc_linux_file_h
+
+struct file_operations;
+
+#endif /* stub_linux_inc_linux_file_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/fs.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/fs.h
new file mode 100644
index 0000000000..b9d92707c1
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/fs.h
@@ -0,0 +1,125 @@
+#ifndef stub_linux_inc_linux_fs_h
+#define stub_linux_inc_linux_fs_h
+
+#include <linux/types.h>
+#include <linux/asm.h>
+#include <linux/file.h>
+#include <linux/list.h>
+#include <linux/rcupdate.h>
+#include <linux/path.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+
+struct fown_struct {};
+struct file_ra_state {};
+struct address_space {};
+struct poll_table_struct;
+
+struct file {
+ /*
+ * fu_list becomes invalid after file_free is called and queued via
+ * fu_rcuhead for RCU freeing
+ */
+ union {
+ struct list_head fu_list;
+ struct rcu_head fu_rcuhead;
+ } f_u;
+ struct path f_path;
+#define f_dentry f_path.dentry
+#define f_vfsmnt f_path.mnt
+ const struct file_operations *f_op;
+ atomic_t f_count;
+ unsigned int f_flags;
+ mode_t f_mode;
+ loff_t f_pos;
+ struct fown_struct f_owner;
+ unsigned int f_uid, f_gid;
+ struct file_ra_state f_ra;
+ u64 f_version;
+//#ifdef CONFIG_SECURITY
+// void *f_security;
+//#endif
+ /* needed for tty driver, and maybe others */
+ void *private_data;
+//#ifdef CONFIG_EPOLL
+// /* Used by fs/eventpoll.c to link all the hooks to this file */
+// struct list_head f_ep_links;
+// spinlock_t f_ep_lock;
+//#endif /* #ifdef CONFIG_EPOLL */
+ struct address_space *f_mapping;
+};
+
+struct inode {
+ struct hlist_node i_hash;
+ struct list_head i_list;
+ struct list_head i_sb_list;
+ struct list_head i_dentry;
+ unsigned long i_ino;
+ atomic_t i_count;
+ unsigned int i_nlink;
+ uid_t i_uid;
+ gid_t i_gid;
+ dev_t i_rdev;
+ u64 i_version;
+ loff_t i_size;
+//#ifdef __NEED_I_SIZE_ORDERED
+// seqcount_t i_size_seqcount;
+//#endif
+ struct timespec i_atime;
+ struct timespec i_mtime;
+ struct timespec i_ctime;
+ unsigned int i_blkbits;
+ blkcnt_t i_blocks;
+ unsigned short i_bytes;
+ umode_t i_mode;
+ spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
+ struct mutex i_mutex;
+ struct rw_semaphore i_alloc_sem;
+ const struct inode_operations *i_op;
+ const struct file_operations *i_fop; /* former ->i_op->default_file_ops */
+ struct super_block *i_sb;
+ struct file_lock *i_flock;
+ struct address_space *i_mapping;
+ struct address_space i_data;
+//#ifdef CONFIG_QUOTA
+// struct dquot *i_dquot[MAXQUOTAS];
+//#endif
+ struct list_head i_devices;
+ union {
+ struct pipe_inode_info *i_pipe;
+ struct block_device *i_bdev;
+ struct cdev *i_cdev;
+ };
+ int i_cindex;
+ __u32 i_generation;
+//#ifdef CONFIG_DNOTIFY
+// unsigned long i_dnotify_mask; /* Directory notify events */
+// struct dnotify_struct *i_dnotify; /* for directory notifications */
+//#endif
+//#ifdef CONFIG_INOTIFY
+// struct list_head inotify_watches; /* watches on this inode */
+// struct mutex inotify_mutex; /* protects the watches list */
+//#endif
+ unsigned long i_state;
+ unsigned long dirtied_when; /* jiffies of first dirtying */
+ unsigned int i_flags;
+ atomic_t i_writecount;
+//#ifdef CONFIG_SECURITY
+// void *i_security;
+//#endif
+ void *i_private; /* fs or device private pointer */
+};
+
+struct file_operations {
+ struct module *owner;
+ ssize_t (*read) (struct file *, char *, size_t, loff_t *);
+ ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
+ unsigned int (*poll) (struct file *, struct poll_table_struct *);
+ int (*open) (struct inode *, struct file *);
+ int (*release) (struct inode *, struct file *);
+};
+
+extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *);
+extern void unregister_chrdev_region(dev_t, unsigned);
+
+#endif /* stub_linux_inc_linux_fs_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/gfp.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/gfp.h
new file mode 100644
index 0000000000..e74554b782
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/gfp.h
@@ -0,0 +1,10 @@
+#ifndef stub_linux_inc_linux_gfp_h
+#define stub_linux_inc_linux_gfp_h
+
+#define __GFP_HIGH ((gfp_t)0x20u)
+#define GFP_ATOMIC (__GFP_HIGH)
+
+#define GFP_KERNEL 1
+#define GFP_DMA 1
+
+#endif /* stub_linux_inc_linux_gfp_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/if.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/if.h
new file mode 100644
index 0000000000..0641cbde81
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/if.h
@@ -0,0 +1,8 @@
+#ifndef stub_linux_inc_linux_if_h
+#define stub_linux_inc_linux_if_h
+
+struct ifreq {
+ char dummy;
+};
+
+#endif /* stub_linux_inc_linux_if_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/if_ether.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/if_ether.h
new file mode 100644
index 0000000000..ae973e4d35
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/if_ether.h
@@ -0,0 +1,17 @@
+#ifndef stub_linux_inc_linux_if_ether_h
+#define stub_linux_inc_linux_if_ether_h
+
+#include <linux/types.h>
+
+#define ETH_P_8021Q 0x8100
+
+#define ETH_ALEN 6 /* Octets in one ethernet addr */
+#define ETH_HLEN 14 /*Total octets in header */
+
+struct ethhdr {
+ unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
+ unsigned char h_source[ETH_ALEN]; /* source ether addr */
+ __be16 h_proto; /* packet type ID field */
+} __attribute__((packed));
+
+#endif /* stub_linux_inc_linux_if_ether_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/if_vlan.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/if_vlan.h
new file mode 100644
index 0000000000..3c4db05de9
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/if_vlan.h
@@ -0,0 +1,20 @@
+#ifndef stub_linux_inc_linux_if_vlan_h
+#define stub_linux_inc_linux_if_vlan_h
+
+#include <linux/types.h>
+
+#define VLAN_ETH_ALEN 6
+#define VLAN_ETH_HLEN 18
+
+#define VLAN_VID_MASK 0x0fff
+
+struct vlan_ethhdr
+{
+ unsigned char h_dest[ETH_ALEN];
+ unsigned char h_source[ETH_ALEN];
+ unsigned short int h_vlan_proto;
+ unsigned short int h_vlan_TCI;
+ unsigned short int h_vlan_encapsulated_proto;
+} __attribute__((packed));
+
+#endif /* stub_linux_inc_linux_if_vlan_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/init.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/init.h
new file mode 100644
index 0000000000..761d2e53b2
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/init.h
@@ -0,0 +1,11 @@
+#ifndef stub_linux_inc_linux_init_h
+#define stub_linux_inc_linux_init_h
+
+#define module_init(a)
+#define module_exit(a)
+
+#define __init
+#define __exit
+#define __devinitdata
+
+#endif /* stub_linux_inc_linux_init_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/interrupt.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/interrupt.h
new file mode 100644
index 0000000000..bf7348ce88
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/interrupt.h
@@ -0,0 +1,38 @@
+#ifndef stub_linux_inc_linux_interrupt_h
+#define stub_linux_inc_linux_interrupt_h
+
+#include <linux/asm.h>
+#include <linux/irqreturn.h>
+
+typedef irqreturn_t (*irq_handler_t)(int, void *);
+
+struct tasklet_struct
+{
+ struct tasklet_struct *next;
+ unsigned long state;
+ atomic_t count;
+ void (*func)(unsigned long);
+ unsigned long data;
+};
+
+static inline void tasklet_enable(struct tasklet_struct *t)
+{
+}
+
+static inline void tasklet_disable(struct tasklet_struct *t)
+{
+}
+
+extern void tasklet_schedule(struct tasklet_struct *t);
+
+extern void tasklet_kill(struct tasklet_struct *t);
+
+extern void tasklet_init(struct tasklet_struct *t,
+ void (*func)(unsigned long), unsigned long data);
+
+extern int request_irq(unsigned int, irq_handler_t handler,
+ unsigned long, const char *, void *);
+
+extern void free_irq(unsigned int, void *);
+
+#endif /* stub_linux_inc_linux_interrupt_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/irqreturn.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/irqreturn.h
new file mode 100644
index 0000000000..355bea55ca
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/irqreturn.h
@@ -0,0 +1,9 @@
+#ifndef stub_linux_inc_linux_irqreturn_h
+#define stub_linux_inc_linux_irqreturn_h
+
+#define IRQ_HANDLED 1
+#define IRQ_NONE 0
+
+typedef int irqreturn_t;
+
+#endif /* stub_linux_inc_linux_irqreturn_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/kdev_t.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/kdev_t.h
new file mode 100644
index 0000000000..8429e6f0c9
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/kdev_t.h
@@ -0,0 +1,11 @@
+#ifndef stub_linux_inc_linux_kdev_t_h
+#define stub_linux_inc_linux_kdev_t_h
+
+#define MINORBITS 20
+#define MINORMASK ((1U << MINORBITS) - 1)
+
+#define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))
+#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
+#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))
+
+#endif /* stub_linux_inc_linux_kdev_t_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/kernel.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/kernel.h
new file mode 100644
index 0000000000..022d68bad7
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/kernel.h
@@ -0,0 +1,34 @@
+#ifndef stub_linux_inc_linux_kernel_h
+#define stub_linux_inc_linux_kernel_h
+
+/* from stddef.h */
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+
+#define min(x,y) ({ \
+ typeof(x) _x = (x); \
+ typeof(y) _y = (y); \
+ (void) (&_x == &_y); \
+ _x < _y ? _x : _y; })
+
+#define KERN_ERR "<3>"
+#define KERN_WARNING "<4>"
+#define KERN_INFO "<6>"
+
+static inline int printk(const char *s, ...)
+{
+ return 0;
+}
+
+/* from byteorder/generic.h */
+static inline unsigned short int ntohs(unsigned short int x)
+{
+ return x<<8 | x>>8;
+}
+
+#define be16_to_cpu(x) ((__u16)(__be16)(x))
+
+#endif /* stub_linux_inc_linux_kernel_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/list.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/list.h
new file mode 100644
index 0000000000..64a8de0366
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/list.h
@@ -0,0 +1,71 @@
+#ifndef stub_linux_inc_linux_list_h
+#define stub_linux_inc_linux_list_h
+
+/* from linux/poison.h */
+#define LIST_POISON1 ((void *) 0x00100100)
+#define LIST_POISON2 ((void *) 0x00200200)
+
+struct hlist_node {
+ struct hlist_node *next, **pprev;
+};
+
+struct list_head {
+ struct list_head *next, *prev;
+};
+
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define list_entry(ptr, type, member) \
+ container_of(ptr, type, member)
+
+#define list_for_each_entry(pos, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member); \
+ prefetch(pos->member.next), &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member))
+
+#define list_for_each_entry_safe(pos, n, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member), \
+ n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+static inline void INIT_LIST_HEAD(struct list_head *list)
+{
+ list->next = list;
+ list->prev = list;
+}
+
+static inline void __list_add(struct list_head *new,
+ struct list_head *prev,
+ struct list_head *next)
+{
+ next->prev = new;
+ new->next = next;
+ new->prev = prev;
+ prev->next = new;
+}
+
+static inline void list_add_tail(struct list_head *new, struct list_head *head)
+{
+ __list_add(new, head->prev, head);
+}
+
+static inline void __list_del(struct list_head * prev, struct list_head * next)
+{
+ next->prev = prev;
+ prev->next = next;
+}
+
+static inline void list_del(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+ entry->next = LIST_POISON1;
+ entry->prev = LIST_POISON2;
+}
+
+static inline int list_empty(const struct list_head *head)
+{
+ return head->next == head;
+}
+
+#endif /* stub_linux_inc_linux_list_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/module.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/module.h
new file mode 100644
index 0000000000..1cb1188291
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/module.h
@@ -0,0 +1,13 @@
+#ifndef stub_linux_inc_linux_module_h
+#define stub_linux_inc_linux_module_h
+
+struct module;
+
+#define THIS_MODULE ((struct module *)0)
+
+#define MODULE_AUTHOR(a)
+#define MODULE_DESCRIPTION(a)
+#define MODULE_LICENSE(a)
+#define MODULE_PARM_DESC(a,b)
+
+#endif /* stub_linux_inc_linux_module_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/moduleparam.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/moduleparam.h
new file mode 100644
index 0000000000..d932f30e88
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/moduleparam.h
@@ -0,0 +1,6 @@
+#ifndef stub_linux_inc_linux_moduleparam_h
+#define stub_linux_inc_linux_moduleparam_h
+
+#define module_param(a,b,c)
+
+#endif /* stub_linux_inc_linux_moduleparam_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/mutex.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/mutex.h
new file mode 100644
index 0000000000..d22eee7353
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/mutex.h
@@ -0,0 +1,30 @@
+#ifndef stub_linux_inc_linux_mutex_h
+#define stub_linux_inc_linux_mutex_h
+
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+
+struct mutex {
+ /* 1: unlocked, 0: locked, negative: locked, possible waiters */
+ atomic_t count;
+ spinlock_t wait_lock;
+ struct list_head wait_list;
+};
+
+#define __MUTEX_INITIALIZER(lockname) \
+ { .count = ATOMIC_INIT(1) \
+ , .wait_lock = __SPIN_LOCK_UNLOCKED(lockname.wait_lock) \
+ , .wait_list = LIST_HEAD_INIT(lockname.wait_list) }
+
+#define DEFINE_MUTEX(mutexname) \
+ struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)
+
+/* mutex_lock is defined in libcheck too, so we have to stub it using */
+/* a different name... */
+#define mutex_lock my_mutex_lock
+extern void my_mutex_lock(struct mutex *lock);
+
+extern void mutex_unlock(struct mutex *lock);
+
+#endif /* stub_linux_inc_linux_mutex_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/netdevice.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/netdevice.h
new file mode 100644
index 0000000000..2b9ab7ceb6
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/netdevice.h
@@ -0,0 +1,92 @@
+#ifndef stub_linux_inc_linux_netdevice_h
+#define stub_linux_inc_linux_netdevice_h
+
+#include <linux/types.h>
+#include <linux/skbuff.h>
+#include <linux/if.h>
+
+struct net_device_stats {
+ unsigned long rx_packets; /* total packets received */
+ unsigned long tx_packets; /* total packets transmitted */
+ unsigned long rx_bytes; /* total bytes received */
+ unsigned long tx_bytes; /* total bytes transmitted */
+ unsigned long rx_errors; /* bad packets received */
+ unsigned long tx_errors; /* packet transmit problems */
+ unsigned long rx_dropped; /* no space in linux buffers */
+ unsigned long tx_dropped; /* no space available in linux */
+ unsigned long multicast; /* multicast packets received */
+ unsigned long collisions;
+
+ /* detailed rx_errors: */
+ unsigned long rx_length_errors;
+ unsigned long rx_over_errors; /* receiver ring buff overflow */
+ unsigned long rx_crc_errors; /* recved pkt with crc error */
+ unsigned long rx_frame_errors; /* recv'd frame alignment error */
+ unsigned long rx_fifo_errors; /* recv'r fifo overrun */
+ unsigned long rx_missed_errors; /* receiver missed packet */
+
+ /* detailed tx_errors */
+ unsigned long tx_aborted_errors;
+ unsigned long tx_carrier_errors;
+ unsigned long tx_fifo_errors;
+ unsigned long tx_heartbeat_errors;
+ unsigned long tx_window_errors;
+
+ /* for cslip etc */
+ unsigned long rx_compressed;
+ unsigned long tx_compressed;
+};
+
+/* linux_drv_utests.h stub */
+struct net_device {
+ char name[16];
+ unsigned long base_addr;
+ void *priv;
+ unsigned char dev_addr[32];
+ unsigned char addr_len;
+ unsigned int irq;
+ unsigned int mtu;
+ unsigned long trans_start;
+ int (*init)(struct net_device *dev);
+ int (*hard_start_xmit)(struct sk_buff *skb, struct net_device *dev);
+ int (*open)(struct net_device *dev);
+ int (*stop)(struct net_device *dev);
+ int (*set_mac_address)(struct net_device *dev, void *addr);
+ struct net_device_stats* (*get_stats)(struct net_device *dev);
+ int (*do_ioctl)(struct net_device *dev, struct ifreq *ifr, int cmd);
+ int (*change_mtu)(struct net_device *dev, int new_mtu);
+};
+
+static inline void *netdev_priv(const struct net_device *dev)
+{
+ return dev->priv;
+}
+
+extern int register_netdev(struct net_device *dev);
+extern void unregister_netdev(struct net_device *dev);
+extern struct net_device *alloc_netdev(int sizeof_priv, const char *name,
+ void (*setup)(struct net_device *));
+extern void free_netdev(struct net_device* dev);
+
+extern int netif_rx(struct sk_buff *skb);
+extern void netif_carrier_on(struct net_device *dev);
+extern void netif_carrier_off(struct net_device *dev);
+static inline void netif_start_queue(struct net_device *dev)
+{
+}
+static inline void netif_stop_queue(struct net_device *dev)
+{
+}
+static inline void netif_wake_queue(struct net_device *dev)
+{
+}
+static inline int netif_queue_stopped(const struct net_device *dev)
+{
+ return 0;
+}
+
+extern void ether_setup(struct net_device *dev);
+/* from etherdevice.h */
+extern __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev);
+
+#endif /* stub_linux_inc_linux_netdevice_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/netlink.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/netlink.h
new file mode 100644
index 0000000000..efc020fe48
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/netlink.h
@@ -0,0 +1,84 @@
+#ifndef stub_linux_inc_linux_netlink_h
+#define stub_linux_inc_linux_netlink_h
+
+#include <linux/types.h>
+#include <linux/socket.h>
+#include <linux/capability.h>
+#include <linux/skbuff.h>
+#include <linux/compiler.h>
+#include <linux/mutex.h>
+#include <linux/module.h>
+#include <net/net_namespace.h>
+#include <net/sock.h>
+
+#define NETLINK_PLC_DRV 20
+#define NETLINK_PLC_MME 21
+
+struct nlmsghdr
+{
+ __u32 nlmsg_len; /* Length of message including header */
+ __u16 nlmsg_type; /* Message content */
+ __u16 nlmsg_flags; /* Additional flags */
+ __u32 nlmsg_seq; /* Sequence number */
+ __u32 nlmsg_pid; /* Sending process port ID */
+};
+
+#define NLMSG_DONE 0x3
+
+#define NLMSG_ALIGNTO 4
+#define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
+#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
+#define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(NLMSG_HDRLEN))
+#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
+#define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0)))
+
+static inline struct nlmsghdr *nlmsg_hdr(const struct sk_buff *skb)
+{
+ return (struct nlmsghdr *)skb->data;
+}
+
+static __inline__ struct nlmsghdr *
+__nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags)
+{
+ struct nlmsghdr *nlh;
+ int size = NLMSG_LENGTH(len);
+
+ nlh = (struct nlmsghdr*)skb_put(skb, NLMSG_ALIGN(size));
+ nlh->nlmsg_type = type;
+ nlh->nlmsg_len = size;
+ nlh->nlmsg_flags = flags;
+ nlh->nlmsg_pid = pid;
+ nlh->nlmsg_seq = seq;
+ memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size);
+ return nlh;
+}
+
+#define NLMSG_NEW(skb, pid, seq, type, len, flags) \
+({ if (unlikely(skb_tailroom(skb) < (int)NLMSG_SPACE(len))) \
+ goto nlmsg_failure; \
+ __nlmsg_put(skb, pid, seq, type, len, flags); })
+
+#define NLMSG_PUT(skb, pid, seq, type, len) \
+ NLMSG_NEW(skb, pid, seq, type, len, 0)
+
+struct netlink_skb_parms
+{
+ struct ucred creds; /* Skb credentials */
+ __u32 pid;
+ __u32 dst_group;
+ kernel_cap_t eff_cap;
+ __u32 loginuid; /* Login (audit) uid */
+ __u32 sid; /* SELinux security id */
+};
+
+#define NETLINK_CB(skb) (*(struct netlink_skb_parms*)&((skb)->cb))
+
+extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock);
+
+extern struct sock *netlink_kernel_create(struct net *net, int unit,
+ unsigned int groups, void (*input)(struct sk_buff *skb),
+ struct mutex *cb_mutex, struct module *module);
+
+extern void netlink_kernel_release(struct sock *sk);
+
+#endif /* stub_linux_inc_linux_netlink_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/path.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/path.h
new file mode 100644
index 0000000000..86f83ac02c
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/path.h
@@ -0,0 +1,12 @@
+#ifndef stub_linux_inc_linux_path_h
+#define stub_linux_inc_linux_path_h
+
+struct dentry;
+struct vfsmount;
+
+struct path {
+ struct vfsmount *mnt;
+ struct dentry *dentry;
+};
+
+#endif /* stub_linux_inc_linux_path_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/poll.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/poll.h
new file mode 100644
index 0000000000..a0a441031b
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/poll.h
@@ -0,0 +1,20 @@
+#ifndef stub_linux_inc_linux_poll_h
+#define stub_linux_inc_linux_poll_h
+
+#include <linux/types.h>
+#include <linux/wait.h>
+#include <linux/fs.h>
+
+typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *);
+
+typedef struct poll_table_struct {
+ poll_queue_proc qproc;
+} poll_table;
+
+static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
+{
+ if (p && wait_address)
+ p->qproc(filp, wait_address, p);
+}
+
+#endif /* stub_linux_inc_linux_poll_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/proc_fs.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/proc_fs.h
new file mode 100644
index 0000000000..dc3ac29603
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/proc_fs.h
@@ -0,0 +1,29 @@
+#ifndef stub_linux_inc_linux_proc_fs_h
+#define stub_linux_inc_linux_proc_fs_h
+
+#include <linux/types.h>
+#include <linux/spinlock.h>
+
+typedef int (read_proc_t)(char *page, char **start, off_t off,
+ int count, int *eof, void *data);
+
+struct proc_dir_entry {
+ void *data;
+ read_proc_t *read_proc;
+};
+
+static inline struct proc_dir_entry *proc_mkdir(const char *name,
+ struct proc_dir_entry *parent)
+{
+ return NULL;
+}
+
+static inline struct proc_dir_entry *create_proc_entry(const char *name,
+ mode_t mode, struct proc_dir_entry *parent)
+{
+ return NULL;
+}
+
+#define remove_proc_entry(name, parent) do {} while (0)
+
+#endif /* stub_linux_inc_linux_proc_fs_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/rcupdate.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/rcupdate.h
new file mode 100644
index 0000000000..667c4d4896
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/rcupdate.h
@@ -0,0 +1,9 @@
+#ifndef stub_linux_inc_linux_rcupdate_h
+#define stub_linux_inc_linux_rcupdate_h
+
+struct rcu_head {
+ struct rcu_head *next;
+ void (*func)(struct rcu_head *head);
+};
+
+#endif /* stub_linux_inc_linux_rcupdate_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/sched.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/sched.h
new file mode 100644
index 0000000000..6e180a080c
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/sched.h
@@ -0,0 +1,10 @@
+#ifndef stub_linux_inc_linux_sched_h
+#define stub_linux_inc_linux_sched_h
+
+#define TASK_INTERRUPTIBLE 1
+
+#define set_current_state(state_value) ((int) 0)
+
+extern signed long schedule_timeout(signed long timeout);
+
+#endif /* stub_linux_inc_linux_sched_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/skbuff.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/skbuff.h
new file mode 100644
index 0000000000..523824e453
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/skbuff.h
@@ -0,0 +1,45 @@
+#ifndef stub_linux_inc_linux_skbuff_h
+#define stub_linux_inc_linux_skbuff_h
+
+#include <linux/types.h>
+
+#define CHECKSUM_UNNECESSARY 1
+
+/* linux_drv_utests.h stub */
+struct sk_buff {
+ unsigned char *data;
+ struct net_device *dev;
+ unsigned int len;
+ unsigned short protocol;
+ unsigned char ip_summed;
+ char cb[48];
+};
+
+static inline struct sk_buff *alloc_skb(unsigned int size, int priority)
+{
+ struct sk_buff* skb;
+ skb = (struct sk_buff*)malloc((unsigned int)(sizeof(struct sk_buff)));
+ return skb;
+}
+static inline void kfree_skb(struct sk_buff *skb)
+{
+ if(skb)
+ free(skb);
+}
+
+static inline unsigned char *skb_put(struct sk_buff *skb, unsigned int len)
+{
+ return NULL;
+}
+
+static inline int skb_tailroom(const struct sk_buff *skb)
+{
+ return 0;
+}
+
+static inline unsigned char *skb_pull(struct sk_buff *skb, unsigned int len)
+{
+ return NULL;
+}
+
+#endif /* stub_linux_inc_linux_skbuff_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/socket.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/socket.h
new file mode 100644
index 0000000000..4160ed85a2
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/socket.h
@@ -0,0 +1,18 @@
+#ifndef stub_linux_inc_linux_socket_h
+#define stub_linux_inc_linux_socket_h
+
+#include <linux/types.h>
+
+#define MSG_DONTWAIT 0x40
+
+struct sockaddr {
+ char sa_data[14];
+};
+
+struct ucred {
+ __u32 pid;
+ __u32 uid;
+ __u32 gid;
+};
+
+#endif /* stub_linux_inc_linux_socket_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/spinlock.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/spinlock.h
new file mode 100644
index 0000000000..76bb624db0
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/spinlock.h
@@ -0,0 +1,35 @@
+#ifndef stub_linux_inc_linux_spinlock_h
+#define stub_linux_inc_linux_spinlock_h
+
+#include <linux/types.h>
+
+# define SPIN_DEP_MAP_INIT(lockname)
+#define __RAW_SPIN_LOCK_UNLOCKED { 0 }
+
+/* From asm. */
+typedef struct {
+ volatile unsigned int lock;
+} raw_spinlock_t;
+
+typedef struct {
+ raw_spinlock_t raw_lock;
+// #ifdef CONFIG_GENERIC_LOCKBREAK
+// unsigned int break_lock;
+// #endif
+} spinlock_t;
+
+# define __SPIN_LOCK_UNLOCKED(lockname) \
+ (spinlock_t) { .raw_lock = __RAW_SPIN_LOCK_UNLOCKED, \
+ SPIN_DEP_MAP_INIT(lockname) }
+
+#define SPIN_LOCK_UNLOCKED __SPIN_LOCK_UNLOCKED(old_style_spin_init)
+
+# define spin_lock_init(lock) \
+ do { *(lock) = SPIN_LOCK_UNLOCKED; } while (0)
+
+#define spin_lock_irqsave(lock, flags) ((int) 0)
+#define spin_lock_irqrestore(lock, flags) ((int) 0)
+
+#define spin_unlock_irqrestore(lock, flags) ((int) 0)
+
+#endif /* stub_linux_inc_linux_spinlock_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/types.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/types.h
new file mode 100644
index 0000000000..0643cc52b9
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/types.h
@@ -0,0 +1,23 @@
+#ifndef stub_linux_inc_linux_types_h
+#define stub_linux_inc_linux_types_h
+
+#include <linux/asm.h>
+
+#include <stdint.h>
+#include <sys/types.h>
+
+typedef _Bool bool;
+#define false 0
+#define true 1
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned long u32;
+typedef unsigned long long u64;
+
+typedef __u16 __be16;
+
+typedef unsigned int gfp_t;
+typedef unsigned int dma_addr_t;
+
+#endif /* stub_linux_inc_linux_types_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/wait.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/wait.h
new file mode 100644
index 0000000000..c2b2fdd940
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/linux/wait.h
@@ -0,0 +1,32 @@
+#ifndef stub_linux_inc_linux_wait_h
+#define stub_linux_inc_linux_wait_h
+
+#include <linux/list.h>
+#include <linux/spinlock.h>
+
+struct __wait_queue_head {
+ spinlock_t lock;
+ struct list_head task_list;
+};
+
+typedef struct __wait_queue_head wait_queue_head_t;
+
+#define __WAIT_QUEUE_HEAD_INITIALIZER(name) { \
+ .lock = __SPIN_LOCK_UNLOCKED(name.lock), \
+ .task_list = { &(name).task_list, &(name).task_list } }
+
+#define DECLARE_WAIT_QUEUE_HEAD(name) \
+ wait_queue_head_t name = __WAIT_QUEUE_HEAD_INITIALIZER(name)
+
+#define wait_event_interruptible(wq, condition) ((int) 0)
+#define wake_up(x) ((int) 0)
+#define wake_up_interruptible(x) ((int) 0)
+
+static inline int waitqueue_active(wait_queue_head_t *q)
+{
+ return !list_empty(&q->task_list);
+}
+
+extern void init_waitqueue_head(wait_queue_head_t *q);
+
+#endif /* stub_linux_inc_linux_wait_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/net/net_namespace.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/net/net_namespace.h
new file mode 100644
index 0000000000..62203caf20
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/net/net_namespace.h
@@ -0,0 +1,55 @@
+#ifndef stub_linux_inc_net_net_namespace_h
+#define stub_linux_inc_net_net_namespace_h
+
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/netdevice.h>
+#include <linux/spinlock.h>
+#include <linux/proc_fs.h>
+#include <net/sock.h>
+
+struct net {
+ atomic_t count; /* To decided when the network
+ * namespace should be freed.
+ */
+ atomic_t use_count; /* To track references we
+ * destroy on demand
+ */
+ struct list_head list; /* list of network namespaces */
+// struct work_struct work; /* work struct for freeing */
+
+ struct proc_dir_entry *proc_net;
+ struct proc_dir_entry *proc_net_stat;
+
+ struct list_head sysctl_table_headers;
+
+ struct net_device *loopback_dev; /* The loopback */
+
+ struct list_head dev_base_head;
+// struct hlist_head *dev_name_head;
+// struct hlist_head *dev_index_head;
+
+ /* core fib_rules */
+ struct list_head rules_ops;
+ spinlock_t rules_mod_lock;
+
+ struct sock *rtnl; /* rtnetlink socket */
+
+// /* core sysctls */
+// struct ctl_table_header *sysctl_core_hdr;
+// int sysctl_somaxconn;
+//
+// struct netns_packet packet;
+// struct netns_unix unx;
+// struct netns_ipv4 ipv4;
+//#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+// struct netns_ipv6 ipv6;
+//#endif
+//#ifdef CONFIG_NETFILTER
+// struct netns_xt xt;
+//#endif
+};
+
+extern struct net init_net;
+
+#endif /* stub_linux_inc_net_net_namespace_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/net/seq_check.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/net/seq_check.h
new file mode 100644
index 0000000000..894ea52690
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/net/seq_check.h
@@ -0,0 +1,28 @@
+#ifndef stub_linux_inc_net_seq_check_h
+#define stub_linux_inc_net_seq_check_h
+
+#include <linux/types.h>
+#include <linux/skbuff.h>
+
+#define SEQ_CHECK_VLAN_MAX 64
+#define SEQ_CHECK_DRV_NAME_SZ 10
+
+/* seq_check context. */
+struct seq_check_ctx
+{
+ /* Expected sequence number for the next received packet. For each VLAN. */
+ uint16_t seq_num_expected_rx[SEQ_CHECK_VLAN_MAX];
+
+ /* Expected sequence number for the next sent packet. For each VLAN. */
+ uint16_t seq_num_expected_tx[SEQ_CHECK_VLAN_MAX];
+
+ /* Name of the network driver. */
+ char drv_name[SEQ_CHECK_DRV_NAME_SZ];
+};
+
+/* we will have to create a corresponding source file if we want to use these functions */
+#define seq_check_init(ctx, drv_name) do {} while(0)
+#define seq_check_rx(ctx, skb) do {} while(0)
+#define seq_check_tx(ctx, skb) do {} while(0)
+
+#endif /* stub_linux_inc_net_seq_check_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/net/sock.h b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/net/sock.h
new file mode 100644
index 0000000000..0db9d16fb1
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/inc/net/sock.h
@@ -0,0 +1,13 @@
+#ifndef stub_linux_inc_net_sock_h
+#define stub_linux_inc_net_sock_h
+
+#include <linux/types.h>
+#include <linux/skbuff.h>
+#include <linux/socket.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+
+struct sock_common;
+struct sock;
+
+#endif /* stub_linux_inc_linux_skbuff_h */
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/af_netlink.c b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/af_netlink.c
new file mode 100644
index 0000000000..10588fdbbf
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/af_netlink.c
@@ -0,0 +1,24 @@
+#include <linux/types.h>
+#include <linux/netlink.h>
+#include <linux/skbuff.h>
+#include <linux/mutex.h>
+#include <linux/module.h>
+#include <net/net_namespace.h>
+#include <net/sock.h>
+
+int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock)
+{
+ return 0;
+}
+
+struct sock *netlink_kernel_create(struct net *net, int unit,
+ unsigned int groups, void (*input)(struct sk_buff *skb),
+ struct mutex *cb_mutex, struct module *module)
+{
+ return NULL;
+}
+
+void netlink_kernel_release(struct sock *sk)
+{
+}
+
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/afe.c b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/afe.c
new file mode 100644
index 0000000000..55bfbfaa1b
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/afe.c
@@ -0,0 +1,6 @@
+# include <linux/afe.h>
+
+int afe_write_reg(uint8_t reg, uint8_t val)
+{
+ return 0;
+}
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/bitops.c b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/bitops.c
new file mode 100644
index 0000000000..824bdeeba1
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/bitops.c
@@ -0,0 +1,6 @@
+#include <linux/bitops.h>
+
+inline int test_bit(int nr, const volatile unsigned long *addr)
+{
+ return 0;
+}
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/char_dev.c b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/char_dev.c
new file mode 100644
index 0000000000..caeb5b8d3d
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/char_dev.c
@@ -0,0 +1,26 @@
+#include <linux/types.h>
+#include <linux/cdev.h>
+#include <linux/fs.h>
+
+int cdev_add(struct cdev *p, dev_t dev, unsigned count)
+{
+ return 0;
+}
+
+void cdev_del(struct cdev *p)
+{
+}
+
+void cdev_init(struct cdev *cdev, const struct file_operations *fops)
+{
+}
+
+int alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count,
+ const char *name)
+{
+ return 0;
+}
+
+void unregister_chrdev_region(dev_t from, unsigned count)
+{
+}
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/delay.c b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/delay.c
new file mode 100644
index 0000000000..dafdeee6f5
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/delay.c
@@ -0,0 +1,6 @@
+#include <linux/delay.h>
+
+unsigned long msleep_interruptible(unsigned int msecs)
+{
+ return 0;
+}
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/dma.c b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/dma.c
new file mode 100644
index 0000000000..0fdcd00a21
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/dma.c
@@ -0,0 +1,25 @@
+#include <linux/dma-mapping.h>
+#include <linux/device.h>
+#include <linux/asm.h>
+
+void *
+dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *handle, gfp_t gfp)
+{
+ return NULL;
+}
+
+void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
+ dma_addr_t handle)
+{
+}
+
+dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
+ enum dma_data_direction dir)
+{
+ return 0;
+}
+
+void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
+ enum dma_data_direction dir)
+{
+}
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/eth.c b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/eth.c
new file mode 100644
index 0000000000..37eac916a7
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/eth.c
@@ -0,0 +1,12 @@
+#include <linux/types.h>
+#include <linux/netdevice.h>
+#include <linux/skbuff.h>
+
+void ether_setup(struct net_device *dev)
+{
+}
+
+__be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev)
+{
+ return 5;
+}
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/ioremap.c b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/ioremap.c
new file mode 100644
index 0000000000..c5113eeaf9
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/ioremap.c
@@ -0,0 +1,10 @@
+#include <linux/asm.h>
+
+void * __arm_ioremap(unsigned long phys_addr, size_t size, unsigned int mtype)
+{
+ return (void*)phys_addr;
+}
+
+void __iounmap(volatile void *addr)
+{
+}
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/irq_manage.c b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/irq_manage.c
new file mode 100644
index 0000000000..e236dd44bb
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/irq_manage.c
@@ -0,0 +1,12 @@
+#include <linux/irqreturn.h>
+#include <linux/interrupt.h>
+
+void free_irq(unsigned int irq, void *dev_id)
+{
+}
+
+int request_irq(unsigned int irq, irq_handler_t handler,
+ unsigned long irqflags, const char *devname, void *dev_id)
+{
+ return 0;
+}
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/mutex.c b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/mutex.c
new file mode 100644
index 0000000000..e70b55bdab
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/mutex.c
@@ -0,0 +1,11 @@
+#include <linux/mutex.h>
+
+/* mutex_lock is defined in libcheck too, so we have to stub it using */
+/* a different name... */
+inline void my_mutex_lock(struct mutex *lock)
+{
+}
+
+inline void mutex_unlock(struct mutex *lock)
+{
+}
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/net_dev.c b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/net_dev.c
new file mode 100644
index 0000000000..31f63a46ba
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/net_dev.c
@@ -0,0 +1,42 @@
+#include <linux/netdevice.h>
+
+#include <stdlib.h>
+
+int register_netdev(struct net_device *dev)
+{
+ return 0;
+}
+
+void unregister_netdev(struct net_device *dev)
+{
+}
+
+struct net_device *alloc_netdev(int sizeof_priv, const char *name,
+ void (*setup)(struct net_device *))
+{
+ struct net_device* dev;
+ dev = (struct net_device*)malloc((unsigned int)(sizeof(struct net_device)));
+ dev->priv = malloc((unsigned int)(sizeof_priv));
+ return dev;
+}
+
+void free_netdev(struct net_device* dev)
+{
+ if(dev->priv)
+ free(dev->priv);
+ free((void*)(dev));
+}
+
+int netif_rx(struct sk_buff *skb)
+{
+ return 0;
+}
+
+void netif_carrier_on(struct net_device *dev)
+{
+}
+
+void netif_carrier_off(struct net_device *dev)
+{
+}
+
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/softirq.c b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/softirq.c
new file mode 100644
index 0000000000..fbcd75c2bf
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/softirq.c
@@ -0,0 +1,15 @@
+#include <linux/interrupt.h>
+#include <linux/asm.h>
+
+void tasklet_init(struct tasklet_struct *t,
+ void (*func)(unsigned long), unsigned long data)
+{
+}
+
+void tasklet_kill(struct tasklet_struct *t)
+{
+}
+
+void tasklet_schedule(struct tasklet_struct *t)
+{
+}
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/uaccess.c b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/uaccess.c
new file mode 100644
index 0000000000..8d03603f73
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/uaccess.c
@@ -0,0 +1,32 @@
+#include <linux/asm.h>
+#include <linux/compiler.h>
+#include <stdlib.h>
+
+/* temporary hack */
+#define sizeof(plccode) 124
+
+unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
+{
+ if(n)
+ {
+ memcpy(to, from, sizeof(plccode));
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+}
+
+unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
+{
+ if(n)
+ {
+ memcpy(to, from, sizeof(plccode));
+ return 0;
+ }
+ else
+ {
+ return -1;
+ }
+}
diff --git a/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/wait.c b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/wait.c
new file mode 100644
index 0000000000..7a0f77f67f
--- /dev/null
+++ b/cleopatre/devkit/tests/plcdrv/arm/utests/stub/linux/src/wait.c
@@ -0,0 +1,7 @@
+#include <linux/wait.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+
+void init_waitqueue_head(wait_queue_head_t *q)
+{
+}
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/ftests/.exrc b/cleopatre/devkit/tests/plcdrv/gidel/ftests/.exrc
deleted file mode 100644
index 1a8f6166fd..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/ftests/.exrc
+++ /dev/null
@@ -1,74 +0,0 @@
-if &cp | set nocp | endif
-let s:cpo_save=&cpo
-set cpo&vim
-nmap \cv <Plug>VCSVimDiff
-nmap \cu <Plug>VCSUpdate
-nmap \cU <Plug>VCSUnlock
-nmap \cs <Plug>VCSStatus
-nmap \cr <Plug>VCSReview
-nmap \cq <Plug>VCSRevert
-nmap \cl <Plug>VCSLog
-nmap \cL <Plug>VCSLock
-nmap \ci <Plug>VCSInfo
-nmap \cg <Plug>VCSGotoOriginal
-nmap \cd <Plug>VCSDiff
-nmap \cD <Plug>VCSDelete
-nmap \cc <Plug>VCSCommit
-nmap \cG <Plug>VCSClearAndGotoOriginal
-nmap \cn <Plug>VCSAnnotate
-nmap \ca <Plug>VCSAdd
-nmap \f :FunctionHeader
-map \dk <Plug>DirDiffPrev
-map \dj <Plug>DirDiffNext
-map \dp <Plug>DirDiffPut
-map \dg <Plug>DirDiffGet
-nmap gx <Plug>NetrwBrowseX
-nnoremap <silent> <Plug>NetrwBrowseX :call netrw#NetBrowseX(expand("<cWORD>"),0)
-nnoremap <silent> <Plug>CVSWatchRemove :CVSWatch remove
-nnoremap <silent> <Plug>CVSWatchOn :CVSWatch on
-nnoremap <silent> <Plug>CVSWatchOff :CVSWatch off
-nnoremap <silent> <Plug>CVSWatchAdd :CVSWatch add
-nnoremap <silent> <Plug>CVSWatchers :CVSWatchers
-nnoremap <silent> <Plug>CVSUnedit :CVSUnedit
-nnoremap <silent> <Plug>CVSEditors :CVSEditors
-nnoremap <silent> <Plug>CVSEdit :CVSEdit
-nnoremap <silent> <Plug>VCSVimDiff :VCSVimDiff
-nnoremap <silent> <Plug>VCSUpdate :VCSUpdate
-nnoremap <silent> <Plug>VCSUnlock :VCSUnlock
-nnoremap <silent> <Plug>VCSStatus :VCSStatus
-nnoremap <silent> <Plug>VCSReview :VCSReview
-nnoremap <silent> <Plug>VCSRevert :VCSRevert
-nnoremap <silent> <Plug>VCSLog :VCSLog
-nnoremap <silent> <Plug>VCSLock :VCSLock
-nnoremap <silent> <Plug>VCSInfo :VCSInfo
-nnoremap <silent> <Plug>VCSClearAndGotoOriginal :VCSGotoOriginal!
-nnoremap <silent> <Plug>VCSGotoOriginal :VCSGotoOriginal
-nnoremap <silent> <Plug>VCSDiff :VCSDiff
-nnoremap <silent> <Plug>VCSDelete :VCSDelete
-nnoremap <silent> <Plug>VCSCommit :VCSCommit
-nnoremap <silent> <Plug>VCSAnnotate :VCSAnnotate
-nnoremap <silent> <Plug>VCSAdd :VCSAdd
-let &cpo=s:cpo_save
-unlet s:cpo_save
-set backspace=indent,eol,start
-set cindent
-set cinoptions=:0g0t0(0u0W1s
-set expandtab
-set fileencodings=ucs-bom,utf-8,default,latin1
-set grepprg=grep\ -r\ -n\ --exclude\ 'tags'\ --exclude\ 'CVS'\ --exclude\ '*.svn*'\ --exclude\ '*.cmd*'\ --exclude\ '*.hg*'\ $*\ *\ /dev/null
-set helplang=fr
-set hlsearch
-set incsearch
-set laststatus=2
-set printoptions=paper:a4
-set ruler
-set runtimepath=~/.vim,/var/lib/vim/addons,/usr/share/vim/vimfiles,/usr/share/vim/vim71,/usr/share/vim/vimfiles/after,/var/lib/vim/addons/after,~/.vim/after
-set shiftwidth=4
-set showcmd
-set smarttab
-set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc
-set tags=./tags,./TAGS,tags,TAGS,~/undersvn/trunk/cleopatre/tags
-set textwidth=78
-set wildmenu
-set wildmode=longest:full,full
-" vim: set ft=vim :
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/ftests/Makefile b/cleopatre/devkit/tests/plcdrv/gidel/ftests/Makefile
deleted file mode 100644
index b853d881d0..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/ftests/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-all:
- make -C ../../../../plcdrv/gidel
- make -C lo_ecos
-
-clean:
- make -C ../../../../plcdrv/gidel clean
- make -C lo_ecos clean
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/Config b/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/Config
deleted file mode 100644
index 50fb50f374..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/Config
+++ /dev/null
@@ -1,2 +0,0 @@
-CONFIG_DEBUG = y
-CONFIG_TRACE = n
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/Makefile b/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/Makefile
deleted file mode 100644
index 286f3cb463..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-BASE = ../../../../../../../cesar
-
-ECOS = y
-TARGET = sparc
-
-DEFS = -DLOOPBACK_DEBUG
-
-TARGET_PROGRAMS = loopback
-
-loopback_SOURCES = loopback.c
-loopback_MODULES = lib hal/hle
-
-include $(BASE)/common/make/top.mk
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/Makefile_debug b/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/Makefile_debug
deleted file mode 100644
index 996536a124..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/Makefile_debug
+++ /dev/null
@@ -1,30 +0,0 @@
-OBJPATH=obj
-CC=sparc-elf-
-
-
-FILES_ELF=$(shell (ls $(OBJPATH)/*.elf))
-FILES=$(foreach i,$(FILES_ELF),$(basename $(shell (basename $i))))
-TODO_HEX=$(foreach i,$(FILES),$(OBJPATH)/$i.hex)
-TODO_BIN=$(foreach i,$(FILES),$(OBJPATH)/$i.bin)
-TODO_DIS=$(foreach i,$(FILES),$(OBJPATH)/$i.dis)
-
-
-all: $(TODO_HEX) $(TODO_BIN) $(TODO_DIS)
-
-clean:
- rm -f $(TODO_HEX) $(TODO_DIS)
-
-$(OBJPATH)/%.bin: $(OBJPATH)/%.elf
- $(CC)objcopy -O binary $< $@
-
-$(OBJPATH)/%.hex: $(OBJPATH)/%.elf
- $(CC)objcopy -SO ihex $< $@
-
-$(OBJPATH)/%.dis: $(OBJPATH)/%.elf
- $(CC)objdump -DSt $< > $@
-
-$(OBJPATH)/%.elf:
- @if [ ! \( -f $@ \) ]; then \
- echo "Please compile the $@ before"; \
- false; \
- fi
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/common.h b/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/common.h
deleted file mode 100644
index 0e60d6c9fa..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/common.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef common_h
-#define common_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file common.h
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-
-/** Debug mode */
-#ifdef LOOPBACK_DEBUG
-#define TRACE diag_printf
-#else
-#define TRACE(...)
-#endif
-
-
-#endif /* common_h */
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/ecos.ecc.sh b/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/ecos.ecc.sh
deleted file mode 100644
index db2208c6cc..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/ecos.ecc.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-config=${1:-ecos-gen.ecc}
-ecosconfig --config=$config new sparc_leon default
-cat >> $config <<'EOF'
-EOF
-ecosconfig --config=$config check
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/src/loopback.c b/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/src/loopback.c
deleted file mode 100644
index 5874119ddd..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/ftests/lo_ecos/src/loopback.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file loopback.c
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-
-#include <cyg/kernel/kapi.h>
-#include <cyg/infra/diag.h>
-
-#include "common/std.h"
-#include "hal/hle/ipmbox.h"
-#include "hal/hle/defs.h"
-#include "lib/utils.h"
-#include "hal/hle/inc/trace.h"
-
-#include "common.h"
-
-#define MAIL_THREAD_STACK_SIZE (4096 / sizeof(int))
-
-int mail_thread_stack[MAIL_THREAD_STACK_SIZE];
-cyg_handle_t mail_thread_handle;
-cyg_thread mail_thread_obj;
-
-ipmbox_t *ipmbox_ctx;
-
-/**
- * Thread procedure.
- */
-void mail_thread(cyg_addrword_t index)
-{
- unsigned int my_counter = 0;
- while(1)
- {
- cyg_thread_delay(300);
-// diag_printf("ct=%d\n",my_counter);
- if(!my_counter)
- ipmbox_trace_print(ipmbox_ctx);
- my_counter++;
- }
-}
-
-/**
- * Mailbox receive handler functions.
- */
-void ipmbox_rx(void *user_data, u32 *first_msg, uint length)
-{
- ipmbox_msg_hdr_t *msg_hdr;
- uint offset = 0;
- uint msg_size;
-
- TRACE("\n\nin IPMBOX RX\n");
-
- while(length)
- {
- //Recover message header.
- msg_hdr = (ipmbox_msg_hdr_t*)(first_msg + offset);
- //Recover message size.
- msg_size = (sizeof(ipmbox_msg_hdr_t)/sizeof(u32)) + msg_hdr->length;
-
- switch((hle_msg_type_t)msg_hdr->type)
- {
- case HLE_MSG_TYPE_BUFFER_ADD:
- TRACE("RECEIVE a buffer add\n");
- //Transform buffer_add message into send_done.
- msg_hdr->type = (msg_hdr->type & ~BF_MASK(IPMBOX_REG__MSG_TYPE)) | BF_SHIFT(IPMBOX_REG__MSG_TYPE, 0x02);
- //Send this new message.
- ipmbox_tx(ipmbox_ctx, (u32*)msg_hdr, msg_size);
- break;
- case HLE_MSG_TYPE_INTERFACE:
- TRACE("RECEIVE an interface\n");
- //Send the same message.
- ipmbox_tx(ipmbox_ctx, (u32*)msg_hdr, msg_size);
- break;
- case HLE_MSG_TYPE_DATA:
- TRACE("RECEIVE a data\n");
- //Send the same message.
- ipmbox_tx(ipmbox_ctx, (u32*)msg_hdr, msg_size);
- break;
- default:
- break;
- }
- //Prepare ptrs for next messages
- offset += msg_size;
- length -= msg_size;
- }
-
- TRACE("end IPMBOX RX\n");
-}
-
-/**
- * Main starting point for the application.
- */
-void cyg_user_start(void)
-{
- //Initialise the mailbox.
- ipmbox_ctx = ipmbox_init(0, &ipmbox_rx);
-
- //Activate ipmboxes.
- ipmbox_activate(ipmbox_ctx, true);
-
- //Create a thread
- cyg_thread_create(12, mail_thread, (cyg_addrword_t) 0, "Mail Thread", &mail_thread_stack, MAIL_THREAD_STACK_SIZE, &mail_thread_handle, &mail_thread_obj);
-
- cyg_thread_resume(mail_thread_handle);
-
- cyg_scheduler_start();
-}
-
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/htests/Makefile b/cleopatre/devkit/tests/plcdrv/gidel/htests/Makefile
deleted file mode 100644
index b65925e5c2..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/htests/Makefile
+++ /dev/null
@@ -1,43 +0,0 @@
-BASE := $(CURDIR)/../../../..
-OBJPATH := ./obj
-GIDEL_LIBPATH := $(BASE)/hal/gidel
-INC_GIDEL_LIBPATH := $(GIDEL_LIBPATH)
-PRJPATH := $(BASE)/plcdrv/gidel
-###################################################
-
-# Common stuff
-CC := g++
-CFLAGS := -Wall -g3 -D__HTESTS__ -DLINUX -I. -I./inc -I$(INC_GIDEL_LIBPATH) -I$(PRJPATH)/inc
-LIBS := -L$(GIDEL_LIBPATH) -lgidel -lgidelproc
-export LD_LIBRARY_PATH=\$$LD_LIBRARY_PATH:$(GIDEL_LIBPATH)
-
-# Rules
-all: $(GIDEL_LIBPATH)/libgidel.so
- mkdir -p $(OBJPATH)
- $(MAKE) $(OBJPATH)/mbx_htests
- $(MAKE) $(OBJPATH)/hal_htests
-
-$(GIDEL_LIBPATH)/libgidel.so:
- $(MAKE) -C $(GIDEL_LIBPATH)
-
-$(OBJPATH)/mbx_htests : $(OBJPATH)/mbx_htests.o $(OBJPATH)/mailbox.o $(OBJPATH)/hal.o $(OBJPATH)/processing.o $(OBJPATH)/plc_drv.o
- $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
-
-$(OBJPATH)/hal_htests : $(OBJPATH)/hal_htests.o $(OBJPATH)/hal.o
- $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
-
-$(OBJPATH)/%.o : src/%.cpp
- $(CC) $(CFLAGS) -c -o $@ $<
-
-$(OBJPATH)/%.o : src/%.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-$(OBJPATH)/%.o : $(PRJPATH)/src/%.cpp
- $(CC) $(CFLAGS) -c -o $@ $<
-
-$(OBJPATH)/%.o : $(PRJPATH)/src/%.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-clean :
- rm -rf $(OBJPATH)
-
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/htests/src/hal_htests.cpp b/cleopatre/devkit/tests/plcdrv/gidel/htests/src/hal_htests.cpp
deleted file mode 100644
index 79b04d735c..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/htests/src/hal_htests.cpp
+++ /dev/null
@@ -1,270 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test_hal.cpp
- * \brief tests of the HAL layer.
- * \ingroup Cleopatre - Isis
- *
- * For all tests of the hal procedure we have to check our functionnalities
- * directly with the hardware
- */
-
-#include <iostream>
-#include <vector>
-#include "hal.h"
-
-struct init_info init;
-static void test_handler(void* data)
-{
- printf("Catched Interrupt\n");
-}
-
-void test_init(void)
-{
- printf("Init................");
- //Test init procedure
- halmbx_init(&init, &test_handler);
- printf("OK\n");
-}
-
-
-void test_uninit(void)
-{
- printf("UnInit..............");
- //Test uninit procedure
- halmbx_uninit();
- printf("OK\n");
-}
-
-void test_A2La_it_disable(void)
-{
- printf("A2La_it_disable.....");
- //Test Arm to Leon ack interrupt disable procedure
- A2La_it_disable();
- printf("OK\n");
-}
-
-void test_L2At_it_disable(void)
-{
- printf("L2At_it_disable.....");
- //Test Leon to Arm interrupt disable procedure
- L2At_it_disable();
- printf("OK\n");
-}
-
-void test_A2La_it_enable(void)
-{
- printf("A2La_it_enable......");
- //Test Arm to Leon ack interrupt enable procedure
- A2La_it_enable();
- printf("OK\n");
-}
-
-void test_L2At_it_enable(void)
-{
- printf("L2At_it_enable......");
- //Test Leon to Arm interrupt enable procedure
- L2At_it_enable();
- printf("OK\n");
-}
-
-void test_A2Lmail_status_queue(void)
-{
- printf("A2L_satus_queue....\n");
- printf(" Prepare for FULL...");
- //Just wait you check hardware
- getchar();
- getchar();
- //Test Arm to Leon status queue procedure
- if(halmbx_A2Lmail_status_queue())
- printf("FULL\n");
- else
- printf("NOT FULL\n");
- printf(" Prepare for NOT FULL...");
- //Just wait you check hardware
- getchar();
- //Test Arm to Leon status queue procedure
- if(halmbx_A2Lmail_status_queue())
- printf("FULL\n");
- else
- printf("NOT FULL\n");
-}
-
-void test_set_A2Lt_interrupt()
-{
- printf("Set A2Lt_it......");
- //Test Arm to Leon interrupt set procedure
- set_A2Lt_interrupt();
- printf("OK\n");
-}
-void test_set_L2Aa_interrupt()
-{
- printf("Set L2Aa_it......");
- //Test Leon to Arm acknowledge interrupt set procedure
- set_L2Aa_interrupt();
- printf("OK\n");
-}
-void test_clr_L2At_interrupt()
-{
- printf("Clr L2At_it......");
- //Test Leon to Arm interrupt clear procedure
- clr_L2At_interrupt();
- printf("OK\n");
-}
-void test_clr_A2La_interrupt()
-{
- printf("Clr A2La_it......");
- //Test Arm to Leon acknowledge interrupt clear procedure
- clr_A2La_interrupt();
- printf("OK\n");
-}
-
-void test_check_its(void)
-{
- enum pending_its result;
- printf("check_its....");
- //Test interrupt handler for Leon to Arm interrupt
- result = check_its();
- if(result == ALL)
- printf("ALL\n");
- else if(result == A2LA)
- printf("A2LA\n");
- else if(result == L2AT)
- printf("L2AT\n");
- else if(result == NONE)
- printf("NONE\n");
-}
-
-void test_ring_copy(void)
-{
- uint32_t buffer[] = {0xDEADBEEF, 0xFEEDBEEF};
- printf("copy_to_ring....");
- //Test copy to ring buffers
- halmbx_copy_to_ring(buffer, 8);
- printf("OK\n");
-}
-
-void test_update_copy(void)
-{
- printf("ring update....");
- //Test update ring pointers
- halmbx_A2Lmail_update(8);
- printf("OK\n");
-}
-
-void test_gidel_buffers(void)
-{
- uint32_t msg;
- uint32_t buffer[] = {0xDEADBEEF, 0xFEEDBEEF};
-
- printf("gidel buffers....");
- //Test gidel buffer mechanism
- msg = halmbx_save_in_gidel_memory(buffer, 8);
- printf("(0x%x)....",msg);
- halmbx_free_in_gidel_memory((uint32_t*)msg);
- printf("OK\n");
-}
-
-int main(void)
-{
- int choice;
- int cont = 1;
-
- printf("Starting Tests for HAL layer with a real hardware\n");
-
- do
- {
- printf("\n[0] Exit\n");
- printf("[1] Init\n");
- printf("[2] UnInit\n");
- printf("[3] A2La_it_disable\n");
- printf("[4] L2At_it_disable\n");
- printf("[5] A2La_it_enable\n");
- printf("[6] L2At_it_enable\n");
- printf("[7] A2Lmail_status_queue\n");
- printf("[8] Set_A2Lt_interrupt\n");
- printf("[9] Set_L2Aa_interrupt\n");
- printf("[10] Clr_L2At_interrupt\n");
- printf("[11] Clr_A2La_interrupt\n");
- printf("[12] Check interrupts\n");
- printf("[13] Ring copy\n");
- printf("[14] Update ring pointers\n");
- printf("[15] Gidel buffers mechanism\n");
- printf("\nWhich test do you want ? : ");
- scanf("%d",&choice);
-
- switch(choice)
- {
- //Test hal init procedure
- case 1: test_init();
- break;
-
- //Test hal uninit procedure
- case 2: test_uninit();
- break;
-
- //Test Arm to Leon ack interrupt disable procedure
- case 3: test_A2La_it_disable();
- break;
-
- //Test Leon to Arm interrupt disable procedure
- case 4: test_L2At_it_disable();
- break;
-
- //Test Arm to Leon ack interrupt enable procedure
- case 5: test_A2La_it_enable();
- break;
-
- //Test Leon to Arm interrupt enable procedure
- case 6: test_L2At_it_enable();
- break;
-
- //Test Arm to Leon status queue procedure
- case 7: test_A2Lmail_status_queue();
- break;
-
- //Test Arm to Leon interrupt set procedure
- case 8: test_set_A2Lt_interrupt();
- break;
-
- //Test Leon to Arm acknowledge interrupt set procedure
- case 9: test_set_L2Aa_interrupt();
- break;
-
- //Test Leon to Arm interrupt clear procedure
- case 10: test_clr_L2At_interrupt();
- break;
-
- //Test Arm to Leon acknowledge interrupt clear procedure
- case 11: test_clr_A2La_interrupt();
- break;
-
- //Test interrupt handler for Leon to Arm interrupt
- case 12: test_check_its();
- break;
-
- //Test copy to ring buffers
- case 13: test_ring_copy();
- break;
-
- //Test update ring pointers
- case 14: test_update_copy();
- break;
-
- //Test gidel buffers
- case 15: test_gidel_buffers();
- break;
-
- case 0:
- default: cont = 0;
- }
- } while(cont);
-
- return 0;
-}
-
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/htests/src/mbx_htests.cpp b/cleopatre/devkit/tests/plcdrv/gidel/htests/src/mbx_htests.cpp
deleted file mode 100644
index ae6a63e1d7..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/htests/src/mbx_htests.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test_hal.cpp
- * \brief tests of the HAL layer.
- * \ingroup Cleopatre - Isis
- *
- * For all tests of the hal procedure we have to check our functionnalities
- * directly with the hardware
- */
-
-#include <iostream>
-#include <vector>
-#include "mailbox.h"
-
-struct init_info init;
-static void test_handler(void)
-{
- printf("TX ack Interrupt\n");
-}
-
-void test_init(void)
-{
- printf("Init................");
-
- init.nb_data_buf_alloc = 1;
- init.nb_mme_buf_alloc = 1;
- init.nb_interface_buf_alloc = 1;
- init.txack_handler = &test_handler;
-
- //Test init procedure
- mailbox_init(&init);
- printf("OK\n");
-}
-
-
-void test_uninit(void)
-{
- printf("UnInit..............");
- //Test uninit procedure
- mailbox_uninit();
- printf("OK\n");
-}
-
-void test_send(void)
-{
- char msg[] = {0xEF, 0xBE, 0xAD, 0xDE, 0xEF, 0xBE, 0xED, 0xFE, 0xFE, 0xCA};
- printf("Send......................");
- printf("\nPrepare for FULL case.....");
- getchar();
- getchar();
- //Test mailbox send procedure
- if(mailbox_send((void*)msg, sizeof(msg), MME) != 0)
- printf("OK\n");
- else
- printf("KO\n");
-
- printf("Prepare for NORMAL case...");
- getchar();
- //Test mailbox send procedure
- if(mailbox_send((void*)msg, sizeof(msg), MME) == 0)
- printf("OK\n");
- else
- printf("KO\n");
-}
-
-int main(void)
-{
- int choice;
- int cont = 1;
-
- printf("Starting Tests for MAILBOX layer with a real hardware\n");
-
- do
- {
- printf("\n[0] Exit\n");
- printf("[1] Init\n");
- printf("[2] UnInit\n");
- printf("[3] Send\n");
- printf("\nWhich test do you want ? : ");
- scanf("%d",&choice);
-
- switch(choice)
- {
- //Test mailbox init procedure
- case 1: test_init();
- break;
-
- //Test mailbox uninit procedure
- case 2: test_uninit();
- break;
-
- //Test mailbox send procedure
- case 3: test_send();
- break;
-
- case 0:
- default: cont = 0;
- }
- } while(cont);
-
- return 0;
-}
-
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/utests/Makefile b/cleopatre/devkit/tests/plcdrv/gidel/utests/Makefile
deleted file mode 100644
index ae3172b54f..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/utests/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-PRJ_BASE = ../../../../plcdrv/gidel
-FILES = hal
-FILES += mailbox
-FILES += processing
-FILES += plc_drv
-
-include ../../../utests_makerules
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/utests/inc/hal_stub.h b/cleopatre/devkit/tests/plcdrv/gidel/utests/inc/hal_stub.h
deleted file mode 100644
index 4e9bfafddf..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/utests/inc/hal_stub.h
+++ /dev/null
@@ -1,507 +0,0 @@
-#ifndef hal_stub_h
-#define hal_stub_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal_stub.h
- * \brief HAL layer stub for mailbox tests.
- * \ingroup Cleopatre - Isis
- *
- * this layer provide all Hardware Abstraction:
- * registers, Gidel memory, interrupts.
- */
-
-#include "common.h"
-#include <string.h>
-#include <stdio.h>
-
-#define TYPICAL_BUFF_ADD_PTR 0x12345678
-#define TYPICAL_RCV_BUFF_PTR 0x12345678
-uint32_t gidel_ring[3];
-uint32_t gidel_size;
-uint32_t msg_ptr;
-uint32_t msg_size;
-
-/** Precise which IT arrived */
-enum pending_its {
- NONE = 0,
- A2LA = 1,
- L2AT = 2,
- ALL = 3,
-};
-
-/**
- * Initialize the hal layer.
- *
- * \param init user information.
- * \param irq_handler interrupt handler for L->A.
- */
-inline void halmbx_init(struct init_info *init, void(*irq_handler)(void*))
-{
-}
-
-/**
- * UnInitialize the hal layer.
- */
-inline void halmbx_uninit(void)
-{
-}
-
-/**
- * Check if Leon to Arm mailbox queue is empty.
- *
- * \return 0 if the queue is empty.
- */
-inline int halmbx_L2Amail_not_empty_queue(void)
-{
- static int nbtests = 0;
- if(nbtests == 0)
- { //return empty to test this function
- nbtests++;
- return 0;
- }
- else if(nbtests == 1)
- {//return empty to test copy_from_ring function
- nbtests++;
- return 8;
- }
- else if(nbtests == 2)
- {//return empty to test L2Amail_update function
- nbtests++;
- return 8;
- }
- else if(nbtests == 3)
- {//return empty to test send done false function
- nbtests++;
- return 8;
- }
- else if(nbtests == 4)
- {//return empty to test send done true function
- nbtests++;
- return 8;
- }
- else if(nbtests == 5)
- {//return empty to quit between each correct function tests
- nbtests++;
- return 0;
- }
- else if(nbtests == 6)
- {//return empty to test interface false with save memory function
- nbtests++;
- return 8;
- }
- else if(nbtests == 7)
- {//return empty to test interface false with processing receive function
- nbtests++;
- return 8;
- }
- else if(nbtests == 8)
- {//return empty to test interface true function
- nbtests++;
- return 8;
- }
- else if(nbtests == 9)
- {//return empty to quit between each correct function tests
- nbtests++;
- return 0;
- }
- else if(nbtests == 10)
- {//return empty to test data false with save memory function
- nbtests++;
- return 8;
- }
- else if(nbtests == 11)
- {//return empty to test data mme false with processing receive function
- nbtests++;
- return 8;
- }
- else if(nbtests == 12)
- {//return empty to test data mme true function
- nbtests++;
- return 8;
- }
- else if(nbtests == 13)
- {//return empty to quit between each correct function tests
- nbtests++;
- return 0;
- }
- else if(nbtests == 14)
- {//return empty to test data data false with processing receive function
- nbtests++;
- return 8;
- }
- else if(nbtests == 15)
- {//return empty to test data data true function
- nbtests++;
- return 8;
- }
- else if(nbtests == 16)
- {//return empty to quit between each correct function tests
- nbtests++;
- return 0;
- }
- else if(nbtests == 17)
- {//return empty to test general false case
- nbtests++;
- return 8;
- }
- else
- {
- nbtests++;
- return 8;
- }
-}
-
-/**
- * Check Arm to Leon mailbox queue status.
- *
- * \return queue state.
- */
-inline int halmbx_A2Lmail_status_queue(void)
-{
- //first time we will use it in a function it will generate an error
- static int nbtests = 0;
- if(nbtests++ == 0)
- return FULL;
- else
- return NOT_FULL;
-}
-
-/**
- * Check Leon to Arm mailbox queue status.
- *
- * \return queue state.
- */
-inline int halmbx_L2Amail_status_queue(void)
-{
- //first time we will use it in a function it will generate an error
- static int nbtests = 0;
- if(nbtests++ == 0)
- return FULL;
- else
- return NOT_FULL;
-}
-
-/**
- * Copy message from the Gidel Memory
- * to the PC Memory.
- *
- * \param message pointer to the message.
- * \param size message size in bytes.
- * \return address on the Gidel memory.
- */
-inline uint32_t halmbx_save_in_pc_memory(uint32_t *message, int size)
-{
- //first and third time we will use it in a function it will generate an error
- //for the interface type and the data type
- static int nbtests = 0;
- if(nbtests == 0 || nbtests == 3)
- {
- nbtests++;
- return 0;
- }
- else
- {
- nbtests++;
- msg_size = size;
- msg_ptr = (uint32_t)message;
- return (uint32_t)message;
- }
-}
-
-/**
- * Free message space in the PC Memory.
- *
- * \param message pointer to the message.
- * \return error code.
- */
-inline int halmbx_free_in_pc_memory(uint32_t *message)
-{
- return 0;
-}
-
-/**
- * Alloc message space on the Gidel Memory.
- *
- * \return address on the Gidel memory.
- */
-inline uint32_t halmbx_alloc_in_gidel_memory(void)
-{
- //first time we will use it in a function it will generate an error
- static int nbtests = 0;
- if(nbtests++ == 0)
- return 0;
- else
- return (uint32_t)TYPICAL_BUFF_ADD_PTR;
-}
-
-/**
- * Copy message from the PC Memory
- * to the Gidel Memory.
- *
- * \param message pointer to the message.
- * \param size message size in bytes.
- * \return address on the Gidel memory.
- */
-inline uint32_t halmbx_save_in_gidel_memory(uint32_t *message, int size)
-{
- //first time we will use it in a function it will generate an error
- static int nbtests = 0;
- if(nbtests++ == 0)
- return 0;
- else
- return (uint32_t)message;
-}
-
-/**
- * Free message space in the Gidel Memory.
- *
- * \param message pointer to the message.
- * \return error code.
- */
-inline int halmbx_free_in_gidel_memory(uint32_t *message)
-{
- //first time we will use it in a function it will generate an error
- static int nbtests = 0;
- if(nbtests++ == 0)
- return -1;
- else
- return 0;
-}
-
-/**
- * Copy message to the ring buffer.
- *
- * \param message pointer to the message align on 32bits.
- * \param size message size in bytes and align on 32bits.
- * \return error code.
- */
-inline int halmbx_copy_to_ring (uint32_t *message, int size)
-{
- //first time we will use it in a function it will generate an error
- static int nbtests = 0;
- if(nbtests++ == 0)
- return -1;
- else
- {
- memcpy(gidel_ring, message, size);
- return 0;
- }
-}
-
-/**
- * Copy message from the ring buffer.
- *
- * \param message pointer to the message align on 32bits.
- * \param size max message size in bytes and align on 32bits.
- * \return error code.
- */
-inline int halmbx_copy_from_ring (uint32_t *message, int size)
-{
- static int nbtests = 0;
- if(nbtests == 0)
- {
- nbtests++;
- return -1;
- }
- else if(nbtests == 1)
- {//L2A_update = error
- nbtests++;
- return 0;
- }
- else if(nbtests == 2)
- {//send done false
- nbtests++;
- *message = 0x00000102;
- *(message+1) = TYPICAL_RCV_BUFF_PTR;
- return 0;
- }
- else if(nbtests == 3)
- {//send done true
- nbtests++;
- *message = 0x00000102;
- *(message+1) = TYPICAL_RCV_BUFF_PTR;
- return 0;
- }
- else if(nbtests == 4)
- {//interface copy false
- nbtests++;
- *message = 0x00000103;
- *(message+1) = TYPICAL_RCV_BUFF_PTR;
- return 0;
- }
- else if(nbtests == 5)
- {//interface processing false
- nbtests++;
- *message = 0x00000103;
- *(message+1) = TYPICAL_RCV_BUFF_PTR;
- return 0;
- }
- else if(nbtests == 6)
- {//interface true
- nbtests++;
- *message = 0x00200103;
- *(message+1) = TYPICAL_RCV_BUFF_PTR;
- return 0;
- }
- else if(nbtests == 7)
- {//data copy false
- nbtests++;
- *message = 0x00000100;
- *(message+1) = TYPICAL_RCV_BUFF_PTR;
- return 0;
- }
- else if(nbtests == 8)
- {//data processing mme false
- nbtests++;
- *message = 0x00001100;
- *(message+1) = TYPICAL_RCV_BUFF_PTR;
- return 0;
- }
- else if(nbtests == 9)
- {//data processing mme true
- nbtests++;
- *message = 0x00000100;
- *(message+1) = TYPICAL_RCV_BUFF_PTR;
- return 0;
- }
- else if(nbtests == 10)
- {//data precessing data false
- nbtests++;
- *message = 0x00000100;
- *(message+1) = TYPICAL_RCV_BUFF_PTR;
- return 0;
- }
- else if(nbtests == 11)
- {//data precessing data true
- nbtests++;
- *message = 0x00004100;
- *(message+1) = TYPICAL_RCV_BUFF_PTR;
- return 0;
- }
- else if(nbtests == 12)
- {//type msg error
- nbtests++;
- *message = 0x00000105;
- *(message+1) = TYPICAL_RCV_BUFF_PTR;
- return 0;
- }
- else
- {
- nbtests++;
- return 0;
- }
-}
-
-/**
- * Update the ring management for Leon to Arm mailbox (TX).
- *
- * \param size real size of the last proceed message.
- * \return error code.
- */
-inline int halmbx_A2Lmail_update (int size)
-{
- //first time we will use it in a function it will generate an error
- static int nbtests = 0;
- if(nbtests++ == 0)
- return -1;
- else
- {
- //return the size for tests_mailbox.c with global variable
- gidel_size = size;
- return 0;
- }
-}
-
-/**
- * Update the ring management for Arm to Leon mailbox (RX).
- *
- * \param size real size of the last proceed message.
- * \return error code.
- */
-inline int halmbx_L2Amail_update (int size)
-{
- //first time we will use it in a function it will generate an error
- static int nbtests = 0;
- if(nbtests++ == 0)
- return -1;
- else
- {
- //return the size for tests_mailbox.c with global variable
- gidel_size = size;
- return 0;
- }
-}
-
-/**
- * Enable the Arm to Leon Acknowledge Interrupt.
- */
-inline void A2La_it_enable(void)
-{
-}
-
-/**
- * Enable the Leon to Arm Trigger Interrupt.
- */
-inline void L2At_it_enable(void)
-{
-}
-
-/**
- * Disable the Arm to Leon Acknowledge Interrupt.
- */
-inline void A2La_it_disable(void)
-{
-}
-
-/**
- * Disable the Leon to Arm Trigger Interrupt.
- */
-inline void L2At_it_disable(void)
-{
-}
-
-/**
- * Set the Arm to Leon Interrupt.
- */
-inline void set_A2Lt_interrupt(void)
-{
-}
-
-/**
- * Set the Arm to Leon acknowledge Interrupt.
- */
-inline void set_L2Aa_interrupt(void)
-{
-}
-
-/**
- * Clear the Leon to Arm Interrupt.
- */
-inline void clr_L2At_interrupt(void)
-{
-}
-
-/**
- * Clear the Leon to Arm acknowledge Interrupt.
- */
-inline void clr_A2La_interrupt(void)
-{
-}
-
-/**
- * Disable the Leon to Arm Trigger Interrupt.
- *
- * \return waiting its.
- */
-inline enum pending_its check_its(void)
-{
- return NONE;
-}
-
-#endif /* hal_stub_h */
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/utests/inc/hard_stub.h b/cleopatre/devkit/tests/plcdrv/gidel/utests/inc/hard_stub.h
deleted file mode 100644
index cf82a2d9f1..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/utests/inc/hard_stub.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef hard_stub_h
-#define hard_stub_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hard_stub.h
- * \brief Hardware stub for tests.
- * \ingroup Cleopatre - Isis
- *
- * For tests we don't need the hardware so we have to stub it.
- */
-
-#define A2L_RING_SIZE (0x10)
-#define L2A_RING_SIZE (A2L_RING_SIZE)
-#define A2L_RING_MASK (A2L_RING_SIZE-1)
-#define L2A_RING_MASK (L2A_RING_SIZE-1)
-
-extern uint32_t A2L_ring[A2L_RING_SIZE];
-extern uint32_t L2A_ring[L2A_RING_SIZE];
-
-#define A2L_RING_BASE_ADDR ((uint32_t)&A2L_ring[0])
-#define L2A_RING_BASE_ADDR ((uint32_t)&L2A_ring[0])
-
-extern uint32_t **A2L_ptr;
-extern uint32_t **L2A_ptr;
-
-extern uint32_t *A2L_head;
-extern uint32_t *A2L_tail;
-extern uint32_t *L2A_head;
-extern uint32_t *L2A_tail;
-extern uint32_t *A2L_it;
-extern uint32_t *L2A_it;
-extern uint32_t *L2A_it_mask;
-
-#define L2AT_EN_MASK (0x00000001)
-#define L2AA_EN_MASK (0x00000002)
-#define A2LT_MASK (0x00000001)
-#define A2LA_MASK (0x00000002)
-#define L2AT_MASK (0x00000001)
-#define L2AA_MASK (0x00000002)
-
-
-#define MAX_GIDEL_BUFFER ((A2L_RING_SIZE+L2A_RING_SIZE)*2)
-extern uint32_t buffer_gidel[MAX_GIDEL_BUFFER][ETH_MAX_SIZE];
-#define BUFFER_GIDEL_BASE_ADDR ((uint32_t)&buffer_gidel[0][0])
-
-#endif /* hard_stub_h */
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/utests/inc/mailbox_stub.h b/cleopatre/devkit/tests/plcdrv/gidel/utests/inc/mailbox_stub.h
deleted file mode 100644
index e7f39b1b9f..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/utests/inc/mailbox_stub.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef mailbox_stub_h
-#define mailbox_stub_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file mailbox_stub.h
- * \brief Mailbox stub for the PLC driver processing layer tests.
- * \ingroup Cleopatre - Isis
- */
-
-#include "common.h"
-
-#define MAX_MSG_SIZE 12 //max size of a mailbox message in bytes
-
-/**
- * Initialize the mailbox layer.
- *
- * \param init user information.
- */
-inline void mailbox_init(struct init_info *init)
-{
-}
-
-/**
- * UnInitialize the mailbox layer.
- */
-inline void mailbox_uninit(void)
-{
-}
-
-/**
- * Send a message to the HLE layer.
- *
- * \param pointer the message pointer.
- * \param length the length of the message.
- * \param type type of message.
- * \return error code.
- */
-inline int mailbox_send(void *pointer, uint32_t length, enum buffer_type type)
-{
- return 0;
-}
-
-/**
- * Receive everything from the HLE layer.
- *
- * \return error code.
- */
-inline int mailbox_receive(void)
-{
- return 0;
-}
-
-
-#endif /* mailbox_stub_h */
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/utests/inc/plc_drv_stub.h b/cleopatre/devkit/tests/plcdrv/gidel/utests/inc/plc_drv_stub.h
deleted file mode 100644
index da65b6995e..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/utests/inc/plc_drv_stub.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef plc_drv_stub_h
-#define plc_drv_stub_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file plc_drv_stub.h
- * \brief OS layer stub for the PLC driver processing layer tests.
- * \ingroup Cleopatre - Isis
- */
-
-#include "common.h"
-
-/**
- * Receive a packet.
- *
- * \param pointer the packet pointer.
- * \param length the length of the packet.
- * \return error code.
- */
-inline int plcdrv_rx(void *pointer, int length)
-{
- return 0;
-}
-
-/**
- * Precedure executed when the frame is really sending to CESAR
- * and only when there are few buffer in the mailbox ring.
- */
-inline void plcdrv_tx_ack(void)
-{
-}
-
-#endif /* plc_drv_stub_h */
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/utests/inc/processing_stub.h b/cleopatre/devkit/tests/plcdrv/gidel/utests/inc/processing_stub.h
deleted file mode 100644
index 03113f12a1..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/utests/inc/processing_stub.h
+++ /dev/null
@@ -1,102 +0,0 @@
-#ifndef processing_stub_h
-#define processing_stub_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file processing.h
- * \brief Processing layer for the PLC driver.
- * \ingroup Cleopatre - Isis
- *
- * this layer is used to check every packet received by CESAR or TUN/TAP
- * and sometime drop it.
- */
-
-#include "common.h"
-#include <stdio.h>
-
-static inline uint32_t hal_ctrl_dsp_ss_read(uint32_t offset)
-{
- return 0;
-}
-static inline int hal_ctrl_dsp_ss_write(uint32_t offset, uint32_t *value)
-{
- return 0;
-}
-static inline uint32_t hal_afredi_memory_read(uint32_t offset)
-{
- return 0;
-}
-static inline int hal_afredi_memory_write(uint32_t offset, uint32_t *value)
-{
- return 0;
-}
-
-/**
- * Initialize the processing layer.
- *
- * \param init user information.
- */
-inline void processing_init(struct init_info *init)
-{
-}
-
-/**
- * UnInitialize the processing layer.
- */
-inline void processing_uninit(void)
-{
-}
-
-/**
- * Processing procedure for a A->L message.
- *
- * \param pointer packet pointer.
- * \param length length of the packet pointed.
- * \return status queue.
- */
-inline int processing_send (void *pointer, int length)
-{
- //first time we will use it in a function it will generate an error
- static int nbtests = 0;
- if(nbtests == 0)
- {
- nbtests++;
- return -1;
- }
- else
- {
- nbtests++;
- return 0;
- }
-}
-
-/**
- * Processing procedure for a L->A message.
- *
- * \param pointer packet pointer.
- * \param length length of the packet pointed.
- * \param type type of message.
- * \return error code.
- */
-inline int processing_receive (void *pointer, int length, enum buffer_type type)
-{
- //half time we will use it in a function it will generate an error
- static int nbtests = 0;
- if(nbtests == 0 || nbtests == 2 || nbtests == 4)
- {
- nbtests++;
- return -1;
- }
- else
- {
- nbtests++;
- return 0;
- }
-}
-
-#endif /* processing_stub_h */
diff --git a/cleopatre/devkit/tests/plcdrv/gidel/utests/src/hal_utests.cpp b/cleopatre/devkit/tests/plcdrv/gidel/utests/src/hal_utests.cpp
deleted file mode 100644
index 8a6e337b18..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/utests/src/hal_utests.cpp
+++ /dev/null
@@ -1,430 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test_hal.cpp
- * \brief tests of the HAL layer.
- * \ingroup Cleopatre - Isis
- */
-
-#include <iostream>
-#include <vector>
-#include <check.h>
-#include <stdio.h>
-#include "hal.h"
-
-/** global variables used by stub files to recover informations */
-extern std::vector<uint32_t> free_buff_list;
-
-/** local variables */
-static struct init_info init;
-void testhal_handler(void* data)
-{
- printf("testhal_handler\n");
-}
-
-/** init test procedure */
-START_TEST (test_halmbx_init)
-{
- int i;
- halmbx_init(&init, &testhal_handler);
-
- //Check mailbox pointer initialization
- fail_if(*A2L_head != A2L_RING_BASE_ADDR, "A2L_head pointer not initialize");
- fail_if(*A2L_tail != A2L_RING_BASE_ADDR, "A2L_tail pointer not initialize");
- fail_if(*L2A_head != L2A_RING_BASE_ADDR, "L2A_head pointer not initialize");
- fail_if(*L2A_tail != L2A_RING_BASE_ADDR, "L2A_tail pointer not initialize");
-
- //Check list of free buffers
- fail_if(free_buff_list.size() != MAX_GIDEL_BUFFER, "Number of free buffer uncorrect");
-
- std::vector<uint32_t>::iterator it;
- for(it=free_buff_list.begin(), i=0 ; it<free_buff_list.end(); it++, i++)
- {
- fail_if(*it != (BUFFER_GIDEL_BASE_ADDR+i*ETH_MAX_SIZE), "Free buffer address error");
- }
-}
-END_TEST
-
-START_TEST (test_set_A2Lt_interrupt)
-{
- *A2L_it = 0;
- set_A2Lt_interrupt();
- fail_if(*A2L_it != 0x01, "A2L trigger not set");
- *A2L_it = 3;
- set_A2Lt_interrupt();
- fail_if(*A2L_it != 0x03, "A2L trigger not set");
-}
-END_TEST
-
-START_TEST (test_set_L2Aa_interrupt)
-{
- *A2L_it = 0;
- set_L2Aa_interrupt();
- fail_if(*A2L_it != 0x02, "L2A acknowledge not set");
- *A2L_it = 3;
- set_L2Aa_interrupt();
- fail_if(*A2L_it != 0x03, "L2A acknowledge not set");
-}
-END_TEST
-
-START_TEST (test_clr_L2At_interrupt)
-{
- *L2A_it = 1;
- clr_L2At_interrupt();
- fail_if(*L2A_it != 0x01, "L2A trigger not clr");
- *L2A_it = 2;
- clr_L2At_interrupt();
- fail_if(*L2A_it != 0x01, "L2A trigger not clr");
-}
-END_TEST
-
-START_TEST (test_clr_A2La_interrupt)
-{
- *L2A_it = 2;
- clr_A2La_interrupt();
- fail_if(*L2A_it != 0x02, "A2L acknowledge not clr");
- *L2A_it = 1;
- clr_A2La_interrupt();
- fail_if(*L2A_it != 0x02, "A2L acknowledge not clr");
-}
-END_TEST
-
-START_TEST (test_A2La_it_enable)
-{
- *L2A_it_mask = 2;
- A2La_it_enable();
- fail_if(*L2A_it_mask != 0x00, "A2L acknowledge not enable");
- *L2A_it_mask = 1;
- A2La_it_enable();
- fail_if(*L2A_it_mask != 0x01, "A2L acknowledge not enable");
-}
-END_TEST
-
-START_TEST (test_L2At_it_enable)
-{
- *L2A_it_mask = 1;
- L2At_it_enable();
- fail_if(*L2A_it_mask != 0x00, "L2A trigger not enable");
- *L2A_it_mask = 2;
- L2At_it_enable();
- fail_if(*L2A_it_mask != 0x02, "L2A trigger not enable");
-}
-END_TEST
-
-START_TEST (test_A2La_it_disable)
-{
- *L2A_it_mask = 0;
- A2La_it_disable();
- fail_if(*L2A_it_mask != 0x02, "A2L acknowledge not disable");
- *L2A_it_mask = 3;
- A2La_it_disable();
- fail_if(*L2A_it_mask != 0x03, "A2L acknowledge not disable");
-}
-END_TEST
-
-START_TEST (test_L2At_it_disable)
-{
- *L2A_it_mask = 0;
- L2At_it_disable();
- fail_if(*L2A_it_mask != 0x01, "L2A trigger not disable");
- *L2A_it_mask = 3;
- L2At_it_disable();
- fail_if(*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 0xF
- *L2A_tail = L2A_RING_BASE_ADDR + 0x5;
- *L2A_head = L2A_RING_BASE_ADDR + 0x5;
- fail_if(halmbx_L2Amail_not_empty_queue() != 0, "Error checking L2A not empty queue");
- *L2A_tail = L2A_RING_BASE_ADDR + 0xA;
- *L2A_head = L2A_RING_BASE_ADDR + 0x7;
- fail_if(halmbx_L2Amail_not_empty_queue() == 0, "Error checking L2A not empty queue");
- *L2A_tail = L2A_RING_BASE_ADDR + 0x0;
- *L2A_head = L2A_RING_BASE_ADDR + 0xE;
- fail_if(halmbx_L2Amail_not_empty_queue() == 0, "Error checking L2A not empty queue");
-}
-END_TEST
-
-START_TEST (test_halmbx_A2Lmail_status_queue)
-{
- //The ring size for the test is 0xF
- *A2L_tail = A2L_RING_BASE_ADDR + 0x5;
- *A2L_head = A2L_RING_BASE_ADDR + 0x5;
- fail_if(halmbx_A2Lmail_status_queue() != NOT_FULL, "Error checking A2L status queue");
- *A2L_tail = A2L_RING_BASE_ADDR + 0xA;
- *A2L_head = A2L_RING_BASE_ADDR + 0x7;
- fail_if(halmbx_A2Lmail_status_queue() != NOT_FULL, "Error checking A2L status queue");
- *A2L_tail = A2L_RING_BASE_ADDR + 0x0;
- *A2L_head = A2L_RING_BASE_ADDR + 0xE;
- fail_if(halmbx_A2Lmail_status_queue() != NOT_FULL, "Error checking A2L status queue");
- *A2L_tail = A2L_RING_BASE_ADDR + 0x7;
- *A2L_head = A2L_RING_BASE_ADDR + 0xA;
- fail_if(halmbx_A2Lmail_status_queue() != FULL, "Error checking A2L status queue");
-}
-END_TEST
-
-START_TEST (test_halmbx_L2Amail_status_queue)
-{
- //The ring size for the test is 0xF
- *L2A_tail = L2A_RING_BASE_ADDR + 0x5;
- *L2A_head = L2A_RING_BASE_ADDR + 0x5;
- fail_if(halmbx_L2Amail_status_queue() != NOT_FULL, "Error checking L2A status queue");
- *L2A_tail = L2A_RING_BASE_ADDR + 0xA;
- *L2A_head = L2A_RING_BASE_ADDR + 0x7;
- fail_if(halmbx_L2Amail_status_queue() != NOT_FULL, "Error checking L2A status queue");
- *L2A_tail = L2A_RING_BASE_ADDR + 0x0;
- *L2A_head = L2A_RING_BASE_ADDR + 0xE;
- fail_if(halmbx_L2Amail_status_queue() != NOT_FULL, "Error checking L2A status queue");
- *L2A_tail = L2A_RING_BASE_ADDR + 0x7;
- *L2A_head = L2A_RING_BASE_ADDR + 0xA;
- fail_if(halmbx_L2Amail_status_queue() != FULL, "Error checking L2A status queue");
-}
-END_TEST
-
-START_TEST (test_halmbx_alloc_free_in_gidel_memory)
-{
- //Init HAL to fill the vector
- halmbx_init(&init, &testhal_handler);
- //Alloc part
- uint32_t addr = free_buff_list.back();
- fail_if(halmbx_alloc_in_gidel_memory() != addr, "Uncorrect free buffer");
- fail_if(free_buff_list.back() == addr, "Error with free buffer allocation");
-
- //Free part
- halmbx_free_in_gidel_memory((uint32_t*)addr);
- fail_if(free_buff_list.back() != addr, "Error with free buffer liberation");
-}
-END_TEST
-
-START_TEST (test_halmbx_save_in_gidel_memory)
-{
- //Init HAL to fill the vector
- halmbx_init(&init, &testhal_handler);
-
- //Check arguments
- fail_if(halmbx_save_in_gidel_memory(NULL,ETH_MAX_SIZE+5) != 0, "Error with a too big size");
- fail_if(halmbx_save_in_gidel_memory(NULL,0) != 0, "Error without size");
- fail_if(halmbx_save_in_gidel_memory(NULL,5) != 0, "Error without pointer");
-
- //Check function
- char msg[] = "Hello I'm a test";
- char *new_msg = (char*)halmbx_save_in_gidel_memory((uint32_t*)msg, sizeof(msg));
- fail_if(strncmp(new_msg, msg, sizeof(msg)) != 0, "Error with copy");
- halmbx_free_in_gidel_memory((uint32_t*)new_msg);
-}
-END_TEST
-
-START_TEST (test_halmbx_save_in_pc_memory)
-{
- //Init HAL to fill the vector
- halmbx_init(&init, &testhal_handler);
-
- //Check arguments
- fail_if(halmbx_save_in_pc_memory(NULL,ETH_MAX_SIZE+5) != 0, "Error with a too big size");
- fail_if(halmbx_save_in_pc_memory(NULL,0) != 0, "Error without size");
- fail_if(halmbx_save_in_pc_memory(NULL,5) != 0, "Error without pointer");
-
- //Check function
- char msg_origin[] = "Hello I'm a test";
- char *msg = (char *)halmbx_alloc_in_gidel_memory();
- strncpy(msg, msg_origin, sizeof(msg_origin));
-
- uint32_t new_msg_addr = halmbx_save_in_pc_memory((uint32_t*)msg, sizeof(msg_origin));
- char* new_msg = (char*)new_msg_addr;
- fail_if(strncmp(new_msg, msg_origin, sizeof(msg_origin)) != 0, "Error with copy");
-
- halmbx_free_in_pc_memory((uint32_t*)new_msg_addr);
-}
-END_TEST
-
-START_TEST (test_halmbx_copy_to_ring)
-{
- //Init HAL to fill the vector
- halmbx_init(&init, &testhal_handler);
-
- //Check arguments
- fail_if(halmbx_copy_to_ring(NULL,ETH_MAX_SIZE+5) == 0, "Error with a too big size");
- fail_if(halmbx_copy_to_ring(NULL,0) == 0, "Error without size");
- fail_if(halmbx_copy_to_ring(NULL,3) == 0, "Error with size not align");
- fail_if(halmbx_copy_to_ring(NULL,4) == 0, "Error without pointer");
- fail_if(halmbx_copy_to_ring((uint32_t*)0x67546421,4) == 0, "Error with pointer not align");
-
- //Check function
- uint32_t msg[] = {0x12345678, 0xFEDCBA98};
- *A2L_tail = A2L_RING_BASE_ADDR + 0x4;
- *A2L_head = A2L_RING_BASE_ADDR + 0x4;
- fail_if(halmbx_copy_to_ring((uint32_t*)msg, sizeof(msg)) != 0, "Error before copy");
- uint32_t *res = (uint32_t*)*A2L_tail;
- fail_if(*res++ != msg[0], "Error with copy");
- fail_if(*res != msg[1], "Error with copy");
-
- *A2L_tail = A2L_RING_BASE_ADDR + 0xC;
- *A2L_head = A2L_RING_BASE_ADDR + 0xC;
- fail_if(halmbx_copy_to_ring((uint32_t*)msg, sizeof(msg)) != 0, "Error before copy");
- res = (uint32_t*)*A2L_tail;
- fail_if(*res != msg[0], "Error with rollover copy"); //offset=C to F
- 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)
-{
- //Init HAL to fill the vector
- halmbx_init(&init, &testhal_handler);
-
- //Check arguments
- fail_if(halmbx_copy_from_ring(NULL,ETH_MAX_SIZE+5) == 0, "Error with a too big size");
- fail_if(halmbx_copy_from_ring(NULL,0) == 0, "Error without size");
- fail_if(halmbx_copy_from_ring(NULL,3) == 0, "Error with size not align");
- fail_if(halmbx_copy_from_ring(NULL,4) == 0, "Error without pointer");
- fail_if(halmbx_copy_from_ring((uint32_t*)0x67546421,4) == 0, "Error with pointer not align");
-
- //Check function
- uint32_t msg_origin[] = {0x87654321, 0x89ABCDEF};
- uint32_t msg[2];
- *L2A_tail = L2A_RING_BASE_ADDR + 0x4;
- *L2A_head = L2A_RING_BASE_ADDR + 0x4;
- uint32_t *res = (uint32_t*)*L2A_head;
- *res = msg_origin[0];
- *(res+1) = msg_origin[1];
- fail_if(halmbx_copy_from_ring((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*)*L2A_head, 0, 4);
- *L2A_tail = L2A_RING_BASE_ADDR + 0xC;
- *L2A_head = L2A_RING_BASE_ADDR + 0xC;
- res = (uint32_t*)*L2A_head; //offset=C to F
- *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((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)
-{
- fail_if(halmbx_A2Lmail_update(0) == 0, "Error without size");
- *A2L_tail = A2L_RING_BASE_ADDR + 0x4;
- *A2L_head = A2L_RING_BASE_ADDR + 0x4;
- fail_if(halmbx_A2Lmail_update(8) != 0, "Error before update");
- fail_if(*A2L_tail != (A2L_RING_BASE_ADDR + 0xC), "Error with update");
- *A2L_tail = A2L_RING_BASE_ADDR + 0xC;
- *A2L_head = A2L_RING_BASE_ADDR + 0xC;
- fail_if(halmbx_A2Lmail_update(8) != 0, "Error before update");
- fail_if(*A2L_tail != (A2L_RING_BASE_ADDR + 0x4), "Error with rollover update");
-}
-END_TEST
-
-START_TEST (test_halmbx_L2Amail_update)
-{
- fail_if(halmbx_L2Amail_update(0) == 0, "Error without size");
- *L2A_tail = L2A_RING_BASE_ADDR + 0x4;
- *L2A_head = L2A_RING_BASE_ADDR + 0x4;
- fail_if(halmbx_L2Amail_update(4) != 0, "Error before update");
- fail_if(*L2A_head != (L2A_RING_BASE_ADDR + 0x8), "Error with update");
- *L2A_tail = L2A_RING_BASE_ADDR + 0xC;
- *L2A_head = L2A_RING_BASE_ADDR + 0xC;
- fail_if(halmbx_L2Amail_update(0xC) != 0, "Error before update");
- fail_if(*L2A_head != (L2A_RING_BASE_ADDR + 0x8), "Error with rollover update");
-}
-END_TEST
-
-START_TEST (test_check_its)
-{
- *L2A_it = 0x4;
- fail_if(check_its() != NONE, "Error with no It reception");
- *L2A_it = 0x0;
- fail_if(check_its() != NONE, "Error with no It reception");
- *L2A_it = 0x3;
- fail_if(check_its() != ALL, "Error with two It reception");
- *L2A_it = 0x2;
- fail_if(check_its() != A2LA, "Error with A2L acknowledge It reception");
- *L2A_it = 0x1;
- fail_if(check_its() != L2AT, "Error with L2A trigger It reception");
-}
-END_TEST
-
-extern "C" Suite* halmbx_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_alloc_in_gidel_memory
- tcase_add_test(tc_core, test_halmbx_alloc_free_in_gidel_memory);
- //Test halmbx_save_in_gidel_memory
- tcase_add_test(tc_core, test_halmbx_save_in_gidel_memory);
- //Test halmbx_save_in_pc_memory
- tcase_add_test(tc_core, test_halmbx_save_in_pc_memory);
-
- //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);
-
- //Test pending_its_check_its
- tcase_add_test(tc_core, test_check_its);
-
- suite_add_tcase(s, tc_core);
- return s;
-}
-
-int main(void)
-{
- int number_failed = 0;
- Suite *s;
-
- //Run HAL tests
- s = halmbx_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/gidel/utests/src/mailbox_utests.c b/cleopatre/devkit/tests/plcdrv/gidel/utests/src/mailbox_utests.c
deleted file mode 100644
index da44081732..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/utests/src/mailbox_utests.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test_mailbox.c
- * \brief tests of the MAILBOX layer.
- * \ingroup Cleopatre - Isis
- */
-
-#include <check.h>
-#include <stdio.h>
-#include "mailbox.h"
-
-/** global variables used by stub files to recover informations */
-#define TYPICAL_BUFF_ADD_PTR 0x12345678
-#define TYPICAL_RCV_BUFF_PTR 0x12345678
-extern uint32_t gidel_ring[3];
-extern uint32_t gidel_size;
-extern uint32_t msg_ptr;
-extern uint32_t msg_size;
-extern void (*txack_handler)(void);
-
-/** local variables */
-static struct init_info init;
-void test_handler(void)
-{
- printf("txack_handler\n");
-}
-
-/** buffer add test procedure */
-START_TEST (test_mailbox_buffer_add)
-{
- uint32_t *res = &gidel_ring[0];
-
- //Check code with the status queue error (remember the first time we call
- //status_queue it returns an error)
- fail_if(mailbox_buffer_add(DATA) != FULL, "Error with status queue");
- //Check code with Alloc_in_gidel_memory error (remember the first time we call
- //Alloc_in_gidel_memory it returns an error)
- fail_if(mailbox_buffer_add(DATA) != FULL, "Error with Alloc_in_gidel");
- //Check code with copy_to_ring error (remember the first time we call
- //copy_to_ring it returns an error)
- fail_if(mailbox_buffer_add(DATA) == 0, "Error with copy to ring");
- //Check code with A2L_update error (remember the first time we call
- //A2L_update it returns an error)
- fail_if(mailbox_buffer_add(DATA) == 0, "Error with update ring pointer");
-
- //CHECK THE REAL FUNCTIONNALITY OF THE FUNCTION
- //WITH BUFFER_ADD TYPE DATA
- fail_if(mailbox_buffer_add(DATA) != 0, "Error with buffer add data");
- //Check msg header for buffer add type data
- fail_if(*res != 0x00000101,"Error with buffer add msg header construction");
- //Check size with the global variable of the hal_stub
- fail_if(gidel_size != 0x8,"Error with size msg");
- //the hal_stub always return TYPICAL_BUFF_ADD_PTR as message buffer_ptr
- fail_if(*(res+1) != TYPICAL_BUFF_ADD_PTR ,"Error with buffer add msg construction");
-
- *res = 0;
- *(res+1) = 0;
-
- //WITH BUFFER_ADD TYPE MME
- fail_if(mailbox_buffer_add(MME) != 0, "Error with buffer add data");
- //Check msg header for buffer add type mme
- fail_if(*res != 0x00001101,"Error with buffer add msg header construction");
- //Check size with the global variable of the hal_stub
- fail_if(gidel_size != 0x8,"Error with size msg");
- //the hal_stub always return TYPICAL_BUFF_ADD_PTR as message buffer_ptr
- fail_if(*(res+1) != TYPICAL_BUFF_ADD_PTR ,"Error with buffer add msg construction");
-}
-END_TEST
-
-/** init test procedure */
-START_TEST (test_mailbox_init)
-{
- //Fill init structure used with init
- init.txack_handler = &test_handler;
- init.nb_data_buf_alloc = 3;
- init.nb_mme_buf_alloc = 2;
-
- //Start function
- mailbox_init(&init);
-
- //Check irq handler pointer
- fail_if((uint32_t)(txack_handler) != (uint32_t)(&test_handler),"Error with IRQ handler pointer");
-}
-END_TEST
-
-/** send test procedure */
-START_TEST (test_mailbox_send)
-{
- uint32_t *res = &gidel_ring[0];
- uint32_t msg[] = {0x11223344, 0x55667788, 0x99AABBCC};
-
- //Check code error for each parameters
- fail_if(mailbox_send(NULL,5,DATA) == 0, "Error with null pointer");
- fail_if(mailbox_send((void*)TYPICAL_RCV_BUFF_PTR,0,DATA) == 0, "Error with null size");
-
- //Check code with the status queue error (remember the first time we call
- //status_queue it returns an error)
- fail_if(mailbox_send((void*)TYPICAL_RCV_BUFF_PTR,1,DATA) != FULL, "Error with status queue");
- //Check code with save_in_gidel_memory error (remember the first time we call
- //save_in_gidel_memory it returns an error)
- fail_if(mailbox_send((void*)TYPICAL_RCV_BUFF_PTR,1,DATA) != FULL, "Error with save_in_gidel");
- //Check code with copy_to_ring error (remember the first time we call
- //copy_to_ring it returns an error)
- fail_if(mailbox_send(msg, sizeof(msg), DATA) == 0, "Error with copy to ring");
- //Check code with A2L_update error (remember the first time we call
- //A2L_update it returns an error)
- fail_if(mailbox_send(msg, sizeof(msg), DATA) == 0, "Error with update ring pointer");
-
-
- //CHECK THE REAL FUNCTIONNALITY OF THE FUNCTION
- //WITH SEND TYPE DATA
- fail_if(mailbox_send(msg, sizeof(msg), DATA) != 0, "Error with send data");
- //Check msg header for send type data
- fail_if(*res != 0x00018100,"Error with send data msg header construction");
- //Check size with the global variable of the hal_stub
- fail_if(gidel_size != 0x8,"Error with size msg");
- //Check the if buffer_ptr is good
- fail_if(*(res+1) != (uint32_t)&msg[0] ,"Error with send msg construction");
-
- *res = 0;
- *(res+1) = 0;
-
- //WITH SEND TYPE MME
- fail_if(mailbox_send(msg, sizeof(msg), MME) != 0, "Error with send mme");
- //Check msg header for send type mme
- fail_if(*res != 0x00019100,"Error with send mme msg header construction");
- //Check size with the global variable of the hal_stub
- fail_if(gidel_size != 0x8,"Error with size msg");
- //Check the if buffer_ptr is good
- fail_if(*(res+1) != (uint32_t)&msg[0] ,"Error with send msg construction");
-}
-END_TEST
-
-/** receive test procedure */
-START_TEST (test_mailbox_receive)
-{
- //Check code with the L2Amail_not_empty_queue (remember the first time we call
- //L2Amail_not_empty_queue it returns empty)
- fail_if(mailbox_receive() != 0, "Error with not empty queue");
- //Check code with the copy_from_ring error (remember the first time we call
- //copy_from_ring it returns an error)
- fail_if(mailbox_receive() != -2, "Error with copy from ring");
- //Check code with the update_ring_pointer error (remember the first time we call
- //update_ring_pointer it 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 the free_in_gidel_memory error (remember the first time we call
- //free_in_gidel_memory it returns an error)
- fail_if(mailbox_receive() != -4, "Error with send done false");
- //Check the real functionnality of send_done
- fail_if(mailbox_receive() != 0, "Error with send done true");
-
- //WITH INTERFACE
- //Check code with the save_in_pc_memory error (remember the first time we call
- //save_in_pc_memory it returns an error)
- fail_if(mailbox_receive() != -5, "Error with interface save memory false");
- //Check code with the processing_receive error (remember the first time we call
- //processing_receive it returns an error)
- fail_if(mailbox_receive() != -6, "Error with interface processing receive false");
- //Check the real functionnality of interface
- fail_if(mailbox_receive() != 0, "Error with interface true");
- //Check size with the global variable of the hal_stub
- fail_if(msg_size != 2, "Error with interface message format receive");
- //Check buffer_ptr with the global variable of the hal_stub
- fail_if(msg_ptr != TYPICAL_RCV_BUFF_PTR, "Error with interface message format receive");
-
- //WITH DATA
- //Check code with the save_in_pc_memory error (remember the first time we call
- //save_in_pc_memory it returns an error)
- fail_if(mailbox_receive() != -7, "Error with data save memory false");
- //Check code with the processing_receive error (remember the first time we call
- //processing_receive it returns an error)
- fail_if(mailbox_receive() != -8, "Error with data processing receive mme false");
- //Check the real functionnality of data under-type mme
- fail_if(mailbox_receive() != 0, "Error with data processing receive mme true");
- //Check code with the processing_receive error (remember the first time we call
- //processing_receive it returns an error)
- fail_if(mailbox_receive() != -9, "Error with data processing receive data false");
- //Check the real functionnality of data under-type mme
- fail_if(mailbox_receive() != 0, "Error with data processing receive data true");
- //Check size with the global variable of the hal_stub
- fail_if(msg_size != 2, "Error with data message format receive");
- //Check buffer_ptr with the global variable of the hal_stub
- fail_if(msg_ptr != TYPICAL_RCV_BUFF_PTR, "Error with data message format receive");
-
- //WITH ERROR TYPE
- fail_if(mailbox_receive() != -1, "Error with message type");
-}
-END_TEST
-
-extern Suite* mailbox_suite(void)
-{
- Suite *s = suite_create("MAILBOX");
- TCase *tc_core = tcase_create("Core");
-
- //Test buffer_add
- tcase_add_test(tc_core, test_mailbox_buffer_add);
- //Test mailbox_init
- tcase_add_test(tc_core, test_mailbox_init);
- //Test mailbox_send
- tcase_add_test(tc_core, test_mailbox_send);
- //Test mailbox_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 MAILBOX tests
- s = mailbox_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/gidel/utests/src/plc_drv_utests.c b/cleopatre/devkit/tests/plcdrv/gidel/utests/src/plc_drv_utests.c
deleted file mode 100644
index fa3a4dcb3f..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/utests/src/plc_drv_utests.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test_plc_drv.c
- * \brief tests of the PLC_DRV layer.
- * \ingroup Cleopatre - Isis
- */
-
-#include <check.h>
-#include <stdio.h>
-#include <string.h>
-#include "plc_drv.h"
-
-/** global variables used by stub files to recover informations */
-extern int help_function;
-
-/** local variables */
-static struct init_info init;
-
-/** parse arguments procedure */
-START_TEST (test_plc_drv_parse_args)
-{
- int argc;
- char values[11][30] = {"/toto/plcdrv", "--help", "--", "--rbf", "/test/rbf", "--tun", "./test/tun", "--data", "5", "--mme", "12"};
- char *argv[3];
-
- //Check the help procedure
- argc = 2;
- argv[0] = &values[0][0];
- argv[1] = &values[1][0];
- fail_if(parse_args(&init, argc, argv) != 0 && help_function != 1, "Error parse args with help");
- help_function = 0;
-
- //Check error procedure
- argc = 2;
- argv[0] = &values[0][0];
- argv[1] = &values[2][0];
- fail_if(parse_args(&init, argc, argv) != 0 && help_function != 1, "Error parse args with wrong parameter");
-
- //Check rbf parameter
- argc = 3;
- argv[0] = &values[0][0];
- argv[1] = &values[3][0];
- argv[2] = &values[4][0];
- fail_if(parse_args(&init, argc, argv) != 0 && strcmp(init.rbf,values[4]) != 0, "Error parse args with rbf parameter");
-
- //Check tun/tap parameter
- argc = 3;
- argv[0] = &values[0][0];
- argv[1] = &values[5][0];
- argv[2] = &values[6][0];
- fail_if(parse_args(&init, argc, argv) != 0 && strcmp(init.tuntap_name,values[6]) != 0, "Error parse args with tuntap parameter");
-
- //Check number of data buffer parameter
- argc = 3;
- argv[0] = &values[0][0];
- argv[1] = &values[7][0];
- argv[2] = &values[8][0];
- fail_if(parse_args(&init, argc, argv) != 0 && init.nb_data_buf_alloc != 5, "Error parse args with data parameter");
-
- //Check number of mme buffer parameter
- argc = 3;
- argv[0] = &values[0][0];
- argv[1] = &values[9][0];
- argv[2] = &values[10][0];
- fail_if(parse_args(&init, argc, argv) != 0 && init.nb_mme_buf_alloc != 12, "Error parse args with mme parameter");
-}
-END_TEST
-
-/** tun/tap creation procedure */
-START_TEST (test_plc_drv_create_tuntap)
-{
- //Check tun/tap name procedure with bad name
- strcpy(init.tuntap_name, "tap-1");
- fail_if(create_tuntap(&init) == 0, "Error with tuntap name during creation");
- //Check tun/tap name procedure with good name
- strcpy(init.tuntap_name, "tap0");
- fail_if(create_tuntap(&init) != 0, "Error with tuntap name during creation");
- //Check tun/tap name procedure with good name
- strcpy(init.tuntap_name, "tap5");
- fail_if(create_tuntap(&init) != 0, "Error with tuntap name during creation");
- //Check tun/tap name procedure with good name
- strcpy(init.tuntap_name, "tap10");
- fail_if(create_tuntap(&init) != 0, "Error with tuntap name during creation");
-}
-END_TEST
-
-extern Suite* plc_drv_suite(void)
-{
- Suite *s = suite_create("PLC_DRV");
- TCase *tc_core = tcase_create("Core");
-
- //Test parse_args
- tcase_add_test(tc_core, test_plc_drv_parse_args);
- //Test create_tuntap
- tcase_add_test(tc_core, test_plc_drv_create_tuntap);
-
- 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/gidel/utests/src/processing_utests.c b/cleopatre/devkit/tests/plcdrv/gidel/utests/src/processing_utests.c
deleted file mode 100644
index bbd5e9456f..0000000000
--- a/cleopatre/devkit/tests/plcdrv/gidel/utests/src/processing_utests.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test_processing.c
- * \brief tests of the PROCESSING layer.
- * \ingroup Cleopatre - Isis
- */
-
-#include <check.h>
-#include <stdio.h>
-#include <string.h>
-#include "processing.h"
-
-extern Suite* processing_suite(void)
-{
- Suite *s = suite_create("PROCESSING");
- TCase *tc_core = tcase_create("Core");
-
- 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;
-}
-
diff --git a/cleopatre/devkit/tests/utests_makerules b/cleopatre/devkit/tests/utests_makerules
deleted file mode 100644
index 532afed988..0000000000
--- a/cleopatre/devkit/tests/utests_makerules
+++ /dev/null
@@ -1,70 +0,0 @@
-#You need to precise : PRJ_BASE and FILES before calling this file
-#EXTRA_CFLAGS and OBJ_FILES are optionnal
-# If some object files depend on function stubs in utests:
-# Source files with function stubs should be put in TEST_STUBPATH directory
-# Names of object files with stubs should be given in OBJ_FILES (under TEST_OBJPATH)
-
-TEST_NAME = utests
-
-PRJ_SRCPATH = $(PRJ_BASE)/src
-TEST_SRCPATH = src
-PRJ_INCPATH = $(PRJ_BASE)/inc
-TEST_INCPATH = ./inc
-
-OBJPATH = obj
-PRJ_OBJPATH = $(OBJPATH)/prj
-TEST_OBJPATH = $(OBJPATH)/test
-
-TEST_STUBPATH = stubs
-
-BINS = $(foreach file, $(FILES), $(OBJPATH)/$(file).elf)
-
-ifneq ($(wildcard $(PRJ_SRCPATH)/*.cpp),)
- LDCC=g++
-else
- ifneq ($(wildcard $(TEST_SRCPATH)/*.cpp),)
- LDCC=g++
- else
- LDCC=gcc
- endif
-endif
-CC=gcc
-CPP=g++
-CFLAGS = -Wall -g -D__UTESTS__ -I$(PRJ_INCPATH) -I$(TEST_INCPATH) $(EXTRA_CFLAGS)
-LDFLAGS = $(EXTRA_LDFLAGS)
-LIBS = -lcheck -lpthread $(EXTRA_LIBS)
-
-all: preall $(PREBINS) $(BINS)
-
-clean:
- rm -f $(OBJPATH)/*.elf
- rm -f $(PRJ_OBJPATH)/*.o $(TEST_OBJPATH)/*.o $(OBJPATH)/*.o
- rm -rf $(TEST_OBJPATH)
- rm -rf $(PRJ_OBJPATH)
- rm -rf $(OBJPATH)
-
-preall:
- mkdir -p $(OBJPATH)
- mkdir -p $(PRJ_OBJPATH)
- mkdir -p $(TEST_OBJPATH)
-
-.PHONY: all clean
-.PRECIOUS: $(PRJ_OBJPATH)/%.o $(TEST_OBJPATH)/%.o
-
-$(OBJPATH)/%.elf: $(PRJ_OBJPATH)/%.o $(TEST_OBJPATH)/%_$(TEST_NAME).o $(OBJ_FILES)
- $(LDCC) $(LDFLAGS) -o $@ $^ $(LIBS)
-
-$(TEST_OBJPATH)/%.o: $(TEST_STUBPATH)/%.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-$(TEST_OBJPATH)/%.o: $(TEST_SRCPATH)/%.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-$(TEST_OBJPATH)/%.o: $(TEST_SRCPATH)/%.cpp
- $(CPP) $(CFLAGS) -c -o $@ $<
-
-$(PRJ_OBJPATH)/%.o: $(PRJ_SRCPATH)/%.c
- $(CC) $(CFLAGS) -c -o $@ $<
-
-$(PRJ_OBJPATH)/%.o: $(PRJ_SRCPATH)/%.cpp
- $(CPP) $(CFLAGS) -c -o $@ $<