summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorburet2008-05-20 15:30:03 +0000
committerburet2008-05-20 15:30:03 +0000
commitae4673ba8f32c8fb0085a7b2f33541f4549d7311 (patch)
tree4fa36e81057ec17d06c0bccade92d8f2b0baf759
parentfd8bb15a1bbf73683803ee1086a8cd6ca398b1ee (diff)
Maximus proto: develop a functional test using pipes between the python script and the proto station.
(Still some little/big endian issues to enhance) git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2030 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cesar/common/tests/tests5
-rw-r--r--cesar/host/fcall/fcall.h9
-rw-r--r--cesar/host/fcall/src/fcall.c26
-rw-r--r--cesar/host/fcall/src/fcall_param.c2
-rw-r--r--cesar/host/sci/cesar/inc/sci.h2
-rw-r--r--cesar/interface/fcall/doc/victrix_fcall.odtbin150304 -> 150822 bytes
-rw-r--r--cesar/interface/fcall/inc/context.h1
-rw-r--r--cesar/interface/fcall/inc/interface_fcall.h2
-rw-r--r--cesar/interface/fcall/interface_fcall.h3
-rw-r--r--cesar/interface/fcall/src/interface_fcall.c34
-rw-r--r--cesar/interface/fcall/test/src/test_interface_fcall.c16
-rw-r--r--cesar/maximus/prototest/Makefile6
-rw-r--r--cesar/maximus/prototest/ecos.ecc.sh3
-rw-r--r--cesar/maximus/prototest/inc/syscall.h134
-rw-r--r--cesar/maximus/prototest/src/test_fcall.c320
-rw-r--r--cesar/maximus/python/lib/proto/fcall.py32
-rw-r--r--cesar/maximus/python/lib/proto/maximus_proto.py39
-rw-r--r--cesar/maximus/python/test/test_lib_proto.py31
-rwxr-xr-xcesar/maximus/test/test_python.sh4
19 files changed, 605 insertions, 64 deletions
diff --git a/cesar/common/tests/tests b/cesar/common/tests/tests
index 5f1097f850..bd8697ddfc 100644
--- a/cesar/common/tests/tests
+++ b/cesar/common/tests/tests
@@ -88,6 +88,9 @@ cov test_circular_buffer: ./obj/test_circular_list
maximus/stationtest:
make
+maximus/prototest:
+make
+
maximus/python:
make: make COV=y
python test/test_channel.py -e ../stationtest/obj/test_station.elf -d false -t 2500000000
@@ -96,7 +99,7 @@ python test/test_ethernet.py -e ../stationtest/obj/test_ether.elf -d false -t 25
python test/test_fsm.py
python test/test_interface.py -e ../stationtest/obj/stationtest.elf -d false -t 2500000000
python test/test_lib_cesar.py -e ../stationtest/obj/test_lib_cesar.elf -d false -t 2500000000
-python test/test_lib_proto.py
+python test/test_lib_proto.py -e ../prototest/obj/test_fcall.elf -t 2500000000
python test/test_macframe.py -e ../stationtest/obj/test_send.elf -d false -t 2500000000
python test/test_mme.py -e ../stationtest/obj/stationtest.elf -d false -t 2500000000
python test/test_result.py
diff --git a/cesar/host/fcall/fcall.h b/cesar/host/fcall/fcall.h
index 26b0fe877a..87cb7c5f5c 100644
--- a/cesar/host/fcall/fcall.h
+++ b/cesar/host/fcall/fcall.h
@@ -30,6 +30,13 @@
#include "host/fwd.h"
#include "host/sci/sci.h"
#include "host/station/station.h"
+#include "lib/bitstream.h"
+#include "lib/read_word.h"
+
+#ifdef FCALL_PROTO
+#undef FUNCTION_CALL_PARAM_MAX_SIZE
+#define FUNCTION_CALL_PARAM_MAX_SIZE 1024
+#endif /* FCALL_PROTO */
#define PROBE_ID_MAX_SIZE FUNCTION_CALL_ID_MAX_SIZE
#define PROBE_VAR_MAX_NB FUNCTION_CALL_FUNCTION_MAX_NB
@@ -86,6 +93,8 @@ struct fcall_ctx
struct fcall_function function_table[FUNCTION_CALL_FUNCTION_MAX_NB];
/** number of registered functions */
int function_nb;
+ /** bitstream context */
+ bitstream_t bitstream_ctx;
};
/** variable register structure */
diff --git a/cesar/host/fcall/src/fcall.c b/cesar/host/fcall/src/fcall.c
index 0c02883cdb..96bc07e484 100644
--- a/cesar/host/fcall/src/fcall.c
+++ b/cesar/host/fcall/src/fcall.c
@@ -277,6 +277,10 @@ int fcall_recv(sci_msg_t *msg, void *fcall_data)
unsigned char return_flags = 0;
int len = 0;
+#ifdef FCALL_PROTO
+ u8 tmp = 0;
+#endif /* FCALL_PROTO */
+
fcall = (fcall_ctx_t *)fcall_data;
DBG_ASSERT(fcall);
@@ -305,8 +309,19 @@ int fcall_recv(sci_msg_t *msg, void *fcall_data)
/* fill the param structure */
/* get the parameter number */
+
+#ifndef FCALL_PROTO
param_ref->param_nb = msg->hdr.fcall->param_nb;
param_ref->msg_id = ntohs(msg->hdr.fcall->msg_id);
+#else /* FCALL_PROTO */
+ bitstream_init (&fcall->bitstream_ctx, msg->hdr.fcall, sizeof(struct fcall_msg_hdr), BITSTREAM_READ);
+ bitstream_access (&fcall->bitstream_ctx, &tmp, 8); // version
+ bitstream_access (&fcall->bitstream_ctx, &tmp, 8); // type
+ bitstream_access (&fcall->bitstream_ctx, &param_ref->msg_id, 16);
+ bitstream_access (&fcall->bitstream_ctx, &param_ref->param_nb, 8);
+ bitstream_finalise (&fcall->bitstream_ctx);
+#endif /* FCALL_PROTO */
+
if(sci_msg_pop(msg, sizeof(struct fcall_msg_hdr)) < (int)sizeof(struct fcall_msg_hdr))
{
station_log(fcall->sci->station, STATION_LOG_ERROR, STATION_LOGTYPE_FCALL,
@@ -363,6 +378,7 @@ int fcall_recv(sci_msg_t *msg, void *fcall_data)
/* get all param */
for(index = 0; index < param_ref->param_nb; index++)
{
+ int length = 0;
DBG_ASSERT(msg->length != 0);
if(msg->length == 0)
{
@@ -379,7 +395,15 @@ int fcall_recv(sci_msg_t *msg, void *fcall_data)
"%s: errno = %d because cannot get data", __FUNCTION__, errno);
return -1;
}
+
param_ref->param_table[index].length = (unsigned short *)(msg->data_begin);
+
+#ifndef FCALL_PROTO
+ length = ntohs(*param_ref->param_table[index].length);
+#else /* FCALL_PROTO */
+ length = read_u16_from_word((u8 *)param_ref->param_table[index].length);
+#endif /* FCALL_PROTO */
+
if(sci_msg_pop(msg, sizeof(unsigned short)) < (int)sizeof(unsigned short))
{
station_log(fcall->sci->station, STATION_LOG_ERROR, STATION_LOGTYPE_FCALL,
@@ -387,7 +411,7 @@ int fcall_recv(sci_msg_t *msg, void *fcall_data)
return -1;
}
param_ref->param_table[index].data = msg->data_begin;
- if(sci_msg_pop(msg, ntohs(*param_ref->param_table[index].length)) < ntohs(*param_ref->param_table[index].length))
+ if(sci_msg_pop(msg, length) < length)
{
station_log(fcall->sci->station, STATION_LOG_ERROR, STATION_LOGTYPE_FCALL,
"%s: errno = %d because cannot fill param data", __FUNCTION__, errno);
diff --git a/cesar/host/fcall/src/fcall_param.c b/cesar/host/fcall/src/fcall_param.c
index 46b0f7fc98..4397d4bedd 100644
--- a/cesar/host/fcall/src/fcall_param.c
+++ b/cesar/host/fcall/src/fcall_param.c
@@ -199,7 +199,7 @@ int fcall_param_bind(fcall_param_t *param, sci_msg_t *msg, char *id, unsigned in
{
/* found id */
/* get length */
- length = ntohs(*param->param_table[index].length);
+ length = *param->param_table[index].length;
/* check the maximum available length */
if(length > max_length)
length = max_length;
diff --git a/cesar/host/sci/cesar/inc/sci.h b/cesar/host/sci/cesar/inc/sci.h
index 3be9a01ca6..6acbcfe247 100644
--- a/cesar/host/sci/cesar/inc/sci.h
+++ b/cesar/host/sci/cesar/inc/sci.h
@@ -20,7 +20,7 @@
*/
#undef SCI_MSG_MAX_SIZE
-#define SCI_MSG_MAX_SIZE 1508
+#define SCI_MSG_MAX_SIZE 1514 // ETH_PACKET_MAX_SIZE - sizeof(u32) /* vlantag */
/**
* register a send callback function to send a message
diff --git a/cesar/interface/fcall/doc/victrix_fcall.odt b/cesar/interface/fcall/doc/victrix_fcall.odt
index cff820ccf9..9b00cdad7b 100644
--- a/cesar/interface/fcall/doc/victrix_fcall.odt
+++ b/cesar/interface/fcall/doc/victrix_fcall.odt
Binary files differ
diff --git a/cesar/interface/fcall/inc/context.h b/cesar/interface/fcall/inc/context.h
index 2a902c4d81..e997af40e8 100644
--- a/cesar/interface/fcall/inc/context.h
+++ b/cesar/interface/fcall/inc/context.h
@@ -23,6 +23,7 @@ typedef void (*interface_fcall_send_done_message_cb_t) (void *user_data, u8 *mes
typedef struct interface_fcall_t
{
fcall_ctx_t *fcall_ctx; /** pointer to fcall context */
+ probe_ctx_t *probe_ctx; /** pointer to probe context */
interface_fcall_send_message_cb_t send_cb; /** callback function to call when interface fcall module needs to send a message */
interface_fcall_send_done_message_cb_t send_done_cb; /** callback function to call when interface fcall module needs to release a buffer */
void *user_data; /** data to provide on callback function */
diff --git a/cesar/interface/fcall/inc/interface_fcall.h b/cesar/interface/fcall/inc/interface_fcall.h
index 06fea15260..1a87ccb969 100644
--- a/cesar/interface/fcall/inc/interface_fcall.h
+++ b/cesar/interface/fcall/inc/interface_fcall.h
@@ -14,7 +14,7 @@
*
*/
-#define INTERFACE_FCALL_OFFSET 20 /* mme header without vlan tag (19) + sub-module type (1) */
+#define INTERFACE_FCALL_PAYLOAD_OFFSET 22 /* mme header without vlan tag (19) + sub-module type (1) + payload length (2) */
#define INTERFACE_FCALL_MMTYPE 0xABCD // TBD
/**
diff --git a/cesar/interface/fcall/interface_fcall.h b/cesar/interface/fcall/interface_fcall.h
index ef8f03e593..8c1d7c0a1e 100644
--- a/cesar/interface/fcall/interface_fcall.h
+++ b/cesar/interface/fcall/interface_fcall.h
@@ -17,7 +17,8 @@
/**
* initialise the interface fcall module and the callback functions
- * \param cb the function to call when the interface fcall needs to send a message
+ * \param send_cb the function to call when the interface fcall needs to send an INTERFACE message
+ * \param send_done_cb the function to call when the interface fcall needs to send a SEND DONE message
* \param user_data the data to provide on callback function
*/
interface_fcall_t*
diff --git a/cesar/interface/fcall/src/interface_fcall.c b/cesar/interface/fcall/src/interface_fcall.c
index 73d68f27cf..e92837c8f1 100644
--- a/cesar/interface/fcall/src/interface_fcall.c
+++ b/cesar/interface/fcall/src/interface_fcall.c
@@ -27,7 +27,8 @@
/**
* initialise the interface fcall module and the callback functions
- * \param cb the function to call when the interface fcall needs to send a message
+ * \param send_cb the function to call when the interface fcall needs to send an INTERFACE message
+ * \param send_done_cb the function to call when the interface fcall needs to send a SEND DONE message
* \param user_data the data to provide on callback function
*/
interface_fcall_t*
@@ -38,6 +39,7 @@ interface_fcall_init (interface_fcall_send_message_cb_t send_cb,
static interface_fcall_t ctx;
static sci_ctx_t sci_ctx;
static fcall_ctx_t fcall_ctx;
+ static probe_ctx_t probe_ctx;
dbg_assert_ptr(send_cb);
dbg_assert_ptr(send_done_cb);
@@ -52,6 +54,7 @@ interface_fcall_init (interface_fcall_send_message_cb_t send_cb,
memset(&ctx, '\0', sizeof(interface_fcall_t));
ctx.fcall_ctx = &fcall_ctx;
+ ctx.probe_ctx = &probe_ctx;
ctx.send_cb = send_cb;
ctx.send_done_cb = send_done_cb;
ctx.user_data = user_data;
@@ -70,6 +73,11 @@ interface_fcall_init (interface_fcall_send_message_cb_t send_cb,
dbg_assert_print(false, "fcall init failed with errno = %d", errno);
return NULL;
}
+ if (probe_init(&probe_ctx, &fcall_ctx) < 0)
+ {
+ dbg_assert_print(false, "probe init failed with errno = %d", errno);
+ return NULL;
+ }
return &ctx;
}
@@ -102,7 +110,7 @@ void
interface_fcall_mme_recv (void *data, u8 *mme, u8 *buffer)
{
interface_fcall_t *ctx = NULL;
- sci_msg_t msg;
+ static sci_msg_t msg;
uint length = 0;
dbg_assert_ptr(data);
@@ -119,13 +127,13 @@ interface_fcall_mme_recv (void *data, u8 *mme, u8 *buffer)
ctx = (interface_fcall_t*)data;
/** Read ODA and OSA. */
- bitstream_init (&ctx->bitstream_ctx, mme, INTERFACE_FCALL_OFFSET, BITSTREAM_READ);
+ bitstream_init (&ctx->bitstream_ctx, mme, INTERFACE_FCALL_PAYLOAD_OFFSET, BITSTREAM_READ);
bitstream_access (&ctx->bitstream_ctx, &ctx->oda, 48);
bitstream_access (&ctx->bitstream_ctx, &ctx->osa, 48);
bitstream_finalise (&ctx->bitstream_ctx);
/** Read payload length. */
- length = read_u16_from_word (mme + INTERFACE_FCALL_OFFSET);
+ length = read_u16_from_word(mme + INTERFACE_FCALL_PAYLOAD_OFFSET - sizeof(u16)) + INTERFACE_FCALL_PAYLOAD_OFFSET;
if (sci_msg_init(&msg, buffer, SCI_MSG_MAX_SIZE) < 0)
{
@@ -137,7 +145,12 @@ interface_fcall_mme_recv (void *data, u8 *mme, u8 *buffer)
dbg_assert_print(false, "sci msg push failed with errno = %d", errno);
return;
}
- memcpy(msg.data_begin, mme + INTERFACE_FCALL_OFFSET + sizeof(u16), length);
+ bitstream_memcpy(msg.data_begin, mme, length);
+ if (INTERFACE_FCALL_PAYLOAD_OFFSET != sci_msg_pop(&msg, INTERFACE_FCALL_PAYLOAD_OFFSET))
+ {
+ dbg_assert_print(false, "sci msg pop failed with errno = %d", errno);
+ return;
+ }
dbg_assert_ptr(ctx->fcall_ctx);
if ( (NULL != ctx->fcall_ctx)
&& (sci_recv_msg(ctx->fcall_ctx->sci, &msg) < 0) )
@@ -162,8 +175,8 @@ interface_fcall_mme_recv (void *data, u8 *mme, u8 *buffer)
void
interface_fcall_mme_send (void *data, sci_msg_t *msg)
{
- interface_fcall_t *ctx;
- uint field;
+ interface_fcall_t *ctx = NULL;
+ uint field = 0, length = 0;
uint word[2];
dbg_assert_ptr(data);
@@ -177,14 +190,14 @@ interface_fcall_mme_send (void *data, sci_msg_t *msg)
ctx = (interface_fcall_t*)data;
- if (INTERFACE_FCALL_OFFSET + sizeof(u16) != sci_msg_push(msg, INTERFACE_FCALL_OFFSET + sizeof(u16)))
+ if (INTERFACE_FCALL_PAYLOAD_OFFSET != sci_msg_push(msg, INTERFACE_FCALL_PAYLOAD_OFFSET))
{
dbg_assert_print(false, "sci msg push failed with errno = %d", errno);
return;
}
// Fill the MME Header.
- bitstream_init (&ctx->bitstream_ctx, msg->data_begin, INTERFACE_FCALL_OFFSET + sizeof(u16), BITSTREAM_WRITE);
+ bitstream_init (&ctx->bitstream_ctx, msg->data_begin, INTERFACE_FCALL_PAYLOAD_OFFSET, BITSTREAM_WRITE);
/* Inserting the ODA and the OSA. */
bitstream_access (&ctx->bitstream_ctx, &ctx->osa, 48);
@@ -211,7 +224,8 @@ interface_fcall_mme_send (void *data, sci_msg_t *msg)
bitstream_access (&ctx->bitstream_ctx, &field, 8);
/* Inserting the payload length. */
- bitstream_access (&ctx->bitstream_ctx, &msg->length - INTERFACE_FCALL_OFFSET - sizeof(u16), 16);
+ length = msg->length - INTERFACE_FCALL_PAYLOAD_OFFSET;
+ bitstream_access (&ctx->bitstream_ctx, &length, 16);
bitstream_finalise (&ctx->bitstream_ctx);
diff --git a/cesar/interface/fcall/test/src/test_interface_fcall.c b/cesar/interface/fcall/test/src/test_interface_fcall.c
index e99596f319..3873126d3e 100644
--- a/cesar/interface/fcall/test/src/test_interface_fcall.c
+++ b/cesar/interface/fcall/test/src/test_interface_fcall.c
@@ -16,7 +16,6 @@
#include "interface/fcall/interface_fcall.h"
#include "interface/fcall/inc/interface_fcall.h"
#include "interface/forward.h"
-#include "common/defs/ethernet.h" // for 'ETH_PACKET_MIN_SIZE' and 'ETH_PACKET_MAX_SIZE'
#include <stdio.h> // for 'printf'
#include <errno.h>
@@ -32,7 +31,7 @@ interface_fcall_send_message_cb (void *user_data, uint *message, uint length)
dbg_assert_ptr(message);
dbg_assert(2 == length);
data = (u8*)(*(message + 1));
- dbg_assert_print((0 == memcmp(data + INTERFACE_FCALL_OFFSET + sizeof(u16) + sizeof(struct fcall_msg_hdr), test, strlen(test) + 1)),
+ dbg_assert_print((0 == memcmp(data + INTERFACE_FCALL_PAYLOAD_OFFSET + sizeof(struct fcall_msg_hdr), test, strlen(test) + 1)),
"registered send function");
return;
}
@@ -117,6 +116,7 @@ interface_fcall_init_test_case(test_t t)
(NULL != ctx)
&& (EINVAL != errno)
&& (ctx->fcall_ctx != NULL)
+ && (ctx->probe_ctx != NULL)
&& (ctx->send_cb == &interface_fcall_send_message_cb)
&& (ctx->send_done_cb == &interface_fcall_send_done_message_cb)
&& (ctx->user_data == &user_data)
@@ -127,10 +127,10 @@ interface_fcall_init_test_case(test_t t)
void
interface_fcall_mme_recv_test_case(test_t t)
{
- u8 mme[ETH_PACKET_MAX_SIZE];
+ u8 mme[SCI_MSG_MAX_SIZE];
u8 buffer[SCI_MSG_MAX_SIZE];
struct fcall_msg_hdr fcall_hdr;
- memset(mme, '\0', ETH_PACKET_MAX_SIZE);
+ memset(mme, '\0', SCI_MSG_MAX_SIZE);
memset(buffer, '\0', SCI_MSG_MAX_SIZE);
test_case_begin(t, "mme recv");
@@ -176,14 +176,14 @@ interface_fcall_mme_recv_test_case(test_t t)
test_begin(t, "check mme recv")
{
- u16 length = sizeof(fcall_hdr) + strlen(test) + 1;
+ u16 length = sizeof(struct fcall_msg_hdr) + strlen(test) + 1;
fcall_register(ctx->fcall_ctx, test, (void*)&host_fcall_test, NULL);
memset(&fcall_hdr, '\0', sizeof(fcall_hdr));
fcall_hdr.version = FUNCTION_CALL_VERSION;
fcall_hdr.type = FUNCTION_CALL_TYPE_REQ;
- memcpy((char*)mme + INTERFACE_FCALL_OFFSET, &length, sizeof(u16));
- memcpy((char*)mme + INTERFACE_FCALL_OFFSET + sizeof(u16), &fcall_hdr, sizeof(fcall_hdr));
- strcpy((char*)mme + INTERFACE_FCALL_OFFSET + sizeof(u16) + sizeof(fcall_hdr), test);
+ memcpy((char*)mme + INTERFACE_FCALL_PAYLOAD_OFFSET - sizeof(u16), &length, sizeof(u16));
+ memcpy((char*)mme + INTERFACE_FCALL_PAYLOAD_OFFSET, &fcall_hdr, sizeof(fcall_hdr));
+ strcpy((char*)mme + INTERFACE_FCALL_PAYLOAD_OFFSET + sizeof(fcall_hdr), test);
interface_fcall_mme_recv (ctx, mme, buffer);
test_fail_unless(
(errno != EINVAL)
diff --git a/cesar/maximus/prototest/Makefile b/cesar/maximus/prototest/Makefile
index 514a4b33e1..ae2f35d7ea 100644
--- a/cesar/maximus/prototest/Makefile
+++ b/cesar/maximus/prototest/Makefile
@@ -2,11 +2,13 @@ BASE = ../..
ECOS = y
-TARGET = sparc
+#TARGET = sparc
+
+EXTRA_TARGET_CFLAGS+= -DFCALL_PROTO
TARGET_PROGRAMS = test_fcall
test_fcall_SOURCES = test_fcall.c
-test_fcall_MODULES = lib host
+test_fcall_MODULES = lib interface interface/fcall
include $(BASE)/common/make/top.mk \ No newline at end of file
diff --git a/cesar/maximus/prototest/ecos.ecc.sh b/cesar/maximus/prototest/ecos.ecc.sh
index db2208c6cc..7cb7f452d8 100644
--- a/cesar/maximus/prototest/ecos.ecc.sh
+++ b/cesar/maximus/prototest/ecos.ecc.sh
@@ -1,5 +1,6 @@
config=${1:-ecos-gen.ecc}
-ecosconfig --config=$config new sparc_leon default
+#ecosconfig --config=$config new sparc_leon default
+ecosconfig --config=$config new linux default
cat >> $config <<'EOF'
EOF
ecosconfig --config=$config check
diff --git a/cesar/maximus/prototest/inc/syscall.h b/cesar/maximus/prototest/inc/syscall.h
new file mode 100644
index 0000000000..dcaa3b0488
--- /dev/null
+++ b/cesar/maximus/prototest/inc/syscall.h
@@ -0,0 +1,134 @@
+#ifndef syscall_h
+#define syscall_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file syscall.h
+ * \brief Linux System Calls redefinition
+ * \ingroup maximus/prototest
+ *
+ * Redefinition of Linux System Calls
+ */
+#include "ecos/packages/hal/synth/arch/current/include/hal_io.h"
+
+/** flags redefinition */
+
+/* open/fcntl flags */
+#define O_RDONLY CYG_HAL_SYS_O_RDONLY
+#define O_WRONLY CYG_HAL_SYS_O_WRONLY
+#define O_RDWR CYG_HAL_SYS_O_RDWR
+#define O_CREAT CYG_HAL_SYS_O_CREAT
+#define O_EXCL CYG_HAL_SYS_O_EXCL
+#define O_NOCTTY CYG_HAL_SYS_O_NOCTTY
+#define O_TRUNC CYG_HAL_SYS_O_TRUNC
+#define O_APPEND CYG_HAL_SYS_O_APPEND
+#define O_NONBLOCK CYG_HAL_SYS_O_NONBLOCK
+#define O_NDELAY CYG_HAL_SYS_O_NDELAY
+#define O_SYNC CYG_HAL_SYS_O_SYNC
+#define O_FSYNC CYG_HAL_SYS_O_FSYNC
+#define O_ASYN CYG_HAL_SYS_O_ASYNC
+
+/* open mode flags */
+#define S_IRUSR CYG_HAL_SYS_S_IRUSR
+#define S_IREAD CYG_HAL_SYS_S_IREAD
+#define S_IWUSR CYG_HAL_SYS_S_IWUSR
+#define S_IWRITE CYG_HAL_SYS_S_IWRITE
+#define S_IXUSR CYG_HAL_SYS_S_IXUSR
+#define S_IEXEC CYG_HAL_SYS_S_IEXEC
+#define S_IRWXU CYG_HAL_SYS_S_IRWXU
+#define S_IRWXG CYG_HAL_SYS_S_IRWXG
+#define S_IRGRP CYG_HAL_SYS_S_IRGRP
+#define S_IWGRP CYG_HAL_SYS_S_IWGRP
+#define S_IXGRP CYG_HAL_SYS_S_IXGRP
+#define S_IRWXO CYG_HAL_SYS_S_IRWXO
+#define S_IROTH CYG_HAL_SYS_S_IROTH
+#define S_IWOTH CYG_HAL_SYS_S_IWOTH
+#define S_IXOTH CYG_HAL_SYS_S_IXOTH
+
+/* stat flags */
+#define S_IFMT CYG_HAL_SYS_S_IFMT
+#define S_IFSOCK CYG_HAL_SYS_S_IFSOCK
+#define S_IFLNK CYG_HAL_SYS_S_IFLNK
+#define S_IFREG CYG_HAL_SYS_S_IFREG
+#define S_IFBLK CYG_HAL_SYS_S_IFBLK
+#define S_IFDIR CYG_HAL_SYS_S_IFDIR
+#define S_IFCHR CYG_HAL_SYS_S_IFCHR
+#define S_IFIFO CYG_HAL_SYS_S_IFIFO
+#define S_ISUID CYG_HAL_SYS_S_ISUID
+#define S_ISGID CYG_HAL_SYS_S_ISGID
+#define S_ISVTX CYG_HAL_SYS_S_ISVTX
+
+/** functions redefinition */
+
+static inline int open(const char *pathname, int flags, mode_t mode)
+{
+ int result;
+ if((result = cyg_hal_sys_open(pathname, flags, mode)) < 0)
+ {
+ errno = -result;
+ result = -1;
+ }
+ return result;
+}
+
+static inline int close(int fd)
+{
+ int result;
+ if((result = cyg_hal_sys_close(fd)) < 0)
+ {
+ errno = -result;
+ result = -1;
+ }
+ return result;
+}
+
+static inline ssize_t read(int fd, void *buf, size_t count)
+{
+ int result;
+ if((result = cyg_hal_sys_read(fd, buf, count)) < 0)
+ {
+ errno = -result;
+ result = -1;
+ }
+ return result;
+}
+
+static inline ssize_t write(int fd, const void *buf, size_t count)
+{
+ int result;
+ if ((result = (ssize_t)cyg_hal_sys_write(fd, buf, count)) < 0)
+ {
+ errno = -result;
+ result = -1;
+ }
+ return result;
+}
+
+static inline int mknod(const char *pathname, mode_t mode, dev_t dev)
+{
+ int result;
+ if((result = cyg_hal_sys_mknod(pathname, mode, dev)) < 0)
+ {
+ errno = -result;
+ result = -1;
+ }
+ return result;
+}
+
+static inline int unlink(const char *pathname)
+{
+ int result;
+ if((result = cyg_hal_sys_unlink(pathname)) < 0)
+ {
+ errno = -result;
+ result = -1;
+ }
+ return result;
+}
+
+#endif /* syscall_h */
diff --git a/cesar/maximus/prototest/src/test_fcall.c b/cesar/maximus/prototest/src/test_fcall.c
index 268938b8c5..3728f182fb 100644
--- a/cesar/maximus/prototest/src/test_fcall.c
+++ b/cesar/maximus/prototest/src/test_fcall.c
@@ -12,8 +12,326 @@
*
* this is a test program to check fcall module well work
*/
+#include <cyg/infra/diag.h>
+#include <cyg/kernel/kapi.h>
+#include <errno.h>
+#include "common/std.h"
+#include "interface/fcall/interface_fcall.h"
+#include "interface/fcall/inc/interface_fcall.h"
+#include "lib/read_word.h"
+#include "maximus/prototest/inc/syscall.h"
-void cyg_user_start(void)
+#define MY_THREAD_STACK_SIZE (8192 / sizeof(int))
+
+int my_thread_stack[MY_THREAD_STACK_SIZE];
+cyg_handle_t my_thread_handle;
+cyg_thread my_thread_obj;
+
+interface_fcall_t *ctx;
+
+int proto_in_fd = -1, proto_out_fd = -1;
+
+void my_thread(cyg_addrword_t index)
+{
+ static u8 my_mme[SCI_MSG_MAX_SIZE];
+ static u8 my_buffer[SCI_MSG_MAX_SIZE];
+ int len = 0, data_length = 0;
+
+ diag_write_string("=> my_thread\n");
+ while(1)
+ {
+ memset(my_mme, 0x00, SCI_MSG_MAX_SIZE);
+ memset(my_buffer, 0x00, SCI_MSG_MAX_SIZE);
+ while (INTERFACE_FCALL_PAYLOAD_OFFSET != len)
+ {
+ len = read(proto_in_fd, my_mme, INTERFACE_FCALL_PAYLOAD_OFFSET);
+ }
+ dbg_assert(INTERFACE_FCALL_PAYLOAD_OFFSET == len);
+ data_length = read_u16_from_word(my_mme + INTERFACE_FCALL_PAYLOAD_OFFSET - sizeof(u16));
+ if ((len = read(proto_in_fd, my_mme + INTERFACE_FCALL_PAYLOAD_OFFSET, data_length)) < 0)
+ {
+ diag_write_string("error when reading proto in file\n");
+ return;
+ }
+ diag_printf("READ len = %d - data length = %d\n", len, data_length);
+ dbg_assert(len == data_length);
+ diag_write_string("=> interface_fcall_mme_recv\n");
+ interface_fcall_mme_recv (ctx, my_mme, my_buffer);
+ }
+}
+
+void
+my_interface_hle_send (void *user_data, uint *message, uint length)
+{
+ int len = 0, data_length = 0;
+ u8 *data = NULL;
+
+ dbg_assert_ptr(user_data);
+ dbg_assert_ptr(message);
+ dbg_assert(2 == length);
+
+ diag_write_string("=> interface_hle_send\n");
+ data = (u8 *)message[1];
+ data_length = read_u16_from_word(data + INTERFACE_FCALL_PAYLOAD_OFFSET - sizeof(u16)) + INTERFACE_FCALL_PAYLOAD_OFFSET;
+ if ((len = write(proto_out_fd, data, data_length)) < 0)
+ {
+ diag_write_string("error when writing proto out file\n");
+ return;
+ }
+ dbg_assert(len == data_length);
+ diag_printf("WRITE len = %d - data length = %d\n", len, data_length);
+ diag_write_string("END interface_hle_send\n");
+
+ return;
+}
+
+void
+my_interface_hle_send_done (void *user_data, u8 *message)
+{
+ dbg_assert_ptr(user_data);
+ dbg_assert_ptr(message);
+
+ diag_write_string("=> interface_hle_send_done\n");
+
+ return;
+}
+
+typedef struct my_struct
+{
+ int i1;
+ int i2;
+ bool b;
+} my_struct_t;
+
+typedef long long my_type_t;
+
+my_type_t my_param4;
+
+unsigned int my_param6 = 123; // 0x0000007B
+unsigned int my_param7 = 456; // 0x000001C8
+bool my_param8 = false;
+bool my_param9 = true;
+unsigned short my_param10 = 0xFFEE;
+unsigned long my_param11 = 0xFFEEDDCC;
+
+void
+my_return_function (void *data)
+{
+ static fcall_param_t return_param;
+ static sci_msg_t return_msg;
+ static unsigned char return_buffer[SCI_MSG_MAX_SIZE];
+ unsigned short *return_msg_id = (unsigned short *)data;
+
+ /* init structures */
+ fcall_param_init(&return_param, "function_1_rsp", *return_msg_id);
+ if (0 != sci_msg_init(&return_msg, return_buffer, SCI_MSG_MAX_SIZE))
+ {
+ diag_printf("%s: errno = %d", __FUNCTION__, errno);
+ }
+
+ /* do other tasks ... */
+ diag_write_string("=> my_return_function\n");
+
+ /* now make the return parameter list */
+ fcall_param_reset(&return_param);
+ fcall_param_add(&return_param, &return_msg, "result_2", sizeof(my_type_t), &my_param4);
+ fcall_return(ctx->fcall_ctx, &return_param, &return_msg);
+
+ return;
+}
+
+int
+my_function1 (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ unsigned short asynchronous_msg_id = 0;
+ my_struct_t my_param1;
+ int my_param2[10];
+ char my_param3[6];
+ int i;
+
+ /* get parameters content */
+ fcall_param_bind(*param, *msg, "param_1", sizeof(my_struct_t), &my_param1);
+ fcall_param_bind(*param, *msg, "param_2", 10*sizeof(int), my_param2);
+ fcall_param_bind(*param, *msg, "param_3", 6, (char*)my_param3);
+ fcall_param_bind(*param, *msg, "param_4", sizeof(my_type_t), &my_param4);
+
+ /* do other tasks ... */
+ diag_write_string("=> my_function1\n");
+ diag_printf("param 1 . i1 = %d\n", my_param1.i1);
+ diag_printf("param 1 . i2 = %d\n", my_param1.i2);
+ diag_printf("param 1 . b = %d\n", my_param1.b);
+ diag_write_string("param 2 = ");
+ for (i=0; i<10; i++)
+ {
+ diag_printf(" %d", my_param2[i]);
+ }
+ diag_write_string("\n");
+ diag_printf("param 3 = %s\n", my_param3);
+ diag_printf("param 4 = %lld\n", my_param4);
+
+ /* prepare the future asynchronous return */
+ fcall_param_set_async(*param, 1);
+ asynchronous_msg_id = (*param)->msg_id;
+
+ /* my_return_function() call */
+ my_return_function(&asynchronous_msg_id);
+
+ /* now return */
+ return 0;
+}
+
+int
+my_function2 (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ bool my_param5;
+ char my_result1[] = "this is result 1\0";
+
+ /* get parameters content */
+ if (-1 == fcall_param_bind(*param, *msg, "param_5", sizeof(bool), &my_param5))
+ {
+ diag_printf("errno = %d\n", errno);
+ diag_printf("param nb = %d\n", (*param)->param_nb);
+ }
+
+ /* do other tasks ... */
+ diag_write_string("=> my_function2\n");
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+ fcall_param_add(*param, *msg, "result_1", strlen(my_result1)+1, &my_result1);
+
+ return 0;
+}
+
+void
+my_function_rsp (void *data)
+{
+ static fcall_param_t return_param;
+ static sci_msg_t return_msg;
+ static unsigned char return_buffer[SCI_MSG_MAX_SIZE];
+ unsigned short *return_msg_id = (unsigned short *)data;
+
+ /* init structures */
+ fcall_param_init(&return_param, "function_rsp", *return_msg_id);
+ if (0 != sci_msg_init(&return_msg, return_buffer, SCI_MSG_MAX_SIZE))
+ {
+ diag_printf("%s: errno = %d", __FUNCTION__, errno);
+ }
+
+ /* do other tasks ... */
+ diag_write_string("=> my_function_rsp\n");
+
+ /* now make the return parameter list */
+ fcall_param_reset(&return_param);
+ fcall_return(ctx->fcall_ctx, &return_param, &return_msg);
+
+ return;
+}
+
+int
+my_function3 (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
{
+ unsigned short asynchronous_msg_id = 0;
+
+ /* do other tasks ... */
+ diag_write_string("=> my_function3\n");
+
+ /* prepare the future asynchronous return */
+ fcall_param_set_async(*param, 1);
+ asynchronous_msg_id = (*param)->msg_id;
+
+ /* call my_function_rsp() */
+ my_function_rsp((void*)&asynchronous_msg_id);
+
+ return 0;
+}
+
+int
+my_function4 (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ unsigned short asynchronous_msg_id = 0;
+
+ /* do other tasks ... */
+ diag_write_string("=> my_function4\n");
+
+ /* prepare the future asynchronous return */
+ fcall_param_set_async(*param, 1);
+ asynchronous_msg_id = (*param)->msg_id;
+
+ /* call my_function_rsp() */
+ my_function_rsp((void*)&asynchronous_msg_id);
+
+ return 0;
+}
+
+int
+my_function5 (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ unsigned short asynchronous_msg_id = 0;
+
+ /* do other tasks ... */
+ diag_write_string("=> my_function5\n");
+
+ /* prepare the future asynchronous return */
+ fcall_param_set_async(*param, 1);
+ asynchronous_msg_id = (*param)->msg_id;
+
+ /* call my_function_rsp() */
+ my_function_rsp((void*)&asynchronous_msg_id);
+
+ return 0;
+}
+
+void
+cyg_user_start(void)
+{
+ int user_data = 123;
+ ctx = interface_fcall_init (&my_interface_hle_send,
+ &my_interface_hle_send_done,
+ &user_data);
+
+ fcall_register(ctx->fcall_ctx, "function_1", (void*)&my_function1, NULL);
+ fcall_register(ctx->fcall_ctx, "function_2", (void*)&my_function2, NULL);
+ fcall_register(ctx->fcall_ctx, "function_3", (void*)&my_function3, NULL);
+ fcall_register(ctx->fcall_ctx, "function_4", (void*)&my_function4, NULL);
+ fcall_register(ctx->fcall_ctx, "function_5", (void*)&my_function5, NULL);
+
+ probe_register(ctx->probe_ctx, "param_6", sizeof(unsigned int), &my_param6);
+ probe_register(ctx->probe_ctx, "param_7", sizeof(unsigned int), &my_param7);
+ probe_register(ctx->probe_ctx, "param_8", sizeof(bool), &my_param8);
+ probe_register(ctx->probe_ctx, "param_9", sizeof(bool), &my_param9);
+ probe_register(ctx->probe_ctx, "param_10", sizeof(unsigned short), &my_param10);
+ probe_register(ctx->probe_ctx, "param_11", sizeof(unsigned long), &my_param11);
+
+ unlink("/tmp/proto_in");
+ unlink("/tmp/proto_out");
+ if ( (mknod("/tmp/proto_in", 0770 | S_IFIFO, 0) < 0)
+ || (mknod("/tmp/proto_out", 0770 | S_IFIFO, 0) < 0) )
+ {
+ diag_write_string("error when creating proto inout files\n");
+ return;
+ }
+ if ((proto_in_fd = open("/tmp/proto_in", O_RDWR | O_NONBLOCK, S_IRWXU | S_IRWXG)) < 0)
+ {
+ diag_write_string("error when opening proto in file\n");
+ return;
+ }
+ if ((proto_out_fd = open("/tmp/proto_out", O_RDWR | O_NONBLOCK, S_IRWXU | S_IRWXG)) < 0)
+ {
+ diag_write_string("error when opening proto out file\n");
+ return;
+ }
+
+ cyg_thread_create(12, my_thread, (cyg_addrword_t) 0,
+ "My Thread", &my_thread_stack, MY_THREAD_STACK_SIZE,
+ &my_thread_handle, &my_thread_obj);
+ cyg_thread_resume(my_thread_handle);
+ diag_write_string("scheduler starting...\n");
+ cyg_scheduler_start();
+
+ //interface_fcall_uninit(ctx);
+ //close(proto_in_fd);
+ //close(proto_out_fd);
+
return;
}
diff --git a/cesar/maximus/python/lib/proto/fcall.py b/cesar/maximus/python/lib/proto/fcall.py
index 909dcce556..c9ee449804 100644
--- a/cesar/maximus/python/lib/proto/fcall.py
+++ b/cesar/maximus/python/lib/proto/fcall.py
@@ -17,7 +17,7 @@ from scapy import *
from uuid import getnode
# Constants
-FUNCTION_CALL_VERSION = 0x03
+FUNCTION_CALL_VERSION = 0x02
FUNCTION_CALL_FLAG_FAILED = 0x01
FUNCTION_CALL_TYPE_REQ = 0x01
FUNCTION_CALL_TYPE_RSP = 0x02
@@ -33,6 +33,11 @@ SIZE_OF_TYPE = SIZE_OF_U16 # in octets
SIZE_OF_MMV = 1 # in octets
SIZE_OF_MMTYPE = 2 # in octets
SIZE_OF_FMI = 2 # in octets
+INTERFACE_FCALL_PAYLOAD_OFFSET = 22 # in octets
+
+# For unitary test purpose
+FUNCTION_CALL_WRITE_FILE = "/tmp/proto_in"
+FUNCTION_CALL_READ_FILE = "/tmp/proto_out"
class Param:
@@ -240,7 +245,7 @@ class Fcall:
# Interface sub-module (1 octet)
# Payload length (2 octets)
#
- mmentry = htohp8(INTERFACE_MODULE_FCALL) + htohp16(len(fcall_data))
+ mmentry = htohp8(INTERFACE_MODULE_FCALL) + htohp16(len(fcall_hdr + fcall_data))
return mmentry + fcall_hdr + fcall_data
@@ -268,10 +273,7 @@ class Fcall:
# In case of unitary test
else:
print "Sending an MME..."
- display(mme)
- file = open("/tmp/" + FUNCTION_CALL_NETWORK_INTERFACE + ".txt", 'w+')
- file.write(str(mme))
- file.close()
+ os.write(self.__maximus.write_file, str(mme))
def display(mme):
try:
@@ -323,7 +325,7 @@ def display(mme):
end += SIZE_OF_U16
print "reserved =", hex(hptoh16(mme.payload.load[begin:end]))
- print "Fcall Payload:", mme.payload.load[end:]
+ print "Fcall Payload:"
print "payload =",
for i in range(16, len(mme.payload.load)):
print hex(hptoh8(mme.payload.load[i])),
@@ -340,12 +342,14 @@ def read_param_name(data):
return read_name(data)
def read_param_length(data):
- return hptoh16(data[:SIZE_OF_U16])
+ #return hptoh16(data[:SIZE_OF_U16])
+ return ntoh16(data[:SIZE_OF_U16])
def read_param_value(data, length):
return data[:length]
def read(mme, maximus):
+
# MM Header
#
@@ -405,7 +409,7 @@ def read(mme, maximus):
display(mme)
raise Error("MM Header: bad Module! (" + hex(hptoh8(mme.payload.load[begin:end])) + ")")
- # Length: Payload length (0 to 1484) - 2 octets
+ # Length: Payload length (0 to 1492) - 2 octets
begin = end
end += SIZE_OF_U16
length = hptoh16(mme.payload.load[begin:end])
@@ -431,10 +435,10 @@ def read(mme, maximus):
display(mme)
raise Error("FCALL header: bad version! (" + hex(hptoh8(fcall_hdr[0])) + ")")
if hptoh8(fcall_hdr[1]) != FUNCTION_CALL_TYPE_RSP: # uint8_t type
- if not maximus.UNIT_TEST or (maximus.UNIT_TEST and hptoh8(fcall_hdr[1]) != FUNCTION_CALL_TYPE_REQ):
- display(mme)
- raise Error("FCALL header: bad type! (" + hex(hptoh8(fcall_hdr[1])) + ")")
- msg_id = hptoh16(fcall_hdr[2:4])
+ display(mme)
+ raise Error("FCALL header: bad type! (" + hex(hptoh8(fcall_hdr[1])) + ")")
+ #msg_id = hptoh16(fcall_hdr[2:4])
+ msg_id = ntoh16(fcall_hdr[2:4])
param_nb = hptoh8(fcall_hdr[4]) # uint8_t param_nb
if hptoh8(fcall_hdr[5]) >= FUNCTION_CALL_FLAG_FAILED: # uint8_t flags
display(mme)
@@ -445,7 +449,7 @@ def read(mme, maximus):
index = end
name = read_name(mme.payload.load[index:])
fcall = Fcall(name, maximus)
- length -= len(name) + 1
+ length -= SIZE_OF_FUNCTION_CALL_HEADER + len(name) + 1
index += len(name) + 1
for n in range(0, param_nb):
param_name = read_param_name(mme.payload.load[index:])
diff --git a/cesar/maximus/python/lib/proto/maximus_proto.py b/cesar/maximus/python/lib/proto/maximus_proto.py
index ec61b50cf9..cf1ccc2d49 100644
--- a/cesar/maximus/python/lib/proto/maximus_proto.py
+++ b/cesar/maximus/python/lib/proto/maximus_proto.py
@@ -6,6 +6,10 @@ from fcall import *
from sta_proto import StaProto
from time import time
+# For unitary test purpose
+from time import sleep
+import threading, os, pipes
+
# Constants
SIZE_OF_VLANTAG = SIZE_OF_U32 # in octets
MIN_VALUE_OF_VLANTAG = 0x81000000
@@ -17,6 +21,15 @@ SIZE_OF_MMTYPE = SIZE_OF_U16 # in octets
# For unitary test purpose
class Struct:
pass
+class Proto(threading.Thread):
+ def __init__(self, proto):
+ threading.Thread.__init__(self)
+ self.proto = proto
+ def run(self):
+ print "Launching proto..."
+ os.system(self.proto)
+ def stop(self):
+ os.system("killall " + self.proto)
class MaximusProto:
@@ -35,8 +48,21 @@ class MaximusProto:
for i in range (1, len(argv)):
if argv[i] == '-t' or argv[i] == '--max-tick-value':
if i+1 < len(argv):
- self.__max_time_value = self.__start_time_value + (argv[i+1]/25000000) # in seconds
+ self.__max_time_value = self.__start_time_value + (float(argv[i+1])/float(25000000)) # in seconds
break
+
+ # In case of unitary test, launch the proto station
+ if self.UNIT_TEST:
+ for i in range (1, len(argv)):
+ if argv[i] == '-e' or argv[i] == '--station-executable':
+ if i+1 < len(argv):
+ proto = argv[i+1]
+ break
+ self.background = Proto(proto)
+ self.background.start()
+ sleep(2)
+ self.read_file = os.open(FUNCTION_CALL_READ_FILE, os.O_RDWR | os.O_NONBLOCK)
+ self.write_file = os.open(FUNCTION_CALL_WRITE_FILE, os.O_RDWR | os.O_NONBLOCK)
def process(self):
"""Listen to "br0" network interface.
@@ -61,11 +87,12 @@ class MaximusProto:
# In case of unitary test
else:
print "Receiving an MME..."
+ sleep(2)
mme = Struct()
mme.payload = Struct()
- file = open("/tmp/" + FUNCTION_CALL_NETWORK_INTERFACE + ".txt", 'r')
- mme.payload.load = file.read()
- file.close()
+ mme.payload.load = os.read(self.read_file, INTERFACE_FCALL_PAYLOAD_OFFSET)
+ length = hptoh16(mme.payload.load[INTERFACE_FCALL_PAYLOAD_OFFSET-SIZE_OF_U16:INTERFACE_FCALL_PAYLOAD_OFFSET])
+ mme.payload.load += os.read(self.read_file, length)
return read(mme, self)
def create_sta(self, mac_address):
@@ -157,9 +184,7 @@ class MaximusProto:
# In case of unitary test
else:
- file = open("/tmp/" + FUNCTION_CALL_NETWORK_INTERFACE, 'w')
- file.write(msdu.get())
- file.close()
+ os.write(self.write_file, msdu.get())
def set_msdu_rx(self, user_cb, create_eth_function, create_mme_function, create_buffer_function, create_sniffer_function):
"""As it is not applicable on the Gidel prototype or final product,
diff --git a/cesar/maximus/python/test/test_lib_proto.py b/cesar/maximus/python/test/test_lib_proto.py
index f97f26deb4..46ca81989a 100644
--- a/cesar/maximus/python/test/test_lib_proto.py
+++ b/cesar/maximus/python/test/test_lib_proto.py
@@ -36,7 +36,7 @@ param1 = pack('iiB',1,2,True)
fc1.add_param("param_1", param1)
param2 = pack('iiiiiiiiii',0,1,2,3,4,5,6,7,8,9)
fc1.add_param("param_2", param2)
-param3 = "hello"
+param3 = "hello\0"
fc1.add_param("param_3", param3)
param4 = pack('q',123)
fc1.add_param("param_4", param4)
@@ -63,7 +63,7 @@ param7 = probe2.bind_param("param_7")
print "RESULT: param 7 =",param7
probe2.send(stationC)
-if None == param7:
+if param7 is not None:
fc3 = maximus.create_fcall("function_3")
fc3.send_async(stationC)
@@ -123,8 +123,7 @@ class TestFcallFunctions(unittest.TestCase):
def setUp(self):
# Create Maximus
- self.maximus = MaximusProto(UNIT_TEST=True)
- self.maximus.init(sys.argv)
+ self.maximus = maximus
# Create a station
self.station = StaProto("11:22:33:44:55:66")
@@ -267,7 +266,7 @@ class TestFcallFunctions(unittest.TestCase):
fcall1.add_param("param_2", param2)
# Add a third parameter to the created message
- param3 = "hello"
+ param3 = "hello\0"
fcall1.add_param("param_3", param3)
# Add a fourth parameter to the created message
@@ -304,8 +303,9 @@ class TestFcallFunctions(unittest.TestCase):
fcall2 = self.maximus.create_fcall("function_2")
fcall2.add_param_bool("param_5", True)
fcall2 = fcall2.send(self.station)
- param5 = fcall2.bind_param_bool("param_5")
- self.assertEqual(param5,True)
+ result1 = fcall2.bind_param_string("result_1")
+ self.assertEqual(result1,"this is result 1")
+ self.assertEqual(len(result1),16)
# Create a probe message,
# set the destination station,
@@ -313,8 +313,8 @@ class TestFcallFunctions(unittest.TestCase):
# send the message,
# and get the result
#
- probe = self.maximus.create_probe().set_sta(self.station).add_param_ulong("param_6",0x7B000000).send()
- self.assertEqual(probe.bind_param_ulong("param_6"),0x7B000000)
+ probe = self.maximus.create_probe().set_sta(self.station).add_param("param_6").send()
+ self.assertEqual(probe.bind_param_ulong("param_6"),0x0000007B)
def test_is_param(self):
@@ -355,8 +355,8 @@ class TestFcallFunctions(unittest.TestCase):
# and get the result
#
probe = self.maximus.create_probe()
- probe = probe.add_param_ushort("param_10",0xEEFF).send(self.station)
- self.assertEqual(probe.bind_param_ushort("param_10"),0xEEFF)
+ probe = probe.add_param("param_10").send(self.station)
+ self.assertEqual(probe.bind_param_ushort("param_10"),0xFFEE)
def test_bind_param_ulong(self):
@@ -365,15 +365,15 @@ class TestFcallFunctions(unittest.TestCase):
# and get the result
#
probe = self.maximus.create_probe()
- probe = probe.add_param_ulong("param_11",0xCCDDEEFF).send(self.station)
- self.assertEqual(probe.bind_param_ulong("param_11"),0xCCDDEEFF)
+ probe = probe.add_param("param_11").send(self.station)
+ self.assertEqual(probe.bind_param_ulong("param_11"),0xFFEEDDCC)
suite = unittest.TestLoader().loadTestsFromTestCase(TestFcallFunctions)
class TestMaximusProtoFunctions(unittest.TestCase):
def setUp(self):
- self.m = MaximusProto()
+ self.m = maximus
def tearDown(self):
pass
@@ -412,3 +412,6 @@ except ValueError:
if __name__ == '__main__':
testResult = unittest.TextTestRunner(verbosity=2).run(suite)
+
+# To stop proto executable in case of unitary tests
+maximus.background.stop()
diff --git a/cesar/maximus/test/test_python.sh b/cesar/maximus/test/test_python.sh
index 8e2110b934..87cbd2b507 100755
--- a/cesar/maximus/test/test_python.sh
+++ b/cesar/maximus/test/test_python.sh
@@ -7,6 +7,8 @@ echo "*** Compile stations executables ***"
echo
cd $WORKSPACE/maximus/stationtest
make clean; make
+cd $WORKSPACE/maximus/prototest
+make clean; make
# Maximus Python unitary tests
echo
@@ -20,7 +22,7 @@ python test/test_ethernet.py -e ../stationtest/obj/test_ether.elf -d false -t 25
python test/test_fsm.py
python test/test_interface.py -e ../stationtest/obj/stationtest.elf -d false -t 2500000000
python test/test_lib_cesar.py -e ../stationtest/obj/test_lib_cesar.elf -d false -t 2500000000
-python test/test_lib_proto.py
+python test/test_lib_proto.py -e ../prototest/obj/test_fcall.elf -t 2500000000
python test/test_macframe.py -e ../stationtest/obj/test_send.elf -d false -t 2500000000
python test/test_mme.py -e ../stationtest/obj/stationtest.elf -d false -t 2500000000
python test/test_result.py