summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorburet2007-07-05 16:14:32 +0000
committerburet2007-07-05 16:14:32 +0000
commitf0b89b7002c341388af05af595c0f84e23f3a7c7 (patch)
treea8a3c0e0335cb3a89f08b5a452c9dbd29562e098
parentd368fff518821440c33cc805a66d7299f3cc1a38 (diff)
Phy sci msg unitary tests
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@449 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--hal/phy/maximus/inc/maximus_phy_ctx.h52
-rw-r--r--hal/phy/maximus/src/maximus_phy_ctrl.c161
-rw-r--r--hal/phy/maximus/test/Makefile2
-rw-r--r--hal/phy/maximus/test/src/test_phy_access.c41
-rw-r--r--hal/phy/maximus/test/src/test_phy_ctrl.c176
-rw-r--r--hal/phy/maximus/test/src/test_phy_maximus.c10
6 files changed, 367 insertions, 75 deletions
diff --git a/hal/phy/maximus/inc/maximus_phy_ctx.h b/hal/phy/maximus/inc/maximus_phy_ctx.h
index f67be3d71b..6b241780ae 100644
--- a/hal/phy/maximus/inc/maximus_phy_ctx.h
+++ b/hal/phy/maximus/inc/maximus_phy_ctx.h
@@ -18,6 +18,8 @@
#include "hal/phy/forward.h"
#include "hal/phy/pbdma.h"
#include "hal/phy/phy.h"
+#include "host/station.h"
+#include "maximus/common/types/phy_types.h"
/** Phy access structure for Maximus */
struct maximus_phy_access_t
@@ -74,6 +76,8 @@ struct maximus_phy_ctrl_t
phy_fc_mode_t fc_mode;
/** Argument 'flag' of 'phy_rx_activate'. 'true' to activate. */
bool activate_rx;
+ /** Station context. */
+ station_ctx_t *station;
};
typedef struct maximus_phy_ctrl_t maximus_phy_ctrl_t;
@@ -131,6 +135,54 @@ struct phy_t
};
/* Forward declaration in hal/phy/forward.h. */
+
+/**
+ * Maximus Phy init called during station context creation.
+ * \param station pointer to the station context.
+ * \return 0 if ok, -1 if failed, with errno = EINVAL if station is NULL
+ */
+int maximus_phy_init (station_ctx_t *station);
+
+/**
+ * Maximus Phy context init.
+ */
+void maximus_phy_ctx_init (void);
+
+/**
+ * fill a blank phy header
+ * \param phy current phy context
+ * \param msg pointer to sci message to fill header
+ * \param type type of message (FC_HYBRID_MODE, FC_AV_ONLY_MODE, PRS, MPDU_PAYLOAD, TONEMAP, NOISE, SPECTRUM)
+ * \param mpdu_format MPDU format of message (BEACON, SOF, SACK, RTS_CTS, SOUND, RSOF)
+ * \param pb_nb number of PBs into message
+ * \param tonemap_index tone map index used for message
+ * \param flags flags of message
+ * \param nek nek used for message
+ * \param pb_measurement ber, halfit and crc measured for each PB of message
+ * \param pb_header PB header for each PB of message
+ * \return 0 if ok, -1 if failed with errno = EINVAL if msg is NULL
+ */
+int
+maximus_phy_fill_hdr(phy_t *phy,
+ sci_msg_t *msg,
+ uint8_t type,
+ uint8_t mpdu_format,
+ uint8_t pb_nb,
+ uint8_t tonemap_index,
+ uint8_t flags,
+ uint32_t nek[4],
+ uint32_t pb_measurement[PHY_PB_MAX_NB],
+ uint32_t pb_header[PHY_PB_MAX_NB]);
+
+/**
+ * Process phy message received by the sci layer.
+ * This function must be registred to SCI layer with SCI_MSG_TYPE_PHY type.
+ * \param msg message to process
+ * \param phy phy current context
+ * \return 0 if ok, -1 if failed, with errno = EINVAL if phy or msg is NULL, or errno from sci_send() call
+ */
+int maximus_phy_recv (sci_msg_t *msg, void *phy);
+
/**
* Maximus TX frame first callback called when the corresponding netclock message is received.
* \param data pointer to 'maximus_tx_fc_t' structure, containing argument 'want_conf' of 'phy_tx_frame'.
diff --git a/hal/phy/maximus/src/maximus_phy_ctrl.c b/hal/phy/maximus/src/maximus_phy_ctrl.c
index 15ba37f3c2..17fea7c5dd 100644
--- a/hal/phy/maximus/src/maximus_phy_ctrl.c
+++ b/hal/phy/maximus/src/maximus_phy_ctrl.c
@@ -13,16 +13,22 @@
#include "common/std.h"
#include "hal/phy/maximus/inc/maximus_phy_ctx.h"
-#include "host/station.h"
+#include "maximus/common/types/phy_types.h"
+#include "host/fwd.h" // for 'phy_msg_hdr_t'
#include <string.h> // for 'memset'
#include <errno.h>
+/** type of phy message */
+typedef enum Phy_Type phy_type_t;
+
+phy_t ctx;
/**
* Maximus TX frame first callback called when the corresponding netclock message is received.
* \param data pointer to 'maximus_tx_fc_t' structure, containing argument 'want_conf' of 'phy_tx_frame'.
*/
-void maximus_tx_fc_cb (void *data)
+void
+maximus_tx_fc_cb (void *data)
{
}
@@ -32,7 +38,8 @@ void maximus_tx_fc_cb (void *data)
* Maximus TX frame second callback called when the corresponding netclock message is received.
* \param data pointer to 'maximus_tx_frame_t' structure, containing PHY context.
*/
-void maximus_tx_frame_cb (void *data)
+void
+maximus_tx_frame_cb (void *data)
{
}
@@ -42,13 +49,117 @@ void maximus_tx_frame_cb (void *data)
* Maximus RX activate callback called when the corresponding netclock message is received.
* \param data pointer to 'maximus_rx_activate_t' structure, containing argument 'flag' of 'phy_rx_activate'.
*/
-void maximus_rx_activate_cb (void *data)
+void
+maximus_rx_activate_cb (void *data)
{
}
/**
+ * Maximus Phy init called during station context creation.
+ * \param station pointer to the station context.
+ * \return 0 if ok, -1 if failed, with errno = EINVAL if station is NULL
+ */
+int
+maximus_phy_init (station_ctx_t *station)
+{
+ int ret = 0;
+
+ if (NULL == station)
+ {
+ errno = EINVAL;
+ ret = -1;
+ }
+ else
+ {
+ maximus_phy_ctx_init();
+ ctx.control.station = station;
+ station->phy = &ctx;
+
+ // register phy_recv to the sci layer
+ if (0 > sci_register_callback(ctx.control.station->sci, SCI_MSG_TYPE_PHY, maximus_phy_recv, ctx.control.station->phy))
+ {
+ ret = -1;
+ }
+ }
+
+ return ret;
+}
+
+
+/**
+ * Maximus Phy context init.
+ */
+void
+maximus_phy_ctx_init (void)
+{
+ static bool phy_ctx_init = false;
+
+ if (!phy_ctx_init)
+ {
+ memset(&ctx, '\0', sizeof(phy_t));
+ phy_ctx_init = true;
+ }
+}
+
+
+/**
+ * fill a blank phy header
+ * \param phy current phy context
+ * \param msg pointer to sci message to fill header
+ * \param type type of message (FC_HYBRID_MODE, FC_AV_ONLY_MODE, PRS, MPDU_PAYLOAD, TONEMAP, NOISE, SPECTRUM)
+ * \param mpdu_format MPDU format of message (BEACON, SOF, SACK, RTS_CTS, SOUND, RSOF)
+ * \param pb_nb number of PBs into message
+ * \param tonemap_index tone map index used for message
+ * \param flags flags of message
+ * \param nek nek used for message
+ * \param pb_measurement ber, halfit and crc measured for each PB of message
+ * \param pb_header PB header for each PB of message
+ * \return 0 if ok, -1 if failed with errno = EINVAL if msg is NULL
+ */
+int
+maximus_phy_fill_hdr(phy_t *phy,
+ sci_msg_t *msg,
+ uint8_t type,
+ uint8_t mpdu_format,
+ uint8_t pb_nb,
+ uint8_t tonemap_index,
+ uint8_t flags,
+ uint32_t nek[4],
+ uint32_t pb_measurement[PHY_PB_MAX_NB],
+ uint32_t pb_header[PHY_PB_MAX_NB])
+{
+ int ret = -1;
+
+ return ret;
+}
+
+
+/**
+ * Process phy message received by the sci layer.
+ * This function must be registred to SCI layer with SCI_MSG_TYPE_PHY type.
+ * \param msg message to process
+ * \param phy phy current context
+ * \return 0 if ok, -1 if failed, with errno = EINVAL if phy or msg is NULL, or errno from sci_send() call
+ */
+int
+maximus_phy_recv (sci_msg_t *msg, void *phy)
+{
+ int ret = -1;
+
+ /* Check phy header. */
+
+ /* Set phy header. */
+
+ /* Depending on the phy header type, different actions have to be done. */
+
+ /* If 'msg->hdr.phy->type' equals 'PHY_TYPE_FC_HYBRID_MODE', set 'phy.control.fc_10' and 'phy.control.fc_av'. */
+
+ return ret;
+}
+
+/**
* Initialise the HAL Phy.
* \param user_data User data passed to any callback
* \param rx_fc_cb RX FC event callback
@@ -63,29 +174,27 @@ phy_init (void *user_data, phy_rx_fc_cb_t rx_fc_cb, phy_access_cb_t access_cb,
phy_access_conf_cb_t access_conf_cb, phy_pbdma_cb_t pbdma_cb,
phy_deferred_cb_t deferred_cb)
{
- static phy_t ctx;
- memset(&ctx, '\0', sizeof(phy_t));
-
- if ((NULL == user_data)
- ||(NULL == rx_fc_cb)
- ||(NULL == access_cb)
- ||(NULL == access_conf_cb)
- ||(NULL == pbdma_cb)
- ||(NULL == deferred_cb))
- {
- errno = EINVAL;
- }
- else
- {
- ctx.control.user_data = user_data;
- ctx.control.rx_fc_cb = rx_fc_cb;
- ctx.control.access_cb = access_cb;
- ctx.control.access_conf_cb = access_conf_cb;
- ctx.control.pbdma_cb = pbdma_cb;
- ctx.control.deferred_cb = deferred_cb;
- }
+ if ((NULL == user_data)
+ ||(NULL == rx_fc_cb)
+ ||(NULL == access_cb)
+ ||(NULL == access_conf_cb)
+ ||(NULL == pbdma_cb)
+ ||(NULL == deferred_cb))
+ {
+ errno = EINVAL;
+ }
+ else
+ {
+ maximus_phy_ctx_init();
+ ctx.control.user_data = user_data;
+ ctx.control.rx_fc_cb = rx_fc_cb;
+ ctx.control.access_cb = access_cb;
+ ctx.control.access_conf_cb = access_conf_cb;
+ ctx.control.pbdma_cb = pbdma_cb;
+ ctx.control.deferred_cb = deferred_cb;
+ }
- return &ctx;
+ return &ctx;
}
diff --git a/hal/phy/maximus/test/Makefile b/hal/phy/maximus/test/Makefile
index dc74b734eb..80c8f42c45 100644
--- a/hal/phy/maximus/test/Makefile
+++ b/hal/phy/maximus/test/Makefile
@@ -1,7 +1,7 @@
BASE = ../../../..
EXTRA_HOST_CFLAGS+= -DUNIT_TEST
HOST_PROGRAMS = test_phy_maximus
-test_phy_maximus_SOURCES = test_bridgedma.c test_pbdma.c test_phy_access.c test_phy_ctrl.c test_tmdma.c test_phy_maximus.c
+test_phy_maximus_SOURCES = test_phy_access.c test_phy_ctrl.c test_phy_maximus.c test_bridgedma.c test_pbdma.c test_tmdma.c
test_phy_maximus_MODULES = lib hal/phy/maximus host
INCLUDES = hal/phy/maximus/test/inc
diff --git a/hal/phy/maximus/test/src/test_phy_access.c b/hal/phy/maximus/test/src/test_phy_access.c
index b46f05798b..c0688c84ca 100644
--- a/hal/phy/maximus/test/src/test_phy_access.c
+++ b/hal/phy/maximus/test/src/test_phy_access.c
@@ -18,6 +18,8 @@
#include "hal/phy/maximus/test/inc/test_phy_maximus.h"
#include "host/station.h"
#include "host/sci.h"
+#include "maximus/common/types/phy_types.h"
+#include "host/fwd.h" // for 'phy_msg_hdr_t'
#include <stdio.h> // for 'printf'
#include <string.h> // for 'memset'
#include <netinet/in.h> // for 'ntohl' and 'ntohs' functions
@@ -26,7 +28,6 @@
#include <errno.h>
uint32_t maximus_pending_isrs; // used in 'station.c'
-extern station_ctx_t my_station;
phy_t *ctx;
int netclock_id = 0;
@@ -49,7 +50,7 @@ void phy_access_backoff_start_test_case(test_t t)
int fd_in = -1;
// open pipe
- fd_in = open(my_station.pipe_out_name, O_RDONLY);
+ fd_in = open(ctx->control.station->pipe_out_name, O_RDONLY);
// read sci header and netclock header
memset(data, '\0', 256);
@@ -88,7 +89,7 @@ void phy_access_backoff_start_test_case(test_t t)
int fd_in = -1;
// open pipe
- fd_in = open(my_station.pipe_out_name, O_RDONLY);
+ fd_in = open(ctx->control.station->pipe_out_name, O_RDONLY);
// read sci header
test_fail_unless ((-1 != fd_in)
@@ -113,7 +114,7 @@ void phy_access_backoff_start_test_case(test_t t)
| (unsigned long long)(ntohl(sci_hdr.netclock_low));
// update current tick value
- my_station.current_tick_tck = msg_tick_tck;
+ ctx->control.station->current_tick_tck = msg_tick_tck;
// close pipe
close(fd_in);
@@ -159,13 +160,9 @@ void phy_access_backoff_slot_count_test_case(test_t t)
test_begin(t, "backoff slot count")
{
- if (NULL != ctx)
- {
- ctx->access.slot_count = 5;
- }
- test_fail_unless ((EINVAL != errno)
- && (NULL != ctx)
- && (ctx->access.slot_count == phy_access_backoff_slot_count(ctx)));
+ test_fail_unless ((NULL != ctx)
+ && (ctx->access.slot_count == phy_access_backoff_slot_count(ctx))
+ && (EINVAL != errno));
} test_end;
return;
@@ -181,9 +178,9 @@ void phy_access_backoff_prp_won_test_case(test_t t)
{
ctx->access.prp_result = 1;
}
- test_fail_unless ((EINVAL != errno)
- && (NULL != ctx)
- && (ctx->access.prp_result == phy_access_backoff_prp_won(ctx)));
+ test_fail_unless ((NULL != ctx)
+ && (ctx->access.prp_result == phy_access_backoff_prp_won(ctx))
+ && (EINVAL != errno));
} test_end;
return;
@@ -205,7 +202,7 @@ void phy_access_timer_program_test_case(test_t t)
int fd_in = -1;
// open pipe
- fd_in = open(my_station.pipe_out_name, O_RDONLY);
+ fd_in = open(ctx->control.station->pipe_out_name, O_RDONLY);
// read sci header and netclock header
memset(data, '\0', 256);
@@ -237,7 +234,8 @@ void phy_access_timer_program_test_case(test_t t)
test_begin(t, "access cb")
{
- test_fail_unless ((*ctx->control.access_cb)(ctx->control.user_data));
+ test_fail_unless ((NULL != ctx->control.access_cb)
+ && ((*ctx->control.access_cb)(ctx->control.user_data)));
} test_end;
return;
@@ -257,7 +255,7 @@ void phy_access_timer_cancel_test_case(test_t t)
int fd_in = -1;
// open pipe
- fd_in = open(my_station.pipe_out_name, O_RDONLY);
+ fd_in = open(ctx->control.station->pipe_out_name, O_RDONLY);
// read sci header and netclock header
memset(data, '\0', 256);
@@ -282,6 +280,7 @@ void phy_access_test_suite(test_t t)
int user_data = 1234567890;
unsigned char buffer[1024];
int fd_out = -1;
+ station_ctx_t station;
ctx = phy_init ((void*)&user_data,
&phy_rx_fc_cb,
@@ -289,11 +288,12 @@ void phy_access_test_suite(test_t t)
&phy_access_conf_cb,
&phy_pbdma_cb,
&phy_deferred_cb);
- station_init(&my_station);
+ station_init (&station);
+ sci_init(station.sci, &station);
// TO REMOVE
memset(buffer, 'a', 1024);
- fd_out = open(my_station.pipe_out_name, O_WRONLY);
+ fd_out = open(station.pipe_out_name, O_WRONLY);
write(fd_out, buffer, 1024);
close(fd_out);
@@ -305,5 +305,6 @@ void phy_access_test_suite(test_t t)
phy_access_timer_program_test_case(t);
phy_access_timer_cancel_test_case(t);
- station_down (&my_station);
+ phy_uninit (ctx);
+ station_down (&station);
}
diff --git a/hal/phy/maximus/test/src/test_phy_ctrl.c b/hal/phy/maximus/test/src/test_phy_ctrl.c
index d17d7ef3a5..cf9ca6dc7b 100644
--- a/hal/phy/maximus/test/src/test_phy_ctrl.c
+++ b/hal/phy/maximus/test/src/test_phy_ctrl.c
@@ -18,6 +18,8 @@
#include "hal/phy/maximus/test/inc/test_phy_maximus.h"
#include "host/station.h"
#include "host/sci.h"
+#include "maximus/common/types/phy_types.h"
+#include "host/fwd.h" // for 'phy_msg_hdr_t'
#include <stdio.h> // for 'printf'
#include <string.h> // for 'memset'
#include <netinet/in.h> // for 'ntohl' and 'ntohs' functions
@@ -26,9 +28,129 @@
#include <errno.h>
uint32_t maximus_pending_isrs; // used in 'station.c'
-extern station_ctx_t my_station;
phy_t *ctx;
+void maximus_phy_fill_hdr_test_case(test_t t)
+{
+ test_case_begin(t, "fill hdr");
+
+ test_begin(t, "fill hdr")
+ {
+ sci_msg_t msg;
+ uint8_t type = PHY_TYPE_MPDU_PAYLOAD;
+ uint8_t mpdu_format = PHY_MPDU_FORMAT_SOF;
+ uint8_t pb_nb = 3;
+ uint8_t tonemap_index = 0;
+ uint8_t flags = 0x06;
+ uint32_t nek[4];
+ uint32_t pb_measurement[PHY_PB_MAX_NB];
+ uint32_t pb_header[PHY_PB_MAX_NB];
+
+ memset(nek, '\0', 4*sizeof(uint32_t));
+ memset(pb_measurement, '\0', PHY_PB_MAX_NB*sizeof(uint32_t));
+ memset(pb_header, '\0', PHY_PB_MAX_NB*sizeof(uint32_t));
+
+ test_fail_unless ((0 == maximus_phy_fill_hdr(ctx,
+ &msg,
+ type,
+ mpdu_format,
+ pb_nb,
+ tonemap_index,
+ flags,
+ nek,
+ pb_measurement,
+ pb_header))
+ && (PHY_VERSION == msg.hdr.phy->version)
+ && (PHY_VERSION == msg.hdr.phy->type)
+ && (PHY_VERSION == msg.hdr.phy->mpdu_format)
+ && (PHY_VERSION == msg.hdr.phy->pb_nb)
+ && (PHY_VERSION == msg.hdr.phy->tonemap_index)
+ && (PHY_VERSION == msg.hdr.phy->flags)
+ && (0 == memcmp (nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
+ && (0 == memcmp (pb_measurement, msg.hdr.phy->pb_measurement, PHY_PB_MAX_NB*sizeof(uint32_t)))
+ && (0 == memcmp (pb_header, msg.hdr.phy->pb_header, PHY_PB_MAX_NB*sizeof(uint32_t)))
+ && (EINVAL != errno));
+ } test_end;
+}
+
+void maximus_phy_recv_test_case(test_t t)
+{
+ sci_msg_t msg;
+ unsigned char buffer[SCI_MSG_MAX_SIZE];
+ uint32_t nek[4];
+ uint32_t pb_measurement[PHY_PB_MAX_NB];
+ uint32_t pb_header[PHY_PB_MAX_NB];
+ //sci_msg_hdr_t hdr;
+ phy_msg_hdr_t phy_hdr;
+
+ test_case_begin(t, "recv");
+
+ test_begin(t, "sci init")
+ {
+ memset(buffer, '\0', SCI_MSG_MAX_SIZE);
+ test_fail_unless (0 == sci_msg_init(&msg, buffer, SCI_MSG_MAX_SIZE));
+ } test_end;
+
+ test_begin(t, "NULL msg")
+ {
+ test_fail_unless ((0 > (maximus_phy_recv(NULL, ctx)))
+ && (EINVAL == errno));
+ } test_end;
+
+ test_begin(t, "NULL phy")
+ {
+ test_fail_unless ((0 > (maximus_phy_recv(&msg, NULL)))
+ && (EINVAL == errno));
+ } test_end;
+
+ test_begin(t, "recv")
+ {
+ memset(nek, '\0', 4*sizeof(uint32_t));
+ memset(pb_measurement, '\0', PHY_PB_MAX_NB*sizeof(uint32_t));
+ memset(pb_header, '\0', PHY_PB_MAX_NB*sizeof(uint32_t));
+
+ // fill the phy header
+ phy_hdr.version = PHY_VERSION;
+ phy_hdr.type = PHY_TYPE_MPDU_PAYLOAD;
+ phy_hdr.mpdu_format = PHY_MPDU_FORMAT_BEACON;
+ phy_hdr.pb_nb = 3;
+ phy_hdr.tonemap_index = 0;
+ phy_hdr.flags = 0x06;
+ phy_hdr.reserved = 0;
+ memcpy(phy_hdr.nek, nek, 4*sizeof(uint32_t));
+ memcpy(phy_hdr.pb_measurement, pb_measurement, PHY_PB_MAX_NB*sizeof(uint32_t));
+ memcpy(phy_hdr.pb_header, pb_header, PHY_PB_MAX_NB*sizeof(uint32_t));
+
+ // fill the sci header
+ test_fail_unless (0 == sci_fill_hdr(ctx->control.station->sci, &msg, SCI_MSG_TYPE_PHY, 0));
+
+ // fill the sci data
+ test_fail_unless ((sizeof(phy_msg_hdr_t) == sci_msg_push(&msg, sizeof(phy_msg_hdr_t)))
+ && (EINVAL != errno)
+ && (ENOSPC != errno));
+ memcpy(msg.data_begin, &phy_hdr, sizeof(phy_msg_hdr_t));
+ test_fail_unless ((512*phy_hdr.pb_nb == sci_msg_push(&msg, 512*phy_hdr.pb_nb))
+ && (EINVAL != errno)
+ && (ENOSPC != errno));
+ memcpy(msg.data_begin, buffer, 512*phy_hdr.pb_nb);
+
+ test_fail_unless ((0 <= (maximus_phy_recv(&msg, ctx)))
+ && (EINVAL != errno));
+
+ test_fail_unless ((phy_hdr.version == msg.hdr.phy->version)
+ && (phy_hdr.type == msg.hdr.phy->type)
+ && (phy_hdr.mpdu_format == msg.hdr.phy->mpdu_format)
+ && (phy_hdr.pb_nb == msg.hdr.phy->pb_nb)
+ && (phy_hdr.tonemap_index == msg.hdr.phy->tonemap_index)
+ && (phy_hdr.flags == msg.hdr.phy->flags)
+ && (phy_hdr.reserved == msg.hdr.phy->reserved)
+ && (0 == memcmp (phy_hdr.nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
+ && (0 == memcmp (phy_hdr.pb_measurement, msg.hdr.phy->pb_measurement, PHY_PB_MAX_NB*sizeof(uint32_t)))
+ && (0 == memcmp (phy_hdr.pb_header, msg.hdr.phy->pb_header, PHY_PB_MAX_NB*sizeof(uint32_t)))
+ && (EINVAL != errno));
+ } test_end;
+}
+
void phy_init_test_case(test_t t)
{
int user_data = 1234567890;
@@ -55,10 +177,15 @@ void phy_init_test_case(test_t t)
test_begin(t, "rx fc cb")
{
- test_fail_unless ((*ctx->control.rx_fc_cb)(ctx->control.user_data, ctx->control.current_date, ctx->control.fc_av));
+ test_fail_unless ((NULL != ctx->control.rx_fc_cb)
+ && ((*ctx->control.rx_fc_cb)(ctx->control.user_data, ctx->control.current_date, ctx->control.fc_av)));
} test_end;
- (*ctx->control.deferred_cb)(ctx->control.user_data);
+ test_begin(t, "deferred cb")
+ {
+ test_fail_unless (NULL != ctx->control.deferred_cb);
+ (*ctx->control.deferred_cb)(ctx->control.user_data);
+ } test_end;
return;
}
@@ -107,9 +234,9 @@ void phy_date_test_case(test_t t)
{
ctx->control.current_date = 5;
}
- test_fail_unless ((EINVAL != errno)
- && (NULL != ctx)
- && (ctx->control.current_date == phy_date(ctx)));
+ test_fail_unless ((NULL != ctx)
+ && (ctx->control.current_date == phy_date(ctx))
+ && (EINVAL != errno));
} test_end;
return;
@@ -166,14 +293,14 @@ void phy_tx_frame_test_case(test_t t)
int fd_in = -1;
// open pipe
- fd_in = open(my_station.pipe_out_name, O_RDONLY);
+ fd_in = open(ctx->control.station->pipe_out_name, O_RDONLY);
// read sci header
test_fail_unless ((-1 != fd_in)
&& ((int)sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
// read netclock header
- test_fail_unless((int)sizeof(netclock_msg_hdr_t) == read(fd_in, &netclock_hdr, sizeof(netclock_msg_hdr_t)));
+ test_fail_unless ((int)sizeof(netclock_msg_hdr_t) == read(fd_in, &netclock_hdr, sizeof(netclock_msg_hdr_t)));
// check netclock tick value
test_fail_unless (date == ntohl(netclock_hdr.tick_low));
@@ -183,7 +310,7 @@ void phy_tx_frame_test_case(test_t t)
| (unsigned long long)(ntohl(sci_hdr.netclock_low));
// update current tick value
- my_station.current_tick_tck = msg_tick_tck;
+ ctx->control.station->current_tick_tck = msg_tick_tck;
// close pipe
close(fd_in);
@@ -204,7 +331,8 @@ void phy_tx_frame_test_case(test_t t)
test_begin(t, "access conf cb")
{
- test_fail_unless ((*ctx->control.access_conf_cb)(ctx->control.user_data));
+ test_fail_unless ((NULL != ctx->control.access_conf_cb)
+ && ((*ctx->control.access_conf_cb)(ctx->control.user_data)));
} test_end;
// check that the correct phy message has been sent to Maximus
@@ -216,7 +344,7 @@ void phy_tx_frame_test_case(test_t t)
int fd_in = -1;
// open pipe
- fd_in = open(my_station.pipe_out_name, O_RDONLY);
+ fd_in = open(ctx->control.station->pipe_out_name, O_RDONLY);
// read sci header
test_fail_unless ((-1 != fd_in)
@@ -241,7 +369,7 @@ void phy_tx_frame_test_case(test_t t)
| (unsigned long long)(ntohl(sci_hdr.netclock_low));
// update current tick value
- my_station.current_tick_tck = msg_tick_tck;
+ ctx->control.station->current_tick_tck = msg_tick_tck;
// close pipe
close(fd_in);
@@ -259,7 +387,7 @@ void phy_tx_frame_test_case(test_t t)
int fd_in = -1;
// open pipe
- fd_in = open(my_station.pipe_out_name, O_RDONLY);
+ fd_in = open(ctx->control.station->pipe_out_name, O_RDONLY);
// read sci header
test_fail_unless ((-1 != fd_in)
@@ -276,7 +404,7 @@ void phy_tx_frame_test_case(test_t t)
| (unsigned long long)(ntohl(sci_hdr.netclock_low));
// update current tick value
- my_station.current_tick_tck = msg_tick_tck;
+ ctx->control.station->current_tick_tck = msg_tick_tck;
// close pipe
close(fd_in);
@@ -304,7 +432,7 @@ void phy_tx_frame_test_case(test_t t)
int fd_in = -1;
// open pipe
- fd_in = open(my_station.pipe_out_name, O_RDONLY);
+ fd_in = open(ctx->control.station->pipe_out_name, O_RDONLY);
// read sci header
test_fail_unless ((-1 != fd_in)
@@ -329,7 +457,7 @@ void phy_tx_frame_test_case(test_t t)
| (unsigned long long)(ntohl(sci_hdr.netclock_low));
// update current tick value
- my_station.current_tick_tck = msg_tick_tck;
+ ctx->control.station->current_tick_tck = msg_tick_tck;
// close pipe
close(fd_in);
@@ -348,7 +476,7 @@ void phy_clock_set_test_case(test_t t)
phy_clock_set (phy_clock);
test_fail_unless ((EINVAL != errno)
- &&(phy_clock == my_station.current_tick_tck));
+ &&(phy_clock == ctx->control.station->current_tick_tck));
} test_end;
return;
@@ -371,7 +499,7 @@ void phy_rx_activate_test_case(test_t t)
int fd_in = -1;
// open pipe
- fd_in = open(my_station.pipe_out_name, O_RDONLY);
+ fd_in = open(ctx->control.station->pipe_out_name, O_RDONLY);
// read sci header and netclock header
memset(data, '\0', 256);
@@ -428,16 +556,20 @@ void phy_ctrl_test_suite(test_t t)
{
unsigned char buffer[1024];
int fd_out = -1;
+ station_ctx_t station;
- station_init(&my_station);
+ station_init (&station);
+ sci_init(station.sci, &station);
// TO REMOVE
memset(buffer, 'a', 1024);
- fd_out = open(my_station.pipe_out_name, O_WRONLY);
+ fd_out = open(station.pipe_out_name, O_WRONLY);
write(fd_out, buffer, 1024);
- close(fd_out);
+ close(fd_out);
test_suite_begin(t, "phy control");
+ maximus_phy_fill_hdr_test_case(t);
+ maximus_phy_recv_test_case(t);
phy_init_test_case(t);
phy_date_test_case(t);
phy_tx_fc10_test_case(t);
@@ -448,5 +580,5 @@ void phy_ctrl_test_suite(test_t t)
phy_reset_test_case(t);
phy_uninit_test_case(t);
- station_down (&my_station);
+ station_down (&station);
}
diff --git a/hal/phy/maximus/test/src/test_phy_maximus.c b/hal/phy/maximus/test/src/test_phy_maximus.c
index aea46633d2..2dea2750a3 100644
--- a/hal/phy/maximus/test/src/test_phy_maximus.c
+++ b/hal/phy/maximus/test/src/test_phy_maximus.c
@@ -21,8 +21,6 @@ void phy_access_test_suite (test_t t);
void phy_ctrl_test_suite (test_t t);
void tmdma_test_suite (test_t t);
-station_ctx_t my_station;
-
bool phy_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av)
{
return true;
@@ -30,7 +28,7 @@ bool phy_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av)
bool phy_access_cb (void *user)
{
- return true;
+ return true;
}
bool phy_access_conf_cb (void *user)
@@ -54,11 +52,11 @@ main (int argc, char **argv)
test_t t;
test_init(t, argc, argv);
- //bridgedma_test_suite(t);
- //pbdma_test_suite(t);
+ bridgedma_test_suite(t);
+ pbdma_test_suite(t);
phy_access_test_suite(t);
phy_ctrl_test_suite(t);
- //tmdma_test_suite(t);
+ tmdma_test_suite(t);
test_result(t);
return test_nb_failed(t) == 0 ? 0 : 1;