summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cesar/ecos/packages/hal/maximus/arch/current/src/maximus_diag.c4
-rw-r--r--cesar/ecos/packages/hal/maximus/arch/current/src/maximus_intr.c4
-rw-r--r--cesar/hal/ipmbox/maximus/test/Config2
-rw-r--r--cesar/hal/ipmbox/maximus/test/Makefile10
-rw-r--r--cesar/hal/ipmbox/maximus/test/inc/test_maximus_hal.h56
-rw-r--r--cesar/hal/ipmbox/maximus/test/src/test_maximus_ether.c650
-rw-r--r--cesar/hal/ipmbox/maximus/test/src/test_maximus_hal.c85
-rw-r--r--cesar/hal/ipmbox/maximus/test/src/test_maximus_ipmbox.c355
-rw-r--r--cesar/hal/leon/maximus/test/Config3
-rw-r--r--cesar/hal/leon/maximus/test/Makefile9
-rw-r--r--cesar/hal/leon/maximus/test/inc/test_maximus_timer.h40
-rw-r--r--cesar/hal/leon/maximus/test/src/test_maximus_timer.c311
-rw-r--r--cesar/hal/phy/maximus/test/Config4
-rw-r--r--cesar/hal/phy/maximus/test/Makefile11
-rw-r--r--cesar/hal/phy/maximus/test/inc/test_phy_maximus.h93
-rw-r--r--cesar/hal/phy/maximus/test/src/test_aes.c34
-rw-r--r--cesar/hal/phy/maximus/test/src/test_pbdma.c315
-rw-r--r--cesar/hal/phy/maximus/test/src/test_phy_access.c884
-rw-r--r--cesar/hal/phy/maximus/test/src/test_phy_ctrl.c3856
-rw-r--r--cesar/hal/phy/maximus/test/src/test_phy_maximus.c106
-rw-r--r--cesar/hal/phy/maximus/test/src/test_tmdma.c144
-rw-r--r--cesar/hal/phy/test/phy/src/test_phy.c5
-rw-r--r--cesar/host/sci/maximus/inc/socket.h2
-rw-r--r--cesar/host/sci/maximus/src/sci.c12
-rw-r--r--cesar/host/station/src/station.c366
-rw-r--r--cesar/host/station/station.h66
-rw-r--r--cesar/host/test/Makefile10
-rw-r--r--cesar/host/test/src/test_fcall.c633
-rw-r--r--cesar/host/test/src/test_fcall_param.c528
-rw-r--r--cesar/host/test/src/test_host.c56
-rw-r--r--cesar/host/test/src/test_netclock.c499
-rw-r--r--cesar/host/test/src/test_probe.c374
-rw-r--r--cesar/host/test/src/test_sci.c504
-rw-r--r--cesar/host/test/src/test_sci_msg.c214
-rw-r--r--cesar/host/test/src/test_station.c280
-rw-r--r--cesar/host/test/src/test_system.c161
-rw-r--r--cesar/mac/pbproc/test/int/src/test_pbproc.c3
-rw-r--r--cesar/maximus/interface/station/inc/Station.h34
-rw-r--r--cesar/maximus/interface/station/src/Station.cpp201
-rw-r--r--cesar/maximus/python/utest/stationtest/src/exception.c2
-rw-r--r--cesar/maximus/python/utest/stationtest/src/hello_world.c1
-rw-r--r--cesar/maximus/python/utest/stationtest/src/main_example.c1
-rw-r--r--cesar/maximus/python/utest/stationtest/src/test_cb.c1
-rw-r--r--cesar/maximus/python/utest/stationtest/src/test_ether.c1
-rw-r--r--cesar/maximus/python/utest/stationtest/src/test_false_alarm.c1
-rw-r--r--cesar/maximus/python/utest/stationtest/src/test_lib_cesar.c1
-rw-r--r--cesar/maximus/python/utest/stationtest/src/test_log.c1
-rw-r--r--cesar/maximus/python/utest/stationtest/src/test_send.c1
-rw-r--r--cesar/maximus/python/utest/stationtest/src/test_station.c1
-rw-r--r--cesar/maximus/python/utest/stationtest/src/test_tx_rx.c1
-rw-r--r--cesar/maximus/sci/utest/server/src/TestSciServer.cpp2
-rw-r--r--cesar/maximus/sci/utest/server/src/fake_Station.cpp131
-rw-r--r--cesar/test_general/dataplane/src/test_dataplane.c1
-rw-r--r--cesar/test_general/station/common/src/station.c4
-rw-r--r--common/tests/tests16
55 files changed, 297 insertions, 10793 deletions
diff --git a/cesar/ecos/packages/hal/maximus/arch/current/src/maximus_diag.c b/cesar/ecos/packages/hal/maximus/arch/current/src/maximus_diag.c
index df63e4134e..884445b522 100644
--- a/cesar/ecos/packages/hal/maximus/arch/current/src/maximus_diag.c
+++ b/cesar/ecos/packages/hal/maximus/arch/current/src/maximus_diag.c
@@ -75,7 +75,7 @@ void hal_diag_write_char(char c)
#ifdef DIAG_WITH_STDIN
written = cyg_hal_sys_write(1, next, diag_index);
#else
- written = cyg_hal_sys_write(my_station.pipe_log_fd, next, diag_index);
+ written = cyg_hal_sys_write(my_station.fd_log, next, diag_index);
#endif
if (written > 0) {
diag_index -= written;
@@ -92,7 +92,7 @@ void hal_diag_write_char(char c)
#ifdef DIAG_WITH_STDIN
cyg_hal_sys_fdatasync(1);
#else
- cyg_hal_sys_fdatasync(my_station.pipe_log_fd);
+ cyg_hal_sys_fdatasync(my_station.fd_log);
#endif
}
}
diff --git a/cesar/ecos/packages/hal/maximus/arch/current/src/maximus_intr.c b/cesar/ecos/packages/hal/maximus/arch/current/src/maximus_intr.c
index 0847bed8c0..368d960c0f 100644
--- a/cesar/ecos/packages/hal/maximus/arch/current/src/maximus_intr.c
+++ b/cesar/ecos/packages/hal/maximus/arch/current/src/maximus_intr.c
@@ -307,7 +307,7 @@ maximus_terminate_sighandler(int sig)
// Disable interrupts.
HAL_DISABLE_INTERRUPTS(old);
- station_down(&my_station);
+ station_uninit (&my_station);
HAL_PLATFORM_EXIT(0);
}
// ----------------------------------------------------------------------------
@@ -382,7 +382,7 @@ hal_idle_thread_action(cyg_uint32 loop_count)
STATION_LOGTYPE_STATION,
"%s: SCI message has not been correctly received and/or processed",
__FUNCTION__);
- station_down(&my_station);
+ station_uninit (&my_station);
}
// An IRQ can occur only when we leave the station_idle function because
// it's the SCI Layer which inform the HALPhy layer that an IRQ can occur
diff --git a/cesar/hal/ipmbox/maximus/test/Config b/cesar/hal/ipmbox/maximus/test/Config
deleted file mode 100644
index 5077dbafd3..0000000000
--- a/cesar/hal/ipmbox/maximus/test/Config
+++ /dev/null
@@ -1,2 +0,0 @@
-CONFIG_DEBUG = y
-CONFIG_DEBUG_FATAL_CATCH = y
diff --git a/cesar/hal/ipmbox/maximus/test/Makefile b/cesar/hal/ipmbox/maximus/test/Makefile
deleted file mode 100644
index e0bfb92708..0000000000
--- a/cesar/hal/ipmbox/maximus/test/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-BASE = ../../../..
-EXTRA_HOST_CFLAGS += -DUNIT_TEST
-HOST_PROGRAMS = test_maximus_hal
-test_maximus_hal_SOURCES = test_maximus_hal.c test_maximus_ipmbox.c test_maximus_ether.c
-test_maximus_hal_MODULES = lib hal/ipmbox/maximus host
-test_maximus_hal_CONFIG_MODULES = mac/common
-
-INCLUDES = hal/ipmbox/maximus/test/inc
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/hal/ipmbox/maximus/test/inc/test_maximus_hal.h b/cesar/hal/ipmbox/maximus/test/inc/test_maximus_hal.h
deleted file mode 100644
index 6f1249d97e..0000000000
--- a/cesar/hal/ipmbox/maximus/test/inc/test_maximus_hal.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef hal_ipmbox_maximus_test_inc_test_maximus_hal_h
-#define hal_ipmbox_maximus_test_inc_test_maximus_hal_h
-
-/* Cesar project {{{
- *
- * Copyright (C) 2007-2012 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/ipmbox/maximus/test/inc/test_maximus_hal.h
- * \brief Test header for Maximus.
- * \ingroup hal_ipmbox_maximus
- */
-
-#include "host/fwd.h" /* for 'station_ctx_t' */
-
-#define RX_CB_DATA_USER_DATA 111
-#define RX_CB_MBX_USER_DATA 222
-#define EMPTY_BUF_CB_USER_DATA 333
-
-/**
- * RX DSR callback function.
- * \param user_data user data
- * \param first_msg pointer to the first received message header
- * \param length total length (in words) of received messages
- */
-void
-rx_cb_data (void *user_data, u32 *first_msg, uint length);
-void
-rx_cb_mbx (void *user_data, u32 *first_msg, uint length);
-
-/**
- * Empty buffer DSR callback function.
- * \param user_data user data
- */
-void
-empty_buf_cb (void *user_data);
-
-/**
- * Open pipe or socket.
- * \param station pointer to the station context
- * \return file descriptor for pipe or socket
- */
-int
-maximus_ether_open (station_ctx_t *station);
-
-/**
- * Close pipe.
- * \param fd file descriptor for pipe or socket
- */
-void
-maximus_ether_close (int fd);
-
-#endif /* hal_ipmbox_maximus_test_inc_test_maximus_hal_h */
diff --git a/cesar/hal/ipmbox/maximus/test/src/test_maximus_ether.c b/cesar/hal/ipmbox/maximus/test/src/test_maximus_ether.c
deleted file mode 100644
index 7124f11465..0000000000
--- a/cesar/hal/ipmbox/maximus/test/src/test_maximus_ether.c
+++ /dev/null
@@ -1,650 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007-2012 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/ipmbox/maximus/test/src/test_maximus_ipmbox.c
- * \brief HAL ipmbox test functions for Maximus.
- * \ingroup hal_ipmbox_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "hal/ipmbox/maximus/test/inc/test_maximus_hal.h"
-#include "hal/ipmbox/maximus/inc/maximus_ether.h"
-#include "hal/ipmbox/maximus/inc/maximus_ipmbox_ctx.h"
-#include "hal/ipmbox/maximus/inc/maximus_interrupts.h"
-#include "hal/ipmbox/ipmbox.h"
-#include "host/station/station.h" /* for 'station_ctx_t' */
-#include "maximus/common/types/ethernet_types.h" /* for 'ETHERNET_TYPE_...' */
-#include "common/ipmbox/msg.h"
-#include "lib/swap.h" /* for 'swap16()' */
-#include <stdio.h> /* for 'printf' */
-#include <string.h> /* for 'memset' */
-#include <unistd.h> /* for 'read' */
-#include <fcntl.h> /* for 'read' */
-#include <stdlib.h> /* for 'free' */
-#include <errno.h>
-
-extern uint32_t maximus_pending_isrs; /* used in 'station.c' */
-extern station_ctx_t my_station;
-ipmbox_t *ctx;
-
-void
-maximus_ether_fill_hdr_test_case (test_t t)
-{
- test_case_begin (t, "fill hdr");
-
- sci_msg_t msg;
- unsigned char buffer[SCI_MSG_MAX_SIZE];
- uint8_t type = ETHERNET_TYPE_DATA;
- uint8_t flags = ETHERNET_FLAG_NONE;
-
- 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))
- && (EINVAL != errno));
- msg.length = 0;
- } test_end;
-
- test_begin (t, "fill hdr")
- {
- test_fail_unless ((0 == maximus_ether_fill_hdr (ctx, &msg, type, flags))
- && (EINVAL != errno)
- && (ETHERNET_VERSION == msg.hdr.ether->version)
- && (type == msg.hdr.ether->type)
- && (flags == msg.hdr.ether->flags)
- && (0 == msg.hdr.ether->reserved));
- } test_end;
-
- test_begin (t, "fill hdr with incorrect type")
- {
- type = ETHERNET_TYPE_NONE;
-
- dbg_fatal_try_begin
- {
- test_fail_unless ((-1 == maximus_ether_fill_hdr(ctx, &msg, type,
- flags))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("fill hdr with incorrect type\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
-
- /* Reset type to correct value. */
- type = ETHERNET_TYPE_DATA;
- } test_end;
-
- test_begin (t, "fill hdr with incorrect flags")
- {
- flags = ETHERNET_FLAG_MAX + 1;
-
- dbg_fatal_try_begin
- {
- test_fail_unless ((-1 == maximus_ether_fill_hdr (ctx, &msg, type,
- flags))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("fill hdr with incorrect flags\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
-}
-
-void
-maximus_ether_recv_test_case (test_t t)
-{
- sci_msg_t msg;
- unsigned char buffer[SCI_MSG_MAX_SIZE];
-
- 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))
- && (EINVAL != errno));
- msg.length = 0;
- } test_end;
-
- test_begin (t, "NULL msg")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_recv (NULL, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("NULL msg\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
-
- test_begin (t, "NULL ipmbox")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_recv (&msg, NULL)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("NULL ipmbox\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
-
- test_begin (t, "recv")
- {
- u32 buf_id = 1;
- u32 total_buf_nb = 10;
- maximus_ipmbox_buffer_t *first_buffer = NULL;
- maximus_ipmbox_buffer_t *current_buffer = NULL;
-
- /* Ether header. */
- ether_msg_hdr_t ether_hdr;
-
- /* Sci header. */
- sci_msg_hdr_t sci_hdr;
-
- /* Sci data. */
- uint data_length = 1500;
- u8 data[data_length];
-
- /* Initialize sci data. */
- memset (data, '\0', data_length);
-
- /* Set ether header values. */
- ether_hdr.version = ETHERNET_VERSION;
- ether_hdr.type = ETHERNET_TYPE_NONE;
- ether_hdr.flags = ETHERNET_FLAG_NONE;
- ether_hdr.reserved = 0;
-
- for (ether_hdr.type = ETHERNET_TYPE_DATA;
- ether_hdr.type < ETHERNET_TYPE_BUFFER_RELEASED;
- ether_hdr.type++)
- {
- /* Fill sci data. */
-
- /* Ether type data or mme. */
- if ((ETHERNET_TYPE_DATA == ether_hdr.type)
- || (ETHERNET_TYPE_MME == ether_hdr.type))
- {
- uint i;
- for (i=0; i < data_length; i++)
- {
- data[i] = (u8) i;
- }
- test_fail_unless (0 <= sci_msg_push (&msg, data_length)
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy (msg.data_begin, data, data_length);
- }
- /* Ether type buffer add. */
- else if (ETHERNET_TYPE_BUFFER_ADD == ether_hdr.type)
- {
- for (buf_id = total_buf_nb; buf_id > 0; buf_id--)
- {
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (u32))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy (msg.data_begin, &buf_id, sizeof (u32));
- }
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (u32))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy (msg.data_begin, &total_buf_nb, sizeof (u32));
- }
-
- /* Fill ether header. */
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (ether_msg_hdr_t))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy (msg.data_begin, &ether_hdr, sizeof (ether_msg_hdr_t));
-
- /* Fill sci header. */
- memcpy ((u8 *) &sci_hdr.magic_id, SCI_MSG_MAGIC, 4);
- sci_hdr.version = SCI_MSG_VERSION;
- sci_hdr.type = SCI_MSG_TYPE_ETHERNET;
- sci_hdr.flags = 0;
- sci_hdr.station_id = my_station.id;
- sci_hdr.length = msg.length - sizeof (sci_msg_hdr_t);
- sci_hdr.msg_id = my_station.sci->current_msg_id | SCI_MSG_ID_STATION;
- sci_hdr.netclock_high = my_station.current_tick_tck >> 32;
- sci_hdr.netclock_low = my_station.current_tick_tck & 0xffffffff;
- msg.sci_hdr = &sci_hdr;
-
- test_fail_unless ((0 <= (maximus_ether_recv (&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != errno));
-
- test_fail_unless ((ether_hdr.version == msg.hdr.ether->version)
- && (ether_hdr.type == msg.hdr.ether->type)
- && (ether_hdr.flags == msg.hdr.ether->flags)
- && (ether_hdr.reserved == msg.hdr.ether->reserved));
-
- /* Check results. */
-
- /* Test ether type data or mme. */
- if (ETHERNET_TYPE_DATA == ether_hdr.type)
- {
- ipmbox_msg_data_t msg_data;
- msg_data.header = ipmbox_msg_create_header_data (data_length, 0);
-
- test_begin (t, "ether type data")
- {
- test_fail_unless ((maximus_pending_isrs & \
- (1 << HAL_IPMBOX_RX_INTERRUPT))
- && (2 == ctx->rx_data.length)
- && (ctx->rx_data.mailbox[0] == msg_data.header)
- && (0 == memcmp ((u8 *) ctx->rx_data.mailbox[1], data,
- data_length)));
- (*ctx->rx_cb_data) (ctx->rx_data_user_data, ctx->rx_data.mailbox,
- ctx->rx_data.length);
- maximus_pending_isrs &= ~(1 << HAL_IPMBOX_RX_INTERRUPT);
- ctx->rx_data.length = 0;
-
- /* Release allocated buffer. */
- test_fail_unless (NULL != (u32 *) ctx->rx_data.mailbox[1]);
- free ((u32 *) ctx->rx_data.mailbox[1]);
- } test_end;
- }
- else if (ETHERNET_TYPE_MME == ether_hdr.type)
- {
- ipmbox_msg_mbx_t msg_mbx;
- msg_mbx.header = ipmbox_msg_create_header_mme_priv (data_length);
-
- test_begin (t, "ether type mme")
- {
- test_fail_unless ((maximus_pending_isrs & \
- (1 << HAL_IPMBOX_RX_INTERRUPT))
- && (2 == ctx->rx_mbx.length)
- && (ctx->rx_mbx.mailbox[0] == msg_mbx.header)
- && (0 == memcmp ((u8 *) ctx->rx_mbx.mailbox[1], data,
- data_length)));
- (*ctx->rx_cb_mbx) (ctx->rx_mbx_user_data, ctx->rx_mbx.mailbox,
- ctx->rx_mbx.length);
- maximus_pending_isrs &= ~(1 << HAL_IPMBOX_RX_INTERRUPT);
- ctx->rx_mbx.length = 0;
-
- /* Release allocated buffer. */
- test_fail_unless (NULL != (u32 *) ctx->rx_mbx.mailbox[1]);
- free ((u32 *) ctx->rx_mbx.mailbox[1]);
- } test_end;
- }
- /* Test ether type buffer add. */
- else if (ETHERNET_TYPE_BUFFER_ADD == ether_hdr.type)
- {
- uint i;
-
- test_begin (t, "ether type buffer add")
- {
- ipmbox_msg_empty_buf_t expected_msg[total_buf_nb];
- first_buffer = ctx->first_buffer->next;
- current_buffer = first_buffer;
- for (i = 0; i < total_buf_nb; i++)
- {
- expected_msg[i].buffer_addr = (u32) current_buffer->data;
- current_buffer = current_buffer->next;
- }
-
- /* Check mailbox contents. */
- test_fail_unless ((maximus_pending_isrs & \
- (1 << HAL_IPMBOX_BUF_INTERRUPT))
- && (total_buf_nb == \
- ctx->rx_empty_buf.length)
- && (0 == memcmp (ctx->rx_empty_buf.mailbox,
- expected_msg,
- total_buf_nb * sizeof (u32))));
-
- /* Check list of the 10 allocated buffers. */
- current_buffer = first_buffer;
- for (i = 1; i < total_buf_nb; i++)
- {
- test_fail_unless ((NULL != current_buffer->next)
- && (i == current_buffer->id)
- && (NULL != current_buffer->data));
- current_buffer = current_buffer->next;
- }
- test_fail_unless ((NULL == current_buffer->next)
- && (total_buf_nb == current_buffer->id)
- && (NULL != current_buffer->data));
-
- (*ctx->empty_buf_cb) (ctx->buf_user_data);
- maximus_pending_isrs &= ~(1 << HAL_IPMBOX_BUF_INTERRUPT);
- test_fail_unless (ctx->rx_empty_buf.length != 0);
- } test_end;
-
- test_begin (t, "empty buf get")
- {
- uint nb_requested = 4;
- u32 msg_buf[IPMBOX_PROTOCOL_QUEUE_SIZE_A2L_EMPTY_BUF];
- test_fail_unless (ipmbox_empty_buf_get (ctx, msg_buf,
- nb_requested) == nb_requested);
- test_fail_unless (ctx->rx_empty_buf.length == \
- total_buf_nb - nb_requested);
- current_buffer = first_buffer;
- for (i = 0; i < nb_requested; i++)
- {
- test_fail_unless ((u32) current_buffer->data == \
- msg_buf[i]);
- current_buffer = current_buffer->next;
- }
-
- uint remaining_length = ctx->rx_empty_buf.length;
- nb_requested = 22;
- test_fail_unless (ipmbox_empty_buf_get (ctx, msg_buf,
- nb_requested) == remaining_length);
- for (i = 0; i < remaining_length; i++)
- {
- test_fail_unless ((u32) current_buffer->data == \
- msg_buf[i]);
- current_buffer = current_buffer->next;
- }
-
- test_fail_unless (ctx->rx_empty_buf.length == 0);
- } test_end;
-
- test_begin (t, "release allocated buffers")
- {
- uint rls_buf_nb = 0;
- maximus_ipmbox_buffer_t *next_buffer = NULL;
- current_buffer = ctx->first_buffer->next;
- while (NULL != current_buffer)
- {
- next_buffer = current_buffer->next;
- free (current_buffer->data);
- free (current_buffer);
- current_buffer = next_buffer;
- rls_buf_nb++;
- }
- ctx->first_buffer->next = NULL;
- test_fail_unless (total_buf_nb == rls_buf_nb);
- } test_end;
- }
- }
-
- /* Test ether type none. */
- ether_hdr.type = ETHERNET_TYPE_NONE;
-
- /* Fill ether header. */
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (ether_msg_hdr_t))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy (msg.data_begin, &ether_hdr, sizeof (ether_msg_hdr_t));
-
- test_begin (t, "ether type none")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_recv (&msg, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("ether type none\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
-
- /* Test ether type buffer released. */
- ether_hdr.type = ETHERNET_TYPE_BUFFER_RELEASED;
-
- /* Fill ether header. */
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (ether_msg_hdr_t))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy (msg.data_begin, &ether_hdr, sizeof (ether_msg_hdr_t));
-
- test_begin (t, "ether type buffer released")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_recv (&msg, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("ether type buffer released\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
- } test_end;
-}
-
-void
-maximus_ether_send_test_case (test_t t)
-{
- /* Ether type. */
- u8 type = ETHERNET_TYPE_DATA;
- u8 flags = ETHERNET_FLAG_NONE;
-
- /* Data. */
- int data_length = 1500;
- u8 data[1500];
-
- /* Initialize data. */
- memset (data, '\0', data_length);
-
- test_case_begin (t, "send");
-
- test_begin (t, "send incorrect flags")
- {
- flags = ETHERNET_FLAG_MAX + 1;
-
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_send (ctx, type, flags,
- data_length, (u32 *)data)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("send incorrect flags\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
-
- /* Set flags to correct value. */
- flags = ETHERNET_FLAG_MAX;
- } test_end;
-
- test_begin (t, "send incorrect data length")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_send (ctx, type, flags, 0,
- (u32 *) data)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("send incorrect data length\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
-
- test_begin (t, "send null data")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_send (ctx, type, flags,
- data_length, NULL)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("send null data\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
-
- for (type = ETHERNET_TYPE_NONE; type < ETHERNET_TYPE_NB; type++)
- {
- /* Ether type none or buffer add. */
- if ((ETHERNET_TYPE_NONE == type)
- || (ETHERNET_TYPE_BUFFER_ADD == type))
- {
- test_begin (t, "send invalid")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_ether_send (ctx, type, flags,
- data_length, (u32 *) data)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("send invalid\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
- }
-
- // Ether type data, mme or buffer released. */
- else if ((ETHERNET_TYPE_DATA == type)
- || (ETHERNET_TYPE_MME == type)
- || (ETHERNET_TYPE_BUFFER_RELEASED == type))
- {
- /* Ether type data or mme. */
- if ((ETHERNET_TYPE_DATA == type)
- || (ETHERNET_TYPE_MME == type))
- {
- /* Set data. */
- int i;
- for (i = 0; i < data_length; i++)
- {
- data[i] = (u8) i;
- }
- }
-
- /* Ether type buffer released. */
- else
- {
- /* Set data length and data. */
- int i;
- data_length = 4;
- for (i = 0; i < data_length; i++)
- {
- data[i] = i;
- }
- }
-
- test_begin (t, "send ether")
- {
- test_fail_unless ((0 == maximus_ether_send (ctx, type, flags,
- data_length, (u32 *) data))
- && (EINVAL != errno));
- } test_end;
-
- /* Check results. */
-
- /* Check that the correct ether message has been sent to Maximus. */
- test_begin (t, "ether message")
- {
- unsigned char buffer[SCI_MSG_MAX_SIZE];
- ether_msg_hdr_t *ether_hdr;
- int fd_in = -1;
-
- /* Open pipe or socket. */
- fd_in = maximus_ether_open (&my_station);
-
- /* Read sci and ether headers. */
- memset (buffer, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof (sci_msg_hdr_t) == \
- read (fd_in, buffer, sizeof(sci_msg_hdr_t)))
- && (sizeof (ether_msg_hdr_t) == \
- read (fd_in, buffer + \
- sizeof (sci_msg_hdr_t),
- sizeof(ether_msg_hdr_t))));
-
- /* Set sci and ether headers pointers. */
- ether_hdr = (ether_msg_hdr_t *) (buffer + sizeof (sci_msg_hdr_t));
-
- /* Check ether header. */
- test_fail_unless ((type == ether_hdr->type)
- && (flags == ether_hdr->flags));
-
- /* Read the remaining part of message. */
- test_fail_unless (data_length == read (fd_in, buffer + \
- sizeof (sci_msg_hdr_t) + sizeof(ether_msg_hdr_t),
- data_length));
-
- /* Check ether data. */
- test_fail_unless (0 == memcmp (data, buffer + \
- sizeof (sci_msg_hdr_t) + sizeof (ether_msg_hdr_t),
- data_length));
-
- // close pipe
- maximus_ether_close (fd_in);
- } test_end;
- }
- }
-}
-
-void ether_test_suite (test_t t)
-{
- int rx_user_data = 0x12345678;
- int buf_user_data = 0xFFFFFFFF;
-
- /* Reset errno. */
- errno = 0;
-
- station_init (&my_station);
- station_log_set_level (&my_station, STATION_LOG_DEBUG);
- station_log_set_mask (&my_station, STATION_LOGTYPE_ALL);
-
- ctx = ipmbox_init ();
- ctx->warning_assert = true;
- ipmbox_register_rx_data_cb (ctx, (void *) &rx_user_data, &rx_cb_data);
- ipmbox_register_rx_mbx_cb (ctx, (void *) &rx_user_data, &rx_cb_mbx);
- ipmbox_register_empty_buf_cb (ctx, (void *) &buf_user_data, &empty_buf_cb);
- ipmbox_activate (ctx, true);
-
- test_suite_begin (t, "ether");
- maximus_ether_fill_hdr_test_case (t);
- maximus_ether_recv_test_case (t);
- maximus_ether_send_test_case (t);
-
- ipmbox_uninit (ctx);
- station_down (&my_station);
-}
diff --git a/cesar/hal/ipmbox/maximus/test/src/test_maximus_hal.c b/cesar/hal/ipmbox/maximus/test/src/test_maximus_hal.c
deleted file mode 100644
index 2a30eb074b..0000000000
--- a/cesar/hal/ipmbox/maximus/test/src/test_maximus_hal.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007-2012 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/ipmbox/maximus/test/src/test_maximus_hal.c
- * \brief HAL IPMBox main test function for Maximus.
- * \ingroup hal_ipmbox_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "host/station/station.h" /* for 'station_ctx_t' */
-#include "inc/test_maximus_hal.h"
-#include <unistd.h> /* for 'open()' and 'close()' */
-#include <fcntl.h> /* for 'open()' and 'close()' */
-
-void
-ipmbox_test_suite (test_t t);
-void
-ether_test_suite (test_t t);
-
-uint32_t maximus_pending_isrs;
-station_ctx_t my_station;
-
-void
-rx_cb_data (void *user_data, u32 *first_msg, uint length)
-{
- int *my_data = (int *) user_data;
- *my_data = RX_CB_DATA_USER_DATA;
- return;
-}
-
-void
-rx_cb_mbx (void *user_data, u32 *first_msg, uint length)
-{
- int *my_data = (int *) user_data;
- *my_data = RX_CB_MBX_USER_DATA;
- return;
-}
-
-void empty_buf_cb (void *user_data)
-{
- int *my_data = (int *) user_data;
- *my_data = EMPTY_BUF_CB_USER_DATA;
- return;
-}
-
-int
-maximus_ether_open (station_ctx_t *station)
-{
- int fd;
-
-#ifdef STATION_SOCK
- fd = station->sock_pair_fd;
-#else /* STATION_SOCK */
- fd = open (station->pipe_out_name, O_RDONLY);
-#endif /* STATION_SOCK */
-
- return fd;
-}
-
-void
-maximus_ether_close (int fd)
-{
-#ifndef STATION_SOCK
- close (fd);
-#endif /* !STATION_SOCK */
-}
-
-int
-main (int argc, char **argv)
-{
- test_t t;
- test_init (t, argc, argv);
-
- ether_test_suite (t);
- ipmbox_test_suite (t);
-
- test_result (t);
- return test_nb_failed (t) == 0 ? 0 : 1;
-}
diff --git a/cesar/hal/ipmbox/maximus/test/src/test_maximus_ipmbox.c b/cesar/hal/ipmbox/maximus/test/src/test_maximus_ipmbox.c
deleted file mode 100644
index 88db6e3780..0000000000
--- a/cesar/hal/ipmbox/maximus/test/src/test_maximus_ipmbox.c
+++ /dev/null
@@ -1,355 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007-2012 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/ipmbox/maximus/test/src/test_maximus_ipmbox.c
- * \brief HAL ipmbox test functions for Maximus.
- * \ingroup hal_ipmbox_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "hal/ipmbox/maximus/test/inc/test_maximus_hal.h"
-#include "hal/ipmbox/maximus/inc/maximus_ipmbox_ctx.h" /* for 'ipmbox_t' */
-#include "hal/ipmbox/ipmbox.h"
-#include "host/station/station.h" /* for 'station_ctx_t' */
-#include "host/fwd.h" /* for 'sci_msg_t' */
-#include "maximus/common/types/ethernet_types.h" /* for 'ether_msg_hdr_t' */
-#include "common/ipmbox/msg.h"
-#include <stdio.h> /* for 'printf' */
-#include <string.h> /* for 'memset' */
-#include <unistd.h> /* for 'read' */
-#include <fcntl.h> /* for 'read' */
-#include <stdlib.h> /* for 'malloc' */
-#include <errno.h>
-
-extern uint32_t maximus_pending_isrs; /* used in 'station.c' */
-extern station_ctx_t my_station;
-ipmbox_t *ctx;
-
-static void
-test_buffer_released (test_t t, u32 buffer_id)
-{
- test_begin (t, "ether message BUFFER RELEASED")
- {
- unsigned char buffer[SCI_MSG_MAX_SIZE];
- ether_msg_hdr_t *ether_hdr;
- int fd_in = -1;
-
- /* Open pipe or socket. */
- fd_in = maximus_ether_open (&my_station);
-
- /* Read sci and ether headers. */
- memset (buffer, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof (sci_msg_hdr_t) == read (fd_in, buffer,
- sizeof (sci_msg_hdr_t)))
- && (sizeof (ether_msg_hdr_t) == read (fd_in, buffer + \
- sizeof (sci_msg_hdr_t), sizeof (ether_msg_hdr_t))));
-
- /* Set sci and ether headers pointers. */
- ether_hdr = (ether_msg_hdr_t *) (buffer + sizeof (sci_msg_hdr_t));
-
- /* Check ether header. */
- test_fail_unless ((ETHERNET_TYPE_BUFFER_RELEASED == ether_hdr->type)
- && (ETHERNET_FLAG_NONE == ether_hdr->flags));
-
- /* Read the remaining part of message. */
- test_fail_unless (sizeof (u32) == read (fd_in, buffer + \
- sizeof (sci_msg_hdr_t) + sizeof (ether_msg_hdr_t), sizeof (u32)));
-
- /* Check ether data. */
- test_fail_unless (buffer_id == *(buffer + sizeof (sci_msg_hdr_t) + \
- sizeof (ether_msg_hdr_t)));
-
- /* Close pipe. */
- maximus_ether_close (fd_in);
- } test_end;
-}
-
-static void
-test_ether_msg (test_t t, u8 *frame, int frame_length, u8 ether_type)
-{
- /* Check that the correct ether message has been sent to Maximus. */
- test_begin (t, "ether message")
- {
- unsigned char buffer[SCI_MSG_MAX_SIZE];
- ether_msg_hdr_t *ether_hdr;
- int fd_in = -1;
-
- /* Open pipe or socket. */
- fd_in = maximus_ether_open (&my_station);
-
- /* Read sci and ether headers. */
- memset (buffer, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof (sci_msg_hdr_t) == read (fd_in, buffer,
- sizeof(sci_msg_hdr_t)))
- && (sizeof (ether_msg_hdr_t) == read (fd_in,
- buffer + sizeof (sci_msg_hdr_t),
- sizeof (ether_msg_hdr_t))));
-
- /* Set sci and ether headers pointers. */
- ether_hdr = (ether_msg_hdr_t *) (buffer + sizeof (sci_msg_hdr_t));
-
- /* Check ether header. */
- test_fail_unless ((ether_type == ether_hdr->type)
- && (ETHERNET_FLAG_NONE == ether_hdr->flags));
-
- /* Read the remaining part of message. */
- test_fail_unless (frame_length == read (fd_in, buffer + \
- sizeof (sci_msg_hdr_t) + sizeof (ether_msg_hdr_t), frame_length));
-
- /* Check ether data. */
- test_fail_unless (0 == memcmp (frame, buffer + sizeof (sci_msg_hdr_t) + \
- sizeof (ether_msg_hdr_t), frame_length));
-
- /* Close pipe. */
- maximus_ether_close (fd_in);
- } test_end;
-}
-
-void
-ipmbox_init_test_case (test_t t)
-{
- test_case_begin (t, "init");
-
- test_begin (t, "init")
- {
- ctx = ipmbox_init ();
- test_fail_unless ((EINVAL != errno)
- && (NULL != ctx)
- && (NULL != ctx->first_buffer)
- && (NULL == ctx->first_buffer->next)
- && (0 == ctx->first_buffer->id)
- && (NULL == ctx->first_buffer->data)
- && (ctx->last_buffer == ctx->first_buffer)
- && (0 == ctx->rx_data.length)
- && (0 == ctx->rx_mbx.length)
- && (0 == ctx->rx_empty_buf.length));
- ctx->warning_assert = true;
- } test_end;
-
- maximus_pending_isrs = 0;
-
- return;
-}
-
-void
-ipmbox_register_rx_cb_test_case (test_t t)
-{
- test_case_begin (t, "register rx cb");
-
- test_begin (t, "register rx cb")
- {
- int rx_user_data = 42;
-
- ipmbox_register_rx_data_cb (ctx, (void *) &rx_user_data,
- &rx_cb_data);
- ipmbox_register_rx_mbx_cb (ctx, (void *) &rx_user_data,
- &rx_cb_mbx);
- test_fail_unless (ctx->rx_cb_data != NULL);
- test_fail_unless (ctx->rx_cb_mbx != NULL);
- test_fail_unless (*(int *) ctx->rx_data_user_data == 42);
- /* Check that the correct callback is registered. */
- (*ctx->rx_cb_data) ((void *) &rx_user_data, NULL, 0);
- test_fail_unless (rx_user_data == RX_CB_DATA_USER_DATA);
- /* Check that the correct callback is registered. */
- (*ctx->rx_cb_mbx) ((void *) &rx_user_data, NULL, 0);
- test_fail_unless (rx_user_data == RX_CB_MBX_USER_DATA);
- } test_end;
-}
-
-void
-ipmbox_register_empty_buf_cb_test_case (test_t t)
-{
- test_case_begin (t, "register empty buf cb");
-
- test_begin (t, "register empty buf cb")
- {
- int buf_user_data = 24;
-
- ipmbox_register_empty_buf_cb (ctx, (void *) &buf_user_data,
- &empty_buf_cb);
- test_fail_unless (ctx->empty_buf_cb != NULL);
- test_fail_unless (*(int *) ctx->buf_user_data == 24);
- /* Check that the correct callback is registered. */
- (*ctx->empty_buf_cb) ((void *) &buf_user_data);
- test_fail_unless (buf_user_data == EMPTY_BUF_CB_USER_DATA);
- } test_end;
-}
-
-void
-ipmbox_activate_test_case (test_t t)
-{
- test_case_begin (t, "activate");
-
- test_begin (t, "NULL ipmbox")
- {
- dbg_fatal_try_begin
- {
- ipmbox_activate (NULL, false);
- test_fail_unless (EINVAL == errno);
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("NULL ipmbox\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* Reset errno. */
- errno = 0;
- } test_end;
-
- test_begin (t, "activate")
- {
- ipmbox_activate (ctx, true);
- test_fail_unless (EINVAL != errno);
- } test_end;
-
- return;
-}
-
-void
-ipmbox_uninit_test_case (test_t t)
-{
- test_case_begin (t, "uninit");
-
- test_begin (t, "uninit")
- {
- ipmbox_uninit (ctx);
- test_fail_unless (EINVAL != errno);
- } test_end;
-
- return;
-}
-
-void
-ipmbox_tx_data_test_case (test_t t)
-{
- test_case_begin (t, "tx data");
-
- /* Ethernet frame data. */
- int frame_length = 1200;
- u8 frame[1200];
- memset (frame, '\0', frame_length); /* init frame */
-
- /* Mailbox msg. */
- ipmbox_msg_data_t msg_data;
- u32 buf_id = 32;
- int i;
-
- maximus_ipmbox_buffer_t *second_buffer = (maximus_ipmbox_buffer_t *) \
- calloc (1, sizeof (maximus_ipmbox_buffer_t));
- second_buffer->next = NULL;
- second_buffer->id = buf_id;
- second_buffer->data = (u32 *) calloc (frame_length, sizeof (u8));
- for (i = 0; i < frame_length; i++)
- {
- frame[i] = (u8)i;
- *((u8*) second_buffer->data + i) = frame[i];
- }
- ctx->first_buffer->next = second_buffer;
-
- /* Fill data message to send. */
- msg_data.header = ipmbox_msg_create_header_data (frame_length, 0);
- msg_data.buffer_addr = (u32) second_buffer->data;
-
- test_begin (t, "tx data")
- {
- ipmbox_tx_data (ctx, (u32 *) &msg_data, 2);
- test_fail_unless (EINVAL != errno);
- } test_end;
-
- /* Check results. */
- test_ether_msg (t, frame, frame_length, ETHERNET_TYPE_DATA);
- test_buffer_released (t, buf_id);
-}
-
-void
-ipmbox_tx_mbx_test_case (test_t t)
-{
- test_case_begin (t, "tx mbx");
-
- /* Ethernet frame data. */
- int frame_length = 1200;
- u8 frame[1200];
- memset (frame, '\0', frame_length); /* init frame */
-
- /* Mailbox msg. */
- ipmbox_msg_mbx_t msg_mbx;
- u32 buf_id = 32;
- int i;
-
- maximus_ipmbox_buffer_t *second_buffer = (maximus_ipmbox_buffer_t *) \
- calloc (1, sizeof (maximus_ipmbox_buffer_t));
- second_buffer->next = NULL;
- second_buffer->id = buf_id;
- second_buffer->data = (u32 *) calloc (frame_length, sizeof (u8));
- for (i = 0; i < frame_length; i++)
- {
- frame[i] = (u8)i;
- *((u8*) second_buffer->data + i) = frame[i];
- }
- ctx->first_buffer->next = second_buffer;
-
- /* Fill mailbox message to send. */
- msg_mbx.header = ipmbox_msg_create_header_mme_priv (frame_length);
- msg_mbx.buffer_addr = (u32) second_buffer->data;
-
- test_begin (t, "tx mme")
- {
- ipmbox_tx_mbx (ctx, (u32 *) &msg_mbx, 2);
- test_fail_unless (EINVAL != errno);
- } test_end;
-
- /* Check results. */
- test_ether_msg (t, frame, frame_length, ETHERNET_TYPE_MME);
- test_buffer_released (t, buf_id);
-}
-
-void
-ipmbox_tx_empty_buf_test_case (test_t t)
-{
- test_case_begin (t, "tx empty buf");
-
- test_begin (t, "tx empty buf")
- {
- /* Allocate buffer. */
- u32 *data = (u32 *) malloc (1500);
-
- /* Fill empty buffer message to send. */
- ipmbox_msg_empty_buf_t empty_buf_msg;
- empty_buf_msg.buffer_addr = (u32) data;
-
- ipmbox_tx_empty_buf (ctx, (u32 *) &empty_buf_msg, 1);
- test_fail_unless (EINVAL != errno);
- } test_end;
-}
-
-void
-ipmbox_test_suite (test_t t)
-{
- /* Reset errno. */
- errno = 0;
-
- station_init (&my_station);
- station_log_set_level (&my_station, STATION_LOG_DEBUG);
- station_log_set_mask (&my_station, STATION_LOGTYPE_ALL);
-
- test_suite_begin (t, "ipmbox");
- ipmbox_init_test_case (t);
- ipmbox_register_rx_cb_test_case (t);
- ipmbox_register_empty_buf_cb_test_case (t);
- ipmbox_activate_test_case (t);
- ipmbox_tx_data_test_case (t);
- ipmbox_tx_empty_buf_test_case (t);
- ipmbox_tx_mbx_test_case (t);
- ipmbox_uninit_test_case (t);
-
- station_down (&my_station);
-}
diff --git a/cesar/hal/leon/maximus/test/Config b/cesar/hal/leon/maximus/test/Config
deleted file mode 100644
index cba3c8284a..0000000000
--- a/cesar/hal/leon/maximus/test/Config
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_DEBUG = y
-CONFIG_DEBUG_FATAL_CATCH = y
-CONFIG_TRACE = y \ No newline at end of file
diff --git a/cesar/hal/leon/maximus/test/Makefile b/cesar/hal/leon/maximus/test/Makefile
deleted file mode 100644
index 8b594c12a8..0000000000
--- a/cesar/hal/leon/maximus/test/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-BASE = ../../../..
-EXTRA_HOST_CFLAGS+= -DUNIT_TEST
-HOST_PROGRAMS = test_maximus_timer
-test_maximus_timer_SOURCES = test_maximus_timer.c
-test_maximus_timer_MODULES = lib host hal/leon/maximus
-test_maximus_timer_CONFIG_MODULES = mac/common
-INCLUDES = hal/leon/maximus/test/inc
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/hal/leon/maximus/test/inc/test_maximus_timer.h b/cesar/hal/leon/maximus/test/inc/test_maximus_timer.h
deleted file mode 100644
index ff8a323380..0000000000
--- a/cesar/hal/leon/maximus/test/inc/test_maximus_timer.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef hal_leon_maximus_test_inc_test_maximus_timer_h
-#define hal_leon_maximus_test_inc_test_maximus_timer_h
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/leon/maximus/test/inc/test_maximus_timer.h
- * \brief test header for Maximus.
- * \ingroup hal_leon_maximus
- */
-
-#include "host/fwd.h" // for 'station_ctx_t'
-
-/**
- * DSR callback function.
- * \param user_data user data
- */
-void
-leon_timer_cb (void *user_data);
-
-/**
- * Open pipe or socket.
- * \param station pointer to the station context
- * \return file descriptor for pipe or socket
- */
-int
-maximus_timer_open (station_ctx_t *station);
-
-/**
- * Close pipe.
- * \param fd file descriptor for pipe or socket
- */
-void
-maximus_timer_close (int fd);
-
-#endif /* hal_leon_maximus_test_inc_test_maximus_timer_h */
diff --git a/cesar/hal/leon/maximus/test/src/test_maximus_timer.c b/cesar/hal/leon/maximus/test/src/test_maximus_timer.c
deleted file mode 100644
index 36607c4275..0000000000
--- a/cesar/hal/leon/maximus/test/src/test_maximus_timer.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/leon/maximus/test/src/test_maximus_timer.c
- * \brief HAL leon timer test functions for Maximus.
- * \ingroup hal_leon_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "lib/trace.h"
-#include "hal/leon/maximus/inc/maximus_timer_ctx.h"
-#include "hal/leon/maximus/inc/maximus_timer.h"
-#include "hal/leon/maximus/inc/maximus_interrupts.h"
-#include "hal/leon/maximus/test/inc/test_maximus_timer.h"
-#include <stdio.h> // for 'printf'
-#include <string.h> // for 'memset'
-#include <netinet/in.h> // for 'ntohl' and 'ntohs' functions
-#include <unistd.h> // for 'read', 'open()' and 'close()'
-#include <fcntl.h> // for 'read', 'open()' and 'close()'
-#include <errno.h>
-
-void leon_timer_test_suite (test_t t);
-
-uint32_t maximus_pending_isrs;
-station_ctx_t my_station;
-leon_timer_t *ctx;
-int user_data = 123456789;
-
-void
-leon_timer_cb (void *data)
-{
- int *my_data = (int *)data;
- *my_data = 987654321;
- return;
-}
-
-int
-maximus_timer_open (station_ctx_t *station)
-{
- int fd;
-
- #ifdef STATION_SOCK
- fd = station->sock_pair_fd;
- #else /* STATION_SOCK */
- fd = open(station->pipe_out_name, O_RDONLY);
- #endif /* STATION_SOCK */
-
- return fd;
-}
-
-void
-maximus_timer_close (int fd)
-{
- #ifndef STATION_SOCK
- close(fd);
- #endif /* !STATION_SOCK */
-}
-
-void
-leon_timer_init_test_case(test_t t)
-{
- printf("init\n");
- test_case_begin(t, "init");
-
- test_begin(t, "init")
- {
- ctx = leon_timer_init ((void *)&user_data, &leon_timer_cb);
- test_fail_unless ((EINVAL != errno)
- && (NULL != ctx)
- && (user_data == *((int *)ctx->user_data))
- && (&leon_timer_cb == ctx->cb));
- ctx->warning_assert = true;
- } test_end;
-
- test_begin(t, "cb")
- {
- (*ctx->cb)(ctx->user_data);
- test_fail_unless (987654321 == *((int *)ctx->user_data));
- } test_end;
-
- maximus_pending_isrs = 0;
-
- return;
-}
-
-void leon_timer_program_test_case(test_t t)
-{
- u32 date = 10;
- netclock_id_t id = 0;
-
- printf("leon timer program\n");
- test_case_begin(t, "leon timer program");
-
- // test a date in the past
- my_station.current_tick_tck = date;
- leon_timer_program (ctx, date-1);
- // test the callback
- test_begin(t, "past date - maximus leon timer cb")
- {
- test_fail_unless ((EINVAL != errno)
- && (maximus_pending_isrs & (1 << HAL_LEON_TIMER_INTERRUPT)));
- } test_end;
- maximus_pending_isrs &= (0 << HAL_LEON_TIMER_INTERRUPT);
-
- date = 0xDEADBEEE;
- leon_timer_program (ctx, date);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_timer_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'leon_timer_cancel()'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->netclock_id);
-
- // close pipe
- maximus_timer_close(fd_in);
- } test_end;
-
- // test the callback
- test_begin(t, "maximus leon timer cb")
- {
- maximus_leon_timer_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (maximus_pending_isrs & (1 << HAL_LEON_TIMER_INTERRUPT)));
- } test_end;
-
- test_begin(t, "leon timer cb")
- {
- test_fail_unless (NULL != ctx->cb);
- (*ctx->cb)(ctx->user_data);
- maximus_pending_isrs &= (0 << HAL_LEON_TIMER_INTERRUPT);
- } test_end;
-
- id = ctx->netclock_id;
- leon_timer_program (ctx, date+1);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "cancel netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_timer_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_timer_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "program netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_timer_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date+1 == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_access_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->netclock_id);
-
- // close pipe
- maximus_timer_close(fd_in);
- } test_end;
-
- return;
-}
-
-void leon_timer_cancel_test_case(test_t t)
-{
- netclock_id_t id = 0;
-
- printf("leon timer cancel\n");
- test_case_begin(t, "leon timer cancel");
-
- test_begin(t, "leon timer cancel")
- {
- id = ctx->netclock_id;
- leon_timer_cancel (ctx);
- test_fail_unless ((EINVAL != errno)
- && (0 == ctx->netclock_id));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_timer_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_timer_close(fd_in);
- } test_end;
-
- return;
-}
-
-void leon_timer_uninit_test_case(test_t t)
-{
- printf("uninit\n");
- test_case_begin(t, "uninit");
-
- test_begin(t, "uninit")
- {
- leon_timer_uninit(ctx);
- test_fail_unless (EINVAL != errno);
- } test_end;
-
- return;
-}
-
-void leon_timer_test_suite(test_t t)
-{
- // reset errno
- errno = 0;
-
- station_init (&my_station);
- station_log_set_level(&my_station, STATION_LOG_DEBUG);
- station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
- //my_station.pipe_log_fd = 1;
-
- test_suite_begin(t, "leon timer");
- leon_timer_init_test_case(t);
- leon_timer_program_test_case(t);
- leon_timer_cancel_test_case(t);
- printf("BEGIN_TRACE\n");
- trace_buffer_dbg_dump(&ctx->trace);
- printf("END_TRACE\n");
- leon_timer_uninit_test_case(t);
-
- station_down (&my_station);
-}
-
-int
-main (int argc, char **argv)
-{
- test_t t;
- test_init(t, argc, argv);
-
- trace_init();
- leon_timer_test_suite(t);
- trace_uninit();
-
- test_result(t);
- return test_nb_failed(t) == 0 ? 0 : 1;
-}
diff --git a/cesar/hal/phy/maximus/test/Config b/cesar/hal/phy/maximus/test/Config
deleted file mode 100644
index 0788d5a0df..0000000000
--- a/cesar/hal/phy/maximus/test/Config
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_DEBUG = y
-CONFIG_DEBUG_FATAL_CATCH = y
-CONFIG_TRACE = n
-CONFIG_MAC_COMMON_EOC_TEI = y
diff --git a/cesar/hal/phy/maximus/test/Makefile b/cesar/hal/phy/maximus/test/Makefile
deleted file mode 100644
index a85c0e911a..0000000000
--- a/cesar/hal/phy/maximus/test/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-BASE = ../../../..
-EXTRA_HOST_CFLAGS+= -DUNIT_TEST
-HOST_PROGRAMS = test_phy_maximus
-test_phy_maximus_SOURCES = test_phy_maximus.c test_phy_access.c \
- test_phy_ctrl.c test_pbdma.c \
- test_tmdma.c test_aes.c
-test_phy_maximus_MODULES = lib hal/phy/maximus host
-test_phy_maximus_CONFIG_MODULES = mac
-INCLUDES = hal/phy/maximus/test/inc
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/hal/phy/maximus/test/inc/test_phy_maximus.h b/cesar/hal/phy/maximus/test/inc/test_phy_maximus.h
deleted file mode 100644
index a4e206e48f..0000000000
--- a/cesar/hal/phy/maximus/test/inc/test_phy_maximus.h
+++ /dev/null
@@ -1,93 +0,0 @@
-#ifndef hal_phy_maximus_test_inc_test_phy_maximus_h
-#define hal_phy_maximus_test_inc_test_phy_maximus_h
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/maximus/test/inc/test_phy_maximus.h
- * \brief test header for Maximus.
- * \ingroup hal_phy_maximus
- */
-
-#include "host/fwd.h" // for 'station_ctx_t'
-
-/**
- * ACCESS event callback.
- * \param user user data
- * \return true if a DSR is requested
- */
-bool phy_access_cb (void *user);
-
-/**
- * ACCESS CONFIRM event callback.
- * \param user user data
- * \return true if a DSR is requested
- */
-bool phy_access_conf_cb (void *user);
-
-/**
- * RX FC event callback.
- * \param user user data
- * \param rx_date start of preamble date
- * \param fc_av frame control, or NULL if FCCS error
- * \return true if a DSR is requested
- */
-bool phy_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av);
-
-/**
- * TX FALSE ALARM event callback.
- * \param user user data
- * \return true if a DSR is requested
- */
-bool phy_tx_false_alarm_cb (void *user);
-
-/**
- * Zero-cross event callback.
- * \param user user data
- * \return true if a DSR is requested
- *
- * Zero-cross event happens every 20 ms (or 16,67 ms).
- */
-bool phy_zero_cross_cb (void *user, const u32 zero_cross_date);
-
-/**
- * If a DSR was requested, this callback is called.
- * \param user user data
- */
-void phy_deferred_cb (void *user);
-
-/**
- * PB DMA callback called when an interrupt occurs.
- * \param user user data
- * \param status_word status read from PB DMA
- * \return true if a DSR is requested
- */
-bool phy_pbdma_cb (void *user, u32 status_word);
-
-/**
- * Extra timer callback.
- * \param user user data
- * \return true if a DSR is requested
- */
-bool phy_extra_timer_cb (void *user);
-
-/**
- * Open pipe or socket.
- * \param station pointer to the station context
- * \return file descriptor for pipe or socket
- */
-int
-maximus_phy_open (station_ctx_t *station);
-
-/**
- * Close pipe.
- * \param fd file descriptor for pipe or socket
- */
-void
-maximus_phy_close (int fd);
-
-#endif /* hal_phy_maximus_test_inc_test_phy_maximus_h */
diff --git a/cesar/hal/phy/maximus/test/src/test_aes.c b/cesar/hal/phy/maximus/test/src/test_aes.c
deleted file mode 100644
index 8f301ce341..0000000000
--- a/cesar/hal/phy/maximus/test/src/test_aes.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2009 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file src/test_aes.c
- * \brief Test AES functions.
- * \ingroup test
- */
-#include "common/std.h"
-#include "lib/test.h"
-#include "hal/phy/maximus/inc/maximus_aes.h"
-
-void
-aes_test_suite (test_t t)
-{
- test_suite_begin (t, "aes");
- test_case_begin (t, "decryption key");
- test_begin (t, "vectors")
- {
- u32 enc[4] = { 0x68a87ed4, 0x654b7514, 0x11a8efd5, 0x3cf2f390 };
- u32 dec_ref[4] = { 0x159f280b, 0x91a47793, 0x1330fc87, 0x6530c66d };
- u32 dec[4];
- maximus_aes_decryption_key (enc, dec);
- test_fail_unless (dec_ref[0] == dec[0]
- && dec_ref[1] == dec[1]
- && dec_ref[2] == dec[2]
- && dec_ref[3] == dec[3]);
- } test_end;
-}
-
diff --git a/cesar/hal/phy/maximus/test/src/test_pbdma.c b/cesar/hal/phy/maximus/test/src/test_pbdma.c
deleted file mode 100644
index 670d24ab14..0000000000
--- a/cesar/hal/phy/maximus/test/src/test_pbdma.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/maximus/test/src/test_pbdma.c
- * \brief HAL Phy PB DMA test functions for Maximus.
- * \ingroup hal_phy_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "lib/trace.h"
-#include "hal/phy/maximus/inc/maximus_phy_ctx.h"
-#include "hal/phy/maximus/inc/maximus_phy_ctrl.h"
-#include "hal/phy/maximus/inc/maximus_interrupts.h"
-#include "hal/phy/maximus/test/inc/test_phy_maximus.h"
-#include "mac/common/defs.h" // for 'MAC_PB520_BYTES'
-#include <stdio.h> // for 'printf'
-#include <string.h> // for 'memset'
-#include <errno.h>
-
-extern station_ctx_t my_station;
-phy_t *ctx;
-
-void phy_pbdma_start_test_case(test_t t)
-{
- printf("pbdma start\n");
- test_case_begin(t, "pbdma start");
-
- bool bypass_aes = false;
- u32 nek[4];
- uint nb_total = PHY_PB_MAX_NB;
- uint nb_pb_it = PHY_PB_MAX_NB-1;
- phy_pb_t pb[PHY_PB_MAX_NB];
- u8 pb_data[PHY_PB_MAX_NB][MAC_PB520_BYTES];
- int i = 0;
- char c = 'a';
-
- memset(nek, 'n', 4*sizeof(u32));
-
- // set pb size (set by 'phy_rx_prepare' in Rx and 'phy_tx_param' in Tx)
- ctx->control.current_tx_param.pb_size = PHY_PB_SIZE_520;
-
- test_begin(t, "pbdma start in Tx")
- {
- // fill PBs for Tx
- for (i=0; i<PHY_PB_MAX_NB; i++)
- {
- memset(pb_data[i], c, MAC_PB520_BYTES);
- pb[i].pb_tx.blk.data = pb_data[i];
- pb[i].pb_tx.header = i+1;
- if (PHY_PB_MAX_NB-1 != i)
- {
- pb[i].pb_tx.blk.next = &pb[i+1].pb_tx.blk;
- }
- else
- {
- pb[i].pb_tx.blk.next = NULL;
- }
- c++;
- }
-
- phy_pbdma_start (ctx, bypass_aes,
- nek, nb_total,
- nb_pb_it, &pb[0], NULL, false);
- test_fail_unless ((EINVAL != errno)
- && (bypass_aes == ctx->pbdma.bypass_aes)
- && (0 == memcmp(nek, ctx->pbdma.nek, 4*sizeof(u32)))
- && (nb_total == ctx->pbdma.nb_total)
- && (nb_total == ctx->pbdma.nb_ready)
- && (nb_pb_it == ctx->pbdma.nb_pb_it)
- && (pb == ctx->pbdma.first_pb)
- && (!ctx->pbdma.chandata_transfer)
- && (ctx->pbdma.current_pb == &ctx->pbdma.first_pb->pb_rx));
- phy_pb_tx_t * current_pb = &ctx->pbdma.first_pb->pb_tx;
- for (i=0; i<PHY_PB_MAX_NB; i++)
- {
- test_fail_unless (0 == memcmp(pb_data[i], current_pb->blk.data, MAC_PB520_BYTES));
- current_pb = PARENT_OF(phy_pb_tx_t, blk, current_pb->blk.next);
- }
- } test_end;
-
- // set pb size (set by 'phy_rx_prepare' in Rx and 'phy_tx_param' in Tx)
- ctx->control.rx_param.pb_size = PHY_PB_SIZE_520;
-
- test_begin(t, "pbdma start in Rx")
- {
- // reset PBs for Rx
- for (i=0; i<PHY_PB_MAX_NB; i++)
- {
- memset(pb_data[i], '\0', MAC_PB520_BYTES);
- pb[i].pb_rx.blk.data = pb_data[i];
- pb[i].pb_rx.header = 0;
- memset(&pb[i].pb_rx.pb_measurement, '\0', sizeof(pb_measurement_t));
- if (PHY_PB_MAX_NB-1 != i)
- {
- pb[i].pb_rx.blk.next = &pb[i+1].pb_rx.blk;
- }
- else
- {
- pb[i].pb_rx.blk.next = NULL;
- }
- c++;
- }
-
- phy_pbdma_start (ctx, bypass_aes,
- nek, nb_total,
- nb_pb_it, &pb[0], NULL, false);
- test_fail_unless ((EINVAL != errno)
- && (bypass_aes == ctx->pbdma.bypass_aes)
- && (0 == memcmp(nek, ctx->pbdma.nek, 4*sizeof(u32)))
- && (nb_total == ctx->pbdma.nb_total)
- && (nb_total == ctx->pbdma.nb_ready)
- && (nb_pb_it == ctx->pbdma.nb_pb_it)
- && (pb == ctx->pbdma.first_pb)
- && (!ctx->pbdma.chandata_transfer)
- && (ctx->pbdma.current_pb == &ctx->pbdma.first_pb->pb_rx));
- } test_end;
-}
-
-void phy_pbdma_update_test_case(test_t t)
-{
- printf("pbdma update\n");
- test_case_begin(t, "pbdma update");
-
- test_begin(t, "pbdma update")
- {
- uint nb_pb_it = PHY_PB_MAX_NB-1;
-
- phy_pbdma_update (ctx, nb_pb_it);
- test_fail_unless ((EINVAL != errno)
- && (nb_pb_it == ctx->pbdma.nb_pb_it));
- } test_end;
-}
-
-void phy_pbdma_get_tail_test_case(test_t t)
-{
- printf("pbdma get tail\n");
- test_case_begin(t, "pbdma get tail");
-
- /* To test the 'phy_pbdma_get_tail()' function, an MPDU frame has to be received by the station,
- * to check if the current PB of the PHY context points to the last PB, as expected. */
-
- test_begin(t, "pbdma get tail")
- {
- unsigned short int pb_counter;
- sci_msg_t msg;
- unsigned char buffer[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t phy_hdr;
- sci_msg_hdr_t sci_hdr;
- u8 pb_data[PHY_PB_MAX_NB][MAC_PB520_BYTES];
- phy_pb_t phy_pb[PHY_PB_MAX_NB];
-
- // set PBDMA
- ctx->pbdma.first_pb = phy_pb;
- ctx->pbdma.current_pb = &ctx->pbdma.first_pb->pb_rx;
-
- // set MPDU reception conditions
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_RX_MPDU;
- ctx->control.rx_prepared = true;
-
- // fill in the SCI data with an MPDU composed of 3 PBs
- test_fail_unless ((0 == sci_msg_init(&msg, buffer, SCI_MSG_MAX_SIZE))
- && (EINVAL != errno));
- for (pb_counter = 0; pb_counter < PHY_PB_MAX_NB; pb_counter++)
- {
- test_fail_unless (0 <= sci_msg_push (&msg, MAC_PB520_BYTES)
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memset(&pb_data[pb_counter][0], '\0', MAC_PB520_BYTES);
- memcpy(msg.data_begin, &pb_data[pb_counter][0], MAC_PB520_BYTES);
- phy_pb[pb_counter].pb_rx.blk.data = &pb_data[pb_counter][0];
- if (PHY_PB_MAX_NB-1 != pb_counter)
- {
- phy_pb[pb_counter].pb_rx.blk.next = &phy_pb[pb_counter+1].pb_rx.blk;
- }
- else
- {
- phy_pb[pb_counter].pb_rx.blk.next = NULL;
- }
- }
-
- // set the expected current PB pointer
- phy_pb_rx_t *current_pb = ctx->pbdma.current_pb;
- for (pb_counter = 1; pb_counter < PHY_PB_MAX_NB; pb_counter++)
- {
- current_pb = PARENT_OF(phy_pb_rx_t, blk, current_pb->blk.next);
- }
-
- // fill in the PHY header
- memset(&phy_hdr, '\0', sizeof(phy_msg_hdr_t));
- phy_hdr.version = PHY_VERSION;
- phy_hdr.type = PHY_TYPE_MPDU_PAYLOAD;
- phy_hdr.mpdu_format = PHY_MPDU_FORMAT_BEACON;
- phy_hdr.pb_nb = PHY_PB_MAX_NB;
- phy_hdr.msg_nb = 1;
- phy_hdr.fc_mode = PHY_FC_MODE_AV_2;
- phy_hdr.short_ppdu = false;
- phy_hdr.mod = PHY_MOD_ROBO;
- phy_hdr.fecrate = PHY_FEC_RATE_1_2;
- phy_hdr.gil = PHY_GIL_417;
- phy_hdr.tonemap_index = 0;
- phy_hdr.reserved = 0;
- phy_hdr.tx_id = 0;
- phy_hdr.flags = ntohs(0x0006);
- phy_hdr.symbol_nb = 0;
-
- // fill in the SCI data with the PHY header
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (phy_msg_hdr_t))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, &phy_hdr, sizeof(phy_msg_hdr_t));
-
- // fill in the SCI header
- memcpy((unsigned char *)&sci_hdr.magic_id, SCI_MSG_MAGIC, 4);
- sci_hdr.version = SCI_MSG_VERSION;
- sci_hdr.type = SCI_MSG_TYPE_PHY;
- sci_hdr.flags = 0;
- sci_hdr.station_id = htons(my_station.id);
- sci_hdr.length = msg.length - sizeof(sci_msg_hdr_t);
- sci_hdr.msg_id = my_station.sci->current_msg_id | SCI_MSG_ID_STATION;
- sci_hdr.netclock_high = my_station.current_tick_tck >> 32;
- sci_hdr.netclock_low = my_station.current_tick_tck & 0xffffffff;
- msg.sci_hdr = &sci_hdr;
-
- // set station id
- ctx->control.rx_param.src_station_id = my_station.id;
-
- // simulates the fact that the station receives the built MPDU
- test_fail_unless ((0 <= (maximus_phy_recv(&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != errno));
-
- // test if the 'phy_pbdma_get_tail()' result points to the expected PB
- test_fail_unless ((EINVAL != errno)
- && (PARENT_OF(phy_pb_t, pb_rx, current_pb) == phy_pbdma_get_tail(ctx)));
- } test_end;
-}
-
-void phy_pbdma_start_chandata_test_case(test_t t)
-{
- printf("pbdma start chandata\n");
- test_case_begin(t, "pbdma start chandata");
-
- phy_chandata_t chandata;
- unsigned short int chandata_size = 128;
- u8 chandata_data[4*chandata_size];
-
- test_begin(t, "pbdma start chandata in Tx")
- {
- // fill chandata for Tx
- memset(chandata_data, 'd', 4*chandata_size);
- chandata.blk.next = NULL;
- chandata.blk.data = chandata_data;
- chandata.conf.size = chandata_size;
- chandata.conf.last = 1;
- chandata.conf.type = PHY_CHANDATA_TYPE_NRJ_SYMBOL;
- chandata.conf.address = 0;
-
- phy_pbdma_start_chandata (ctx, &chandata);
- test_fail_unless ((EINVAL != errno)
- && (&chandata == ctx->pbdma.first_chandata)
- && (0 == memcmp(chandata_data, ctx->pbdma.first_chandata->blk.data, 4*chandata_size))
- && (ctx->pbdma.chandata_transfer));
- } test_end;
-
- test_begin(t, "pbdma start chandata in Rx")
- {
- phy_pbdma_start_chandata (ctx, &chandata);
- test_fail_unless ((EINVAL != errno)
- && (&chandata == ctx->pbdma.first_chandata)
- && (ctx->pbdma.chandata_transfer));
- } test_end;
-}
-
-void pbdma_test_suite(test_t t)
-{
- int user_data = 1234567890;
-
- // reset errno
- errno = 0;
-
- station_init (&my_station);
- station_log_set_level(&my_station, STATION_LOG_DEBUG);
- station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
- //my_station.pipe_log_fd = 1;
- trace_init();
- ctx = phy_init ((void*)&user_data,
- &phy_rx_fc_cb,
- &phy_access_cb,
- &phy_access_conf_cb,
- &phy_pbdma_cb,
- &phy_tx_false_alarm_cb,
- &phy_deferred_cb);
- ctx->warning_assert = true;
-
- test_suite_begin(t, "pb dma");
- phy_pbdma_start_test_case(t);
- phy_pbdma_update_test_case(t);
- phy_pbdma_get_tail_test_case(t);
- phy_pbdma_start_chandata_test_case(t);
-
-#if CONFIG_TRACE
- printf("BEGIN_TRACE\n");
- trace_buffer_dbg_dump(&ctx->trace);
- printf("END_TRACE\n");
-#endif
- phy_uninit (ctx);
- trace_uninit();
- station_down (&my_station);
-}
diff --git a/cesar/hal/phy/maximus/test/src/test_phy_access.c b/cesar/hal/phy/maximus/test/src/test_phy_access.c
deleted file mode 100644
index efeffb3b36..0000000000
--- a/cesar/hal/phy/maximus/test/src/test_phy_access.c
+++ /dev/null
@@ -1,884 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/maximus/test/src/test_phy_access.c
- * \brief HAL Phy access test functions for Maximus.
- * \ingroup hal_phy_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "lib/trace.h"
-#include "maximus/common/types/phy_types.h"
-#include "host/fwd.h" // for 'phy_msg_hdr_t'
-#include "hal/phy/maximus/inc/maximus_phy_ctx.h"
-#include "hal/phy/maximus/inc/maximus_phy_access.h"
-#include "hal/phy/maximus/inc/maximus_phy_ctrl.h" // for 'maximus_phy_recv_preamble_cb()'
-#include "hal/phy/maximus/inc/maximus_interrupts.h"
-#include "hal/phy/maximus/test/inc/test_phy_maximus.h"
-#include "mac/common/timings.h" // for 'MAC_SLOT_TCK'
-#include <stdio.h> // for 'printf'
-#include <string.h> // for 'memset'
-#include <netinet/in.h> // for 'ntohl' and 'ntohs' functions
-#include <unistd.h> // for 'read'
-#include <fcntl.h> // for 'read'
-#include <errno.h>
-
-extern uint32_t maximus_pending_isrs; // used in 'station.c'
-extern station_ctx_t my_station;
-phy_t *ctx;
-
-void phy_access_backoff_start_test_case(test_t t)
-{
- u32 date = 10;
- uint cap = 3;
- tick_t msg_tick_tck;
- netclock_id_t id;
-
- printf("backoff start\n");
- test_case_begin(t, "backoff start");
-
- test_begin(t, "backoff start")
- {
- phy_access_backoff_start (ctx, date, cap);
- test_fail_unless (EINVAL != errno);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message for backoff cb")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr->tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr->tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr->tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the backoff callback
- test_begin(t, "backoff cb")
- {
- maximus_phy_access_backoff_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno) && (EPROTO != errno));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message for slot count cb")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless ((my_station.current_tick_tck & 0x00000000FFFFFFFF) + (unsigned long)MAC_SLOT_TCK == ntohl(netclock_hdr->tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message for prs0 cb")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless ((my_station.current_tick_tck & 0x00000000FFFFFFFF) + (unsigned long)MAXIMUS_PHY_PRS_DETECTION_DELAY_TCK == ntohl(netclock_hdr->tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr->tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr->tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the PRS0 callback
- test_begin(t, "prs0 cb")
- {
- maximus_phy_access_prs0_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (MAXIMUS_PHY_MEDIUM_PRS0 == ctx->access.medium_state));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "phy message for PRS0")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
- uint8_t prs0 = 1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && ((int)(sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)) == read(fd_in, data, sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_PRS == phy_hdr->type);
-
- // read the remaining part of message
- test_fail_unless (sizeof(uint8_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint8_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(&prs0, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(u8)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message for prs0 result cb")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- sci_msg_hdr_t *sci_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set sci and netclock headers pointers
- sci_hdr = (sci_msg_hdr_t *)(data);
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless ((my_station.current_tick_tck & 0x00000000FFFFFFFF) + (unsigned long)MAC_SLOT_TCK - (unsigned long)MAXIMUS_PHY_PRS_DETECTION_DELAY_TCK == ntohl(netclock_hdr->tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(sci_hdr->netclock_high))) << 32)
- | (unsigned long long)(ntohl(sci_hdr->netclock_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the slot count callback
- test_begin(t, "slot count cb")
- {
- maximus_phy_access_slot_count_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (EPROTO != errno)
- && (1 == ctx->access.slot_count));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message for slot count cb")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless ((my_station.current_tick_tck & 0x00000000FFFFFFFF) + (unsigned long)MAC_SLOT_TCK == ntohl(netclock_hdr->tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
-
- // reset slot count netclock id (because callback will not be called)
- ctx->access.backoff_slot_count_netclock_id = 0;
- } test_end;
-
- // test the prs0 result callback
- test_begin(t, "prs0 result cb")
- {
- maximus_phy_access_prs0_result_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (MAXIMUS_PHY_MEDIUM_PRS1 == ctx->access.medium_state)
- && ctx->access.prp_result);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message for prs1 cb")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- sci_msg_hdr_t *sci_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set sci and netclock headers pointers
- sci_hdr = (sci_msg_hdr_t *)(data);
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless ((my_station.current_tick_tck & 0x00000000FFFFFFFF) + (unsigned long)MAXIMUS_PHY_PRS_DETECTION_DELAY_TCK == ntohl(netclock_hdr->tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(sci_hdr->netclock_high))) << 32)
- | (unsigned long long)(ntohl(sci_hdr->netclock_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the prs1 callback
- test_begin(t, "prs1 cb")
- {
- maximus_phy_access_prs1_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (MAXIMUS_PHY_MEDIUM_PRS1 == ctx->access.medium_state));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "phy message for PRS1")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
- uint8_t prs1 = 1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && ((int)(sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)) == read(fd_in, data, sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_PRS == phy_hdr->type);
-
- // read the remaining part of message
- test_fail_unless (sizeof(uint8_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint8_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(&prs1, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(u8)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message for prp result cb")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- sci_msg_hdr_t *sci_hdr;
- int fd_in = -1;
-
- // open pipe ro socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set sci and netclock headers pointers
- sci_hdr = (sci_msg_hdr_t *)(data);
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless ((my_station.current_tick_tck & 0x00000000FFFFFFFF) + (unsigned long)MAC_SLOT_TCK - (unsigned long)MAXIMUS_PHY_PRS_DETECTION_DELAY_TCK - 1 == ntohl(netclock_hdr->tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(sci_hdr->netclock_high))) << 32)
- | (unsigned long long)(ntohl(sci_hdr->netclock_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- /* Do not remove netclock callback (for next test). */
- } test_end;
-
- id = ctx->access.backoff_start_netclock_id;
-
- test_begin(t, "backoff start again")
- {
- phy_access_backoff_start (ctx, date+100000, cap);
- test_fail_unless (EINVAL != errno);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "cancel netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "backoff start netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date+100000 == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_access_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->access.backoff_start_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // test the prp result callback
- test_begin(t, "prp result cb")
- {
- maximus_phy_access_prp_result_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (MAXIMUS_PHY_MEDIUM_CW == ctx->access.medium_state)
- && ctx->control.pre_detection
- && ctx->access.prp_result);
- } test_end;
-
- return;
-}
-
-void phy_access_backoff_update_test_case(test_t t)
-{
- printf("backoff update\n");
- test_case_begin(t, "backoff update");
-
- test_begin(t, "backoff update")
- {
- uint cap = 2;
-
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_IDLE;
- phy_access_backoff_update (ctx, cap);
- test_fail_unless ((EINVAL != errno)
- && (cap == (uint)ctx->access.cap_mpdu));
- } test_end;
-
- return;
-}
-
-void phy_access_backoff_slot_count_test_case(test_t t)
-{
- printf("backoff slot count\n");
- test_case_begin(t, "backoff slot count");
-
- test_begin(t, "backoff slot count")
- {
- test_fail_unless ((ctx->access.slot_count == phy_access_backoff_slot_count(ctx))
- && (EINVAL != errno));
- } test_end;
-
- return;
-}
-
-void phy_access_backoff_prp_won_test_case(test_t t)
-{
- printf("backoff prp won\n");
- test_case_begin(t, "backoff prp won");
-
- test_begin(t, "backoff prp won")
- {
- if (NULL != ctx)
- {
- ctx->access.prp_result = true;
- }
- test_fail_unless ((ctx->access.prp_result == phy_access_backoff_prp_won(ctx))
- && (EINVAL != errno));
- } test_end;
-
- return;
-}
-
-void phy_access_timer_program_test_case(test_t t)
-{
- u32 date = my_station.current_tick_tck + 20;
- netclock_id_t id = 0;
-
- printf("timer program\n");
- test_case_begin(t, "timer program");
-
- test_begin(t, "timer program")
- {
- phy_access_timer_program (ctx, date);
- test_fail_unless(EINVAL != errno);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_access_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->access.timer_program_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- id = ctx->access.timer_program_netclock_id;
- phy_access_timer_program (ctx, date+1);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "cancel netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "program netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date+1 == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_access_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->access.timer_program_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- /* Test that access timer is cancelled when entering into BUSY-RX state. */
- id = ctx->access.timer_program_netclock_id;
- maximus_phy_recv_preamble_t data;
- data.ctx = ctx;
- data.wrong_preamble = false;
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_WAIT_CONF;
- ctx->control.pre_detection = true;
- maximus_phy_recv_preamble_cb (&data);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "cancel netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- phy_access_timer_program (ctx, date+1);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "program netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date+1 == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_access_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->access.timer_program_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the callback
- test_begin(t, "maximus acces timer cb")
- {
- maximus_phy_access_timer_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PHY))
- && (ctx->control.current_cb == ctx->control.access_cb));
- } test_end;
-
- test_begin(t, "access cb")
- {
- test_fail_unless ((NULL != ctx->control.access_cb)
- && ((*ctx->control.access_cb)(ctx->control.user_data)));
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
- } test_end;
-
- return;
-}
-
-void phy_access_timer_cancel_test_case(test_t t)
-{
- netclock_id_t id = 0;
-
- printf("timer cancel\n");
- test_case_begin(t, "timer cancel");
-
- test_begin(t, "timer cancel")
- {
- phy_access_timer_program (ctx, my_station.current_tick_tck+1);
- id = ctx->access.timer_program_netclock_id;
- phy_access_timer_cancel (ctx);
- test_fail_unless ( (EINVAL != errno)
- && (0 == ctx->access.timer_program_netclock_id) );
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- return;
-}
-
-void phy_access_test_suite(test_t t)
-{
- int user_data = 1234567890;
-
- // reset errno
- errno = 0;
-
- station_init (&my_station);
- station_log_set_level(&my_station, STATION_LOG_DEBUG);
- station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
- //my_station.pipe_log_fd = 1;
- trace_init();
- ctx = phy_init ((void*)&user_data,
- &phy_rx_fc_cb,
- &phy_access_cb,
- &phy_access_conf_cb,
- &phy_pbdma_cb,
- &phy_tx_false_alarm_cb,
- &phy_deferred_cb);
- ctx->warning_assert = true;
-
- test_suite_begin(t, "phy access");
- phy_access_backoff_start_test_case(t);
- phy_access_backoff_update_test_case(t);
- phy_access_backoff_slot_count_test_case(t);
- phy_access_backoff_prp_won_test_case(t);
- phy_access_timer_program_test_case(t);
- phy_access_timer_cancel_test_case(t);
-
-#if CONFIG_TRACE
- printf("BEGIN_TRACE\n");
- trace_buffer_dbg_dump(&ctx->trace);
- printf("END_TRACE\n");
-#endif
- phy_uninit (ctx);
- trace_uninit();
- station_down (&my_station);
-}
diff --git a/cesar/hal/phy/maximus/test/src/test_phy_ctrl.c b/cesar/hal/phy/maximus/test/src/test_phy_ctrl.c
deleted file mode 100644
index 1d0b0d9da2..0000000000
--- a/cesar/hal/phy/maximus/test/src/test_phy_ctrl.c
+++ /dev/null
@@ -1,3856 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/maximus/test/src/test_phy_ctrl.c
- * \brief HAL Phy control test functions for Maximus.
- * \ingroup hal_phy_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "lib/trace.h"
-#include "hal/phy/maximus/inc/maximus_phy_ctx.h"
-#include "hal/phy/maximus/inc/maximus_phy_ctrl.h"
-#include "hal/phy/maximus/inc/maximus_interrupts.h"
-#include "hal/phy/maximus/dur/inc/maximus_dur.h"
-#include "hal/phy/maximus/inc/maximus_defs.h"
-#include "hal/phy/maximus/test/inc/test_phy_maximus.h"
-#include "mac/common/timings.h" // for 'MAC_PREAMBLE_TCK', 'MAC_PREAMBLE_HYBRID_TCK', 'MAC_FC_10_TCK' and 'MAC_FC_AV_TCK'
-#include "mac/common/defs.h" // for 'MAC_PB520_BYTES', 'MAC_MAX_SYMB_PER_MPDU' and 'MAC_MAX_PB_PER_MPDU'
-#include <stdio.h> // for 'printf'
-#include <string.h> // for 'memset'
-#include <netinet/in.h> // for 'ntohl' and 'ntohs' functions
-#include <unistd.h> // for 'read'
-#include <fcntl.h> // for 'read'
-#include <errno.h>
-
-#define PHY_PB_NB 96 //MAC_MAX_PB_PER_MPDU // for 'maximus_phy_recv_test_case' (PHY_TYPE_MPDU_PAYLOAD) and 'maximus_phy_send_test_case'
-
-extern uint32_t maximus_pending_isrs; // used in 'station.c'
-extern station_ctx_t my_station;
-phy_t *ctx;
-int user_data = 1234567890;
-
-void maximus_phy_get_medium_state_test_case(test_t t)
-{
- printf("get medium state\n");
- test_case_begin(t, "get medium state");
-
- test_begin(t, "NULL ctx")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ( (NULL == maximus_phy_get_medium_state(NULL))
- && (EINVAL == errno) );
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("get medium state with NULL ctx\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "invalid medium state")
- {
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_STATE_NB;
-
- dbg_fatal_try_begin
- {
- test_fail_unless ( (NULL == maximus_phy_get_medium_state(ctx))
- && (EINVAL == errno) );
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("get medium state with invalid medium state\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "valid medium states")
- {
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_TX;
- test_fail_unless ( !strcmp(maximus_phy_get_medium_state(ctx), "MAXIMUS_PHY_MEDIUM_BUSY_TX")
- && (EINVAL != errno) );
-
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_IDLE;
- test_fail_unless ( !strcmp(maximus_phy_get_medium_state(ctx), "MAXIMUS_PHY_MEDIUM_IDLE")
- && (EINVAL != errno) );
- } test_end;
-}
-
-void maximus_phy_fill_hdr_test_case(test_t t)
-{
- printf("fill hdr\n");
- test_case_begin(t, "fill hdr");
-
- sci_msg_t msg;
- unsigned char buffer[SCI_MSG_MAX_SIZE];
- uint8_t type = PHY_TYPE_MPDU_PAYLOAD;
- uint8_t mpdu_format = PHY_MPDU_FORMAT_SOF;
- uint8_t pb_nb = PHY_PB_MAX_NB;
- uint8_t msg_nb = 1;
- uint8_t fc_mode = PHY_FC_MODE_HYBRID_1;
- uint8_t short_ppdu = 0;
- uint8_t mod = PHY_MOD_ROBO;
- uint8_t fecrate = PHY_FEC_RATE_1_2;
- uint8_t gil = PHY_GIL_417;
- uint8_t tonemap_index = 0;
- uint16_t tx_id = 0;
- uint16_t flags = 0x0006;
- uint32_t symbol_nb = 0;
- uint32_t iv[3];
- uint32_t nek[4];
- uint32_t pb_measurement[PHY_PB_MAX_NB];
- uint32_t pb_header[PHY_PB_MAX_NB];
-
- memset(iv, 'a', 3*sizeof(uint32_t));
- memset(nek, 'b', 4*sizeof(uint32_t));
- memset(pb_measurement, 'c', PHY_PB_MAX_NB*sizeof(uint32_t));
- memset(pb_header, 'd', PHY_PB_MAX_NB*sizeof(uint32_t));
-
- 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))
- && (EINVAL != errno));
- msg.length = 0;
- } test_end;
-
- test_begin(t, "fill hdr")
- {
- test_fail_unless ((0 == maximus_phy_fill_hdr(ctx,
- &msg,
- type,
- mpdu_format,
- pb_nb,
- msg_nb,
- fc_mode,
- short_ppdu,
- mod,
- fecrate,
- gil,
- tonemap_index,
- tx_id,
- flags,
- symbol_nb,
- iv,
- nek,
- pb_measurement,
- pb_header))
- && (EINVAL != errno)
- && (PHY_VERSION == msg.hdr.phy->version)
- && (type == msg.hdr.phy->type)
- && (mpdu_format == msg.hdr.phy->mpdu_format)
- && (pb_nb == msg.hdr.phy->pb_nb)
- && (msg_nb == msg.hdr.phy->msg_nb)
- && (fc_mode == msg.hdr.phy->fc_mode)
- && (short_ppdu == msg.hdr.phy->short_ppdu)
- && (mod == msg.hdr.phy->mod)
- && (fecrate == msg.hdr.phy->fecrate)
- && (gil == msg.hdr.phy->gil)
- && (tonemap_index == msg.hdr.phy->tonemap_index)
- && (tx_id == ntohs(msg.hdr.phy->tx_id))
- && (flags == ntohs(msg.hdr.phy->flags))
- && (symbol_nb == ntohl(msg.hdr.phy->symbol_nb))
- && (0 == memcmp (iv, msg.hdr.phy->iv, 3*sizeof(uint32_t)))
- && (0 == memcmp (nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
- && (0 == memcmp (pb_measurement, msg.hdr.phy->pb_measurement, pb_nb*sizeof(uint32_t)))
- && (0 == memcmp (pb_header, msg.hdr.phy->pb_header, pb_nb*sizeof(uint32_t))));
- } test_end;
-
- test_begin(t, "fill hdr with incorrect flags")
- {
- flags = 0x0010;
-
- dbg_fatal_try_begin
- {
- test_fail_unless ((-1 == maximus_phy_fill_hdr(ctx,
- &msg,
- type,
- mpdu_format,
- pb_nb,
- msg_nb,
- fc_mode,
- short_ppdu,
- mod,
- fecrate,
- gil,
- tonemap_index,
- tx_id,
- flags,
- symbol_nb,
- iv,
- nek,
- pb_measurement,
- pb_header))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("fill hdr with incorrect flags\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "fill hdr with incorrect number of PBs")
- {
- flags = 0x0000;
- pb_nb = MAC_MAX_PB_PER_MPDU + 1;
-
- dbg_fatal_try_begin
- {
- test_fail_unless ((-1 == maximus_phy_fill_hdr(ctx,
- &msg,
- type,
- mpdu_format,
- pb_nb,
- msg_nb,
- fc_mode,
- short_ppdu,
- mod,
- fecrate,
- gil,
- tonemap_index,
- tx_id,
- flags,
- symbol_nb,
- iv,
- nek,
- pb_measurement,
- pb_header))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("fill hdr with incorrect number of PBs\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
- } test_end;
-}
-
-void maximus_phy_recv_test_case(test_t t)
-{
- // for PHY_TYPE_NOISE
- static phy_noise_energy_t freq_noise[PHY_CARRIER_NB];
- static phy_noise_energy_t time_noise[MAC_MAX_SYMB_PER_MPDU];
- const unsigned short int max_transfer_size = 128; // in words
- const unsigned short int freq_noise_count = ((PHY_CARRIER_NB * sizeof(phy_noise_energy_t)) + ((max_transfer_size * 4) - 1)) / (max_transfer_size * 4);
- const unsigned short int time_noise_count = ((MAC_MAX_SYMB_PER_MPDU * sizeof(phy_noise_energy_t)) + ((max_transfer_size * 4) - 1)) / (max_transfer_size * 4);
- static phy_chandata_t freq_noise_chandata[10];
- static phy_chandata_t time_noise_chandata[1];
- static u8 freq_noise_data[10*MAC_PB520_BYTES];
- static u8 time_noise_data[1*MAC_PB520_BYTES];
- phy_chandata_t *current_chandata = NULL;
- unsigned int i = 0;
-
- sci_msg_t msg;
- unsigned char buffer[SCI_MSG_MAX_SIZE];
-
- printf("recv\n");
- 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))
- && (EINVAL != errno));
- msg.length = 0;
- } test_end;
-
- test_begin(t, "NULL msg")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_phy_recv(NULL, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("NULL msg\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "NULL phy")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_phy_recv(&msg, NULL)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("NULL phy\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "recv")
- {
- unsigned short int pb_counter;
-
- // phy header
- phy_msg_hdr_t phy_hdr;
- u32 iv[3];
- u32 nek[4];
- pb_measurement_t pb_measurement[PHY_PB_MAX_NB];
- u32 pb_header[PHY_PB_MAX_NB];
-
- // sci header
- sci_msg_hdr_t sci_hdr;
-
- // sci data
- u32 fc_10 = 1234567890; // for PHY_TYPE_FC_HYBRID_MODE
- u32 fc_av[4]; // for PHY_TYPE_FC_HYBRID_MODE and PHY_TYPE_FC_AV_ONLY_MODE
- u32 prs = 1; // for PHY_TYPE_PRS
- // for PHY_TYPE_MPDU_PAYLOAD
- u8 pb_data[PHY_PB_NB][MAC_PB520_BYTES];
- phy_pb_t phy_pb[PHY_PB_NB];
- // for PHY_TYPE_TONEMAP
- u8 tonemap1_data[MAC_PB520_BYTES];
- u8 tonemap2_data[(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES];
-
- // initialize sci data
- char c = '1';
- memset(iv, 'z', 3*sizeof(u32));
- memset(nek, 'a', 4*sizeof(u32));
- memset(pb_measurement, '0', PHY_PB_MAX_NB*sizeof(pb_measurement_t));
- memset(pb_header, '0', PHY_PB_MAX_NB*sizeof(u32));
- memset(fc_av, 'b', 4*sizeof(u32));
- memset(freq_noise_data, '\0', freq_noise_count*MAC_PB520_BYTES);
- memset(time_noise_data, '\0', time_noise_count*MAC_PB520_BYTES);
- for (i=0; i<PHY_CARRIER_NB; i++)
- {
- freq_noise[i] = 2*i;
- }
- for (i=0; i<MAC_MAX_SYMB_PER_MPDU; i++)
- {
- time_noise[i] = PHY_CARRIER_NB + i;
- }
- for (pb_counter = 0; pb_counter < PHY_PB_MAX_NB; pb_counter++)
- {
- memset(&pb_measurement[pb_counter], c, sizeof(pb_measurement_t));
- c++;
- memset(&pb_header[pb_counter], c, sizeof(u32));
- c++;
- }
- c = 0x00;
- for (pb_counter = 0; pb_counter < PHY_PB_NB; pb_counter++)
- {
- memset(&pb_data[pb_counter][0], c, MAC_PB520_BYTES*sizeof(u8));
- c++;
- }
- memset(tonemap1_data, '9', MAC_PB520_BYTES);
- memset(tonemap2_data, '8', (PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES);
-
- // fill the phy header
- phy_hdr.version = PHY_VERSION;
- phy_hdr.type = PHY_TYPE_NONE;
- phy_hdr.mpdu_format = PHY_MPDU_FORMAT_NONE;
- phy_hdr.pb_nb = PHY_PB_MAX_NB;
- phy_hdr.msg_nb = 1;
- phy_hdr.fc_mode = PHY_FC_MODE_AV_2;
- phy_hdr.short_ppdu = 0;
- phy_hdr.mod = PHY_MOD_ROBO;
- phy_hdr.fecrate = PHY_FEC_RATE_1_2;
- phy_hdr.gil = PHY_GIL_417;
- phy_hdr.tonemap_index = 0;
- phy_hdr.reserved = 0;
- phy_hdr.tx_id = 10;
- phy_hdr.flags = htons(0x0006);
- phy_hdr.symbol_nb = 0;
- memcpy(phy_hdr.iv, iv, 3*sizeof(uint32_t));
- 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));
-
- // set RX parameters
- ctx->control.rx_param.fc_mode = phy_hdr.fc_mode;
-
- for (phy_hdr.type = PHY_TYPE_NONE; phy_hdr.type < PHY_TYPE_NB; phy_hdr.type++)
- {
- /* Fill the sci data. */
- // test phy type none
- if (PHY_TYPE_NONE == phy_hdr.type)
- {
- test_begin(t, "phy type none")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_phy_recv(&msg, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("phy type none\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
- // reset errno
- errno = 0;
- } test_end;
- }
- // preamble
- if (PHY_TYPE_PREAMBLE == phy_hdr.type)
- {
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_IDLE;
- // activate preamble detection
- ctx->control.pre_detection = true;
- // set RX FC mode
- ctx->control.rx_param.fc_mode = PHY_FC_MODE_AV_2;
- }
- // AV Frame Control (16 octets)
- if (PHY_TYPE_FC_AV_ONLY_MODE == phy_hdr.type)
- {
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_RX_FC;
- }
- if ((PHY_TYPE_FC_HYBRID_MODE == phy_hdr.type)
- || (PHY_TYPE_FC_AV_ONLY_MODE == phy_hdr.type))
- {
- ctx->control.rx_param.short_ppdu = false;
- test_fail_unless (0 <= sci_msg_push (&msg, 16)
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, fc_av, 16);
- }
- // HP1.0.1 Frame Control (4 octets)
- if (PHY_TYPE_FC_HYBRID_MODE == phy_hdr.type)
- {
- test_fail_unless (0 <= sci_msg_push (&msg, 4)
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, &fc_10, 4);
- }
- // PRS (1 octet, but must be aligned on 4 octets)
- if (PHY_TYPE_PRS == phy_hdr.type)
- {
- // reset TX ID
- phy_hdr.tx_id = 0;
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_PRS0;
- test_fail_unless (0 <= sci_msg_push (&msg, 4)
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, &prs, 4);
- }
- // PBs
- if (PHY_TYPE_MPDU_PAYLOAD == phy_hdr.type)
- {
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_RX_MPDU;
- // indicate that RX has been prepared
- ctx->control.rx_prepared = true;
- // set mpdu format
- phy_hdr.mpdu_format = PHY_MPDU_FORMAT_BEACON;
-
- // set pb dma
- ctx->pbdma.first_pb = phy_pb;
- ctx->pbdma.current_pb = &ctx->pbdma.first_pb->pb_rx;
- ctx->pbdma.nb_total = PHY_PB_NB;
- ctx->pbdma.nb_ready = PHY_PB_NB;
- ctx->pbdma.nb_pb_it = PHY_PB_NB;
- ctx->pbdma.index_current_pb = 0;
- memset(ctx->pbdma.crc_bitmap, '\0', 8 * sizeof(u32));
- u32 expected_crc_bitmap[8];
- memset(expected_crc_bitmap, '\0', 8 * sizeof(u32));
-
- unsigned short int msg_nb = 1;
- uint8_t last_msg_pb_nb = PHY_PB_MAX_NB;
- unsigned short int msg_counter = 0;
-
- if (PHY_PB_NB > PHY_PB_MAX_NB)
- {
- msg_nb = (unsigned short int)(PHY_PB_NB/PHY_PB_MAX_NB);
- if (0 != (PHY_PB_NB % PHY_PB_MAX_NB))
- {
- last_msg_pb_nb = (uint8_t)(PHY_PB_NB % PHY_PB_MAX_NB);
- msg_nb++;
- }
- }
- else
- {
- phy_hdr.pb_nb = PHY_PB_NB;
- }
-
- for (msg_counter = 0; msg_counter < msg_nb; msg_counter++)
- {
- if ((1 != msg_nb) && (msg_nb-1 == msg_counter))
- {
- phy_hdr.pb_nb = last_msg_pb_nb;
- }
-
- for (pb_counter = 0; pb_counter < phy_hdr.pb_nb; pb_counter++)
- {
- test_fail_unless (0 <= sci_msg_push (&msg, MAC_PB520_BYTES)
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, &pb_data[pb_counter][0], MAC_PB520_BYTES);
- phy_pb[pb_counter].pb_rx.blk.data = &pb_data[pb_counter][0];
- phy_pb[pb_counter].pb_rx.blk.next = &phy_pb[pb_counter+1].pb_rx.blk;
- if (phy_hdr.pb_nb-1 == pb_counter)
- {
- phy_pb[pb_counter].pb_rx.blk.next = &phy_pb[0].pb_rx.blk;
- }
- }
-
- // phy header
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (phy_msg_hdr_t))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, &phy_hdr, sizeof(phy_msg_hdr_t));
-
- // fill the sci header
- memcpy((unsigned char *)&sci_hdr.magic_id, SCI_MSG_MAGIC, 4);
- sci_hdr.version = SCI_MSG_VERSION;
- sci_hdr.type = SCI_MSG_TYPE_PHY;
- sci_hdr.flags = 0;
- sci_hdr.station_id = my_station.id;
- sci_hdr.length = msg.length - sizeof(sci_msg_hdr_t);
- sci_hdr.msg_id = my_station.sci->current_msg_id | SCI_MSG_ID_STATION;
- sci_hdr.netclock_high = my_station.current_tick_tck >> 32;
- sci_hdr.netclock_low = my_station.current_tick_tck & 0xffffffff;
- msg.sci_hdr = &sci_hdr;
-
- test_fail_unless ((0 <= (maximus_phy_recv(&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != 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.fc_mode == msg.hdr.phy->fc_mode)
- && (phy_hdr.short_ppdu == msg.hdr.phy->short_ppdu)
- && (phy_hdr.mod == msg.hdr.phy->mod)
- && (phy_hdr.fecrate == msg.hdr.phy->fecrate)
- && (phy_hdr.gil == msg.hdr.phy->gil)
- && (phy_hdr.tonemap_index == msg.hdr.phy->tonemap_index)
- && (phy_hdr.tx_id == msg.hdr.phy->tx_id)
- && (phy_hdr.flags == msg.hdr.phy->flags)
- && (phy_hdr.reserved == msg.hdr.phy->reserved)
- && (phy_hdr.symbol_nb == msg.hdr.phy->symbol_nb)
- && (0 == memcmp(phy_hdr.iv, msg.hdr.phy->iv, 3*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_measurement, msg.hdr.phy->pb_measurement, msg.hdr.phy->pb_nb*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_header, msg.hdr.phy->pb_header, msg.hdr.phy->pb_nb*sizeof(uint32_t))));
-
- // test PBs
- phy_pb_rx_t *current_pb = &ctx->pbdma.first_pb->pb_rx;
-
- for (pb_counter = 0; pb_counter < phy_hdr.pb_nb; pb_counter++)
- {
- test_fail_unless (pb_header[pb_counter] == current_pb->header);
- test_fail_unless (0 == memcmp(&pb_measurement[pb_counter], &current_pb->pb_measurement, sizeof(pb_measurement_t)));
- test_fail_unless (0 == memcmp(&pb_data[pb_counter][0], current_pb->blk.data, MAC_PB520_BYTES*sizeof(u8)));
- current_pb = PARENT_OF(phy_pb_rx_t, blk, current_pb->blk.next);
- }
-
- // test crc bitmap registers
- for (pb_counter = 0; pb_counter < phy_hdr.pb_nb; pb_counter++)
- {
- u32 tmp = *(u32 *)&pb_measurement[pb_counter];
- tmp = ntohl(tmp);
- expected_crc_bitmap[(msg_counter * PHY_PB_MAX_NB + pb_counter) / 32] |= ((tmp & 0x200000) >> 21) << ((msg_counter * PHY_PB_MAX_NB + pb_counter) % 32); /* crc_error */
- }
- }
- test_fail_unless (0 == memcmp(expected_crc_bitmap, ctx->pbdma.crc_bitmap, 8 * sizeof(u32)));
- }
- // tonemask
- if (PHY_TYPE_TONEMASK == phy_hdr.type)
- {
- test_begin(t, "phy type tonemask")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_phy_recv(&msg, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("phy type tonemask\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
- // reset errno
- errno = 0;
- } test_end;
- }
- // tonemap
- if (PHY_TYPE_TONEMAP == phy_hdr.type)
- {
- test_begin(t, "phy type tonemap")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_phy_recv(&msg, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("phy type tonemap\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
- // reset errno
- errno = 0;
- } test_end;
- }
- // noise
- if (PHY_TYPE_NOISE == phy_hdr.type)
- {
- // reset SCI message
- memset(buffer, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((0 == sci_msg_init(&msg, buffer, SCI_MSG_MAX_SIZE))
- && (EINVAL != errno));
- msg.length = 0;
-
- // set chandata transfer
- ctx->pbdma.chandata_transfer = true;
-
- // frequency noise
- ctx->pbdma.first_chandata = freq_noise_chandata;
- current_chandata = ctx->pbdma.first_chandata;
- for (i=0; i<freq_noise_count; i++)
- {
- current_chandata->conf.type = 1; // frequency noise
- current_chandata->conf.size = max_transfer_size;
- current_chandata->blk.data = &freq_noise_data[i*MAC_PB520_BYTES];
- current_chandata->conf.last = 0;
- if (freq_noise_count != i+1)
- {
- current_chandata->blk.next = &(freq_noise_chandata[i+1].blk);
- }
- else
- {
- // for last chandata
- current_chandata->blk.next = &(time_noise_chandata[0].blk);
- }
- current_chandata = PARENT_OF(phy_chandata_t, blk, current_chandata->blk.next);
- }
-
- // time noise
- for (i=0; i<time_noise_count; i++)
- {
- current_chandata->conf.type = 2; // time noise
- current_chandata->conf.size = max_transfer_size;
- current_chandata->blk.data = &time_noise_data[i*MAC_PB520_BYTES];
- if (time_noise_count != i+1)
- {
- current_chandata->conf.last = 0;
- current_chandata->blk.next = &(time_noise_chandata[i+1].blk);
- current_chandata = PARENT_OF(phy_chandata_t, blk, current_chandata->blk.next);
- }
- else
- {
- // for last chandata
- current_chandata->conf.last = 1;
- current_chandata->blk.next = NULL;
- }
- }
-
- // fill sci data
- test_fail_unless (
- 0 <= sci_msg_push (
- &msg,
- MAC_MAX_SYMB_PER_MPDU * sizeof (phy_noise_energy_t))
- && EINVAL != errno
- && ENOSPC != errno);
- memcpy(msg.data_begin, time_noise, MAC_MAX_SYMB_PER_MPDU*sizeof(phy_noise_energy_t));
- test_fail_unless (
- 0 <= sci_msg_push (
- &msg,
- PHY_CARRIER_NB * sizeof (phy_noise_energy_t))
- && EINVAL != errno
- && ENOSPC != errno);
- memcpy(msg.data_begin, freq_noise, PHY_CARRIER_NB*sizeof(phy_noise_energy_t));
- }
- // RX
- if (PHY_TYPE_RX == phy_hdr.type)
- {
- test_begin(t, "phy type rx")
- {
- dbg_fatal_try_begin
- {
- test_fail_unless ((0 > (maximus_phy_recv(&msg, ctx)))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("phy type rx\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
- // reset errno
- errno = 0;
- } test_end;
- }
- if ((PHY_TYPE_PREAMBLE == phy_hdr.type)
- || (PHY_TYPE_FC_HYBRID_MODE == phy_hdr.type)
- || (PHY_TYPE_FC_AV_ONLY_MODE == phy_hdr.type)
- || (PHY_TYPE_PRS == phy_hdr.type)
- || (PHY_TYPE_NOISE == phy_hdr.type)
- || (PHY_TYPE_ZERO_CROSS == phy_hdr.type))
- {
- // phy header
- test_fail_unless (
- 0 <= sci_msg_push (&msg, sizeof (phy_msg_hdr_t))
- && EINVAL != errno
- && ENOSPC != errno);
- memcpy(msg.data_begin, &phy_hdr, sizeof(phy_msg_hdr_t));
-
- // fill the sci header
- memcpy((unsigned char *)&sci_hdr.magic_id, SCI_MSG_MAGIC, 4);
- sci_hdr.version = SCI_MSG_VERSION;
- sci_hdr.type = SCI_MSG_TYPE_PHY;
- sci_hdr.flags = 0;
- sci_hdr.station_id = my_station.id;
- sci_hdr.length = msg.length - sizeof(sci_msg_hdr_t);
- sci_hdr.msg_id = my_station.sci->current_msg_id | SCI_MSG_ID_STATION;
- sci_hdr.netclock_high = my_station.current_tick_tck >> 32;
- sci_hdr.netclock_low = my_station.current_tick_tck & 0xffffffff;
- msg.sci_hdr = &sci_hdr;
-
- test_fail_unless ((0 <= (maximus_phy_recv(&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != 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.fc_mode == msg.hdr.phy->fc_mode)
- && (phy_hdr.short_ppdu == msg.hdr.phy->short_ppdu)
- && (phy_hdr.mod == msg.hdr.phy->mod)
- && (phy_hdr.fecrate == msg.hdr.phy->fecrate)
- && (phy_hdr.gil == msg.hdr.phy->gil)
- && (phy_hdr.tonemap_index == msg.hdr.phy->tonemap_index)
- && (phy_hdr.tx_id == msg.hdr.phy->tx_id)
- && (phy_hdr.flags == msg.hdr.phy->flags)
- && (phy_hdr.reserved == msg.hdr.phy->reserved)
- && (phy_hdr.symbol_nb == msg.hdr.phy->symbol_nb)
- && (0 == memcmp(phy_hdr.iv, msg.hdr.phy->iv, 3*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_measurement, msg.hdr.phy->pb_measurement, msg.hdr.phy->pb_nb*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_header, msg.hdr.phy->pb_header, msg.hdr.phy->pb_nb*sizeof(uint32_t))));
- }
- /* Check results. */
- // test preamble
- if (PHY_TYPE_PREAMBLE == phy_hdr.type)
- {
- test_fail_unless ((MAXIMUS_PHY_MEDIUM_WAIT_CONF == ctx->access.medium_state)
- && ctx->control.pre_detection);
-
- /* Check that the correct netclock message has been sent to Maximus. */
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless ((u32) (my_station.current_tick_tck \
- - MAXIMUS_PHY_PREAMBLE_DETECTION_DELAY_TCK \
- + PHY_PREAMBLE_CONFIRMATION_DELAY_TCK) \
- == ntohl (netclock_hdr->tick_low));
-
- // check netclock id for 'maximus_phy_recv_preamble_cb'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.rx_param.recv_preamble_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr->id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
-
- // reset netclock id
- ctx->control.rx_param.recv_preamble_netclock_id = 0;
-
- /* Test RX collision. */
-
- // reset rx collision
- ctx->control.rx_collision = false;
-
- // phy header
- test_fail_unless (
- 0 <= 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 ((0 <= (maximus_phy_recv(&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != 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.fc_mode == msg.hdr.phy->fc_mode)
- && (phy_hdr.short_ppdu == msg.hdr.phy->short_ppdu)
- && (phy_hdr.mod == msg.hdr.phy->mod)
- && (phy_hdr.fecrate == msg.hdr.phy->fecrate)
- && (phy_hdr.gil == msg.hdr.phy->gil)
- && (phy_hdr.tonemap_index == msg.hdr.phy->tonemap_index)
- && (phy_hdr.tx_id == msg.hdr.phy->tx_id)
- && (phy_hdr.flags == msg.hdr.phy->flags)
- && (phy_hdr.reserved == msg.hdr.phy->reserved)
- && (phy_hdr.symbol_nb == msg.hdr.phy->symbol_nb)
- && (0 == memcmp(phy_hdr.iv, msg.hdr.phy->iv, 3*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_measurement, msg.hdr.phy->pb_measurement, msg.hdr.phy->pb_nb*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_header, msg.hdr.phy->pb_header, msg.hdr.phy->pb_nb*sizeof(uint32_t))));
-
- test_fail_unless (ctx->control.rx_collision);
-
- // reset rx collision
- ctx->control.rx_collision = false;
-
- /* Test callback:
- * - with a wrong preamble;
- * - then, with a correct preamble. */
- maximus_phy_recv_preamble_t preamble_data;
- preamble_data.ctx = ctx;
- preamble_data.wrong_preamble = true;
- preamble_data.src_tx_id = ntohs(phy_hdr.tx_id);
- preamble_data.src_station_id = ntohs(sci_hdr.station_id);
- ctx->control.tx_blocked_on_false_alarm = true; // set TX blocked
- maximus_phy_recv_preamble_cb((void *)&preamble_data);
- test_fail_unless ((EINVAL != errno)
- && (MAXIMUS_PHY_MEDIUM_IDLE == ctx->access.medium_state)
- && ctx->control.pre_detection
- && (maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PHY))
- && (ctx->control.current_cb == ctx->control.tx_false_alarm_cb));
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
-
- preamble_data.wrong_preamble = false;
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_WAIT_CONF;
- maximus_phy_recv_preamble_cb((void *)&preamble_data);
- test_fail_unless ((EINVAL != errno)
- && (MAXIMUS_PHY_MEDIUM_BUSY_RX_FC == ctx->access.medium_state)
- && !ctx->control.pre_detection
- && (ctx->control.rx_param.src_tx_id == preamble_data.src_tx_id)
- && (ctx->control.rx_param.src_station_id == preamble_data.src_station_id));
- }
- // test fc_av
- if ((PHY_TYPE_FC_HYBRID_MODE == phy_hdr.type)
- || (PHY_TYPE_FC_AV_ONLY_MODE == phy_hdr.type))
- {
- test_fail_unless ((maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PHY))
- && (ctx->control.current_cb == ctx->control.rx_fc_cb)
- && (0 == memcmp(fc_av, ctx->control.rx_fc_param.fc_av, 4*sizeof(u32))));
- (*ctx->control.rx_fc_cb)(ctx->control.user_data, ctx->control.rx_fc_param.rx_date, ctx->control.rx_fc_param.fc_av);
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
- }
- // test fc_10
- if (PHY_TYPE_FC_HYBRID_MODE == phy_hdr.type)
- {
- test_fail_unless (fc_10 == ctx->control.rx_param.fc_10);
- }
- // test RX collision
- if (PHY_TYPE_FC_AV_ONLY_MODE == phy_hdr.type)
- {
- // set rx collision
- ctx->control.rx_collision = true;
-
- // phy header
- test_fail_unless (
- 0 <= sci_msg_push (&msg, sizeof (phy_msg_hdr_t))
- && EINVAL != errno
- && ENOSPC != errno);
- memcpy(msg.data_begin, &phy_hdr, sizeof(phy_msg_hdr_t));
-
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_RX_FC;
-
- test_fail_unless ((0 <= (maximus_phy_recv(&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != 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.fc_mode == msg.hdr.phy->fc_mode)
- && (phy_hdr.short_ppdu == msg.hdr.phy->short_ppdu)
- && (phy_hdr.mod == msg.hdr.phy->mod)
- && (phy_hdr.fecrate == msg.hdr.phy->fecrate)
- && (phy_hdr.gil == msg.hdr.phy->gil)
- && (phy_hdr.tonemap_index == msg.hdr.phy->tonemap_index)
- && (phy_hdr.tx_id == msg.hdr.phy->tx_id)
- && (phy_hdr.flags == msg.hdr.phy->flags)
- && (phy_hdr.reserved == msg.hdr.phy->reserved)
- && (phy_hdr.symbol_nb == msg.hdr.phy->symbol_nb)
- && (0 == memcmp(phy_hdr.iv, msg.hdr.phy->iv, 3*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_measurement, msg.hdr.phy->pb_measurement, msg.hdr.phy->pb_nb*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_header, msg.hdr.phy->pb_header, msg.hdr.phy->pb_nb*sizeof(uint32_t))));
-
- test_fail_unless ((maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PHY))
- && (ctx->control.current_cb == ctx->control.rx_fc_cb)
- && (NULL == ctx->control.rx_fc_param.fc_av)
- && ((u32)-1 == ctx->control.rx_param.fc_10));
- (*ctx->control.rx_fc_cb)(ctx->control.user_data, ctx->control.rx_fc_param.rx_date, ctx->control.rx_fc_param.fc_av);
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
-
- // sci header => FC coming from another station
- sci_hdr.station_id = my_station.id + 1;
-
- // phy header
- test_fail_unless (
- 0 <= sci_msg_push (&msg, sizeof (phy_msg_hdr_t))
- && EINVAL != errno
- && ENOSPC != errno);
- memcpy(msg.data_begin, &phy_hdr, sizeof(phy_msg_hdr_t));
-
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_RX_FC;
-
- test_fail_unless ((0 <= (maximus_phy_recv(&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != 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.fc_mode == msg.hdr.phy->fc_mode)
- && (phy_hdr.short_ppdu == msg.hdr.phy->short_ppdu)
- && (phy_hdr.mod == msg.hdr.phy->mod)
- && (phy_hdr.fecrate == msg.hdr.phy->fecrate)
- && (phy_hdr.gil == msg.hdr.phy->gil)
- && (phy_hdr.tonemap_index == msg.hdr.phy->tonemap_index)
- && (phy_hdr.tx_id == msg.hdr.phy->tx_id)
- && (phy_hdr.flags == msg.hdr.phy->flags)
- && (phy_hdr.reserved == msg.hdr.phy->reserved)
- && (phy_hdr.symbol_nb == msg.hdr.phy->symbol_nb)
- && (0 == memcmp(phy_hdr.iv, msg.hdr.phy->iv, 3*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_measurement, msg.hdr.phy->pb_measurement, msg.hdr.phy->pb_nb*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_header, msg.hdr.phy->pb_header, msg.hdr.phy->pb_nb*sizeof(uint32_t))));
-
- test_fail_unless (0 == maximus_pending_isrs);
-
- // reset rx collision
- ctx->control.rx_collision = false;
- }
- // test PBs
- if (PHY_TYPE_MPDU_PAYLOAD == phy_hdr.type)
- {
- test_fail_unless ((maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PBDMA))
- && (0 == ctx->pbdma.status_word.bf.pb_null)
- && (0 == ctx->pbdma.status_word.bf.null_pb_index)
- && (1 == ctx->pbdma.status_word.bf.pb_it)
- && (1 == ctx->pbdma.status_word.bf.end_rx_pb)
- && !ctx->control.rx_prepared);
- // pb_it
- ctx->pbdma.status_word.bf.end_rx_pb = 0;
- (*ctx->control.pbdma_cb) (ctx->control.user_data,
- ctx->pbdma.status_word.value);
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PBDMA);
- }
- // test PRS
- if (PHY_TYPE_PRS == phy_hdr.type)
- {
- test_fail_unless (2 == ctx->access.cap_medium);
- // set TX ID
- phy_hdr.tx_id = 10;
- }
- // test noise
- if (PHY_TYPE_NOISE == phy_hdr.type)
- {
- // test frequency noise
- current_chandata = ctx->pbdma.first_chandata;
- for (i=0; i<freq_noise_count; i++)
- {
- if (freq_noise_count != i+1)
- {
- test_fail_unless (0 == memcmp(&freq_noise[i*max_transfer_size], current_chandata->blk.data, MAC_PB520_BYTES));
- }
- else
- {
- // for last chandata
- test_fail_unless (0 == memcmp(&freq_noise[i*max_transfer_size], current_chandata->blk.data, PHY_CARRIER_NB*sizeof(phy_noise_energy_t) - i*MAC_PB520_BYTES));
- }
- current_chandata = PARENT_OF(phy_chandata_t, blk, current_chandata->blk.next);
- }
-
- // test time noise
- for (i=0; i<time_noise_count; i++)
- {
- if (time_noise_count != i+1)
- {
- test_fail_unless (0 == memcmp(&time_noise[i*max_transfer_size], current_chandata->blk.data, MAC_PB520_BYTES));
- current_chandata = PARENT_OF(phy_chandata_t, blk, current_chandata->blk.next);
- }
- else
- {
- // for last chandata
- test_fail_unless (0 == memcmp(&time_noise[i*max_transfer_size], current_chandata->blk.data, MAC_MAX_SYMB_PER_MPDU*sizeof(phy_noise_energy_t) - i*MAC_PB520_BYTES));
- }
- }
-
- // end_chandata
- test_fail_unless((maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PBDMA))
- && (0 == ctx->pbdma.status_word.bf.pb_null)
- && (0 == ctx->pbdma.status_word.bf.null_pb_index)
- && (0 == ctx->pbdma.status_word.bf.pb_it)
- && (0 == ctx->pbdma.status_word.bf.end_rx_pb)
- && (1 == ctx->pbdma.status_word.bf.end_chandata));
- (*ctx->control.pbdma_cb) (ctx->control.user_data,
- ctx->pbdma.status_word.value);
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PBDMA);
- }
- // test zero-cross
- if (PHY_TYPE_ZERO_CROSS == phy_hdr.type)
- {
- test_fail_unless ((u32)my_station.current_tick_tck == ctx->control.zero_cross_date);
- }
- }
- } test_end;
-}
-
-void maximus_phy_recv_mpdu_payload_sound_test_case(test_t t)
-{
- sci_msg_t msg;
- unsigned char buffer[SCI_MSG_MAX_SIZE];
-
- printf("recv sound\n");
- test_case_begin(t, "recv sound");
-
- 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))
- && (EINVAL != errno));
- msg.length = 0;
- } test_end;
-
- test_begin(t, "recv sound")
- {
- // phy header
- phy_msg_hdr_t phy_hdr;
- u32 iv[3];
- u32 nek[4];
- pb_measurement_t pb_measurement[MAXIMUS_PHY_SOUND_MAX_PB_NB];
- u32 pb_header[MAXIMUS_PHY_SOUND_MAX_PB_NB];
-
- // sci header
- sci_msg_hdr_t sci_hdr;
-
- // sci data
- u8 pb_data[MAXIMUS_PHY_SOUND_MAX_PB_NB][MAC_PB520_BYTES];
-
- u8 null_pb[MAC_PB520_BYTES];
- unsigned short int pb_counter = 0;
-
- // initialize sci data
- memset(iv, 0, 3*sizeof(u32));
- memset(nek, 0, 4*sizeof(u32));
- memset(pb_measurement, 0, MAXIMUS_PHY_SOUND_MAX_PB_NB*sizeof(pb_measurement_t));
- memset(pb_header, 0, MAXIMUS_PHY_SOUND_MAX_PB_NB*sizeof(u32));
- memset(pb_data, 0x00, MAXIMUS_PHY_SOUND_MAX_PB_NB*MAC_PB520_BYTES*sizeof(u8));
-
- // fill the phy header
- phy_hdr.version = PHY_VERSION;
- phy_hdr.type = PHY_TYPE_MPDU_PAYLOAD;
- phy_hdr.mpdu_format = PHY_MPDU_FORMAT_SOUND;
- phy_hdr.pb_nb = MAXIMUS_PHY_SOUND_MAX_PB_NB;
- phy_hdr.msg_nb = 1;
- phy_hdr.fc_mode = PHY_FC_MODE_AV_2;
- phy_hdr.short_ppdu = 0;
- phy_hdr.mod = PHY_MOD_ROBO;
- phy_hdr.fecrate = PHY_FEC_RATE_1_2;
- phy_hdr.gil = PHY_GIL_417;
- phy_hdr.tonemap_index = 0;
- phy_hdr.reserved = 0;
- phy_hdr.tx_id = 10;
- phy_hdr.flags = htons(0x0006);
- phy_hdr.symbol_nb = 0;
- memcpy(phy_hdr.iv, iv, 3*sizeof(uint32_t));
- memcpy(phy_hdr.nek, nek, 4*sizeof(uint32_t));
- memcpy(phy_hdr.pb_measurement, pb_measurement, MAXIMUS_PHY_SOUND_MAX_PB_NB*sizeof(uint32_t));
- memcpy(phy_hdr.pb_header, pb_header, MAXIMUS_PHY_SOUND_MAX_PB_NB*sizeof(uint32_t));
-
- // set RX parameters
- ctx->control.rx_param.fc_mode = phy_hdr.fc_mode;
- ctx->control.rx_param.short_ppdu = false;
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_RX_MPDU;
- // indicate that RX has been prepared
- ctx->control.rx_prepared = true;
-
- /* Fill the sci data. */
- for (pb_counter = 0; pb_counter < phy_hdr.pb_nb; pb_counter++)
- {
- test_fail_unless (0 <= sci_msg_push (&msg, MAC_PB520_BYTES)
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, &pb_data[pb_counter][0], MAC_PB520_BYTES);
- }
-
- // phy header
- test_fail_unless (0 <= sci_msg_push (&msg, sizeof (phy_msg_hdr_t))
- && (EINVAL != errno)
- && (ENOSPC != errno));
- memcpy(msg.data_begin, &phy_hdr, sizeof(phy_msg_hdr_t));
-
- // fill the sci header
- memcpy((unsigned char *)&sci_hdr.magic_id, SCI_MSG_MAGIC, 4);
- sci_hdr.version = SCI_MSG_VERSION;
- sci_hdr.type = SCI_MSG_TYPE_PHY;
- sci_hdr.flags = 0;
- sci_hdr.station_id = my_station.id;
- sci_hdr.length = msg.length - sizeof(sci_msg_hdr_t);
- sci_hdr.msg_id = my_station.sci->current_msg_id | SCI_MSG_ID_STATION;
- sci_hdr.netclock_high = my_station.current_tick_tck >> 32;
- sci_hdr.netclock_low = my_station.current_tick_tck & 0xffffffff;
- msg.sci_hdr = &sci_hdr;
-
- test_fail_unless ((0 <= (maximus_phy_recv(&msg, ctx)))
- && (EINVAL != errno)
- && (EPROTO != 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.fc_mode == msg.hdr.phy->fc_mode)
- && (phy_hdr.short_ppdu == msg.hdr.phy->short_ppdu)
- && (phy_hdr.mod == msg.hdr.phy->mod)
- && (phy_hdr.fecrate == msg.hdr.phy->fecrate)
- && (phy_hdr.gil == msg.hdr.phy->gil)
- && (phy_hdr.tonemap_index == msg.hdr.phy->tonemap_index)
- && (phy_hdr.tx_id == msg.hdr.phy->tx_id)
- && (phy_hdr.flags == msg.hdr.phy->flags)
- && (phy_hdr.reserved == msg.hdr.phy->reserved)
- && (phy_hdr.symbol_nb == msg.hdr.phy->symbol_nb)
- && (0 == memcmp(phy_hdr.iv, msg.hdr.phy->iv, 3*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.nek, msg.hdr.phy->nek, 4*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_measurement, msg.hdr.phy->pb_measurement, msg.hdr.phy->pb_nb*sizeof(uint32_t)))
- && (0 == memcmp(phy_hdr.pb_header, msg.hdr.phy->pb_header, msg.hdr.phy->pb_nb*sizeof(uint32_t))));
-
- // test PBs
- memset(null_pb, 0, MAC_PB520_BYTES);
- for (pb_counter = 0; pb_counter < phy_hdr.pb_nb; pb_counter++)
- {
- test_fail_unless (0 == pb_header[pb_counter]);
- test_fail_unless (0 == memcmp(&pb_measurement[pb_counter], null_pb, sizeof(pb_measurement_t)));
- test_fail_unless (0 == memcmp(&pb_data[pb_counter][0], null_pb, MAC_PB520_BYTES*sizeof(u8)));
- }
-
- test_fail_unless (!ctx->control.rx_prepared);
- } test_end;
-}
-
-void phy_init_test_case(test_t t)
-{
- printf("init\n");
- test_case_begin(t, "init");
-
- test_begin(t, "init")
- {
- ctx = phy_init ((void*)&user_data,
- &phy_rx_fc_cb,
- &phy_access_cb,
- &phy_access_conf_cb,
- &phy_pbdma_cb,
- &phy_tx_false_alarm_cb,
- &phy_deferred_cb);
- test_fail_unless ((EINVAL != errno)
- && (NULL != ctx)
- && (1234567890 == *((int*)ctx->control.user_data))
- && (&phy_rx_fc_cb == ctx->control.rx_fc_cb)
- && (&phy_access_cb == ctx->control.access_cb)
- && (&phy_access_conf_cb == ctx->control.access_conf_cb)
- && (&phy_pbdma_cb == ctx->control.pbdma_cb)
- && (&phy_tx_false_alarm_cb == ctx->control.tx_false_alarm_cb)
- && (&phy_deferred_cb == ctx->control.deferred_cb)
- && !ctx->pbdma.chandata_transfer
- && ctx->access.prp_result);
- ctx->warning_assert = true;
- } test_end;
-
- test_begin(t, "rx fc cb")
- {
- test_fail_unless ((NULL != ctx->control.rx_fc_cb)
- && ((*ctx->control.rx_fc_cb)(ctx->control.user_data, (u32)my_station.current_tick_tck, ctx->control.rx_param.fc_av)));
- } test_end;
-
- test_begin(t, "deferred cb")
- {
- test_fail_unless (NULL != ctx->control.deferred_cb);
- (*ctx->control.deferred_cb)(ctx->control.user_data);
- } test_end;
-
- maximus_pending_isrs = 0;
-
- return;
-}
-
-void phy_zero_cross_init_test_case(test_t t)
-{
- printf("zero cross init\n");
- test_case_begin(t, "zero cross init");
-
- test_begin(t, "zero cross init")
- {
- phy_zero_cross_init (ctx, &phy_zero_cross_cb);
- test_fail_unless ((NULL != ctx->control.zero_cross_cb)
- && ((*ctx->control.zero_cross_cb)(ctx->control.user_data, ctx->control.zero_cross_date)));
- } test_end;
-
- return;
-}
-void phy_reset_test_case(test_t t)
-{
- printf("reset\n");
- test_case_begin(t, "reset");
-
- test_begin(t, "reset")
- {
- // save tmdma data
- uint carrier_nb = ctx->tmdma.carrier_nb;
- u8 tonemask[(PHY_CARRIER_NB+7)/8]; // uses 192 bytes (1 bit per carrier)
- u8 tonemap1_data[TONEMAP_INDEX_NB][MAC_PB520_BYTES];
- u8 tonemap2_data[TONEMAP_INDEX_NB][(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES]; // 4 bits per carrier
- unsigned short int tonemap_index;
- memcpy(tonemask, ctx->tmdma.tonemask, (PHY_CARRIER_NB+7)/8);
- memset(tonemap1_data, '\0', TONEMAP_INDEX_NB*MAC_PB520_BYTES);
- memset(tonemap2_data, '\0', TONEMAP_INDEX_NB*((PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES));
- for (tonemap_index=0; tonemap_index<TONEMAP_INDEX_NB; tonemap_index++)
- {
- memcpy(&tonemap1_data[tonemap_index][0], ctx->tmdma.tonemap[tonemap_index]->data, MAC_PB520_BYTES);
- memcpy(&tonemap2_data[tonemap_index][0], ctx->tmdma.tonemap[tonemap_index]->next->data, (PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES);
- }
-
- phy_reset (ctx);
- test_fail_unless ((EINVAL != errno)
- && (NULL != ctx)
- && (NULL != (int*)ctx->control.user_data)
- && (NULL != (unsigned long*)ctx->control.extra_timer_user_data)
- && (NULL != ctx->control.rx_fc_cb)
- && (NULL != ctx->control.access_cb)
- && (NULL != ctx->control.access_conf_cb)
- && (NULL != ctx->control.pbdma_cb)
- && (NULL != ctx->control.tx_false_alarm_cb)
- && (NULL != ctx->control.zero_cross_cb)
- && (NULL != ctx->control.deferred_cb)
- && (NULL != ctx->control.extra_timer_cb)
- && (NULL != ctx->access.backoff_start_netclock_cb)
- && (NULL != ctx->access.backoff_slot_count_netclock_cb)
- && (NULL != ctx->access.timer_program_netclock_cb)
- && (NULL != ctx->control.next_tx_param.tx_frame_netclock_cb)
- && (NULL != ctx->control.current_tx_param.tx_frame_netclock_cb)
- && (NULL != ctx->control.rx_param.rx_activate_netclock_cb)
- && (NULL != ctx->control.extra_timer_program_netclock_cb)
- && (carrier_nb == ctx->tmdma.carrier_nb)
- && (0 == memcmp(tonemask, ctx->tmdma.tonemask, (PHY_CARRIER_NB+7)/8))
- && ctx->access.prp_result);
-
- // check tonemap data
- for (tonemap_index=0; tonemap_index<TONEMAP_INDEX_NB; tonemap_index++)
- {
- test_fail_unless ((0 == memcmp(&tonemap1_data[tonemap_index][0], ctx->tmdma.tonemap[tonemap_index]->data, MAC_PB520_BYTES))
- && (0 == memcmp(&tonemap2_data[tonemap_index][0], ctx->tmdma.tonemap[tonemap_index]->next->data, (PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES)));
- }
- } test_end;
-
- return;
-}
-
-void phy_uninit_test_case(test_t t)
-{
- netclock_id_t id;
- u32 date = (u32)my_station.current_tick_tck;
-
- printf("uninit\n");
- test_case_begin(t, "uninit");
-
- phy_extra_timer_program (ctx, date);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "extra timer program netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_extra_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.extra_timer_program_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- id = ctx->control.extra_timer_program_netclock_id;
-
- test_begin(t, "uninit")
- {
- char data[sizeof(phy_t)];
-
- memset(data, '\0', sizeof(phy_t));
- phy_uninit (ctx);
- test_fail_unless ((EINVAL != errno)
- && (NULL != ctx)
- && (0 == memcmp(ctx, data, sizeof(phy_t))));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "extra timer cancel netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- maximus_pending_isrs = 0;
-
- return;
-}
-
-void phy_deferred_schedule_test_case (test_t t)
-{
- printf ("deferred schedule\n");
- test_case_begin (t, "deferred schedule");
-
- test_begin (t, "NULL ctx")
- {
- dbg_fatal_try_begin
- {
- phy_deferred_schedule (NULL);
- test_fail_unless (EINVAL == errno);
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf ("deferred schedule with NULL ctx\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- /* reset errno */
- errno = 0;
- } test_end;
-
- return;
-}
-
-void phy_date_test_case(test_t t)
-{
- printf("date\n");
- test_case_begin(t, "date");
-
- test_begin(t, "date")
- {
- my_station.current_tick_tck = 5;
- test_fail_unless (((u32)my_station.current_tick_tck == phy_date())
- && (EINVAL != errno));
- } test_end;
-
- return;
-}
-
-void phy_seed_test_case(test_t t)
-{
- printf("seed\n");
- test_case_begin(t, "seed");
-
- test_begin(t, "seed")
- {
- my_station.seed = 0x12345678;
- test_fail_unless ((my_station.seed == phy_seed())
- && (EINVAL != errno));
- } test_end;
-
- return;
-}
-
-void phy_tx_fc10_test_case(test_t t)
-{
- printf("tx fc10\n");
- test_case_begin(t, "tx fc10");
-
- test_begin(t, "tx fc10")
- {
- u32 fc_10 = 10;
- phy_tx_fc10 (ctx, 0, fc_10);
- test_fail_unless ((EINVAL != errno)
- && (fc_10 == ctx->control.next_tx_param.fc_10)
- && (my_station.current_tick_tck + PHY_FC_10_PREPARATION_DELAY_TCK == ctx->control.next_tx_param.fc_10_tick));
- } test_end;
-
- return;
-}
-
-void phy_tx_param_test_case(test_t t)
-{
- phy_fc_mode_t fc_mode = PHY_FC_MODE_HYBRID_1;
- bool short_ppdu = false;
- phy_mod_t mod;
- phy_fecrate_t fecrate = PHY_FEC_RATE_16_21;
- phy_pb_size_t pb_size = PHY_PB_SIZE_136;
- phy_gil_t gil = PHY_GIL_417;
- uint tonemap_index = 0;
-
- printf("tx param\n");
- test_case_begin(t, "tx param");
-
- test_begin(t, "tx param with TM modulation")
- {
- mod = PHY_MOD_TM;
-
- phy_tx_param (ctx, fc_mode, PHY_COMBO_PARAMS (mod, fecrate, pb_size),
- gil, 0);
- test_fail_unless((EINVAL != errno)
- && (fc_mode == ctx->control.next_tx_param.fc_mode)
- && (short_ppdu == ctx->control.next_tx_param.short_ppdu)
- && (mod == ctx->control.next_tx_param.mod)
- && (fecrate == ctx->control.next_tx_param.fecrate)
- && (pb_size == ctx->control.next_tx_param.pb_size)
- && (gil == ctx->control.next_tx_param.gil)
- && (tonemap_index == ctx->control.next_tx_param.tonemap_index)
- && (0 == ctx->control.next_tx_param.nb_pb));
- } test_end;
-
- test_begin(t, "tx param with HS ROBO modulation")
- {
- mod = PHY_MOD_HS_ROBO;
-
- phy_tx_param (ctx, fc_mode, PHY_COMBO_PARAMS (mod, fecrate, pb_size),
- gil, 0);
- test_fail_unless((EINVAL != errno)
- && (fc_mode == ctx->control.next_tx_param.fc_mode)
- && (short_ppdu == ctx->control.next_tx_param.short_ppdu)
- && (mod == ctx->control.next_tx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.next_tx_param.fecrate)
- && (PHY_PB_SIZE_520 == ctx->control.next_tx_param.pb_size)
- && (PHY_GIL_417 == ctx->control.next_tx_param.gil)
- && (0 == ctx->control.next_tx_param.tonemap_index)
- && (0 == ctx->control.next_tx_param.nb_pb));
- } test_end;
-
- test_begin(t, "tx param with MINI ROBO modulation")
- {
- mod = PHY_MOD_MINI_ROBO;
-
- phy_tx_param (ctx, fc_mode, PHY_COMBO_PARAMS (mod, fecrate, pb_size),
- gil, 0);
- test_fail_unless((EINVAL != errno)
- && (fc_mode == ctx->control.next_tx_param.fc_mode)
- && (short_ppdu == ctx->control.next_tx_param.short_ppdu)
- && (mod == ctx->control.next_tx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.next_tx_param.fecrate)
- && (PHY_PB_SIZE_136 == ctx->control.next_tx_param.pb_size)
- && (PHY_GIL_567 == ctx->control.next_tx_param.gil)
- && (0 == ctx->control.next_tx_param.tonemap_index)
- && (0 == ctx->control.next_tx_param.nb_pb));
- } test_end;
-
- return;
-}
-
-void phy_tx_param_sound_test_case(test_t t)
-{
- phy_fc_mode_t fc_mode = PHY_FC_MODE_HYBRID_1;
- uint nb_pb = MAXIMUS_PHY_SOUND_MAX_PB_NB;
- phy_mod_t mod;
- phy_fecrate_t fecrate = PHY_FEC_RATE_1_2;
- phy_pb_size_t pb_size = PHY_PB_SIZE_136;
- phy_gil_t gil = PHY_GIL_567;
-
- printf("tx param sound\n");
- test_case_begin(t, "tx param sound");
-
- test_begin(t, "tx param sound with MINI ROBO modulation")
- {
- mod = PHY_MOD_MINI_ROBO;
-
- phy_tx_param_sound (ctx, fc_mode, nb_pb,
- PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil, 0);
- test_fail_unless((EINVAL != errno)
- && (fc_mode == ctx->control.next_tx_param.fc_mode)
- && !ctx->control.next_tx_param.short_ppdu
- && (nb_pb == ctx->control.next_tx_param.nb_pb)
- && (mod == ctx->control.next_tx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.next_tx_param.fecrate)
- && (PHY_PB_SIZE_136 == ctx->control.next_tx_param.pb_size)
- && (PHY_GIL_567 == ctx->control.next_tx_param.gil)
- && (0 == ctx->control.next_tx_param.tonemap_index));
- } test_end;
-
- test_begin(t, "tx param sound with HS ROBO modulation")
- {
- mod = PHY_MOD_HS_ROBO;
- pb_size = PHY_PB_SIZE_520;
- gil = PHY_GIL_417;
-
- phy_tx_param_sound (ctx, fc_mode, nb_pb,
- PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil, 0);
- test_fail_unless((EINVAL != errno)
- && (fc_mode == ctx->control.next_tx_param.fc_mode)
- && !ctx->control.next_tx_param.short_ppdu
- && (nb_pb == ctx->control.next_tx_param.nb_pb)
- && (mod == ctx->control.next_tx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.next_tx_param.fecrate)
- && (PHY_PB_SIZE_520 == ctx->control.next_tx_param.pb_size)
- && (PHY_GIL_417 == ctx->control.next_tx_param.gil)
- && (0 == ctx->control.next_tx_param.tonemap_index));
- } test_end;
-
- test_begin(t, "tx param sound with ROBO modulation")
- {
- mod = PHY_MOD_ROBO;
-
- phy_tx_param_sound (ctx, fc_mode, nb_pb,
- PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil, 0);
- test_fail_unless((EINVAL != errno)
- && (fc_mode == ctx->control.next_tx_param.fc_mode)
- && !ctx->control.next_tx_param.short_ppdu
- && (nb_pb == ctx->control.next_tx_param.nb_pb)
- && (mod == ctx->control.next_tx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.next_tx_param.fecrate)
- && (PHY_PB_SIZE_520 == ctx->control.next_tx_param.pb_size)
- && (PHY_GIL_417 == ctx->control.next_tx_param.gil)
- && (0 == ctx->control.next_tx_param.tonemap_index));
- } test_end;
-
- return;
-}
-
-void phy_tx_frame_test_case(test_t t)
-{
- u32 date = 10;
- u32 date2 = 500000;
- u32 date3 = 300000;
- bool want_conf = true;
- bool stop_tx_on_prp_lost = true;
- u32 fc_av[4];
- tick_t msg_tick_tck;
- netclock_id_t id;
-
- // for tonemask
- uint carrier_nb = PHY_CARRIER_NB;
- u8 tonemask[(PHY_CARRIER_NB+7)/8];
-
- // for tonemap
- blk_t tonemap1;
- blk_t tonemap2;
- u8 tonemap1_data[MAC_PB520_BYTES];
- u8 tonemap2_data[(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES];
- uint tonemap_index = 0;
-
- printf("tx frame\n");
- test_case_begin(t, "tx frame");
-
- // set tonemask: all carriers enabled
- memset(tonemask, 0x00, ((PHY_CARRIER_NB+7)/8)*sizeof(u8));
- phy_set_tonemask (ctx, (u32 *)tonemask, carrier_nb);
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "tonemask phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_TONEMASK == phy_hdr->type);
-
- // read the remaining part of message
- test_fail_unless (sizeof(uint) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint)));
- test_fail_unless ((PHY_CARRIER_NB+7)/8 == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(uint), (PHY_CARRIER_NB+7)/8));
-
- // check phy data
- test_fail_unless (0 == memcmp(&carrier_nb, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint)));
- test_fail_unless (0 == memcmp(tonemask, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(uint), (PHY_CARRIER_NB+7)/8));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // set tonemap: QAM1024 for all carriers
- memset(tonemap1_data, 0x77, MAC_PB520_BYTES*sizeof(u8));
- memset(tonemap2_data, 0x77, ((PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES)*sizeof(u8));
- tonemap2.next = NULL;
- tonemap2.data = tonemap2_data;
- tonemap1.next = &tonemap2;
- tonemap1.data = tonemap1_data;
- ctx->control.next_tx_param.mod = PHY_MOD_TM;
- phy_set_tonemap (ctx, &tonemap1);
-
- // set fc av
- memset(&fc_av, '\0', 4*sizeof(u32));
- fc_av[0] = 0x00000001; // DT_AV = SOF
-
- // set PHY context for transmission/reception time calculation
- ctx->control.next_tx_param.fecrate = PHY_FEC_RATE_1_2;
- ctx->control.next_tx_param.gil = PHY_GIL_417;
- ctx->control.next_tx_param.pb_size = PHY_PB_SIZE_520;
- ctx->control.next_tx_param.mod = PHY_MOD_TM;
- ctx->pbdma.nb_total = PHY_PB_MAX_NB;
- ctx->pbdma.nb_pb_it = ctx->pbdma.nb_total;
- ctx->control.next_tx_param.short_ppdu = false;
- ctx->control.next_tx_param.tonemap_index = tonemap_index;
-
- test_begin(t, "tx frame")
- {
- phy_tx_frame (ctx, date, want_conf, stop_tx_on_prp_lost, fc_av);
- test_fail_unless ((EINVAL != errno)
- && (stop_tx_on_prp_lost == ctx->control.stop_tx_on_prp_lost)
- && (0 == memcmp(fc_av, ctx->control.next_tx_param.fc_av, 4*sizeof(u32))));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "first netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless (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));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the first callback
-
- test_begin(t, "maximus phy tx frame cb with FC 1.0 not ready")
- {
- maximus_phy_tx_frame_t tx_frame;
-
- tx_frame.ctx = ctx;
- tx_frame.want_conf = want_conf;
-
- ctx->control.next_tx_param.fc_10_tick = my_station.current_tick_tck + 1;
-
- dbg_fatal_try_begin
- {
- maximus_phy_tx_frame_cb ((void*)&tx_frame);
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("maximus phy tx frame cb with FC 1.0 not ready\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
- } test_end;
-
- test_begin(t, "maximus phy tx frame cb")
- {
- maximus_phy_tx_frame_t tx_frame;
-
- tx_frame.ctx = ctx;
- tx_frame.want_conf = want_conf;
-
- ctx->control.next_tx_param.fc_10_tick = my_station.current_tick_tck;
-
- maximus_phy_tx_frame_cb ((void*)&tx_frame);
-
- test_fail_unless ((EINVAL != errno)
- && (maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PHY))
- && (ctx->control.current_cb == ctx->control.access_conf_cb)
- && (ctx->control.current_tx_param.fc_10 == ctx->control.next_tx_param.fc_10)
- && (ctx->control.current_tx_param.fc_10_tick == ctx->control.next_tx_param.fc_10_tick)
- && (ctx->control.current_tx_param.fc_mode == ctx->control.next_tx_param.fc_mode)
- && (ctx->control.current_tx_param.short_ppdu == ctx->control.next_tx_param.short_ppdu)
- && (ctx->control.current_tx_param.mod == ctx->control.next_tx_param.mod)
- && (ctx->control.current_tx_param.fecrate == ctx->control.next_tx_param.fecrate)
- && (ctx->control.current_tx_param.pb_size == ctx->control.next_tx_param.pb_size)
- && (ctx->control.current_tx_param.gil == ctx->control.next_tx_param.gil)
- && (ctx->control.current_tx_param.tonemap_index == ctx->control.next_tx_param.tonemap_index)
- && (ctx->control.current_tx_param.symbol_nb == ctx->control.next_tx_param.symbol_nb)
- && (0 == memcmp(ctx->control.current_tx_param.fc_av, ctx->control.next_tx_param.fc_av, 4*sizeof(u32)))
- && (0 == ctx->control.next_tx_param.tx_frame_netclock_id)
- && (0 != ctx->control.current_tx_param.tx_frame_netclock_id)
- && (ctx->control.current_tx_param.nb_pb == ctx->control.next_tx_param.nb_pb));
- } test_end;
-
- test_begin(t, "maximus phy tx frame cb blocked")
- {
- maximus_phy_tx_frame_t tx_frame;
-
- tx_frame.ctx = ctx;
- tx_frame.want_conf = want_conf;
-
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_WAIT_CONF;
-
- maximus_phy_tx_frame_cb ((void*)&tx_frame);
-
- test_fail_unless ((EINVAL != errno)
- && ctx->control.tx_blocked_on_false_alarm);
-
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_TX;
- } test_end;
-
- test_begin(t, "access conf cb")
- {
- test_fail_unless ((NULL != ctx->control.access_conf_cb)
- && ((*ctx->control.access_conf_cb)(ctx->control.user_data)));
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "second netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
- uint duration_in_ticks;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // set preamble transimission time
- duration_in_ticks = MAXIMUS_PHY_PREAMBLE_DETECTION_DELAY_TCK;
- date += duration_in_ticks;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless(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));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- test_begin(t, "second tx frame")
- {
- phy_tx_frame (ctx, date2, want_conf, stop_tx_on_prp_lost, fc_av);
- test_fail_unless ((EINVAL != errno)
- && (stop_tx_on_prp_lost == ctx->control.stop_tx_on_prp_lost)
- && (0 == memcmp(fc_av, ctx->control.next_tx_param.fc_av, 4*sizeof(u32))));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message of second tx frame")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless (sizeof(netclock_msg_hdr_t) == read(fd_in, &netclock_hdr, sizeof(netclock_msg_hdr_t)));
-
- // check netclock tick value
- test_fail_unless (date2 == ntohl(netclock_hdr.tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // test the second callback
- test_begin(t, "maximus phy tx pre cb")
- {
- maximus_phy_tx_pre_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno) && (EPROTO != errno));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "first phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_PREAMBLE == phy_hdr->type);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "thrid netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
- uint pre_duration = MAC_PREAMBLE_TCK; // in AV mode
- uint fc_duration = MAC_FC_AV_TCK; // in AV mode
- uint duration_in_ticks;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // calculate frame control transimission time
- if ((PHY_FC_MODE_HYBRID_2 == ctx->control.current_tx_param.fc_mode)
- || (PHY_FC_MODE_AV_2 == ctx->control.current_tx_param.fc_mode))
- {
- fc_duration *= 2; // 2 symbols
- }
- if ((PHY_FC_MODE_HYBRID_1 == ctx->control.current_tx_param.fc_mode)
- || (PHY_FC_MODE_HYBRID_2 == ctx->control.current_tx_param.fc_mode))
- {
- pre_duration = MAC_PREAMBLE_HYBRID_TCK; // in Hybrid mode
- fc_duration += MAC_FC_10_TCK; // in Hybrid mode
- }
- duration_in_ticks = (pre_duration \
- - MAXIMUS_PHY_PREAMBLE_DETECTION_DELAY_TCK) \
- + fc_duration \
- + MAXIMUS_PHY_FC_RECEPTION_DELAY_TCK;
- date += duration_in_ticks;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless(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));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the third callback
- test_begin(t, "maximus phy tx fc cb")
- {
- maximus_phy_tx_fc_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno) && (EPROTO != errno));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "second phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_FC_HYBRID_MODE == phy_hdr->type);
-
- // read the remaining part of message
- test_fail_unless (5*sizeof(u32) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), 5*sizeof(u32)));
-
- // check phy data
- test_fail_unless (0 == memcmp(&ctx->control.current_tx_param.fc_10, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(u32)));
- test_fail_unless (0 == memcmp(&ctx->control.current_tx_param.fc_av, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(u32), 4*sizeof(u32)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "fourth netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
- uint bits_per_symbol;
- uint symbol_nb;
- uint duration_in_ticks;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // calculate MPDU payload transimission time
- bits_per_symbol = maximus_dur_bits_per_symbol (ctx->control.current_tx_param.mod,
- ctx->tmdma.tonemask,
- ctx->tmdma.tonemap[ctx->control.current_tx_param.tonemap_index],
- ctx->tmdma.carrier_nb);
- symbol_nb = maximus_dur_symbol_nb (ctx->control.current_tx_param.mod,
- ctx->control.current_tx_param.fecrate,
- ctx->control.current_tx_param.pb_size,
- bits_per_symbol,
- ctx->pbdma.nb_total);
- duration_in_ticks = maximus_dur_data_tck(ctx->control.current_tx_param.gil, symbol_nb) \
- - MAXIMUS_PHY_FC_RECEPTION_DELAY_TCK \
- + MAXIMUS_PHY_MPDU_RECEPTION_DELAY_TCK;
- date += duration_in_ticks;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless(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));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the fourth callback
- phy_pb_t pb[PHY_PB_MAX_NB];
- u8 pb_data[PHY_PB_MAX_NB][MAC_PB520_BYTES];
- test_begin(t, "maximus phy tx mpdu cb")
- {
- int i = 0;
- char c = 'a';
-
- for (i=0; i<PHY_PB_MAX_NB; i++)
- {
- memset(&pb_data[i][0], c, MAC_PB520_BYTES);
- pb[i].pb_tx.blk.data = &pb_data[i][0];
- pb[i].pb_tx.header = i;
- if (PHY_PB_MAX_NB-1 != i)
- {
- pb[i].pb_tx.blk.next = &pb[i+1].pb_tx.blk;
- }
- else
- {
- pb[i].pb_tx.blk.next = NULL;
- }
- c++;
- }
-
- ctx->pbdma.nb_ready = PHY_PB_MAX_NB;
- ctx->pbdma.first_pb = pb;
-
- maximus_phy_tx_mpdu_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (EPROTO != errno)
- && (maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PBDMA))
- && (0 == ctx->pbdma.status_word.bf.pb_null)
- && (0 == ctx->pbdma.status_word.bf.null_pb_index)
- && (1 == ctx->pbdma.status_word.bf.pb_it)
- && (1 == ctx->pbdma.status_word.bf.end_tx_pb));
- // pb_it
- ctx->pbdma.status_word.bf.end_tx_pb = 0;
- (*ctx->control.pbdma_cb) (ctx->control.user_data,
- ctx->pbdma.status_word.value);
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PBDMA);
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "third phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- sci_msg_hdr_t *sci_hdr;
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
- unsigned int pb_counter;
- phy_pb_tx_t *current_pb = &ctx->pbdma.first_pb->pb_tx;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- /* TONEMAP */
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_TONEMAP == phy_hdr->type);
- test_fail_unless (ctx->control.current_tx_param.tx_id == ntohs(phy_hdr->tx_id));
-
- // read the remaining part of message
- test_fail_unless ((PHY_CARRIER_NB+1)/2 == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), (PHY_CARRIER_NB+1)/2));
-
- // check phy data
- test_fail_unless (0 == memcmp(tonemap2_data, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), (PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES));
- test_fail_unless (0 == memcmp(tonemap1_data, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES, MAC_PB520_BYTES));
-
- /* MPDU */
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- // set sci and phy headers pointers
- sci_hdr = (sci_msg_hdr_t *)(data);
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_MPDU_PAYLOAD == phy_hdr->type);
- test_fail_unless (PHY_MPDU_FORMAT_SOF == phy_hdr->mpdu_format);
- test_fail_unless (ctx->pbdma.nb_ready == phy_hdr->pb_nb);
-
- // read the remaining part of message
- test_fail_unless (phy_hdr->pb_nb*MAC_PB520_BYTES == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), phy_hdr->pb_nb*MAC_PB520_BYTES));
-
- // check pb header and phy data
- for (pb_counter = 0; pb_counter < phy_hdr->pb_nb; pb_counter++)
- {
- test_fail_unless (phy_hdr->pb_header[pb_counter] == htonl(current_pb->header));
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+(phy_hdr->pb_nb-1-pb_counter)*MAC_PB520_BYTES, current_pb->blk.data, MAC_PB520_BYTES));
- current_pb = PARENT_OF(phy_pb_tx_t, blk, current_pb->blk.next);
- }
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(sci_hdr->netclock_high))) << 32)
- | (unsigned long long)(ntohl(sci_hdr->netclock_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- test_begin(t, "short ppdu")
- {
- // for phy message
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // test the callback
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_TX;
- ctx->control.current_tx_param.short_ppdu = true;
- maximus_phy_tx_fc_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno) && (EPROTO != errno));
-
- // check that the correct phy message has been sent to Maximus
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_FC_HYBRID_MODE == phy_hdr->type);
-
- // read the remaining part of message
- test_fail_unless (5*sizeof(u32) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), 5*sizeof(u32)));
-
- // check phy data
- test_fail_unless (0 == memcmp(&ctx->control.current_tx_param.fc_10, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(u32)));
- test_fail_unless (0 == memcmp(&ctx->control.current_tx_param.fc_av, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(u32), 4*sizeof(u32)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- id = ctx->control.next_tx_param.tx_frame_netclock_id;
-
- test_begin(t, "third tx frame")
- {
- phy_tx_frame (ctx, date3, want_conf, stop_tx_on_prp_lost, fc_av);
- test_fail_unless ((EINVAL != errno)
- && (stop_tx_on_prp_lost == ctx->control.stop_tx_on_prp_lost)
- && (0 == memcmp(fc_av, ctx->control.next_tx_param.fc_av, 4*sizeof(u32))));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message to cancel second tx frame")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message of third tx frame")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless (sizeof(netclock_msg_hdr_t) == read(fd_in, &netclock_hdr, sizeof(netclock_msg_hdr_t)));
-
- // check netclock tick value
- test_fail_unless (date3 == ntohl(netclock_hdr.tick_low));
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
-
- // reset next tx frame netclock id (because callback will not be called)
- ctx->control.next_tx_param.tx_frame_netclock_id = 0;
- } test_end;
-
- return;
-}
-
-void maximus_phy_tx_frame_sound_test_case(test_t t)
-{
- u32 date = 400000;
- bool want_conf = false;
- bool stop_tx_on_prp_lost = false;
- u32 fc_av[4];
- tick_t msg_tick_tck;
- uint nb_pb = MAXIMUS_PHY_SOUND_MAX_PB_NB;
-
- printf("tx frame (sound)\n");
- test_case_begin(t, "tx frame (sound)");
-
- // set fc av
- memset(&fc_av, '\0', 4*sizeof(u32));
- fc_av[0] = 0x00000004; // DT_AV = SOUND
-
- test_begin(t, "tx frame (sound)")
- {
- phy_tx_frame (ctx, date, want_conf, stop_tx_on_prp_lost, fc_av);
- test_fail_unless ((EINVAL != errno)
- && (stop_tx_on_prp_lost == ctx->control.stop_tx_on_prp_lost)
- && (0 == memcmp(fc_av, ctx->control.next_tx_param.fc_av, 4*sizeof(u32))));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "first netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless (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));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the first callback
- test_begin(t, "maximus phy tx frame cb (sound)")
- {
- maximus_phy_tx_frame_t tx_frame;
-
- tx_frame.ctx = ctx;
- tx_frame.want_conf = want_conf;
-
- ctx->control.next_tx_param.fc_10_tick = my_station.current_tick_tck;
-
- maximus_phy_tx_frame_cb ((void*)&tx_frame);
-
- test_fail_unless ((EINVAL != errno)
- && (0 == maximus_pending_isrs)
- && (ctx->control.current_tx_param.fc_10 == ctx->control.next_tx_param.fc_10)
- && (ctx->control.current_tx_param.fc_10_tick == ctx->control.next_tx_param.fc_10_tick)
- && (ctx->control.current_tx_param.fc_mode == ctx->control.next_tx_param.fc_mode)
- && (ctx->control.current_tx_param.short_ppdu == ctx->control.next_tx_param.short_ppdu)
- && (ctx->control.current_tx_param.mod == ctx->control.next_tx_param.mod)
- && (ctx->control.current_tx_param.fecrate == ctx->control.next_tx_param.fecrate)
- && (ctx->control.current_tx_param.pb_size == ctx->control.next_tx_param.pb_size)
- && (ctx->control.current_tx_param.gil == ctx->control.next_tx_param.gil)
- && (ctx->control.current_tx_param.tonemap_index == ctx->control.next_tx_param.tonemap_index)
- && (ctx->control.current_tx_param.symbol_nb == ctx->control.next_tx_param.symbol_nb)
- && (0 == memcmp(ctx->control.current_tx_param.fc_av, ctx->control.next_tx_param.fc_av, 4*sizeof(u32)))
- && (0 == ctx->control.next_tx_param.tx_frame_netclock_id)
- && (0 != ctx->control.current_tx_param.tx_frame_netclock_id)
- && (ctx->control.current_tx_param.nb_pb == ctx->control.next_tx_param.nb_pb));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "second netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
- uint duration_in_ticks;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // set preamble transimission time
- duration_in_ticks = MAXIMUS_PHY_PREAMBLE_DETECTION_DELAY_TCK;
- date += duration_in_ticks;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless(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));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the second callback
- test_begin(t, "maximus phy tx pre cb (sound)")
- {
- maximus_phy_tx_pre_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno) && (EPROTO != errno));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "first phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_PREAMBLE == phy_hdr->type);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "thrid netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
- uint pre_duration = MAC_PREAMBLE_TCK; // in AV mode
- uint fc_duration = MAC_FC_AV_TCK; // in AV mode
- uint duration_in_ticks;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // calculate frame control transimission time
- if ((PHY_FC_MODE_HYBRID_2 == ctx->control.current_tx_param.fc_mode)
- || (PHY_FC_MODE_AV_2 == ctx->control.current_tx_param.fc_mode))
- {
- fc_duration *= 2; // 2 symbols
- }
- if ((PHY_FC_MODE_HYBRID_1 == ctx->control.current_tx_param.fc_mode)
- || (PHY_FC_MODE_HYBRID_2 == ctx->control.current_tx_param.fc_mode))
- {
- pre_duration = MAC_PREAMBLE_HYBRID_TCK; // in Hybrid mode
- fc_duration += MAC_FC_10_TCK; // in Hybrid mode
- }
- duration_in_ticks = (pre_duration \
- - MAXIMUS_PHY_PREAMBLE_DETECTION_DELAY_TCK) \
- + fc_duration \
- + MAXIMUS_PHY_FC_RECEPTION_DELAY_TCK;
- date += duration_in_ticks;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless(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));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the third callback
- test_begin(t, "maximus phy tx fc cb (sound)")
- {
- maximus_phy_tx_fc_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno) && (EPROTO != errno));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "second phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_FC_HYBRID_MODE == phy_hdr->type);
-
- // read the remaining part of message
- test_fail_unless (5*sizeof(u32) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), 5*sizeof(u32)));
-
- // check phy data
- test_fail_unless (0 == memcmp(&ctx->control.current_tx_param.fc_10, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(u32)));
- test_fail_unless (0 == memcmp(&ctx->control.current_tx_param.fc_av, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(u32), 4*sizeof(u32)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "fourth netclock message")
- {
- sci_msg_hdr_t sci_hdr;
- netclock_msg_hdr_t netclock_hdr;
- int fd_in = -1;
- uint bits_per_symbol;
- uint symbol_nb;
- uint duration_in_ticks;
-
- netclock_callback_t reference;
- set_node_t *found_node;
-
- // calculate MPDU payload transimission time
- bits_per_symbol = maximus_dur_bits_per_symbol (ctx->control.current_tx_param.mod,
- ctx->tmdma.tonemask,
- ctx->tmdma.tonemap[ctx->control.current_tx_param.tonemap_index],
- ctx->tmdma.carrier_nb);
- symbol_nb = maximus_dur_symbol_nb (ctx->control.current_tx_param.mod,
- ctx->control.current_tx_param.fecrate,
- ctx->control.current_tx_param.pb_size,
- bits_per_symbol,
- nb_pb);
- duration_in_ticks = maximus_dur_data_tck(ctx->control.current_tx_param.gil, symbol_nb) \
- - MAXIMUS_PHY_FC_RECEPTION_DELAY_TCK \
- + MAXIMUS_PHY_MPDU_RECEPTION_DELAY_TCK;
- date += duration_in_ticks;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, &sci_hdr, sizeof(sci_msg_hdr_t))));
-
- // read netclock header
- test_fail_unless(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));
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(netclock_hdr.tick_high))) << 32)
- | (unsigned long long)(ntohl(netclock_hdr.tick_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
-
- /* Remove netclock callback. */
-
- // init callback to find
- reference.id = ntohs(netclock_hdr.id);
- set_node_init(&reference.node);
-
- // find it
- test_fail_unless((found_node = set_find(&my_station.netclock->callback_set, &reference.node)) != NULL);
-
- // remove it from callback set
- set_remove(&my_station.netclock->callback_set, found_node);
- } test_end;
-
- // test the fourth callback
- test_begin(t, "maximus phy tx mpdu cb (sound)")
- {
- maximus_phy_tx_mpdu_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (EPROTO != errno));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "third phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- unsigned char null_pb[MAC_PB520_BYTES];
- sci_msg_hdr_t *sci_hdr;
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
- unsigned int pb_counter;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- // set sci and phy headers pointers
- sci_hdr = (sci_msg_hdr_t *)(data);
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_MPDU_PAYLOAD == phy_hdr->type);
- test_fail_unless (PHY_MPDU_FORMAT_SOUND == phy_hdr->mpdu_format);
- test_fail_unless (nb_pb == phy_hdr->pb_nb);
-
- // read the remaining part of message
- test_fail_unless (phy_hdr->pb_nb*MAC_PB520_BYTES == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), phy_hdr->pb_nb*MAC_PB520_BYTES));
-
- // check pb header and phy data
- memset(null_pb, 0, MAC_PB520_BYTES);
- for (pb_counter = 0; pb_counter < phy_hdr->pb_nb; pb_counter++)
- {
- test_fail_unless (phy_hdr->pb_header[pb_counter] == 0);
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+(phy_hdr->pb_nb-1-pb_counter)*MAC_PB520_BYTES, null_pb, MAC_PB520_BYTES));
- }
-
- // get new network tick
- msg_tick_tck = (((unsigned long long)(ntohl(sci_hdr->netclock_high))) << 32)
- | (unsigned long long)(ntohl(sci_hdr->netclock_low));
-
- // update current tick value
- my_station.current_tick_tck = msg_tick_tck;
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- return;
-}
-
-void maximus_phy_send_test_case(test_t t)
-{
- // for tonemap
- blk_t tonemap1;
- blk_t tonemap2;
- u8 tonemap1_data[MAC_PB520_BYTES];
- u8 tonemap2_data[(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES];
-
- printf("maximus phy send\n");
- test_case_begin(t, "maximus phy send");
-
- // set tonemap
- memset(tonemap1_data, '1', MAC_PB520_BYTES*sizeof(u8));
- memset(tonemap2_data, '2', ((PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES)*sizeof(u8));
- tonemap2.next = NULL;
- tonemap2.data = tonemap2_data;
- tonemap1.next = &tonemap2;
- tonemap1.data = tonemap1_data;
- phy_set_tonemap (ctx, &tonemap1);
- ctx->control.current_tx_param.mod = PHY_MOD_ROBO;
-
- // set medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY_TX;
-
- test_begin(t, "maximus phy tx mpdu cb")
- {
- u8 pb_data[PHY_PB_NB][MAC_PB520_BYTES];
- phy_pb_t phy_pb[PHY_PB_NB];
- unsigned short int pb_counter = 0;
- char c = 0x00;
- u32 hdr = 0;
-
- unsigned short int msg_nb = 1;
- uint8_t last_msg_pb_nb = PHY_PB_MAX_NB;
- unsigned short int msg_counter = 0;
- uint8_t pb_nb = PHY_PB_NB;
- phy_pb_tx_t *current_pb;
-
- if (PHY_PB_NB > PHY_PB_MAX_NB)
- {
- msg_nb = (unsigned short int)(PHY_PB_NB/PHY_PB_MAX_NB);
- pb_nb = PHY_PB_MAX_NB;
- if (0 != (PHY_PB_NB % PHY_PB_MAX_NB))
- {
- last_msg_pb_nb = (uint8_t)(PHY_PB_NB % PHY_PB_MAX_NB);
- msg_nb++;
- }
- }
-
- // set pb dma
- ctx->pbdma.first_pb = phy_pb;
- ctx->pbdma.nb_total = PHY_PB_NB;
- ctx->pbdma.nb_ready = PHY_PB_NB;
- ctx->pbdma.nb_pb_it = PHY_PB_NB-1;
-
- current_pb = &ctx->pbdma.first_pb->pb_tx;
-
- for (pb_counter = 0; pb_counter < PHY_PB_NB; pb_counter++)
- {
- memset(&pb_data[pb_counter][0], c, MAC_PB520_BYTES);
- phy_pb[pb_counter].pb_tx.blk.data = &pb_data[pb_counter][0];
- phy_pb[pb_counter].pb_tx.header = hdr;
- phy_pb[pb_counter].pb_tx.blk.next = &phy_pb[pb_counter+1].pb_tx.blk;
- if (PHY_PB_NB-1 == pb_counter)
- {
- phy_pb[pb_counter].pb_tx.blk.next = NULL;
- }
- c++;
- hdr += 10;
- }
-
- maximus_phy_tx_mpdu_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (EPROTO != errno)
- && (maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PBDMA))
- && (0 == ctx->pbdma.status_word.bf.pb_null)
- && (0 == ctx->pbdma.status_word.bf.null_pb_index)
- && (1 == ctx->pbdma.status_word.bf.pb_it)
- && (1 == ctx->pbdma.status_word.bf.end_tx_pb));
- // pb_it
- ctx->pbdma.status_word.bf.end_tx_pb = 0;
- (*ctx->control.pbdma_cb) (ctx->control.user_data,
- ctx->pbdma.status_word.value);
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PBDMA);
-
- // check that the correct phy messages have been sent to Maximus
-
- for (msg_counter = 0; msg_counter < msg_nb; msg_counter++)
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- if ((1 != msg_nb) && (msg_nb-1 == msg_counter))
- {
- pb_nb = last_msg_pb_nb;
- }
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_MPDU_PAYLOAD == phy_hdr->type);
- test_fail_unless (pb_nb == phy_hdr->pb_nb);
-
- // read the remaining part of message
- test_fail_unless (phy_hdr->pb_nb*MAC_PB520_BYTES == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), phy_hdr->pb_nb*MAC_PB520_BYTES));
-
- // check pb header and phy data
- for (pb_counter = 0; pb_counter < phy_hdr->pb_nb; pb_counter++)
- {
- test_fail_unless (phy_hdr->pb_header[pb_counter] == htonl(current_pb->header));
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+(phy_hdr->pb_nb-1-pb_counter)*MAC_PB520_BYTES, current_pb->blk.data, MAC_PB520_BYTES));
- current_pb = PARENT_OF(phy_pb_tx_t, blk, current_pb->blk.next);
- }
- // close pipe
- maximus_phy_close(fd_in);
- }
- } test_end;
-
- // set tx id
- ctx->control.current_tx_param.tx_id = 20;
-
- // test the tonemap transmission
- test_begin(t, "maximus phy send tonemap")
- {
- test_fail_unless ((0 == maximus_phy_send_tonemap(ctx))
- && (EINVAL != errno)
- && (EPROTO != errno));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "tonemap phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_TONEMAP == phy_hdr->type);
- test_fail_unless (ctx->control.current_tx_param.tx_id == ntohs(phy_hdr->tx_id));
-
- // read the remaining part of message
- test_fail_unless ((PHY_CARRIER_NB+1)/2 == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), (PHY_CARRIER_NB+1)/2));
-
- // check phy data
- test_fail_unless (0 == memcmp(tonemap2_data, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), (PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES));
- test_fail_unless (0 == memcmp(tonemap1_data, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES, MAC_PB520_BYTES));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // test send RX
- test_begin(t, "maximus phy send rx")
- {
- test_fail_unless ((0 == maximus_phy_send_rx(ctx))
- && (EINVAL != errno)
- && (EPROTO != errno));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "rx phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_RX == phy_hdr->type);
- test_fail_unless (ctx->control.rx_param.src_tx_id == ntohs(phy_hdr->tx_id));
-
- // read source station ID
- test_fail_unless (sizeof(uint16_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint16_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), &ctx->control.rx_param.src_station_id, sizeof(uint16_t)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-}
-
-void phy_rx_param_test_case(test_t t)
-{
- printf("rx param\n");
- test_case_begin(t, "rx param");
-
- test_begin(t, "rx param")
- {
- phy_fc_mode_t fc_mode = PHY_FC_MODE_HYBRID_2;
-
- phy_rx_param (ctx, fc_mode);
- test_fail_unless ((EINVAL != errno)
- && (fc_mode == ctx->control.rx_param.fc_mode));
- } test_end;
-
- return;
-}
-
-void phy_rx_activate_test_case(test_t t)
-{
- u32 date = 1234567891;
- bool pre_detection = true;
- bool now = false;
- netclock_id_t id1, id2;
- uint cap = 3;
-
- printf("rx activate\n");
- test_case_begin(t, "rx activate");
-
- test_begin(t, "rx activate")
- {
- phy_rx_activate (ctx, now, date, pre_detection);
- test_fail_unless(EINVAL != errno);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "rx activate netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci header and netclock header
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr->tick_low));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.rx_param.rx_activate_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- phy_access_backoff_start (ctx, date+10, cap);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "backoff start netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date+10 == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_access_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->access.backoff_start_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- pre_detection = false;
- id1 = ctx->control.rx_param.rx_activate_netclock_id;
- id2 = ctx->access.backoff_start_netclock_id;
-
- test_begin(t, "rx activate")
- {
- phy_rx_activate (ctx, now, date+1, pre_detection);
- test_fail_unless(EINVAL != errno);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "cancel rx activate netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id1);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "cancel backoff start netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id2);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "rx activate netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date+1 == ntohl(netclock_hdr->tick_low));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.rx_param.rx_activate_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- bool prp_result = ctx->access.prp_result;
-
- // test the callback
- test_begin(t, "maximus rx activate cb")
- {
- maximus_phy_rx_activate_t rx_activate;
- rx_activate.ctx = ctx;
- rx_activate.pre_detection = pre_detection;
-
- maximus_phy_rx_activate_cb ((void*)&rx_activate);
- test_fail_unless ((EINVAL != errno)
- && (pre_detection == ctx->control.pre_detection)
- && (prp_result == ctx->access.prp_result));
- } test_end;
-
- now = true;
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_PRS1;
- phy_rx_activate (ctx, now, date, pre_detection);
- test_begin(t, "activate rx now")
- {
- test_fail_unless ((EINVAL != errno)
- && (pre_detection == ctx->control.pre_detection)
- && (prp_result == ctx->access.prp_result)
- && (MAXIMUS_PHY_MEDIUM_IDLE == ctx->access.medium_state));
- } test_end;
-
- pre_detection = true;
- phy_rx_activate (ctx, now, date, pre_detection);
- test_begin(t, "activate rx now")
- {
- test_fail_unless ((EINVAL != errno)
- && (pre_detection == ctx->control.pre_detection)
- && ctx->access.prp_result);
- } test_end;
-
- return;
-}
-
-void phy_rx_prepare_test_case(test_t t)
-{
- bool short_ppdu = false;
- phy_mod_t mod;
- phy_fecrate_t fecrate = PHY_FEC_RATE_1_2;
- phy_pb_size_t pb_size = PHY_PB_SIZE_136;
- phy_gil_t gil = PHY_GIL_417;
- uint tonemap_index = 0;
- uint symbol_nb = 0;
-
- printf("rx prepare\n");
- test_case_begin(t, "rx prepare");
-
- test_begin(t, "rx prepare with TM modulation")
- {
- mod = PHY_MOD_TM;
-
- phy_rx_prepare (ctx, 1, PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil,
- symbol_nb, 1);
- test_fail_unless ((EINVAL != errno)
- && (short_ppdu == ctx->control.rx_param.short_ppdu)
- && (mod == ctx->control.rx_param.mod)
- && (fecrate == ctx->control.rx_param.fecrate)
- && (pb_size == ctx->control.rx_param.pb_size)
- && (gil == ctx->control.rx_param.gil)
- && (tonemap_index == ctx->control.rx_param.tonemap_index)
- && (symbol_nb == ctx->control.rx_param.symbol_nb)
- && ctx->control.rx_prepared
- && (0 == ctx->pbdma.index_current_pb));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "rx phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_RX == phy_hdr->type);
- test_fail_unless (ctx->control.rx_param.src_tx_id == ntohs(phy_hdr->tx_id));
-
- // read source station ID
- test_fail_unless (sizeof(uint16_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint16_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), &ctx->control.rx_param.src_station_id, sizeof(uint16_t)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- test_begin(t, "rx prepare with ROBO modulation")
- {
- mod = PHY_MOD_ROBO;
-
- phy_rx_prepare (ctx, 1, PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil,
- symbol_nb, 1);
- test_fail_unless ((EINVAL != errno)
- && (short_ppdu == ctx->control.rx_param.short_ppdu)
- && (mod == ctx->control.rx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.rx_param.fecrate)
- && (PHY_PB_SIZE_520 == ctx->control.rx_param.pb_size)
- && (PHY_GIL_417 == ctx->control.rx_param.gil)
- && (0 == ctx->control.rx_param.tonemap_index)
- && (symbol_nb == ctx->control.rx_param.symbol_nb)
- && ctx->control.rx_prepared
- && (0 == ctx->pbdma.index_current_pb));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "rx phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_RX == phy_hdr->type);
- test_fail_unless (ctx->control.rx_param.src_tx_id == ntohs(phy_hdr->tx_id));
-
- // read source station ID
- test_fail_unless (sizeof(uint16_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint16_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), &ctx->control.rx_param.src_station_id, sizeof(uint16_t)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- test_begin(t, "rx prepare with MINI ROBO modulation")
- {
- mod = PHY_MOD_MINI_ROBO;
-
- phy_rx_prepare (ctx, 1, PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil,
- symbol_nb, 1);
- test_fail_unless ((EINVAL != errno)
- && (short_ppdu == ctx->control.rx_param.short_ppdu)
- && (mod == ctx->control.rx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.rx_param.fecrate)
- && (PHY_PB_SIZE_136 == ctx->control.rx_param.pb_size)
- && (PHY_GIL_567 == ctx->control.rx_param.gil)
- && (0 == ctx->control.rx_param.tonemap_index)
- && (symbol_nb == ctx->control.rx_param.symbol_nb)
- && ctx->control.rx_prepared
- && (0 == ctx->pbdma.index_current_pb));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "rx phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_RX == phy_hdr->type);
- test_fail_unless (ctx->control.rx_param.src_tx_id == ntohs(phy_hdr->tx_id));
-
- // read source station ID
- test_fail_unless (sizeof(uint16_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint16_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), &ctx->control.rx_param.src_station_id, sizeof(uint16_t)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- return;
-}
-
-void phy_rx_prepare_sound_test_case(test_t t)
-{
- phy_mod_t mod;
- phy_fecrate_t fecrate = PHY_FEC_RATE_1_2;
- phy_pb_size_t pb_size = PHY_PB_SIZE_520;
- phy_gil_t gil = PHY_GIL_417;
- uint symbol_nb = 100;
-
- printf("rx prepare sound\n");
- test_case_begin(t, "rx prepare sound");
-
- test_begin(t, "rx prepare sound with ROBO modulation")
- {
- mod = PHY_MOD_ROBO;
-
- phy_rx_prepare_sound (ctx, 0,
- PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil,
- symbol_nb);
- test_fail_unless ((EINVAL != errno)
- && !ctx->control.rx_param.short_ppdu
- && (mod == ctx->control.rx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.rx_param.fecrate)
- && (PHY_PB_SIZE_520 == ctx->control.rx_param.pb_size)
- && (PHY_GIL_417 == ctx->control.rx_param.gil)
- && (0 == ctx->control.rx_param.tonemap_index)
- && (symbol_nb == ctx->control.rx_param.symbol_nb)
- && ctx->control.rx_prepared
- && (0 == ctx->pbdma.index_current_pb));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "rx phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_RX == phy_hdr->type);
- test_fail_unless (ctx->control.rx_param.src_tx_id == ntohs(phy_hdr->tx_id));
-
- // read source station ID
- test_fail_unless (sizeof(uint16_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint16_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), &ctx->control.rx_param.src_station_id, sizeof(uint16_t)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- test_begin(t, "rx prepare sound with MINI ROBO modulation")
- {
- mod = PHY_MOD_MINI_ROBO;
- pb_size = PHY_PB_SIZE_136;
- gil = PHY_GIL_567;
-
- phy_rx_prepare_sound (ctx, 0,
- PHY_COMBO_PARAMS (mod, fecrate, pb_size), gil,
- symbol_nb);
- test_fail_unless ((EINVAL != errno)
- && !ctx->control.rx_param.short_ppdu
- && (mod == ctx->control.rx_param.mod)
- && (PHY_FEC_RATE_1_2 == ctx->control.rx_param.fecrate)
- && (PHY_PB_SIZE_136 == ctx->control.rx_param.pb_size)
- && (PHY_GIL_567 == ctx->control.rx_param.gil)
- && (0 == ctx->control.rx_param.tonemap_index)
- && (symbol_nb == ctx->control.rx_param.symbol_nb)
- && ctx->control.rx_prepared
- && (0 == ctx->pbdma.index_current_pb));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "rx phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_RX == phy_hdr->type);
- test_fail_unless (ctx->control.rx_param.src_tx_id == ntohs(phy_hdr->tx_id));
-
- // read source station ID
- test_fail_unless (sizeof(uint16_t) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint16_t)));
-
- // check phy data
- test_fail_unless (0 == memcmp(data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), &ctx->control.rx_param.src_station_id, sizeof(uint16_t)));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- return;
-}
-
-void phy_rx_fc10_test_case(test_t t)
-{
- printf("rx fc10\n");
- test_case_begin(t, "rx fc10");
-
- test_begin(t, "rx fc10")
- {
- u32 fc_10 = phy_rx_fc10 (ctx);
- test_fail_unless ((EINVAL != errno)
- && (fc_10 == ctx->control.rx_param.fc_10));
- } test_end;
-
- return;
-}
-
-void phy_rx_sysdate_test_case(test_t t)
-{
- printf("rx sysdate\n");
- test_case_begin(t, "rx sysdate");
-
- test_begin(t, "rx sysdate")
- {
- u32 sysdate = phy_rx_sysdate (ctx);
- test_fail_unless ((EINVAL != errno)
- && (sysdate == ctx->control.rx_param.preamble_start_date));
- } test_end;
-
- return;
-}
-
-void phy_extra_timer_init_test_case(test_t t)
-{
- printf("extra timer init\n");
- test_case_begin(t, "extra timer init");
-
- test_begin(t, "extra timer init")
- {
- unsigned long extra_timer_user_data = 6543210;
- phy_extra_timer_init (ctx,
- (void*)&extra_timer_user_data,
- &phy_extra_timer_cb);
- test_fail_unless ((EINVAL != errno)
- && ((void*)&extra_timer_user_data == ctx->control.extra_timer_user_data)
- && (&phy_extra_timer_cb == ctx->control.extra_timer_cb));
- } test_end;
-
- return;
-}
-
-void phy_extra_timer_program_test_case(test_t t)
-{
- u32 date = 1234567899;
- netclock_id_t id = 0;
-
- printf("extra timer program\n");
- test_case_begin(t, "extra timer program");
-
- phy_extra_timer_program (ctx, date);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_extra_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.extra_timer_program_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // test the callback
- test_begin(t, "maximus extra timer cb")
- {
- maximus_phy_extra_timer_cb ((void*)ctx);
- test_fail_unless ((EINVAL != errno)
- && (maximus_pending_isrs & (1 << PHY_HAL_INTERRUPT_PHY))
- && (ctx->control.current_cb == ctx->control.extra_timer_cb));
- } test_end;
-
- test_begin(t, "extra timer cb")
- {
- test_fail_unless ((NULL != ctx->control.extra_timer_cb)
- && ((*ctx->control.extra_timer_cb)(ctx->control.extra_timer_user_data)));
- maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
- } test_end;
-
- id = ctx->control.extra_timer_program_netclock_id;
- phy_extra_timer_program (ctx, date+1);
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "cancel netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "program netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock tick value
- test_fail_unless (date+1 == ntohl(netclock_hdr->tick_low));
-
- // check netclock id for 'phy_access_timer_cancel'
- test_fail_unless (ntohs(netclock_hdr->id) == ctx->control.extra_timer_program_netclock_id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- return;
-}
-
-void phy_extra_timer_cancel_test_case(test_t t)
-{
- netclock_id_t id = 0;
-
- printf("extra timer cancel\n");
- test_case_begin(t, "extra timer cancel");
-
- test_begin(t, "extra timer cancel")
- {
- id = ctx->control.extra_timer_program_netclock_id;
- phy_extra_timer_cancel (ctx);
- test_fail_unless ((EINVAL != errno)
- && (0 == ctx->control.extra_timer_program_netclock_id));
- } test_end;
-
- // check that the correct netclock message has been sent to Maximus
- test_begin(t, "netclock message")
- {
- unsigned char data[256];
- netclock_msg_hdr_t *netclock_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and netclock headers
- memset(data, '\0', 256);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(netclock_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(netclock_msg_hdr_t))));
-
- // set netclock header pointer
- netclock_hdr = (netclock_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check netclock id
- test_fail_unless (ntohs(netclock_hdr->id) == id);
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-
- return;
-}
-
-void maximus_phy_schedule_tick_test_case(test_t t)
-{
- u32 date, tick_high;
-
- printf("schedule tick\n");
- test_case_begin(t, "schedule tick");
-
- test_begin(t, "date now")
- {
- my_station.current_tick_tck = 0x00001234LL;
- date = 0x00001234;
- tick_high = my_station.current_tick_tck >> 32;
- test_fail_unless (((((tick_t)tick_high << 32) | (tick_t)date) == maximus_phy_schedule_tick(date))
- && (EINVAL != errno));
- } test_end;
-
- test_begin(t, "date in the future")
- {
- my_station.current_tick_tck = 0xFFFFFFFF00001234LL;
- date = 0xF0001233;
- tick_high = my_station.current_tick_tck >> 32;
- test_fail_unless (((((tick_t)tick_high << 32) | (tick_t)date) == maximus_phy_schedule_tick(date))
- && (EINVAL != errno));
-
- my_station.current_tick_tck = 0xFFFF1234LL;
- date = 0xFFFF2222;
- tick_high = my_station.current_tick_tck >> 32;
- test_fail_unless (((((tick_t)tick_high << 32) | (tick_t)date) == maximus_phy_schedule_tick(date))
- && (EINVAL != errno));
- } test_end;
-
- test_begin(t, "date after rollover")
- {
- my_station.current_tick_tck = 0x0000000412341234LL;
- date = 0x02341233;
- tick_high = my_station.current_tick_tck >> 32;
- test_fail_unless (((((tick_t)(tick_high+1) << 32) | (tick_t)date) == maximus_phy_schedule_tick(date))
- && (EINVAL != errno));
-
- my_station.current_tick_tck = 0x12341234LL;
- date = 0x00001234;
- tick_high = my_station.current_tick_tck >> 32;
- test_fail_unless (((((tick_t)(tick_high+1) << 32) | (tick_t)date) == maximus_phy_schedule_tick(date))
- && (EINVAL != errno));
-
- my_station.current_tick_tck = 0x00000000FFFFB1E0LL;
- date = 20000;
- test_fail_unless ((0x0000000100004E20LL == maximus_phy_schedule_tick(date))
- && (EINVAL != errno));
- } test_end;
-
- test_begin(t, "date in the past")
- {
- dbg_fatal_try_begin
- {
- my_station.current_tick_tck = 0x12341234LL;
- date = 0x12341233;
- test_fail_unless (((tick_t)-1 == maximus_phy_schedule_tick(date))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("date in the past\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
-
- dbg_fatal_try_begin
- {
- my_station.current_tick_tck = 0x0000FFFF12341234LL;
- date = 0x02341234;
- test_fail_unless (((tick_t)-1 == maximus_phy_schedule_tick(date))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("date in the past\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
-
- dbg_fatal_try_begin
- {
- my_station.current_tick_tck = 0x0000000100000010LL;
- date = 0xFFFFFFF0;
- test_fail_unless (((tick_t)-1 == maximus_phy_schedule_tick(date))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("date in the past\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
-
- dbg_fatal_try_begin
- {
- my_station.current_tick_tck = 0xFFFFFFFF00001234LL;
- date = 0xFFFF0000;
- test_fail_unless (((tick_t)-1 == maximus_phy_schedule_tick(date))
- && (EINVAL == errno));
- }
- dbg_fatal_try_catch (const char *fatal_message)
- {
- printf("date in the past\n%s\n", fatal_message);
- }
- dbg_fatal_try_end;
-
- // reset errno
- errno = 0;
- } test_end;
-
- return;
-}
-
-void phy_ctrl_test_suite(test_t t)
-{
- // reset errno
- errno = 0;
-
- station_init (&my_station);
- station_log_set_level(&my_station, STATION_LOG_DEBUG);
- station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
- //my_station.pipe_log_fd = 1;
-
- test_suite_begin(t, "phy control");
- trace_init();
- phy_init_test_case(t);
- phy_zero_cross_init_test_case(t);
- maximus_phy_get_medium_state_test_case(t);
- maximus_phy_fill_hdr_test_case(t);
- maximus_phy_recv_test_case(t);
- phy_deferred_schedule_test_case (t);
- phy_date_test_case(t);
- phy_seed_test_case(t);
- phy_tx_fc10_test_case(t);
- phy_tx_param_test_case(t);
- phy_tx_frame_test_case(t);
- maximus_phy_send_test_case(t);
- phy_tx_param_sound_test_case(t);
- maximus_phy_tx_frame_sound_test_case(t);
- phy_rx_param_test_case(t);
- phy_rx_activate_test_case(t);
- phy_rx_prepare_test_case(t);
- phy_rx_prepare_sound_test_case(t);
- maximus_phy_recv_mpdu_payload_sound_test_case(t);
- phy_rx_fc10_test_case(t);
- phy_rx_sysdate_test_case(t);
- phy_extra_timer_init_test_case(t);
- phy_extra_timer_program_test_case(t);
- phy_extra_timer_cancel_test_case(t);
- maximus_phy_schedule_tick_test_case(t);
-#if CONFIG_TRACE
- printf("BEGIN_TRACE\n");
- trace_buffer_dbg_dump(&ctx->trace);
- printf("END_TRACE\n");
-#endif
- phy_reset_test_case(t);
- phy_uninit_test_case(t);
- trace_uninit();
-
- station_down (&my_station);
-}
diff --git a/cesar/hal/phy/maximus/test/src/test_phy_maximus.c b/cesar/hal/phy/maximus/test/src/test_phy_maximus.c
deleted file mode 100644
index c898ecd70e..0000000000
--- a/cesar/hal/phy/maximus/test/src/test_phy_maximus.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/maximus/test/src/test_phy_maximus.c
- * \brief HAL Phy main test function for Maximus.
- * \ingroup hal_phy_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "host/station/station.h"
-#include <unistd.h> // for 'open()' and 'close()'
-#include <fcntl.h> // for 'open()' and 'close()'
-
-void bridgedma_test_suite (test_t t);
-void pbdma_test_suite (test_t t);
-void phy_access_test_suite (test_t t);
-void phy_ctrl_test_suite (test_t t);
-void tmdma_test_suite (test_t t);
-void aes_test_suite (test_t t);
-
-uint32_t maximus_pending_isrs;
-station_ctx_t my_station;
-
-bool phy_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av)
-{
- return true;
-}
-
-bool phy_access_cb (void *user)
-{
- return true;
-}
-
-bool phy_access_conf_cb (void *user)
-{
- return true;
-}
-
-bool phy_pbdma_cb (void *user, u32 status_word)
-{
- return true;
-}
-
-bool phy_tx_false_alarm_cb (void *user)
-{
- return true;
-}
-
-bool phy_zero_cross_cb (void *user, const u32 zero_cross_date)
-{
- return true;
-}
-
-void phy_deferred_cb (void *user)
-{
- return;
-}
-
-bool phy_extra_timer_cb (void *user)
-{
- return true;
-}
-
-int
-maximus_phy_open (station_ctx_t *station)
-{
- int fd;
-
- #ifdef STATION_SOCK
- fd = station->sock_pair_fd;
- #else /* STATION_SOCK */
- fd = open(station->pipe_out_name, O_RDONLY);
- #endif /* STATION_SOCK */
-
- return fd;
-}
-
-void
-maximus_phy_close (int fd)
-{
- #ifndef STATION_SOCK
- close(fd);
- #endif /* !STATION_SOCK */
-}
-
-int
-main (int argc, char **argv)
-{
- test_t t;
- test_init(t, argc, argv);
-
- pbdma_test_suite(t);
- phy_access_test_suite(t);
- phy_ctrl_test_suite(t);
- tmdma_test_suite(t);
- aes_test_suite(t);
-
- test_result(t);
- return test_nb_failed(t) == 0 ? 0 : 1;
-}
diff --git a/cesar/hal/phy/maximus/test/src/test_tmdma.c b/cesar/hal/phy/maximus/test/src/test_tmdma.c
deleted file mode 100644
index d16220da36..0000000000
--- a/cesar/hal/phy/maximus/test/src/test_tmdma.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file hal/phy/maximus/test/src/test_tmdma.c
- * \brief HAL Phy Tone Map DMA test functions for Maximus.
- * \ingroup hal_phy_maximus
- */
-
-#include "common/std.h"
-#include "lib/test.h"
-#include "lib/trace.h"
-#include "maximus/common/types/phy_types.h"
-#include "hal/phy/forward.h"
-#include "host/fwd.h"
-#include "hal/phy/maximus/inc/maximus_phy_ctx.h"
-#include "hal/phy/maximus/test/inc/test_phy_maximus.h"
-#include "mac/common/defs.h" // for 'MAC_PB520_BYTES'
-#include <stdio.h> // for 'printf'
-#include <string.h> // for 'memset'
-#include <unistd.h> // for 'read'
-#include <fcntl.h> // for 'read'
-#include <errno.h>
-
-phy_t *ctx;
-
-void phy_set_tonemask_test_case(test_t t)
-{
- printf("set tonemask\n");
- test_case_begin(t, "set tonemask");
-
- uint carrier_nb = PHY_CARRIER_NB;
- u8 tonemask[(PHY_CARRIER_NB+7)/8]; // 1 bit per carrier
- memset(tonemask, 'a', ((PHY_CARRIER_NB+7)/8)*sizeof(u8));
-
- test_begin(t, "set tonemask")
- {
- phy_set_tonemask(ctx, (u32 *)tonemask, carrier_nb);
- test_fail_unless ((EINVAL != errno)
- && (carrier_nb == ctx->tmdma.carrier_nb)
- && (0 == memcmp(tonemask, ctx->tmdma.tonemask, (PHY_CARRIER_NB+7)/8)));
- } test_end;
-
- // check that the correct phy message has been sent to Maximus
- test_begin(t, "tonemask phy message")
- {
- unsigned char data[SCI_MSG_MAX_SIZE];
- phy_msg_hdr_t *phy_hdr;
- int fd_in = -1;
-
- // open pipe or socket
- fd_in = maximus_phy_open(&my_station);
-
- // read sci and phy headers
- memset(data, '\0', SCI_MSG_MAX_SIZE);
- test_fail_unless ((-1 != fd_in)
- && (sizeof(sci_msg_hdr_t) == read(fd_in, data, sizeof(sci_msg_hdr_t)))
- && (sizeof(phy_msg_hdr_t) == read(fd_in, data+sizeof(sci_msg_hdr_t), sizeof(phy_msg_hdr_t))));
-
- /* Set phy header pointer. */
- phy_hdr = (phy_msg_hdr_t *)(data+sizeof(sci_msg_hdr_t));
-
- // check phy header
- test_fail_unless (PHY_TYPE_TONEMASK == phy_hdr->type);
- test_fail_unless (0 == phy_hdr->tx_id);
-
- // read the remaining part of message
- test_fail_unless (sizeof(uint) == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint)));
- test_fail_unless ((PHY_CARRIER_NB+7)/8 == read(fd_in, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(uint), (PHY_CARRIER_NB+7)/8));
-
- // check phy data
- test_fail_unless (0 == memcmp(&carrier_nb, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t), sizeof(uint)));
- test_fail_unless (0 == memcmp(tonemask, data+sizeof(sci_msg_hdr_t)+sizeof(phy_msg_hdr_t)+sizeof(uint), (PHY_CARRIER_NB+7)/8));
-
- // close pipe
- maximus_phy_close(fd_in);
- } test_end;
-}
-
-void phy_set_tonemap_test_case(test_t t)
-{
- printf("set tonemap\n");
- test_case_begin(t, "set tonemap");
-
- test_begin(t, "set tonemap")
- {
- blk_t tonemap1;
- blk_t tonemap2;
- u8 tonemap1_data[MAC_PB520_BYTES];
- u8 tonemap2_data[(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES]; // 4 bits per carrier
- uint tonemap_index = 0;
-
- memset(tonemap1_data, 'b', MAC_PB520_BYTES*sizeof(u8));
- memset(tonemap2_data, 'c', ((PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES)*sizeof(u8));
- tonemap2.next = NULL;
- tonemap2.data = tonemap2_data;
- tonemap1.next = &tonemap2;
- tonemap1.data = tonemap1_data;
-
- phy_set_tonemap (ctx, &tonemap1);
- test_fail_unless ((EINVAL != errno)
- && (0 == memcmp(tonemap1.data, ctx->tmdma.tonemap[tonemap_index]->data, MAC_PB520_BYTES))
- && (0 == memcmp(tonemap2.data, ctx->tmdma.tonemap[tonemap_index]->next->data, (PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES)));
- } test_end;
-}
-
-void tmdma_test_suite(test_t t)
-{
- int user_data = 1234567890;
-
- // reset errno
- errno = 0;
-
- station_init (&my_station);
- station_log_set_level(&my_station, STATION_LOG_DEBUG);
- station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
- //my_station.pipe_log_fd = 1;
- trace_init();
- ctx = phy_init ((void*)&user_data,
- &phy_rx_fc_cb,
- &phy_access_cb,
- &phy_access_conf_cb,
- &phy_pbdma_cb,
- &phy_tx_false_alarm_cb,
- &phy_deferred_cb);
- ctx->warning_assert = true;
-
- test_suite_begin(t, "tonemap dma");
- phy_set_tonemask_test_case(t);
- phy_set_tonemap_test_case(t);
-
-#if CONFIG_TRACE
- printf("BEGIN_TRACE\n");
- trace_buffer_dbg_dump(&ctx->trace);
- printf("END_TRACE\n");
-#endif
- phy_uninit (ctx);
- trace_uninit();
- station_down (&my_station);
-}
diff --git a/cesar/hal/phy/test/phy/src/test_phy.c b/cesar/hal/phy/test/phy/src/test_phy.c
index 8e9012b454..5e7757580e 100644
--- a/cesar/hal/phy/test/phy/src/test_phy.c
+++ b/cesar/hal/phy/test/phy/src/test_phy.c
@@ -694,11 +694,6 @@ cyg_user_start (void)
fcall_register (fcall, "test_phy_chandata", test_phy_chandata_fcall,
&test_phy_global);
test_phy_burst_init (&test_phy_global, fcall);
-#if !CONFIG_FCALL_MME
- my_station.pipe_log_fd = 1;
- //my_station.log_level = STATION_LOG_DEBUG;
- //my_station.log_mask = STATION_LOGTYPE_FCALL;
-#endif
trace_init ();
test_phy_init (&test_phy_global);
}
diff --git a/cesar/host/sci/maximus/inc/socket.h b/cesar/host/sci/maximus/inc/socket.h
index 414aad9c36..d73a0d5afc 100644
--- a/cesar/host/sci/maximus/inc/socket.h
+++ b/cesar/host/sci/maximus/inc/socket.h
@@ -21,8 +21,6 @@
#include <sys/types.h>
-#undef STATION_SOCK /** enable socket communication */
-
#define HOST_PF_UNIX 1
#define HOST_AF_UNIX HOST_PF_UNIX
diff --git a/cesar/host/sci/maximus/src/sci.c b/cesar/host/sci/maximus/src/sci.c
index bb1eb7e55e..ec7552e5ea 100644
--- a/cesar/host/sci/maximus/src/sci.c
+++ b/cesar/host/sci/maximus/src/sci.c
@@ -151,11 +151,7 @@ sci_send (sci_ctx_t *sci, sci_msg_t *msg)
return -1;
}
-#ifdef STATION_SOCK
- output = sci->station->sock_fd;
-#else
- output = sci->station->pipe_out_fd;
-#endif
+ output = sci->station->fd_out;
len = write (output, msg->data_begin, msg->length);
@@ -193,11 +189,7 @@ sci_recv (sci_ctx_t *sci)
return -1;
}
-#ifdef STATION_SOCK
- input = sci->station->sock_fd;
-#else
- input = sci->station->pipe_in_fd;
-#endif
+ input = sci->station->fd_in;
if (sci_msg_init (&msg, sci_buffer, SCI_MSG_MAX_SIZE) < 0)
return -1;
diff --git a/cesar/host/station/src/station.c b/cesar/host/station/src/station.c
index 5659c31510..16bc1b67e0 100644
--- a/cesar/host/station/src/station.c
+++ b/cesar/host/station/src/station.c
@@ -5,7 +5,7 @@
* <<<Licence>>>
*
* }}} */
-
+
/**
* \file station.c
* \brief The station management functions
@@ -13,28 +13,16 @@
*
* This file provide station management functions
*
- * \todo
+ * \todo
*/
-
#include "common/std.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <errno.h>
#include "ecos/packages/hal/maximus/arch/current/include/hal_host_intr.h"
#include "host/sci/sci.h"
#include "host/station/station.h"
-#ifndef UNIT_TEST
-#include "host/sci/maximus/inc/socket.h"
#include "host/syscall.h"
-#else
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
#define STATION_BUFFER_SIZE (STATION_MAX_LOG_SIZE + 2)
@@ -45,7 +33,7 @@ static fcall_ctx_t _my_fcall;
static probe_ctx_t _my_probe;
static system_ctx_t _my_system;
static netclock_callback_t _ecos_tick_cb;
-
+
/**
* fill buffer with the in/out pipe name for sci msg communication
* \param suffix pipe name suffix; normaly "in" or "out"
@@ -70,133 +58,26 @@ static netclock_callback_t _ecos_tick_cb;
*/
int station_init(station_ctx_t *station)
{
-#ifdef STATION_SOCK
- int sock_server_fd;
-#endif /* STATION_SOCK */
-
DBG_ASSERT(station);
if(station == NULL)
{
errno = EINVAL;
return -1;
}
-
+
memset(station, '\0', sizeof(station_ctx_t));
-#ifdef STATION_SOCK
- station->sock_fd = -1;
- station->sock_pair_fd = -1;
- sock_server_fd = -1;
-#else /* STATION_SOCK */
- station->pipe_in_fd = -1;
- station->pipe_out_fd = -1;
-#endif
- station->pipe_log_fd = -1;
+
+ /* use standard stdin(0), stdout(1), and stderr(2). */
+ station->fd_in = 0;
+ station->fd_out = 1;
+ station->fd_log = 2;
/* get station id */
station->id = getpid();
-
+
/* set variables */
station->log_level = STATION_LOG_WARNING;
- /* build pipe names */
- sprintf(station->pipe_log_name, "%s/%s_log_%d", STATION_PIPE_PATH, STATION_PIPE_PREFIX, station->id);
- unlink(station->pipe_log_name); // in case of an error occurs after, unlink now
-#ifndef STATION_SOCK
- sprintf(station->pipe_in_name, "%s/%s_in_%d", STATION_PIPE_PATH, STATION_PIPE_PREFIX, station->id);
- unlink(station->pipe_in_name); // in case of an error occurs after, unlink now
- sprintf(station->pipe_out_name, "%s/%s_out_%d", STATION_PIPE_PATH, STATION_PIPE_PREFIX, station->id);
- unlink(station->pipe_out_name); // in case of an error occurs after, unlink now
-#endif
- // reset errno generated by the 'unlink() function'
- errno = 0;
-
- /* open log */
- if(mknod(station->pipe_log_name, 0770 | S_IFIFO, 0) < 0)
- goto failed;
- if((station->pipe_log_fd = open(station->pipe_log_name, O_RDWR | O_NONBLOCK, S_IRWXU | S_IRWXG)) < 0)
- goto failed;
-
-#ifdef STATION_SOCK
- /* build sock name */
- sprintf(station->sock_name, "%s/%s_sock_%d", STATION_SOCK_PATH, STATION_SOCK_PREFIX, station->id);
- unlink(station->sock_name);
-
- /* create socket */
-#ifdef UNIT_TEST
- int sock_fd[2];
- socketpair(PF_UNIX, SOCK_STREAM, 0, sock_fd);
- station->sock_fd = sock_fd[0];
- station->sock_pair_fd = sock_fd[1];
-#else /* UNIT_TEST */
- if((sock_server_fd = socket (PF_UNIX, SOCK_STREAM, 0)) < 0)
- {
- station_log(station, STATION_LOG_WARNING, STATION_LOGTYPE_STATION,
- "%s: failed to create socket (errno=%d)",
- __FUNCTION__, errno);
- goto failed;
- }
-
- /* extend send buffer size */
- {
- int bufsize = STATION_MAX_SOCK_BUFFER_SIZE;
- if(setsockopt (sock_server_fd, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize)) < 0)
- {
- station_log(station, STATION_LOG_WARNING, STATION_LOGTYPE_STATION,
- "%s: failed to set buffer size to %d bytes (errno=%d)",
- __FUNCTION__, bufsize, errno);
- goto failed;
- }
- }
-
- /* bind the socket */
- {
- struct sockaddr_un sockaddr;
- sockaddr.sun_family = AF_UNIX;
- strcpy (sockaddr.sun_path, station->sock_name);
- if((bind (sock_server_fd, (struct sockaddr *)&sockaddr, sizeof(sockaddr))) < 0)
- {
- station_log(station, STATION_LOG_WARNING, STATION_LOGTYPE_STATION,
- "%s: bind to '%s' failed (errno=%d)",
- __FUNCTION__, station->sock_name, errno);
- goto failed;
- }
- }
-#endif /* UNIT_TEST */
-#else /* STATION_SOCK */
- /* open in pipe */
- if(mknod(station->pipe_in_name, 0770 | S_IFIFO, 0) < 0)
- {
- station_log(station, STATION_LOG_WARNING, STATION_LOGTYPE_STATION,
- "%s: failed to create fifo '%s' (errno=%d)",
- __FUNCTION__, station->pipe_in_name, errno);
- goto failed;
- }
- if((station->pipe_in_fd = open(station->pipe_in_name, O_RDWR, S_IRWXU | S_IRWXG)) < 0)
- {
- station_log(station, STATION_LOG_WARNING, STATION_LOGTYPE_STATION,
- "%s: failed to open fifo '%s' (errno=%d)",
- __FUNCTION__, station->pipe_in_name, errno);
- goto failed;
- }
-
- /* open out pipe */
- if(mknod(station->pipe_out_name, 0770 | S_IFIFO, 0) < 0)
- {
- station_log(station, STATION_LOG_WARNING, STATION_LOGTYPE_STATION,
- "%s: failed to create fifo '%s' (errno=%d)",
- __FUNCTION__, station->pipe_out_name, errno);
- goto failed;
- }
- if((station->pipe_out_fd = open(station->pipe_out_name, O_RDWR, S_IRWXU | S_IRWXG)) < 0)
- {
- station_log(station, STATION_LOG_WARNING, STATION_LOGTYPE_STATION,
- "%s: failed to open fifo '%s' (errno=%d)",
- __FUNCTION__, station->pipe_out_name, errno);
- goto failed;
- }
-
-#endif /* STATION_SOCK */
-
/* init all contexts */
station->sci = &_my_sci;
sci_init(station->sci, station);
@@ -210,88 +91,33 @@ int station_init(station_ctx_t *station)
system_init(station->system, station->sci);
station->ecos_tick_cb = &_ecos_tick_cb;
station->status = STATION_STATUS_RUNNING;
-
+
/* init the random generator */
srand(station->id);
-
-#if (defined STATION_SOCK) && !defined(UNIT_TEST)
- /* listen and accept connection */
- listen(sock_server_fd, 1);
- if((station->sock_fd = accept(sock_server_fd, NULL, NULL)) < 0)
- {
- station_log(station, STATION_LOG_WARNING, STATION_LOGTYPE_STATION,
- "%s: accept failed (errno=%d)",
- __FUNCTION__, errno);
- goto failed;
- }
- close(sock_server_fd);
-#endif /* STATION_SOCK && !UNIT_TEST */
-
return 0;
-
-failed:
- if(station->pipe_log_fd >= 0)
- close(station->pipe_log_fd);
- unlink(station->pipe_log_name);
- station->pipe_log_fd = -1;
-#ifdef STATION_SOCK
- if(station->sock_fd >= 0)
- close(station->sock_fd);
- if(station->sock_pair_fd >= 0)
- close(station->sock_pair_fd);
- if(sock_server_fd >= 0)
- close(sock_server_fd);
- unlink(station->sock_name);
- station->sock_fd = -1;
- station->sock_pair_fd = -1;
-#else /* STATION_SOCK */
- if(station->pipe_out_fd >= 0)
- close(station->pipe_out_fd);
- if(station->pipe_in_fd >= 0)
- close(station->pipe_in_fd);
- unlink(station->pipe_out_name);
- unlink(station->pipe_in_name);
- station->pipe_out_fd = -1;
- station->pipe_in_fd = -1;
-#endif /* STATION_SOCK */
- station->status = STATION_STATUS_ERROR;
- return -1;
-}
+}
-/**
- * station context to clean and reset, with pipe closing
- * \param station pointer to station context to stop
- */
-void station_down(station_ctx_t *station)
+void
+station_uninit (station_ctx_t *station)
{
- if((station == NULL)
- || (station->status == STATION_STATUS_INIT))
- return;
+ DBG_ASSERT(station);
-#ifdef STATION_SOCK
- if(station->sock_fd >= 0)
- close(station->sock_fd);
- if(station->sock_pair_fd >= 0)
- close(station->sock_pair_fd);
- unlink(station->sock_name);
- station->sock_fd = -1;
- station->sock_pair_fd = -1;
-#else /* STATION_SOCK */
- if(station->pipe_out_fd >= 0)
- close(station->pipe_out_fd);
- if(station->pipe_in_fd >= 0)
- close(station->pipe_in_fd);
- unlink(station->pipe_out_name);
- unlink(station->pipe_in_name);
- station->pipe_out_fd = -1;
- station->pipe_in_fd = -1;
-#endif /* STATION_SOCK */
- if(station->pipe_log_fd >= 0)
- close(station->pipe_log_fd);
- unlink(station->pipe_log_name);
- station->pipe_log_fd = -1;
- return;
-}
+ /* Return to first state. */
+ station->status = STATION_STATUS_INIT;
+
+ /* Unload modules. */
+ station->ecos_tick_cb = NULL;
+ /* TODO: system_uninit (station->system); */
+ station->system = NULL;
+ /* TODO: probe_uninit (station->probe); */
+ station->probe = NULL;
+ /* TODO: fcall_uninit (station->fcall); */
+ station->fcall = NULL;
+ /* TODO: netclock_uninit (station->netclock); */
+ station->netclock = NULL;
+ /* TODO: sci_uninit (station->sci); */
+ station->sci = NULL;
+}
/**
* station is into idle state; it sends a sci 'idle' message and waits for sci message reception
@@ -308,23 +134,22 @@ int station_idle(station_ctx_t *station)
fd_set read_fds;
struct timeval timeout;
int sel;
-
+
DBG_ASSERT(station);
DBG_ASSERT(station->status != STATION_STATUS_INIT);
if((station == NULL)
- || (station->status == STATION_STATUS_INIT))
- //|| !station_is_initialized(station))
+ || (station->status == STATION_STATUS_INIT))
{
errno = EINVAL;
return -1;
}
-
+
if(station->status == STATION_STATUS_RUNNING)
{
/* init msg */
if(sci_msg_init(&msg, buffer, 64) < 0)
return -1;
-
+
/* fill system header */
if (0 > sci_msg_push (&msg, sizeof (station_msg_hdr_t)))
return -1;
@@ -332,7 +157,7 @@ int station_idle(station_ctx_t *station)
msg.hdr.station->version = SYSTEM_VERSION;
msg.hdr.station->type = SYSTEM_TYPE_IDLE;
msg.hdr.station->flags = 0;
-
+
/* fill sci header and send msg */
if(sci_fill_hdr(station->sci, &msg, SCI_MSG_TYPE_SYSTEM, 0) < 0)
return -1;
@@ -341,21 +166,12 @@ int station_idle(station_ctx_t *station)
station_log(station, STATION_LOG_WARNING, STATION_LOGTYPE_STATION, "%s failed to send system idle (errno=%d)", __FUNCTION__, errno);
return -1;
}
- station->status = STATION_STATUS_IDLE;
+ station->status = STATION_STATUS_IDLE;
}
-
- /* don't wait for next message with unit tests */
-#ifdef UNIT_TEST
- return 0;
-#endif
-
- /* vait for next message with 1 second timeout */
+
+ /* wait for next message with 1 second timeout */
FD_ZERO(&read_fds);
-#ifdef STATION_SOCK
- FD_SET(station->sock_fd, &read_fds);
-#else /* STATION_SOCK */
- FD_SET(station->pipe_in_fd, &read_fds);
-#endif /* STATION_SOCK */
+ FD_SET (station->fd_in, &read_fds);
timeout.tv_sec = 1;
timeout.tv_usec = 0;
sel = select(STATION_MAX_FD + 1, &read_fds, NULL, NULL, &timeout);
@@ -365,8 +181,8 @@ int station_idle(station_ctx_t *station)
return -1;
}
else if(sel > 0)
- {
- station->status = STATION_STATUS_RUNNING;
+ {
+ station->status = STATION_STATUS_RUNNING;
return sci_recv(station->sci);
}
else
@@ -380,13 +196,11 @@ int station_idle(station_ctx_t *station)
static void _ecos_set_itimer_cb(void *data)
{
uint32_t *isr;
-#ifndef UNIT_TEST
station_log(&my_station, STATION_LOG_DEBUG, STATION_LOGTYPE_STATION, "%s", __FUNCTION__);
-#endif /* UNIT_TEST */
- isr = (uint32_t *)data;
+ isr = (uint32_t *)data;
*isr |= (1 << CYGNUM_HAL_INTERRUPT_RTC);
return;
-}
+}
/**
* schedule an eCos tick event (every 10ms)
@@ -401,21 +215,21 @@ int station_ecos_set_itimer(station_ctx_t *station, tick_t tick)
DBG_ASSERT(station);
DBG_ASSERT(station->status != STATION_STATUS_INIT);
if((station == NULL)
- || (station->status == STATION_STATUS_INIT))
+ || (station->status == STATION_STATUS_INIT))
{
errno = EINVAL;
return -1;
}
-
- return netclock_schedule(station->netclock,
- station->ecos_tick_cb,
- NETWORK_CLOCK_TYPE_STATION,
- tick,
- _ecos_set_itimer_cb,
- (void *)&maximus_pending_isrs,
- &id);
-}
-
+
+ return netclock_schedule(station->netclock,
+ station->ecos_tick_cb,
+ NETWORK_CLOCK_TYPE_STATION,
+ tick,
+ _ecos_set_itimer_cb,
+ (void *)&maximus_pending_isrs,
+ &id);
+}
+
/**
* set the station log level
* \param station pointer to station context
@@ -430,14 +244,14 @@ int station_log_set_level(station_ctx_t *station, station_log_level_t level)
DBG_ASSERT(level > STATION_LOG_NONE);
DBG_ASSERT(level < STATION_LOG_NB);
if((station == NULL)
- || (station->status == STATION_STATUS_INIT)
- || (level <= STATION_LOG_NONE)
- || (level >= STATION_LOG_NB))
+ || (station->status == STATION_STATUS_INIT)
+ || (level <= STATION_LOG_NONE)
+ || (level >= STATION_LOG_NB))
{
errno = EINVAL;
return -1;
}
-
+
station->log_level = level;
return 0;
}
@@ -446,72 +260,70 @@ int station_log_set_level(station_ctx_t *station, station_log_level_t level)
* send message to station log system
* \param station pointer to station context
* \param level level of log message
- * \param format string structure describing the data log format
+ * \param format string structure describing the data log format
* \param ... suite of parameters to fit the format
*/
- void station_log(station_ctx_t *station,
- station_log_level_t level,
- unsigned long type,
- const char *format,
- ...)
+void station_log(station_ctx_t *station,
+ station_log_level_t level,
+ unsigned long type,
+ const char *format,
+ ...)
{
va_list va_args;
int hdr_len, ret = 0;
static char buffer[STATION_BUFFER_SIZE];
if((station == NULL)
- || (station->status == STATION_STATUS_INIT)
- || (format == NULL)
- || (station->system == NULL))
+ || (station->status == STATION_STATUS_INIT)
+ || (format == NULL)
+ || (station->system == NULL))
return;
- if ((level <= STATION_LOG_NONE)
+ if ((level <= STATION_LOG_NONE)
|| (level > station->log_level))
return;
-
- if (station->pipe_log_fd < 0)
- return;
-
+
if(type == 0)
type = STATION_LOGTYPE_ALL;
-
+
if(!(station->log_mask & type))
return;
-
+
/* build header and send it */
if(strlen(station->system->station_name) == 0)
{
sprintf(buffer, "sta(%d) %Lu: ",
- station->id,
- station->current_tick_tck
- );
+ station->id,
+ station->current_tick_tck
+ );
}
else
{
sprintf(buffer, "== %s ==(%d) %Lu: ",
- station->system->station_name,
- station->id,
- station->current_tick_tck
- );
+ station->system->station_name,
+ station->id,
+ station->current_tick_tck
+ );
}
if(level >= STATION_LOG_DEBUG)
{
strcat(buffer, "<DEBUG> ");
}
hdr_len = strlen(buffer);
- write(station->pipe_log_fd, buffer, hdr_len);
-
+ write (station->fd_log, buffer, hdr_len);
+
/* build body and send it */
buffer[STATION_BUFFER_SIZE - 1] = '\0';
va_start(va_args, format);
ret = vsnprintf (buffer, STATION_BUFFER_SIZE - 1, format, va_args);
va_end (va_args);
- write(station->pipe_log_fd, buffer, strlen(buffer));
+ write (station->fd_log, buffer, strlen(buffer));
/* send CR */
if (ret == STATION_MAX_LOG_SIZE)
- write (station->pipe_log_fd, STATION_MAX_LOG_MSG, strlen (STATION_MAX_LOG_MSG));
- write(station->pipe_log_fd, "\n", 1);
+ write (station->fd_log, STATION_MAX_LOG_MSG,
+ strlen (STATION_MAX_LOG_MSG));
+ write (station->fd_log, "\n", 1);
return;
-}
+}
diff --git a/cesar/host/station/station.h b/cesar/host/station/station.h
index 774caf8c2e..7a7d931a0d 100644
--- a/cesar/host/station/station.h
+++ b/cesar/host/station/station.h
@@ -8,15 +8,15 @@
* <<<Licence>>>
*
* }}} */
-
- /**
+
+/**
* \file station.h
* \brief The station structures for fulminata.
* \ingroup host
*
* This file descibe the content of station structure used by fulminata station
*
- * \todo
+ * \todo
*/
#include <sys/types.h>
@@ -28,22 +28,13 @@
#include "host/fcall/fcall.h"
#include "host/system/system.h"
-#define STATION_PIPE_PATH "/tmp"
-#define STATION_PIPE_PREFIX "station"
-#define STATION_SOCK_PATH STATION_PIPE_PATH
-#define STATION_SOCK_PREFIX STATION_PIPE_PREFIX
#define STATION_MAX_LOG_SIZE 4096
#define STATION_MAX_LOG_MSG " [...] <WARNING> Log exceeds max size"
-#define STATION_MAX_SOCK_BUFFER_SIZE (256*1024)
#define STATION_MAX_FD 16
#define TICK_PERIOD_NS 40 /** period of a tick in nanosecond */
#define TICK_HZ 25000000 /** frequence of tick (tick number per second) */
-#ifndef MAXPATHLEN
-#define MAXPATHLEN 256
-#endif
-
struct sci_ctx;
struct netclock_ctx;
struct fcall_ctx;
@@ -91,20 +82,16 @@ struct station_ctx
struct fcall_ctx *fcall;
struct probe_ctx *probe;
struct system_ctx *system;
- tick_t current_tick_tck; /** current global clock tick got from sci msg */
- u32 seed; /** station seed (may be needed for cesar initialization) */
-#ifdef STATION_SOCK
- int sock_fd; /** file descriptor for messaging input/output */
- int sock_pair_fd; /** file descriptor for socket pair, used by unit test */
- char sock_name[MAXPATHLEN]; /** filename of messaging input/output */
-#else /* STATION_SOCK */
- int pipe_in_fd; /** file descriptor for messaging input pipe */
- char pipe_in_name[MAXPATHLEN]; /** filename of messaging input file */
- int pipe_out_fd; /** file descriptor for messaging output pipe */
- char pipe_out_name[MAXPATHLEN]; /** filename of messaging output pipe */
-#endif /* STATION_SOCK */
- int pipe_log_fd; /** output pipe file desc to send debug data */
- char pipe_log_name[MAXPATHLEN]; /** output pipe filename to send debug data */
+ /** current global clock tick got from sci msg */
+ tick_t current_tick_tck;
+ /** station seed (may be needed for cesar initialization) */
+ u32 seed;
+ /** File descriptor for messaging input. */
+ int fd_in;
+ /** File descriptor for messaging output. */
+ int fd_out;
+ /** Output file descriptor to send debug data. */
+ int fd_log;
station_log_level_t log_level;
unsigned long log_mask;
struct netclock_callback *ecos_tick_cb;
@@ -137,10 +124,10 @@ void station_free(station_ctx_t *station);
int station_init(station_ctx_t *station);
/**
- * station context to clean and reset, with pipe closing
+ * Free station resources.
* \param station pointer to station context to stop
*/
-void station_down(station_ctx_t *station);
+void station_uninit (station_ctx_t *station);
/**
* station is into idle state; it sends a sci 'idle' message and waits for sci message reception
@@ -160,15 +147,6 @@ int station_idle(station_ctx_t *station);
* - EINVAL if station id NULL or if wanted tick is to old
*/
int station_ecos_set_itimer(station_ctx_t *station, tick_t tick);
-
-static inline int station_is_initialized(station_ctx_t *station)
-{
-#ifdef STATION_SOCK
- return (station->sock_fd >= 0);
-#else /* STATION_SOCK */
- return ((station->pipe_in_fd >= 0) && (station->pipe_out_fd >= 0));
-#endif /* STATION_SOCK */
-}
/**
* set the station log level
@@ -203,15 +181,15 @@ extern inline unsigned long station_log_get_mask(station_ctx_t *station)
* send message to station log system
* \param station pointer to station context
* \param level level of log message
- * \param format string structure describing the data log format
+ * \param format string structure describing the data log format
* \param ... suite of parameters to fit the format
*/
-void station_log(station_ctx_t *station,
- station_log_level_t level,
- unsigned long type,
- const char *format,
- ...);
-
+void station_log(station_ctx_t *station,
+ station_log_level_t level,
+ unsigned long type,
+ const char *format,
+ ...);
+
//END_DECLS
#endif /*STATION_H_*/
diff --git a/cesar/host/test/Makefile b/cesar/host/test/Makefile
deleted file mode 100644
index 12f8cdc7d8..0000000000
--- a/cesar/host/test/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-BASE = ../..
-EXTRA_HOST_CFLAGS+= -DUNIT_TEST
-HOST_PROGRAMS = test_host
-test_host_SOURCES = test_host.c test_sci_msg.c test_sci.c \
- test_fcall_param.c test_fcall.c test_probe.c test_netclock.c \
- test_station.c test_system.c
-test_host_MODULES = lib host
-test_host_CONFIG_MODULES = mac/common
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/host/test/src/test_fcall.c b/cesar/host/test/src/test_fcall.c
deleted file mode 100644
index 83121754eb..0000000000
--- a/cesar/host/test/src/test_fcall.c
+++ /dev/null
@@ -1,633 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test_fcall.c
- * \brief Test all fcall functions.
- * \ingroup test
- */
-
-#include <string.h>
-#include <stdio.h>
-#include <arpa/inet.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include "common/std.h"
-#include "host/fcall/fcall.h"
-#include "lib/test.h"
-
-extern char dump_buffer[];
-
-//void fcall_param_new_test_case(test_t t)
-//{
-// fcall_param_t *param;
-// test_case_begin(t, "param_new");
-//
-// test_begin(t, "id = NULL")
-// {
-// test_fail_unless(
-// (fcall_param_new(NULL) == NULL)
-// );
-// } test_end;
-//
-// test_begin(t, "check new")
-// {
-// param = fcall_param_new("test_func");
-// test_fail_unless(
-// (param != NULL)
-// && !strcmp(param->function_id, "test_func")
-// && (param->param_nb == 0)
-// );
-// } test_end;
-//
-// fcall_param_free(param);
-// return;
-//}
-//
-//void fcall_param_free_test_case(test_t t)
-//{
-// // noting to do ?
-// return;
-//}
-
-
-//void fcall_new_test_case(test_t t)
-//{
-// fcall_ctx_t *fcall;
-// station_ctx_t *station;
-//
-// test_case_begin(t, "new");
-// station = station_new();
-//
-// test_begin(t, "station = NULL")
-// {
-// test_fail_unless(
-// (fcall_new(NULL) == NULL)
-// && (errno == EINVAL)
-// );
-// } test_end;
-//
-// test_begin(t, "check new")
-// {
-// test_fail_unless(
-// ((fcall = fcall_new(station)) != NULL)
-// && (fcall->station == station)
-// );
-// } test_end;
-//
-// fcall_free(fcall);
-// station_free(station);
-// return;
-//}
-//
-//void fcall_free_test_case(test_t t)
-//{
-// // how to test it ?
-// return;
-//}
-
-void fcall_init_test_case(test_t t)
-{
- fcall_ctx_t fcall;
- sci_ctx_t sci;
- station_ctx_t station;
- sci_init(&sci, &station);
-
- test_case_begin(t, "init");
-
- test_begin(t, "fcall = NULL")
- {
- test_fail_unless(
- (fcall_init(NULL, &sci) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "sci = NULL")
- {
- test_fail_unless(
- (fcall_init(&fcall, NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check init")
- {
- int i;
- test_fail_unless(
- (fcall_init(&fcall, &sci) >= 0)
- && (fcall.sci == &sci)
- && (fcall.function_nb == 0)
- && (fcall.sci->msg_callback[SCI_MSG_TYPE_FUNCTION_CALL].function == fcall_recv)
- && (fcall.sci->msg_callback[SCI_MSG_TYPE_FUNCTION_CALL].data == &fcall)
- );
- for(i = 0; i < FUNCTION_CALL_FUNCTION_MAX_NB; i++)
- {
- test_fail_unless(
- (fcall.function_table[i].id[0] == '\0')
- );
- }
- } test_end;
-
- return;
-}
-
-static int _test_register(fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
-{
- return 0;
-}
-static int _test_data;
-
-void fcall_register_test_case(test_t t)
-{
- fcall_ctx_t fcall;
- sci_ctx_t sci;
- station_ctx_t station;
-
- test_case_begin(t, "register");
- station_init(&station);
- sci_init(&sci, &station);
- fcall_init(&fcall, &sci);
-
- test_begin(t, "fcall = NULL")
- {
- test_fail_unless(
- (fcall_register(NULL, "test_register", _test_register, &_test_data) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "id = NULL")
- {
- test_fail_unless(
- (fcall_register(&fcall, NULL, _test_register, &_test_data) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "function = NULL")
- {
- test_fail_unless(
- (fcall_register(&fcall, "test_register", NULL, &_test_data) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check register")
- {
- test_fail_unless(
- (fcall_register(&fcall, "test_register", _test_register, &_test_data) >= 0)
- && (fcall.function_nb == 1)
- && !strcmp(fcall.function_table[0].id, "test_register")
- && (fcall.function_table[0].function == _test_register)
- && (fcall.function_table[0].data == &_test_data)
- );
- } test_end;
-
- test_begin(t, "check already existing function")
- {
- test_fail_unless(
- (fcall_register(&fcall, "test_register", _test_register, &_test_data) < 0)
- && (errno == EEXIST)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check full table")
- {
- int i;
- fcall.function_nb = FUNCTION_CALL_FUNCTION_MAX_NB;
- test_fail_unless(
- (fcall_register(&fcall, "test_register", _test_register, &_test_data) < 0)
- && (errno == ENOSPC)
- );
- // reset errno
- errno = 0;
- fcall.function_nb = 1;
- for(i = 0; i < FUNCTION_CALL_FUNCTION_MAX_NB; i++)
- {
- sprintf(fcall.function_table[i].id, "test_%d", i);
- fcall.function_table[i].function = _test_register;
- }
- fcall.function_nb = FUNCTION_CALL_FUNCTION_MAX_NB;
- test_fail_unless(
- (fcall_register(&fcall, "test_register", _test_register, &_test_data) < 0)
- && (errno == ENOSPC)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- station_down(&station);
-
- return;
-}
-
-#define FCALL_DATA_STR "fill_hdr test"
-
-void fcall_fill_hdr_test_case(test_t t)
-{
- fcall_ctx_t fcall;
- station_ctx_t station;
- sci_ctx_t sci;
- sci_msg_t msg;
- fcall_param_t param;
- int data_int;
- unsigned char buffer[1024];
-
- test_case_begin(t, "fill_hdr");
- sci_init(&sci, &station);
- fcall_init(&fcall, &sci);
-
- test_begin(t, "init msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, buffer, 256))
- && (EINVAL != errno)
- );
- } test_end;
-
- fcall_param_init(&param, "test_function", 0x1234);
-
- data_int = 12345;
- fcall_param_add(&param, &msg, "data_int", sizeof(data_int), &data_int);
- fcall_param_add(&param, &msg, "data_str", strlen(FCALL_DATA_STR), FCALL_DATA_STR);
-
- test_begin(t, "fcall = NULL")
- {
- test_fail_unless(
- (fcall_fill_hdr(NULL, &msg, &param, 0) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "msg = NULL")
- {
- test_fail_unless(
- (fcall_fill_hdr(&fcall, NULL, &param, 0) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check fill_hdr")
- {
- test_fail_unless(
- (fcall_fill_hdr(&fcall, &msg, &param, 0xa5) >= 0)
- && ((unsigned char *)msg.hdr.fcall == msg.data_begin)
- && (msg.hdr.fcall->type == FUNCTION_CALL_TYPE_RSP)
- && (msg.hdr.fcall->param_nb == param.param_nb)
- && (msg.hdr.fcall->flags == 0xa5)
- );
- } test_end;
-
- return;
-}
-#undef FCALL_DATA_STR
-
-#define FCALL_REQ_STR "this is a request test"
-#define FCALL_RES_STR "this is a response test"
-
-void fcall_return_test_case(test_t t)
-{
- fcall_ctx_t fcall;
- station_ctx_t station;
- sci_ctx_t sci;
- sci_msg_t msg;
- fcall_param_t param;
- sci_msg_hdr_t *hdr;
- struct fcall_msg_hdr *fcall_hdr;
- int fd_in;
- int data_int;
- unsigned char buffer[1024], *ptr;
-
- test_case_begin(t, "return");
- station_init(&station);
- sci_init(&sci, &station);
- fcall_init(&fcall, &sci);
-
- test_begin(t, "init msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, buffer, 1024))
- && (EINVAL != errno)
- );
- } test_end;
-
- fcall_param_init(&param, "return_function", 30000);
-
- data_int = 12345;
- fcall_param_add(&param, &msg, "data_int", sizeof(data_int), &data_int);
- fcall_param_add(&param, &msg, "data_str", strlen(FCALL_RES_STR), FCALL_RES_STR);
-
- test_begin(t, "fcall = NULL")
- {
- test_fail_unless(
- (fcall_return(NULL, &param, &msg) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "param = NULL")
- {
- test_fail_unless(
- (fcall_return(&fcall, NULL, &msg) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "msg = NULL")
- {
- test_fail_unless(
- (fcall_return(&fcall, &param, NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
-#ifdef STATION_SOCK
- fd_in = station.sock_pair_fd;
-#else /* STATION_SOCK */
- fd_in = open(station.pipe_out_name, O_RDONLY);
-#endif /* STATION_SOCK */
-
- test_begin(t, "fcall_return")
- {
- test_fail_unless(
- (fcall_return(&fcall, &param, &msg) >= 0)
- );
-
- test_fail_if(
- sizeof (sci_msg_hdr_t)
- != read (fd_in, buffer, sizeof (sci_msg_hdr_t))
- );
- hdr = (sci_msg_hdr_t *)buffer;
- test_fail_unless(
- (hdr->type == SCI_MSG_TYPE_FUNCTION_CALL)
- && (ntohs(hdr->station_id) == station.id)
- && (ntohs(hdr->msg_id) == (station.sci->current_msg_id | SCI_MSG_ID_STATION))
- && (htonl(hdr->length) == sizeof(struct fcall_msg_hdr)
- + strlen("return_function") + 1
- + strlen("data_str") + 1 + sizeof(unsigned short) + strlen(FCALL_RES_STR)
- + strlen("data_int") + 1 + sizeof(unsigned short) + sizeof(int))
- );
- test_fail_unless(
- (int) htonl (hdr->length)
- == read (fd_in, buffer + sizeof(sci_msg_hdr_t), htonl (hdr->length))
- );
- fcall_hdr = (struct fcall_msg_hdr *)(buffer + sizeof(sci_msg_hdr_t));
- test_fail_unless(
- (fcall_hdr->type == FUNCTION_CALL_TYPE_RSP)
- && (fcall_hdr->param_nb == 2)
- && (ntohs(fcall_hdr->msg_id) == 30000)
- && !strcmp((char *)fcall_hdr + sizeof(struct fcall_msg_hdr), "return_function")
- );
- ptr = (unsigned char *)fcall_hdr + sizeof(struct fcall_msg_hdr) + strlen("return_function") + 1;
- test_fail_unless(
- !strcmp((char *)ptr, "data_str")
- && (ptr += (strlen("data_str") + 1))
- && (ntohs(*(unsigned short *)(ptr)) == strlen(FCALL_RES_STR))
- && !memcmp(ptr + 2, FCALL_RES_STR, strlen(FCALL_RES_STR))
- );
- ptr += (2 + strlen(FCALL_RES_STR));
- test_fail_unless(
- !strcmp((char *)ptr, "data_int")
- && (ptr += (strlen("data_int") + 1))
- && (ntohs(*(unsigned short *)(ptr)) == sizeof(int))
- && (*(int *)(ptr + 2) == 12345)
- );
- } test_end;
-
- station_down(&station);
-#ifndef STATION_SOCK
- close(fd_in);
-#endif
-}
-
-int _test_recv_result;
-static int _test_recv(fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
-{
- int data_int;
- char data_str[32];
- int *private_data;
-
- private_data = (int *)data;
- _test_recv_result = -1;
- if(((*param)->param_nb != 2)
- || ((*param)->msg_id != 0x4321)
- || (private_data == NULL)
- || (*private_data != 0x12345678))
- goto failed;
- if((fcall_param_bind(*param, *msg, "data_int", sizeof(data_int), &data_int) != sizeof(data_int))
- || (data_int != 12345))
- goto failed;
- if((fcall_param_bind(*param, *msg, "data_str", strlen(FCALL_REQ_STR), data_str) != strlen(FCALL_REQ_STR))
- || memcmp(data_str, FCALL_REQ_STR, strlen(FCALL_REQ_STR)))
- goto failed;
-
- /* now modify parameters */
- fcall_param_reset(*param);
- data_int = 54321;
- fcall_param_add(*param, *msg, "data_int", sizeof(data_int), &data_int);
- _test_recv_result = 0;
- return 0;
-
-failed:
- return -1;
-}
-
-void fcall_recv_test_case(test_t t)
-{
- station_ctx_t station;
- fcall_ctx_t fcall;
- fcall_param_t param;
- sci_ctx_t sci;
- sci_msg_t msg;
- sci_msg_hdr_t *hdr;
- struct fcall_msg_hdr *fcall_hdr;
- int data_int;
- int private_data;
- int fd_in;
- unsigned char buffer[256], *ptr;
-
- test_case_begin(t, "recv");
-
- station_init(&station);
- sci_init(&sci, &station);
- fcall_init(&fcall, &sci);
- fcall_register(&fcall, "test_function", _test_recv, &private_data);
-
- test_begin(t, "msg = NULL")
- {
- test_fail_unless(
- (fcall_recv(NULL, &fcall) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "fcall = NULL")
- {
- test_fail_unless(
- (fcall_recv(&msg, NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
-#ifdef STATION_SOCK
- fd_in = station.sock_pair_fd;
-#else /* STATION_SOCK */
- fd_in = open(station.pipe_out_name, O_RDONLY);
-#endif /* STATION_SOCK */
-
- test_begin(t, "check recv")
- {
- test_begin(t, "init msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, buffer, 256))
- && (EINVAL != errno)
- );
- } test_end;
-
- fcall_param_init(&param, "test_function", 0x4321);
- private_data = 0x12345678;
- data_int = 12345;
- fcall_param_add(&param, &msg, "data_int", sizeof(data_int), &data_int);
- fcall_param_add(&param, &msg, "data_str", strlen(FCALL_REQ_STR), FCALL_REQ_STR);
-
- fcall_fill_hdr(&fcall, &msg, &param, 0);
- msg.hdr.fcall->type = FUNCTION_CALL_TYPE_REQ;
-
- test_fail_unless(
- (fcall_recv(&msg, &fcall) >= 0)
- && (_test_recv_result >= 0)
- );
- test_fail_if(
- sizeof(sci_msg_hdr_t)
- != read (fd_in, buffer, sizeof(sci_msg_hdr_t))
- );
- hdr = (sci_msg_hdr_t *)buffer;
- test_fail_unless(
- (hdr->type == SCI_MSG_TYPE_FUNCTION_CALL)
- && (ntohs(hdr->station_id) == station.id)
- && (ntohs(hdr->msg_id) == ((sci.current_msg_id - 1) | SCI_MSG_ID_STATION))
- && (htonl(hdr->length) == sizeof(struct fcall_msg_hdr) + strlen("test_function") + 1 + strlen("data_int") + 1 + sizeof(unsigned short) + sizeof(int))
- );
- test_fail_unless(
- (int) htonl (hdr->length)
- == read (fd_in, buffer + sizeof (sci_msg_hdr_t), htonl (hdr->length))
- );
- fcall_hdr = (struct fcall_msg_hdr *)(buffer + sizeof(sci_msg_hdr_t));
- test_fail_unless(
- (fcall_hdr->type == FUNCTION_CALL_TYPE_RSP)
- && (fcall_hdr->param_nb == 1)
- && (ntohs(fcall_hdr->msg_id) == 0x4321)
- && !strcmp((char *)fcall_hdr + sizeof(struct fcall_msg_hdr), "test_function")
- );
- ptr = (unsigned char *)fcall_hdr + sizeof(struct fcall_msg_hdr) + strlen("test_function") + 1;
-// test_fail_unless(
-// !strcmp((char *)ptr, "data_str")
-// && (ptr += (strlen("data_str") + 1))
-// && (ntohs(*(unsigned short *)(ptr)) == strlen(FCALL_RES_STR))
-// && !memcmp(ptr + 2, FCALL_RES_STR, strlen(FCALL_RES_STR))
-// );
-// ptr += (2 + strlen(FCALL_RES_STR));
- test_fail_unless(
- !strcmp((char *)ptr, "data_int")
- && (ptr += (strlen("data_int") + 1))
- && (ntohs(*(unsigned short *)(ptr)) == sizeof(int))
- && (*(int *)(ptr + 2) == 54321)
- );
- } test_end;
-
- test_begin(t, "check recv with failed callback")
- {
- test_begin(t, "init msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, buffer, 256))
- && (EINVAL != errno)
- );
- } test_end;
-
- fcall_param_init(&param, "test_function", 0x4321);
- private_data = 0x12345678;
- data_int = 12345;
- fcall_param_add(&param, &msg, "data_int", sizeof(data_int), &data_int);
-
- fcall_fill_hdr(&fcall, &msg, &param, 0);
- msg.hdr.fcall->type = FUNCTION_CALL_TYPE_REQ;
-
- test_fail_unless(
- (fcall_recv(&msg, &fcall) >= 0)
- && (_test_recv_result < 0)
- );
- test_fail_if(
- sizeof (sci_msg_hdr_t)
- != read (fd_in, buffer, sizeof (sci_msg_hdr_t))
- );
- hdr = (sci_msg_hdr_t *)buffer;
- test_fail_unless(
- (hdr->type == SCI_MSG_TYPE_FUNCTION_CALL)
- && (ntohs(hdr->station_id) == station.id)
- && (ntohs(hdr->msg_id) == ((sci.current_msg_id - 1) | SCI_MSG_ID_STATION))
- );
- test_fail_unless(
- (int) htonl(hdr->length)
- == read (fd_in, buffer + sizeof(sci_msg_hdr_t), htonl(hdr->length))
- );
- fcall_hdr = (struct fcall_msg_hdr *)(buffer + sizeof(sci_msg_hdr_t));
- test_fail_unless(
- (fcall_hdr->type == FUNCTION_CALL_TYPE_RSP)
- && (fcall_hdr->param_nb == 0)
- && (ntohs(fcall_hdr->msg_id) == 0x4321)
- && (fcall_hdr->flags & FUNCTION_CALL_FLAG_FAILED)
- && !strcmp((char *)fcall_hdr + sizeof(struct fcall_msg_hdr), "test_function")
- );
- } test_end;
-
- station_down(&station);
-#ifndef STATION_SOCK
- close(fd_in);
-#endif /* STATION_SOCK */
-
- return;
-}
-
-void fcall_test_suite(test_t t)
-{
- test_suite_begin(t, "fcall");
- fcall_init_test_case(t);
- fcall_register_test_case(t);
- fcall_fill_hdr_test_case(t);
- fcall_return_test_case(t);
- fcall_recv_test_case(t);
-}
diff --git a/cesar/host/test/src/test_fcall_param.c b/cesar/host/test/src/test_fcall_param.c
deleted file mode 100644
index b02d5f6211..0000000000
--- a/cesar/host/test/src/test_fcall_param.c
+++ /dev/null
@@ -1,528 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test_fcall_param.c
- * \brief Test all fcall parameter functions.
- * \ingroup test
- */
-
-#include <string.h>
-#include <stdio.h>
-#include <arpa/inet.h>
-#include <errno.h>
-#include "common/std.h"
-#include "host/sci/sci.h"
-#include "host/fcall/fcall.h"
-#include "lib/test.h"
-
-void fcall_param_init_test_case(test_t t)
-{
- fcall_param_t param;
-
- test_case_begin(t, "init");
-
- test_begin(t, "param = NULL")
- {
- test_fail_unless(
- (fcall_param_init(NULL, "test_init", 20000) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "id = NULL")
- {
- test_fail_unless(
- (fcall_param_init(&param, NULL, 20000) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check init")
- {
- int i;
- strcpy(param.id, "fake_id");
- for(i = 0; i < FUNCTION_CALL_PARAM_MAX_NB; i++)
- {
- param.param_table[i].id = "fake_param_id";
- }
- param.param_nb = FUNCTION_CALL_PARAM_MAX_NB;
- test_fail_unless(
- (fcall_param_init(&param, "test_init", 20000) >= 0)
- && !strcmp(param.id, "test_init")
- && (param.param_nb == 0)
- && (param.msg_id == 20000)
- );
- for(i = 0; i < FUNCTION_CALL_PARAM_MAX_NB; i++)
- {
- test_fail_unless(
- (param.param_table[i].id == NULL)
- );
- }
- } test_end;
-
- return;
-}
-
-void fcall_param_reset_test_case(test_t t)
-{
- fcall_param_t param;
-
- test_case_begin(t, "reset");
-
- test_begin(t, "param = NULL")
- {
- test_fail_unless(
- (fcall_param_reset(NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check reset")
- {
- int i;
- strcpy(param.id, "fake_id");
- param.msg_id = 30000;
- param.is_async = 1;
- for(i = 0; i < FUNCTION_CALL_PARAM_MAX_NB; i++)
- {
- param.param_table[i].id = "fake_param_id";
- }
- param.param_nb = FUNCTION_CALL_PARAM_MAX_NB;
-
- test_fail_unless(
- (fcall_param_reset(&param) >= 0)
- && (param.param_nb == 0)
- && !strcmp(param.id, "fake_id")
- && (param.msg_id == 30000)
- && (param.is_async == 1)
- );
- for(i = 0; i < FUNCTION_CALL_PARAM_MAX_NB; i++)
- {
- test_fail_unless(
- (param.param_table[i].id == NULL)
- );
- }
- } test_end;
-
- return;
-}
-
-#define FCALL_TEST1_STR "this is test1"
-#define FCALL_TEST2_STR "and this is test2"
-
-void fcall_param_add_test_case(test_t t)
-{
- fcall_param_t param;
- sci_msg_t msg;
- unsigned char buffer[1024];
-
- test_case_begin(t, "add");
-
- fcall_param_init(&param, "test_add", 12345);
-
- test_begin(t, "init msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, buffer, 1024))
- && (EINVAL != errno)
- );
- } test_end;
-
- test_begin(t, "param = NULL")
- {
- test_fail_unless(
- (fcall_param_add(NULL, &msg, "test", strlen(FCALL_TEST1_STR), FCALL_TEST1_STR) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "msg = NULL")
- {
- test_fail_unless(
- (fcall_param_add(&param, NULL, "test", strlen(FCALL_TEST1_STR), FCALL_TEST1_STR) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "id = NULL")
- {
- test_fail_unless(
- (fcall_param_add(&param, &msg, NULL, strlen(FCALL_TEST1_STR), FCALL_TEST1_STR) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "length >= FUNCTION_CALL_PARAM_MAX_SIZE")
- {
- test_fail_unless(
- (fcall_param_add(&param, &msg, "test", FUNCTION_CALL_PARAM_MAX_SIZE + 1, FCALL_TEST1_STR) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "length >= free place")
- {
- test_fail_unless(
- (fcall_param_add(&param, &msg, "test", 1024, FCALL_TEST1_STR) < 0)
- && (errno == ENOSPC)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check 1st add")
- {
- test_fail_unless(
- (fcall_param_add(&param, &msg, "test1", strlen(FCALL_TEST1_STR), FCALL_TEST1_STR) >= 0)
- && (param.param_nb == 1)
- && !strcmp(param.param_table[0].id, "test1")
- && (param.param_table[0].length == strlen(FCALL_TEST1_STR))
- && !memcmp(param.param_table[0].data, FCALL_TEST1_STR, strlen(FCALL_TEST1_STR))
- && !strcmp((char *)msg.data_begin, "test1")
- && (ntohs(*(unsigned short *)(msg.data_begin + strlen("test1") + 1)) == strlen(FCALL_TEST1_STR))
- && !memcmp(msg.data_begin + strlen("test1") + 3, FCALL_TEST1_STR, strlen(FCALL_TEST1_STR))
- && (msg.length == strlen("test1") + 3 + strlen(FCALL_TEST1_STR))
- );
- } test_end;
-
- test_begin(t, "check 2nd add")
- {
- test_fail_unless(
- (fcall_param_add(&param, &msg, "test2", strlen(FCALL_TEST2_STR), FCALL_TEST2_STR) >= 0)
- && (param.param_nb == 2)
- && !strcmp(param.param_table[1].id, "test2")
- && (param.param_table[1].length == strlen(FCALL_TEST2_STR))
- && !memcmp(param.param_table[1].data, FCALL_TEST2_STR, strlen(FCALL_TEST2_STR))
- && !strcmp((char *)msg.data_begin, "test2")
- && (ntohs(*(unsigned short *)(msg.data_begin + strlen("test2") + 1)) == strlen(FCALL_TEST2_STR))
- && !memcmp(msg.data_begin + strlen("test2") + 3, FCALL_TEST2_STR, strlen(FCALL_TEST2_STR))
- && (msg.length == strlen("test1") + 3 + strlen(FCALL_TEST1_STR) + strlen("test2") + 3 + strlen(FCALL_TEST2_STR))
- );
-
- test_begin(t, "check add long")
- {
- long test_long = 0x11223344L;
- long test_long_result = ntohl(test_long);
- test_fail_unless(
- (fcall_param_add_long(&param, &msg, "test_long", &test_long) >= 0)
- && (param.param_nb == 3)
- && !strcmp(param.param_table[2].id, "test_long")
- && (param.param_table[2].length == sizeof(long))
- && !memcmp(param.param_table[2].data, &test_long_result, sizeof(long))
- && !strcmp((char *)msg.data_begin, "test_long")
- && (ntohs(*(unsigned short *)(msg.data_begin + strlen("test_long") + 1)) == sizeof(long))
- && !memcmp(msg.data_begin + strlen("test_long") + 3, &test_long_result, sizeof(long))
- && (msg.length == strlen("test1") + 3 + strlen(FCALL_TEST1_STR) \
- + strlen("test2") + 3 + strlen(FCALL_TEST2_STR) \
- + strlen("test_long") + 3 + sizeof(long))
- );
- } test_end;
-
- test_begin(t, "check add short")
- {
- short test_short = 0x1122;
- short test_short_result = ntohs(test_short);
- test_fail_unless(
- (fcall_param_add_short(&param, &msg, "test_short", &test_short) >= 0)
- && (param.param_nb == 4)
- && !strcmp(param.param_table[3].id, "test_short")
- && (param.param_table[3].length == sizeof(short))
- && !memcmp(param.param_table[3].data, &test_short_result, sizeof(short))
- && !strcmp((char *)msg.data_begin, "test_short")
- && (ntohs(*(unsigned short *)(msg.data_begin + strlen("test_short") + 1)) == sizeof(short))
- && !memcmp(msg.data_begin + strlen("test_short") + 3, &test_short_result, sizeof(short))
- && (msg.length == strlen("test1") + 3 + strlen(FCALL_TEST1_STR) \
- + strlen("test2") + 3 + strlen(FCALL_TEST2_STR) \
- + strlen("test_long") + 3 + sizeof(long) \
- + strlen("test_short") + 3 + sizeof(short))
- );
- } test_end;
-
- test_begin(t, "check add long long")
- {
- long long test_ll = 0x0000123456789ABCLL;
- long long test_ll_result = 0x34120000BC9A7856LL;
- test_fail_unless(
- (fcall_param_add_ll(&param, &msg, "test_ll", &test_ll) >= 0)
- && (param.param_nb == 5)
- && !strcmp(param.param_table[4].id, "test_ll")
- && (param.param_table[4].length == sizeof(long long))
- && !memcmp(param.param_table[4].data, &test_ll_result, sizeof(long long))
- && !strcmp((char *)msg.data_begin, "test_ll")
- && (ntohs(*(unsigned short *)(msg.data_begin + strlen("test_ll") + 1)) == sizeof(long long))
- && !memcmp(msg.data_begin + strlen("test_ll") + 3, &test_ll_result, sizeof(long long))
- && (msg.length == strlen("test1") + 3 + strlen(FCALL_TEST1_STR) \
- + strlen("test2") + 3 + strlen(FCALL_TEST2_STR) \
- + strlen("test_long") + 3 + sizeof(long) \
- + strlen("test_short") + 3 + sizeof(short) \
- + strlen("test_ll") + 3 + sizeof(long long))
- );
- } test_end;
-
- } test_end;
-
- return;
-}
-#undef FCALL_TEST1_STR
-#undef FCALL_TEST2_STR
-
-#define FCALL_DATA_STR "this is a test"
-void fcall_param_bind_test_case(test_t t)
-{
- fcall_param_t param;
- sci_msg_t msg;
- unsigned char buffer[256];
- int data_int;
- char data_str[32];
-
- test_case_begin(t, "bind_param");
-
- fcall_param_init(&param, "test_bind", 54321);
-
- test_begin(t, "init msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, buffer, 256))
- && (EINVAL != errno)
- );
- } test_end;
-
- test_begin(t, "fcall = NULL")
- {
- test_fail_unless(
- (fcall_param_bind(NULL, &msg, "data_int", sizeof(data_int), &data_int) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "msg = NULL")
- {
- test_fail_unless(
- (fcall_param_bind(&param, NULL, "data_int", sizeof(data_int), &data_int) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "id = NULL")
- {
- test_fail_unless(
- (fcall_param_bind(&param, &msg, NULL, sizeof(data_int), &data_int) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "max_length <= 0")
- {
- test_fail_unless(
- (fcall_param_bind(&param, &msg, "data_int", 0, &data_int) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "data = NULL")
- {
- test_fail_unless(
- (fcall_param_bind(&param, &msg, "data_int", sizeof(data_int), NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- data_int = 12345;
- fcall_param_add(&param, &msg, "data_int", sizeof(data_int), &data_int);
- strcpy(data_str, FCALL_DATA_STR);
- fcall_param_add(&param, &msg, "data_str", strlen(FCALL_DATA_STR), &data_str);
-
- test_begin(t, "check bind")
- {
- memset(data_str, '\0', 32);
- test_fail_unless(
- (fcall_param_bind(&param, &msg, "data_str", strlen(FCALL_DATA_STR), data_str) == (int)strlen(FCALL_DATA_STR))
- && !memcmp(data_str, FCALL_DATA_STR, strlen(FCALL_DATA_STR))
- );
- data_int = 0;
- test_fail_unless(
- (fcall_param_bind(&param, &msg, "data_int", sizeof(data_int), &data_int) == sizeof(data_int))
- && (data_int == 12345)
- );
- } test_end;
-
- test_begin(t, "check bind long")
- {
- long data_long = 0x11223344L;
- long data_long_result = data_long;
- fcall_param_add_long(&param, &msg, "data_long", &data_long);
- data_long = 0;
- test_fail_unless(
- (fcall_param_bind_long(&param, &msg, "data_long", &data_long) == sizeof(data_long))
- && (data_long == data_long_result)
- );
- } test_end;
-
- test_begin(t, "check bind short")
- {
- short data_short = 0x1122;
- short data_short_result = data_short;
- fcall_param_add_short(&param, &msg, "data_short", &data_short);
- data_short = 0;
- test_fail_unless(
- (fcall_param_bind_short(&param, &msg, "data_short", &data_short) == sizeof(data_short))
- && (data_short == data_short_result)
- );
- } test_end;
-
- test_begin(t, "check bind long long")
- {
- long long data_ll = 0x1122334455667788LL;
- long long data_ll_result = data_ll;
- fcall_param_add_ll(&param, &msg, "data_ll", &data_ll);
- data_ll = 0;
- test_fail_unless(
- (fcall_param_bind_ll(&param, &msg, "data_ll", &data_ll) == sizeof(data_ll))
- && (data_ll == data_ll_result)
- );
- } test_end;
-
- test_begin(t, "check bind id failure")
- {
- data_int = 0;
- test_fail_unless(
- (fcall_param_bind(&param, &msg, "id_not_existing", sizeof(data_int), &data_int) < 0)
- && (errno == ENOENT)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- return;
-}
-
-void fcall_is_param_test_case(test_t t)
-{
- fcall_param_t param;
- sci_msg_t msg;
- unsigned char buffer[256];
- int data_int;
- char data_str[32];
-
- test_case_begin(t, "is_param");
-
- fcall_param_init(&param, "test_is", 54321);
-
- test_begin(t, "init msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, buffer, 256))
- && (EINVAL != errno)
- );
- } test_end;
-
- test_begin(t, "fcall = NULL")
- {
- test_fail_unless(
- !fcall_is_param(NULL, &msg, "data_int")
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "msg = NULL")
- {
- test_fail_unless(
- !fcall_is_param(&param, NULL, "data_int")
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "id = NULL")
- {
- test_fail_unless(
- !fcall_is_param(&param, &msg, NULL)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "param_nb = 0")
- {
- param.param_nb = 0;
- test_fail_unless(
- !fcall_is_param(&param, &msg, "data_int")
- && (errno == ENOENT)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- data_int = 12345;
- fcall_param_add(&param, &msg, "data_int", sizeof(data_int), &data_int);
- strcpy(data_str, FCALL_DATA_STR);
- fcall_param_add(&param, &msg, "data_str", strlen(FCALL_DATA_STR), &data_str);
-
- test_begin(t, "check is")
- {
- test_fail_unless(
- fcall_is_param(&param, &msg, "data_int")
- && (errno != EINVAL)
- && (errno != ENOENT)
- );
- test_fail_unless(
- fcall_is_param(&param, &msg, "data_str")
- && (errno != EINVAL)
- && (errno != ENOENT)
- );
- } test_end;
-
- test_begin(t, "check is id failure")
- {
- test_fail_unless(
- !fcall_is_param(&param, &msg, "id_not_existing")
- && (errno != EINVAL)
- && (errno != ENOENT)
- );
- } test_end;
-
- return;
-}
-
-void fcall_param_test_suite(test_t t)
-{
- test_suite_begin(t, "fcall_param");
- fcall_param_init_test_case(t);
- fcall_param_reset_test_case(t);
- fcall_param_add_test_case(t);
- fcall_is_param_test_case(t);
- fcall_param_bind_test_case(t);
-}
diff --git a/cesar/host/test/src/test_host.c b/cesar/host/test/src/test_host.c
deleted file mode 100644
index df88f0827b..0000000000
--- a/cesar/host/test/src/test_host.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test_host.c
- * \brief Test the fulminata host station
- * \ingroup test
- */
-#include "common/std.h"
-#include <stdint.h>
-
-#include "lib/test.h"
-
-#include <stdint.h> // for uint8_t, uint16_t and uint32_t types
-
-char dump_buffer[4096];
-uint32_t maximus_pending_isrs;
-
-void fcall_param_test_suite (test_t t);
-
-void fcall_test_suite (test_t t);
-
-void probe_test_suite (test_t t);
-
-void netclock_test_suite (test_t t);
-
-void sci_msg_test_suite (test_t t);
-
-void sci_test_suite (test_t t);
-
-void station_test_suite (test_t t);
-
-void system_test_suite (test_t t);
-
-int
-main (int argc, char **argv)
-{
- test_t t;
- test_init(t, argc, argv);
-
- sci_msg_test_suite(t);
- sci_test_suite(t);
- station_test_suite(t);
- fcall_param_test_suite(t);
- fcall_test_suite(t);
- probe_test_suite(t);
- netclock_test_suite(t);
- system_test_suite(t);
-
- test_result(t);
- return test_nb_failed(t) == 0 ? 0 : 1;
-}
diff --git a/cesar/host/test/src/test_netclock.c b/cesar/host/test/src/test_netclock.c
deleted file mode 100644
index 858e13d8a7..0000000000
--- a/cesar/host/test/src/test_netclock.c
+++ /dev/null
@@ -1,499 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test_netclock.c
- * \brief Test all netclock functions.
- * \ingroup test
- */
-
-#include <fcntl.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include "common/std.h"
-#include "host/netclock/netclock.h"
-#include "lib/test.h"
-#include <stdio.h>
-extern char dump_buffer[];
-
-void netclock_init_test_case(test_t t)
-{
- netclock_ctx_t netclock;
- station_ctx_t station;
- sci_ctx_t sci;
-
- test_case_begin(t, "init");
-
- sci_init(&sci, &station);
-
- test_begin(t, "netclock = NULL")
- {
- test_fail_unless(
- (netclock_init(NULL, &sci) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "sci = NULL")
- {
- test_fail_unless(
- (netclock_init(&netclock, NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check init")
- {
- test_fail_unless(
- (netclock_init(&netclock, &sci) >= 0)
- && (netclock.sci == &sci)
- && (netclock.callback_nb == 0)
- && (netclock.current_id == 1)
- && (netclock.sci->msg_callback[SCI_MSG_TYPE_NETWORK_CLOCK].function == netclock_recv)
- && (netclock.sci->msg_callback[SCI_MSG_TYPE_NETWORK_CLOCK].data == &netclock)
- );
- } test_end;
-
- return;
-}
-
-#define FCALL_DATA_STR "fill_hdr test"
-
-void netclock_fill_hdr_test_case(test_t t)
-{
- netclock_ctx_t netclock;
- station_ctx_t station;
- sci_ctx_t sci;
- sci_msg_t msg;
- unsigned char buffer[256];
-
- test_case_begin(t, "fill_hdr");
- station_init(&station);
- sci_init(&sci, &station);
- netclock_init(&netclock, &sci);
-
- test_begin(t, "init msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, buffer, 256))
- && (EINVAL != errno)
- );
- } test_end;
-
- test_begin(t, "netclock = NULL")
- {
- test_fail_unless(
- (netclock_fill_hdr(NULL, &msg, NETWORK_CLOCK_TYPE_SYSTEM, 0, 0x1234567890abcdefULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "msg = NULL")
- {
- test_fail_unless(
- (netclock_fill_hdr(&netclock, NULL, NETWORK_CLOCK_TYPE_SYSTEM, 0, 0x1234567890abcdefULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "type < 0")
- {
- test_fail_unless(
- (netclock_fill_hdr(&netclock, &msg, -1, 0, 0x1234567890abcdefULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "type > max type value")
- {
- test_fail_unless(
- (netclock_fill_hdr(&netclock, &msg, NETWORK_CLOCK_TYPE_NB, 0, 0x1234567890abcdefULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check fill_hdr")
- {
- int previous_id = netclock.current_id;
- test_fail_unless(
- (netclock_fill_hdr(&netclock, &msg, NETWORK_CLOCK_TYPE_SYSTEM, 0xa55a, 0x1234567890abcdefULL) >= 0)
- && ((unsigned char *)msg.hdr.netclock == msg.data_begin)
- && (msg.hdr.netclock->type == NETWORK_CLOCK_TYPE_SYSTEM)
- && (ntohs(msg.hdr.netclock->id) == previous_id)
- && (ntohs(msg.hdr.netclock->flags) == 0xa55a)
- && (ntohl(msg.hdr.netclock->tick_high) == 0x12345678)
- && (ntohl(msg.hdr.netclock->tick_low) == 0x90abcdef)
- && (netclock.current_id == ((previous_id + 1) & NETWORK_CLOCK_ID_MASK))
- );
- } test_end;
-
- test_begin(t, "id rollover")
- {
- netclock.current_id = NETWORK_CLOCK_ID_MASK;
- test_fail_unless(
- (netclock_fill_hdr(&netclock, &msg, NETWORK_CLOCK_TYPE_SYSTEM, 0xa55a, 0x1234567890abcdefULL) >= 0)
- && ((unsigned char *)msg.hdr.netclock == msg.data_begin)
- && (ntohs(msg.hdr.netclock->id) == NETWORK_CLOCK_ID_MASK)
- && (netclock.current_id == 1) /* 0 is not allowed */
- );
- } test_end;
-
- station_down(&station);
- return;
-}
-
-static void _test_schedule(void *data)
-{
- return;
-}
-
-static void _fake_schedule(void *data)
-{
- return;
-}
-
-void netclock_schedule_test_case(test_t t)
-{
- netclock_ctx_t netclock;
- netclock_callback_t callback, cb_reference;
- station_ctx_t station;
- sci_ctx_t sci;
- char data[32];
- netclock_id_t id;
- sci_msg_hdr_t *hdr;
- netclock_msg_hdr_t *nclock_hdr;
- int fd_in, len;
- unsigned char buffer[1024];
-
- test_case_begin(t, "schedule");
-
- station_init(&station);
- sci_init(&sci, &station);
- netclock_init(&netclock, &sci);
-
- test_begin(t, "netclock = NULL")
- {
- test_fail_unless(
- (netclock_schedule(NULL, &callback, NETWORK_CLOCK_TYPE_PHY, 0x1234567890abcdefULL, _test_schedule, data, &id) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end
-
- test_begin(t, "callback = NULL")
- {
- test_fail_unless(
- (netclock_schedule(&netclock, NULL, NETWORK_CLOCK_TYPE_PHY, 0x1234567890abcdefULL, _test_schedule, data, &id) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end
-
- test_begin(t, "type < 0")
- {
- test_fail_unless(
- (netclock_schedule(&netclock, &callback, -1, 0x1234567890abcdefULL, _test_schedule, data, &id) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "type >= max value")
- {
- test_fail_unless(
- (netclock_schedule(&netclock, &callback, NETWORK_CLOCK_TYPE_NB, 0x1234567890abcdefULL, _test_schedule, data, &id) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end
-
- test_begin(t, "tick < current_tick")
- {
- station.current_tick_tck = 0x2234567890abcdefULL;
- test_fail_unless(
- (netclock_schedule(&netclock, &callback, NETWORK_CLOCK_TYPE_PHY, 0x1234567890abcdefULL, _test_schedule, data, &id) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end
-
- test_begin(t, "id = NULL")
- {
- test_fail_unless(
- (netclock_schedule(&netclock, &callback, NETWORK_CLOCK_TYPE_PHY, 0x1234567890abcdefULL, _test_schedule, data, &id) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end
-
-#ifdef STATION_SOCK
- fd_in = station.sock_pair_fd;
-#else /* STATION_SOCK */
- fd_in = open(station.pipe_out_name, O_RDONLY);
-#endif /* STATION_SOCK */
-
- test_begin(t, "recv netclock msg")
- {
- station.current_tick_tck = 0x0ULL;
- id = 0;
- set_node_init(&cb_reference.node);
- cb_reference.id = callback.id + 1;
- test_fail_unless(
- (netclock_schedule(&netclock, &callback, NETWORK_CLOCK_TYPE_PHY, 0x1234567890abcdefULL, _test_schedule, data, &id) >= 0)
- && (set_begin(&netclock.callback_set) == set_find(&netclock.callback_set, &cb_reference.node))
- && (set_begin(&netclock.callback_set) == &callback.node)
- && (callback.function == _test_schedule)
- && (callback.data == data)
- && (callback.id == netclock.current_id - 1)
- && (callback.tick == 0x1234567890abcdefULL)
- && (id == netclock.current_id - 1)
- && (netclock.callback_nb == 1)
- );
-
- test_fail_if((len = read(fd_in, buffer, sizeof(sci_msg_hdr_t))) != sizeof(sci_msg_hdr_t));
- hdr = (sci_msg_hdr_t *)buffer;
- test_fail_unless(
- (hdr->type == SCI_MSG_TYPE_NETWORK_CLOCK)
- );
- test_fail_if((len = read(fd_in, buffer + sizeof(sci_msg_hdr_t), htonl(hdr->length)))
- != sizeof(netclock_msg_hdr_t));
- nclock_hdr = (netclock_msg_hdr_t *)(buffer + sizeof(sci_msg_hdr_t));
- test_fail_unless(
- (nclock_hdr->type == NETWORK_CLOCK_TYPE_PHY)
- && (ntohl(nclock_hdr->tick_high) == 0x12345678)
- && (ntohl(nclock_hdr->tick_low) == 0x90abcdef)
- );
- } test_end;
-
- station_down(&station);
-#ifndef STATION_SOCK
- close(fd_in);
-#endif /* STATION_SOCK */
- return;
-}
-
-void netclock_unschedule_test_case(test_t t)
-{
- netclock_ctx_t netclock;
- station_ctx_t station;
- sci_ctx_t sci;
- sci_msg_hdr_t *hdr;
- netclock_msg_hdr_t *nclock_hdr;
- int fd_in;
- int len;
- unsigned char buffer[1024];
- netclock_id_t id1 = 0x1233;
- netclock_id_t id2 = 0x1234;
-
- test_case_begin(t, "unschedule");
-
- station_init(&station);
- sci_init(&sci, &station);
- netclock_init(&netclock, &sci);
-
- test_begin(t, "netclock = NULL")
- {
- test_fail_unless(
- (netclock_unschedule(NULL, 0) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end
-
- test_begin(t, "check unschedule")
- {
- netclock_callback_t callback1, callback2, cb_ref;
- callback1.id = id1;
- callback1.function = &_fake_schedule;
- set_node_init(&callback1.node);
- set_insert (&netclock.callback_set, &callback1.node);
- callback2.id = id2;
- callback2.function = &_test_schedule;
- set_node_init(&callback2.node);
- set_insert (&netclock.callback_set, &callback2.node);
- netclock.callback_nb = 2;
- cb_ref.id = id1;
- set_node_init(&cb_ref.node);
- test_fail_unless(
- (netclock_unschedule (&netclock, id1) >= 0)
- && (set_find(&netclock.callback_set, &cb_ref.node) == NULL)
- && (netclock.callback_nb == 1)
- );
-
-#ifdef STATION_SOCK
- fd_in = station.sock_pair_fd;
-#else /* STATION_SOCK */
- fd_in = open(station.pipe_out_name, O_RDONLY);
-#endif /* STATION_SOCK */
-
- test_fail_if((len = read(fd_in, buffer, sizeof(sci_msg_hdr_t))) != sizeof(sci_msg_hdr_t));
- hdr = (sci_msg_hdr_t *)buffer;
- test_fail_unless(
- (hdr->type == SCI_MSG_TYPE_NETWORK_CLOCK)
- );
- test_fail_if((len = read(fd_in, buffer + sizeof(sci_msg_hdr_t), htonl(hdr->length)))
- != sizeof(netclock_msg_hdr_t));
- nclock_hdr = (netclock_msg_hdr_t *)(buffer + sizeof(sci_msg_hdr_t));
- test_fail_unless(
- (nclock_hdr->type == NETWORK_CLOCK_TYPE_REMOVE)
- && (ntohs (nclock_hdr->id) == id1)
- );
- } test_end;
-
-
- test_begin(t, "id not exist")
- {
- test_fail_unless(
- (netclock_unschedule (&netclock, id1) < 0)
- && (errno == ENOENT)
- && (netclock.callback_nb == 1)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- station_down(&station);
-#ifndef STATION_SOCK
- close(fd_in);
-#endif /* STATION_SOCK */
-
- return;
-}
-
-static void _test_callback(void *data)
-{
- char *buffer;
- if(data == NULL)
- return;
- buffer = (char *)data;
- strcpy(buffer, "test_callback");
- return;
-}
-
-void netclock_recv_test_case(test_t t)
-{
- netclock_ctx_t netclock;
- netclock_callback_t callback;
- station_ctx_t station;
- sci_ctx_t sci;
- sci_msg_t msg;
- sci_msg_hdr_t hdr;
- netclock_id_t id;
- unsigned char buffer[256];
- char data_buffer[32];
- int fd_in;
-
- test_case_begin(t, "recv");
-
- station_init(&station);
- sci_init(&sci, &station);
- netclock_init(&netclock, &sci);
-
- test_begin(t, "init msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, buffer, 256))
- && (EINVAL != errno)
- );
- } test_end;
-
- test_begin(t, "msg = NULL")
- {
- test_fail_unless(
- (netclock_recv(NULL, &netclock) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "netclock = NULL")
- {
- test_fail_unless(
- (netclock_recv(&msg, NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
-#ifdef STATION_SOCK
- fd_in = station.sock_pair_fd;
-#else /* STATION_SOCK */
- fd_in = open(station.pipe_out_name, O_RDONLY);
-#endif /* STATION_SOCK */
-
- memset(data_buffer, '\0', 32);
-
- test_begin(t, "recv")
- {
- int r;
- test_fail_unless(
- (netclock_schedule (
- &netclock,
- &callback,
- NETWORK_CLOCK_TYPE_PHY,
- 0x1234567890abcdefULL,
- _test_callback,
- data_buffer, &id) >= 0)
- );
-
- test_fail_unless(
- (read(fd_in, &hdr, sizeof(sci_msg_hdr_t)) == (int)sizeof(sci_msg_hdr_t))
- );
- test_fail_unless(
- (0 <= sci_msg_push (&msg, ntohl (hdr.length)))
- && (EINVAL != errno)
- && (ENOSPC != errno)
- );
- r = read (fd_in, msg.data_begin, ntohl (hdr.length));
- test_fail_if (r != (int) ntohl (hdr.length));
- test_fail_unless(
- (netclock_recv(&msg, &netclock) >= 0)
- && !memcmp(data_buffer, "test_callback", strlen("test_callback") + 1)
- && (netclock.callback_nb == 0)
- );
- } test_end;
-
-#ifndef STATION_SOCK
- close(fd_in);
-#endif /* STATION_SOCK */
- station_down(&station);
-
- return;
-}
-
-void netclock_test_suite(test_t t)
-{
- test_suite_begin(t, "netclock");
- netclock_init_test_case(t);
- netclock_fill_hdr_test_case(t);
- netclock_schedule_test_case(t);
- netclock_unschedule_test_case(t);
- netclock_recv_test_case(t);
-}
diff --git a/cesar/host/test/src/test_probe.c b/cesar/host/test/src/test_probe.c
deleted file mode 100644
index f7d0f83848..0000000000
--- a/cesar/host/test/src/test_probe.c
+++ /dev/null
@@ -1,374 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test_probe.c
- * \brief Test all probe functions.
- * \ingroup test
- */
-
-#include <string.h>
-#include <stdio.h>
-#include <arpa/inet.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include "common/std.h"
-#include "host/fcall/fcall.h"
-#include "lib/test.h"
-
-extern char dump_buffer[];
-
-void probe_init_test_case(test_t t)
-{
- fcall_ctx_t fcall;
- sci_ctx_t sci;
- station_ctx_t station;
- probe_ctx_t probe;
- sci_init(&sci, &station);
- fcall_init(&fcall, &sci);
-
- test_case_begin(t, "init");
-
- test_begin(t, "probe = NULL")
- {
- test_fail_unless(
- (probe_init(NULL, &fcall) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "fcall = NULL")
- {
- test_fail_unless(
- (probe_init(&probe, NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check init")
- {
- int i;
- test_fail_unless(
- (probe_init(&probe, &fcall) >= 0)
- && (probe.var_nb == 0)
- && !strcmp(fcall.function_table[0].id, PROBE_ID)
- && (fcall.function_table[0].function == probe_recv)
- && (fcall.function_table[0].data == &probe)
- );
- for(i = 0; i < PROBE_VAR_MAX_NB; i++)
- {
- test_fail_unless(
- (probe.var_table[i].id[0] == '\0')
- );
- }
- } test_end;
-
- return;
-}
-
-static int var1;
-static char var2[32];
-static char var3;
-#define TEST_STRING "test string"
-
-void probe_register_test_case(test_t t)
-{
- fcall_ctx_t fcall;
- sci_ctx_t sci;
- station_ctx_t station;
- probe_ctx_t probe;
-
- test_case_begin(t, "register");
- sci_init(&sci, &station);
- fcall_init(&fcall, &sci);
- probe_init(&probe, &fcall);
-
- test_begin(t, "probe = NULL")
- {
- test_fail_unless(
- (probe_register(NULL, "var1", sizeof(var1), &var1) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "id = NULL")
- {
- test_fail_unless(
- (probe_register(&probe, NULL, sizeof(var1), &var1) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "addr = NULL")
- {
- test_fail_unless(
- (probe_register(&probe, "var1", sizeof(var1), NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check register")
- {
- test_fail_unless(
- (probe_register(&probe, "var1", sizeof(var1), &var1) >= 0)
- && (probe.var_nb == 1)
- && !strcmp(probe.var_table[0].id, "var1")
- && (probe.var_table[0].addr == &var1)
- );
- test_fail_unless(
- (probe_register(&probe, "var2", sizeof(var2), var2) >= 0)
- && (probe.var_nb == 2)
- && !strcmp(probe.var_table[1].id, "var2")
- && (probe.var_table[1].addr == var2)
- );
- } test_end;
-
- test_begin(t, "check already existing variable")
- {
- test_fail_unless(
- (probe_register(&probe, "var1", sizeof(var1), &var1) < 0)
- && (errno == EEXIST)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check full table")
- {
-// int i;
- probe.var_nb = PROBE_VAR_MAX_NB;
- test_fail_unless(
- (probe_register(&probe, "var3", sizeof(var3), &var3) < 0)
- && (errno == ENOSPC)
- );
- // reset errno
- errno = 0;
-// probe.var_nb = 2;
-// for(i = 0; i < PROBE_VAR_MAX_NB; i++)
-// {
-// sprintf(probe.var_table[i].id, "var_%d", i);
-// probe.var_table[i].addr = &var3;
-// }
-// test_fail_unless(
-// (probe_register(&probe, "var3", sizeof(var3), &var3) < 0)
-// && (errno == ENOSPC)
-// );
- } test_end;
-
- return;
-}
-
-void probe_recv_test_case(test_t t)
-{
- station_ctx_t station;
- fcall_ctx_t fcall;
- sci_ctx_t sci;
- sci_msg_t msg, *msg_ref;
- fcall_param_t param, *param_ref;
- probe_ctx_t probe;
- unsigned char buffer[256], *ptr;
- int value1;
- char value2[32];
- char value3;
-
- test_case_begin(t, "recv");
-
- station_init(&station);
- sci_init(&sci, &station);
- fcall_init(&fcall, &sci);
- probe_init(&probe, &fcall);
-
- test_begin(t, "init msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, buffer, 256))
- && (EINVAL != errno)
- );
- } test_end;
-
- fcall_param_init(&param, PROBE_ID, 12345);
- param_ref = &param;
- msg_ref = &msg;
-
- probe_register(&probe, "var1", sizeof(var1), &var1);
- probe_register(&probe, "var2", sizeof(var2), var2);
- probe_register(&probe, "var3", sizeof(var3), &var3);
-
- fcall_fill_hdr(&fcall, &msg, &param, 0);
- msg.hdr.fcall->type = FUNCTION_CALL_TYPE_REQ;
-
- test_begin(t, "fcall = NULL")
- {
- test_fail_unless(
- (probe_recv(NULL, &param_ref, &msg_ref, &probe) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "param = NULL")
- {
- test_fail_unless(
- (probe_recv(&fcall, NULL, &msg_ref, &probe) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "msg = NULL")
- {
- test_fail_unless(
- (probe_recv(&fcall, &param_ref, NULL, &probe) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "probe = NULL")
- {
- test_fail_unless(
- (probe_recv(&fcall, &param_ref, &msg_ref, NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- value1 = 0x12345678;
- strcpy(value2, TEST_STRING);
- value3 = 'A';
-
- var1 = 0xdeadbeef;
- strcpy(var2, "deadbeef");
- var3 = 'Z';
-
- fcall_param_init(&param, PROBE_ID, 54321);
- fcall_param_add(&param, &msg, "var1", sizeof(value1), &value1);
- fcall_param_add(&param, &msg, "var2", strlen(value2) + 1, value2);
- fcall_param_add(&param, &msg, "var3", sizeof(value3), &value3);
-
- test_begin(t, "check recv with set")
- {
- test_fail_unless(
- (probe_recv(&fcall, &param_ref, &msg_ref, &probe) == 3)
- && !strcmp(param_ref->id, PROBE_ID)
- && (param_ref->param_nb == 3)
- );
- test_fail_unless(
- (fcall_param_bind(param_ref, msg_ref, "var1", sizeof(value1), &value1) == 0)
- && (value1 == 0x12345678)
- && (var1 == 0x12345678)
- && (fcall_param_bind(param_ref, msg_ref, "var2", sizeof(value2), value2) == 0)
- && !strcmp(value2, TEST_STRING)
- && !strcmp(var2, TEST_STRING)
- && (fcall_param_bind(param_ref, msg_ref, "var3", sizeof(value3), &value3) == 0)
- && (value3 == 'A')
- && (var3 == 'A')
- );
- } test_end;
-
- fcall_param_init(&param, PROBE_ID, 0x1234);
- fcall_param_add(&param, &msg, "var2", sizeof(var2) + 1, value2);
- param_ref = &param;
- msg_ref = &msg;
-
- test_begin(t, "check recv with too big set")
- {
- test_fail_unless(
- (probe_recv(&fcall, &param_ref, &msg_ref, &probe) == 0)
- && (param_ref->param_nb == 0)
- );
- } test_end;
-
- value1 = 0xbeefdead;
- strcpy(value2, "beefdead");
- value3 = 'Y';
- fcall_param_init(&param, PROBE_ID, 0x4321);
- fcall_param_add(&param, &msg, "var1", 0, NULL);
- fcall_param_add(&param, &msg, "var2", 0, NULL);
- fcall_param_add(&param, &msg, "var3", 0, NULL);
- param_ref = &param;
- msg_ref = &msg;
-
- test_begin(t, "check recv with get")
- {
- test_fail_unless(
- (probe_recv(&fcall, &param_ref, &msg_ref, &probe) == 3)
- && (param_ref->param_nb == 3)
- );
- test_fail_unless(
- (fcall_param_bind(param_ref, msg_ref, "var1", sizeof(value1), &value1) == sizeof(value1))
- && (value1 == 0x12345678)
- && (var1 == 0x12345678)
- && (fcall_param_bind(param_ref, msg_ref, "var2", sizeof(value2), value2) == sizeof(value2))
- && !strcmp(value2, TEST_STRING)
- && !strcmp(var2, TEST_STRING)
- && (fcall_param_bind(param_ref, msg_ref, "var3", sizeof(value3), &value3) == sizeof(value3))
- && (value3 == 'A')
- && (var3 == 'A')
- );
- } test_end;
-
- fcall_param_init(&param, PROBE_ID, 12345);
- param_ref = &param;
- msg_ref = &msg;
-
- test_begin(t, "check recv with list")
- {
- test_fail_unless(
- (probe_recv(&fcall, &param_ref, &msg_ref, &probe) == 3)
- && (param_ref->param_nb == 3)
- );
- ptr = msg_ref->data_begin;
- test_fail_unless(
- !strcmp((char *)ptr, "var3")
- && (ptr += (strlen("var3") + 1))
- && (ntohs(*(unsigned short *)(ptr)) == sizeof(var3))
- && !memcmp(ptr + 2, &var3, sizeof(var3))
- );
- ptr += (2 + sizeof(var3));
- test_fail_unless(
- !strcmp((char *)ptr, "var2")
- && (ptr += (strlen("var2") + 1))
- && (ntohs(*(unsigned short *)(ptr)) == sizeof(var2))
- && !memcmp((char *)(ptr + 2), var2, sizeof(var2))
- );
- ptr += (2 + sizeof(var2));
- test_fail_unless(
- !strcmp((char *)ptr, "var1")
- && (ptr += strlen("var1") + 1)
- && (ntohs(*(unsigned short *)(ptr)) == sizeof(var1))
- && !memcmp((char *)(ptr + 2), &var1, sizeof(var1))
- );
- } test_end;
-
- station_down(&station);
-
- return;
-}
-
-void probe_test_suite(test_t t)
-{
- test_suite_begin(t, "probe");
- probe_init_test_case(t);
- probe_register_test_case(t);
- probe_recv_test_case(t);
-}
diff --git a/cesar/host/test/src/test_sci.c b/cesar/host/test/src/test_sci.c
deleted file mode 100644
index f8231f99c5..0000000000
--- a/cesar/host/test/src/test_sci.c
+++ /dev/null
@@ -1,504 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test_sci.c
- * \brief Test all sci functions.
- * \ingroup test
- */
-
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <arpa/inet.h>
-#include <string.h>
-#include <errno.h>
-#include "common/std.h"
-#include "host/sci/sci.h"
-#include "lib/test.h"
-
-extern char dump_buffer[];
-
-void sci_init_test_case(test_t t)
-{
- sci_ctx_t sci;
- station_ctx_t station;
-
- test_case_begin(t, "init");
-
- test_begin(t, "NULL sci")
- {
- test_fail_unless(
- (sci_init(NULL, &station) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "NULL station")
- {
- test_fail_unless(
- (sci_init(&sci, NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check init call")
- {
- test_fail_unless(
- (sci_init(&sci, &station) >= 0)
- && (sci.station == &station)
- );
- } test_end;
- return;
-}
-
-static int _sci_callback(sci_msg_t *msg, void *data)
-{
- return 0;
-}
-
-void sci_register_callback_test_case(test_t t)
-{
- station_ctx_t station;
- sci_ctx_t sci;
-
- test_case_begin(t, "register_callback");
- sci_init(&sci, &station);
-
- test_begin(t, "sci = NULL")
- {
- test_fail_unless(
- (sci_register_callback(NULL, 0, NULL, NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "bad type -1")
- {
- test_fail_unless(
- (sci_register_callback(&sci, -1, NULL, NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "bad type > max")
- {
- test_fail_unless(
- (sci_register_callback(&sci, SCI_MSG_TYPE_NB, NULL, NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "registering NULL function")
- {
- test_fail_unless(
- (sci_register_callback(&sci, SCI_MSG_TYPE_SYSTEM, NULL, &station) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "registering test function")
- {
- test_fail_unless(
- (sci_register_callback(&sci, SCI_MSG_TYPE_PHY, _sci_callback, &station) >= 0)
- && (sci.msg_callback[SCI_MSG_TYPE_PHY].function == _sci_callback)
- && (sci.msg_callback[SCI_MSG_TYPE_PHY].data = &station));
- } test_end;
-
-}
-
-void sci_fill_hdr_test_case(test_t t)
-{
- station_ctx_t station;
- sci_ctx_t sci;
- sci_msg_t msg;
- unsigned char buffer[128];
-
- test_case_begin(t, "fill_hdr");
-
- test_begin(t, "init msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, buffer, 128))
- && (EINVAL != errno)
- );
- } test_end;
-
- station_init(&station);
- sci_init(&sci, &station);
-
- test_begin(t, "sci = NULL")
- {
- test_fail_unless(
- (sci_fill_hdr(NULL, &msg, SCI_MSG_TYPE_PHY, 0) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "msg = NULL")
- {
- test_fail_unless(
- (sci_fill_hdr(&sci, NULL, SCI_MSG_TYPE_PHY, 0) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "type < 0")
- {
- test_fail_unless(
- (sci_fill_hdr(&sci, &msg, -1, 0) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "type >= max")
- {
- test_fail_unless(
- (sci_fill_hdr(&sci, &msg, SCI_MSG_TYPE_NB, 0) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check content")
- {
- test_fail_unless(
- 0 <= sci_msg_push (&msg, 64)
- && (EINVAL != errno)
- && (ENOSPC != errno)
- );
- test_fail_unless(
- (sci_fill_hdr(&sci, &msg, SCI_MSG_TYPE_SYSTEM, 0xaa55) >= 0));
- test_fail_unless(
- ((unsigned char *)msg.sci_hdr == msg.data_begin));
- test_fail_unless(
- !memcmp((unsigned char *)&msg.sci_hdr->magic_id, SCI_MSG_MAGIC,
- 4));
- test_fail_unless(
- (msg.sci_hdr->version == SCI_MSG_VERSION));
- test_fail_unless(
- (msg.sci_hdr->type == SCI_MSG_TYPE_SYSTEM));
- test_fail_unless(
- (ntohl(msg.sci_hdr->length) == 64));
- test_fail_unless(
- (ntohs(msg.sci_hdr->flags) == 0xaa55));
- test_fail_unless(
- (ntohs(msg.sci_hdr->station_id) == sci.station->id));
- test_fail_unless(
- ((ntohs(msg.sci_hdr->msg_id) & ~SCI_MSG_ID_STATION) == sci.current_msg_id - 1));
- test_fail_unless(
- (ntohs(msg.sci_hdr->msg_id) & SCI_MSG_ID_STATION));
- } test_end;
-
- test_begin(t, "check msg_id rollover")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, buffer, 128))
- && (EINVAL != errno)
- );
- sci.current_msg_id = SCI_MSG_ID_MASK;
- test_fail_unless(
- (sci_fill_hdr(&sci, &msg, SCI_MSG_TYPE_SYSTEM, 0) >= 0)
- && (ntohs(msg.sci_hdr->msg_id) == (SCI_MSG_ID_MASK | SCI_MSG_ID_STATION))
- && (sci.current_msg_id == 0)
- );
- } test_end;
-
- station_down(&station);
-}
-
-#define TEST_DATA_STR "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-void sci_send_test_case(test_t t)
-{
- station_ctx_t station;
- sci_ctx_t sci;
- unsigned char msg_buffer[256], buffer[256];
- sci_msg_t msg;
- int fd_out;
-
- test_case_begin(t, "send");
- station_init(&station);
-
- test_begin(t, "init msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, msg_buffer, 256))
- && (EINVAL != errno)
- );
- } test_end;
-
- sci_init(&sci, &station);
-
- test_begin(t, "sci = NULL")
- {
- test_fail_unless(
- 0 > sci_send (NULL, &msg)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "msg = NULL")
- {
- test_fail_unless(
- 0 > sci_send (&sci, NULL)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check send")
- {
- int r;
-#ifdef STATION_SOCK
- fd_out = station.sock_pair_fd;
-#else
- fd_out = open(station.pipe_out_name, O_RDONLY);
-#endif
- test_fail_unless(
- 0 <= sci_msg_push (&msg, strlen (TEST_DATA_STR))
- && (EINVAL != errno)
- && (ENOSPC != errno)
- );
- memcpy(msg.data_begin, TEST_DATA_STR, msg.length);
- test_fail_if (0 > sci_fill_hdr (
- &sci, &msg, SCI_MSG_TYPE_FUNCTION_CALL, 0));
- test_fail_if (0 > sci_send (&sci, &msg));
-
- r = read (fd_out, buffer, msg.length);
- test_fail_if ((sci_size_t) r != msg.length);
- test_fail_if (memcmp (msg.data_begin, buffer, msg.length));
- } test_end;
- close(fd_out);
- station_down(&station);
-}
-
-#define TEST_RECV_STR "test_recv"
-static int _sci_send_callback(sci_msg_t *msg, void *data)
-{
- unsigned char *buffer;
- buffer = (unsigned char *)data;
-
- if((msg == NULL)
- || (msg->length != sizeof(station_msg_hdr_t) + strlen(TEST_DATA_STR))
- || (msg->length
- != (sci_size_t) (msg->data_end - msg->data_begin))
- || ((unsigned char *)msg->hdr.station != msg->data_begin)
- || (buffer == NULL))
- return -1;
- if(msg->hdr.station->type != SYSTEM_TYPE_IDLE)
- return -1;
- if (0 > sci_msg_pop (msg, sizeof(station_msg_hdr_t)))
- return -1;
- if(memcmp(msg->data_begin, TEST_DATA_STR, strlen(TEST_DATA_STR)))
- return -1;
-
- memcpy(buffer, TEST_RECV_STR, strlen(TEST_RECV_STR));
- return 0;
-}
-
-void sci_recv_test_case(test_t t)
-{
- station_ctx_t station;
- sci_ctx_t sci;
- unsigned char msg_buffer[256], data_buffer[16];
- sci_msg_t msg;
- int fd_in;
- char *magic_id = SCI_MSG_MAGIC;
-
- test_case_begin(t, "recv");
- memset(msg_buffer, '\0', 256);
- memset(data_buffer, '\0', 16);
- station_init(&station);
- //station.pipe_log_fd = 1;
- station.current_tick_tck = 0x1234567890abcdefULL;
-
- test_begin(t, "init msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, msg_buffer, 256))
- && (EINVAL != errno)
- );
- } test_end;
-
- sci_init(&sci, &station);
-
- test_begin(t, "sci = NULL")
- {
- test_fail_unless(
- (sci_recv(NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- sci_register_callback(&sci, SCI_MSG_TYPE_SYSTEM, _sci_send_callback, data_buffer);
-
- test_begin(t, "push msg")
- {
- test_fail_unless(
- 0 <= sci_msg_push (&msg, strlen (TEST_DATA_STR))
- && (EINVAL != errno)
- && (ENOSPC != errno)
- );
- memcpy(msg.data_begin, TEST_DATA_STR, strlen(TEST_DATA_STR));
- test_fail_unless(
- 0 <= sci_msg_push (&msg, sizeof (station_msg_hdr_t))
- && (EINVAL != errno)
- && (ENOSPC != errno)
- );
- msg.hdr.station = (station_msg_hdr_t *)msg.data_begin;
- msg.hdr.station->type = SYSTEM_TYPE_IDLE;
- } test_end;
-
- test_begin(t, "fill hdr")
- {
- test_fail_unless(
- sci_fill_hdr(&sci, &msg, SCI_MSG_TYPE_SYSTEM, 0) >= 0
- );
- } test_end;
-#ifdef STATION_SOCK
- fd_in = station.sock_pair_fd;
-#else
- fd_in = open(station.pipe_in_name, O_WRONLY);
-#endif
- test_begin(t, "bad magic")
- {
- int r;
-
- ((char *)&msg.sci_hdr->magic_id)[2] = magic_id[2] + 1;
-
- r = write (fd_in, msg.data_begin, msg.length);
- test_fail_if ((sci_size_t) r != msg.length);
-
- r = sci_recv (&sci);
- test_fail_unless (r < 0 && errno == EPROTOTYPE);
-
- // reset errno
- errno = 0;
- ((char *)&msg.sci_hdr->magic_id)[2] = magic_id[2];
- } test_end;
-
- test_begin(t, "length > SCI_MSG_MAX_SIZE")
- {
- int r;
-
- msg.sci_hdr->length = htonl(SCI_MSG_MAX_SIZE + 1 - sizeof(sci_msg_hdr_t));
-
- r = write (fd_in, msg.data_begin, msg.length);
- test_fail_if ((sci_size_t) r != msg.length);
-
- r = sci_recv (&sci);
- test_fail_unless (r < 0 && errno == ENOSPC);
-
- // reset errno
- errno = 0;
- msg.sci_hdr->length = htonl(msg.length - sizeof(sci_msg_hdr_t));
- } test_end;
-
-
- test_begin(t, "type > SCI_MSG_TYPE_NB")
- {
- int r;
-
- msg.sci_hdr->type = SCI_MSG_TYPE_NB;
- r = write (fd_in, msg.data_begin, msg.length);
- test_fail_if ((sci_size_t) r != msg.length);
-
- r = sci_recv (&sci);
- test_fail_unless (r < 0 && errno == EPROTOTYPE);
-
- // reset errno
- errno = 0;
- msg.sci_hdr->type = SCI_MSG_TYPE_SYSTEM;
- } test_end;
-
- test_begin(t, "bad station id")
- {
- int r;
-
- msg.sci_hdr->station_id = htons(station.id + 1);
- r = write (fd_in, msg.data_begin, msg.length);
- test_fail_if ((sci_size_t) r != msg.length);
-
- r = sci_recv (&sci);
- test_fail_unless (r < 0 && errno == ENODEV);
-
- // reset errno
- errno = 0;
- msg.sci_hdr->station_id = htons(station.id);
- } test_end;
-
- test_begin(t, "msg_tick is older than current_tick")
- {
- int r;
-
- msg.sci_hdr->netclock_low = 0;
- r = write (fd_in, msg.data_begin, msg.length);
-
- test_fail_if ((sci_size_t) r != msg.length);
- test_fail_if (0 > sci_recv (&sci));
- test_fail_if (station.current_tick_tck != 0x1234567890abcdefULL);
-
- msg.sci_hdr->netclock_low = 0x90abcdef;
- } test_end;
-
- memset(data_buffer, '\0', 16);
- test_begin(t, "callback process")
- {
- int r;
-
- msg.sci_hdr->netclock_low = 0xffffffff;
-
- r = write (fd_in, msg.data_begin, msg.length);
-
- test_fail_if ((sci_size_t) r != msg.length);
- test_fail_if (0 > sci_recv (&sci));
- test_fail_if (memcmp (data_buffer, TEST_RECV_STR,
- strlen(TEST_RECV_STR)));
- test_fail_if (station.current_tick_tck != 0x12345678ffffffffULL);
-
- close(fd_in);
- } test_end;
-
- close(fd_in);
- station_down(&station);
- return;
-}
-
-void sci_test_suite(test_t t)
-{
- test_suite_begin(t, "sci");
- sci_init_test_case(t);
- sci_register_callback_test_case(t);
- sci_fill_hdr_test_case(t);
- sci_send_test_case(t);
- sci_recv_test_case(t);
-}
diff --git a/cesar/host/test/src/test_sci_msg.c b/cesar/host/test/src/test_sci_msg.c
deleted file mode 100644
index b4d2b7de81..0000000000
--- a/cesar/host/test/src/test_sci_msg.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test_sci_msg.c
- * \brief Test all sci message functions.
- * \ingroup test
- */
-
-#include "common/std.h"
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include "lib/test.h"
-#include "host/sci/sci.h"
-
-void sci_msg_init_test_case(test_t t)
-{
- sci_msg_t msg;
- unsigned char buffer[SCI_MSG_MAX_SIZE];
- test_case_begin(t, "init");
-
- test_begin(t, "msg = NULL")
- {
- test_fail_unless(
- (sci_msg_init(NULL, buffer, SCI_MSG_MAX_SIZE) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "buffer = NULL")
- {
- test_fail_unless(
- (sci_msg_init(&msg, NULL, SCI_MSG_MAX_SIZE) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "max_size < sizeof(sci_msg_hdr_t)")
- {
- test_fail_unless(
- (sci_msg_init(&msg, buffer, sizeof(sci_msg_hdr_t) - 1) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "max_size > SCI_MSG_MAX_SIZE")
- {
- test_fail_unless(
- (sci_msg_init(&msg, buffer, SCI_MSG_MAX_SIZE + 1) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check init")
- {
- test_fail_unless(
- (sci_msg_init(&msg, buffer, SCI_MSG_MAX_SIZE) >= 0)
- && ((unsigned char *)msg.sci_hdr == NULL)
- && ((unsigned char *)msg.hdr.station == NULL)
- && (msg.data != NULL)
- && (msg.data_begin == msg.data + msg.max_size)
- && (msg.data_end == msg.data_begin)
- && (msg.length == 0)
- && (msg.max_size == SCI_MSG_MAX_SIZE)
- );
- } test_end;
-}
-
-void sci_msg_push_test_case(test_t t)
-{
- sci_msg_t msg;
- unsigned char buffer[256];
-
- test_case_begin(t, "push");
-
- test_begin(t, "init msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, buffer, 256))
- && (EINVAL != errno)
- );
- } test_end;
-
- test_begin(t, "msg = NULL")
- {
- test_fail_unless(
- 0 > sci_msg_push (NULL, 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "length < 0")
- {
- test_fail_unless(
- 0 > sci_msg_push (&msg, -1)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "length > available")
- {
- test_fail_unless(
- 0 > sci_msg_push (&msg, 256 + 1)
- && (errno == ENOSPC)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check push")
- {
- test_fail_unless(
- 0 <= sci_msg_push (&msg, 64)
- && (EINVAL != errno)
- && (ENOSPC != errno));
-
- test_fail_if ((msg.data_end - msg.data_begin) != 64);
- test_fail_if ((sci_size_t) (msg.data_begin - msg.data)
- != msg.max_size - 64);
- test_fail_if (msg.length != 64);
- test_fail_if (msg.max_size != 256);
- } test_end;
- return;
-}
-
-void sci_msg_pop_test_case(test_t t)
-{
- sci_msg_t msg;
- unsigned char buffer[256];
-
- test_case_begin(t, "pop");
-
- test_begin(t, "init and pop msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, buffer, 256))
- && (EINVAL != errno)
- );
- test_fail_unless(
- 0 <= sci_msg_push (&msg, 64)
- && (EINVAL != errno)
- && (ENOSPC != errno)
- );
- } test_end;
-
- test_begin(t, "msg = NULL")
- {
- test_fail_unless(
- 0 > sci_msg_pop (NULL, 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "length < 0")
- {
- test_fail_unless(
- 0 > sci_msg_pop (&msg, -1)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check pop")
- {
- test_fail_unless(
- 0 <= sci_msg_pop (&msg, 5)
- && (EINVAL != errno)
- && (msg.data_begin == msg.data_end - 64 + 5)
- && (msg.data_begin == msg.data + msg.max_size - msg.length)
- && (msg.length == 64 - 5)
- && (msg.max_size == 256)
- );
- } test_end;
-
- test_begin(t, "length >= available")
- {
- test_fail_unless(
- 0 <= sci_msg_pop (&msg, 64)
- && (EINVAL != errno)
- && (msg.data_begin == msg.data_end)
- && (msg.data_begin == msg.data + msg.max_size)
- && (msg.length == 0)
- );
- } test_end;
- return;
-}
-
-void sci_msg_test_suite(test_t t)
-{
- test_suite_begin(t, "sci_msg");
- sci_msg_init_test_case(t);
- sci_msg_push_test_case(t);
- sci_msg_pop_test_case(t);
-}
diff --git a/cesar/host/test/src/test_station.c b/cesar/host/test/src/test_station.c
deleted file mode 100644
index 8e83d70392..0000000000
--- a/cesar/host/test/src/test_station.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test_station.c
- * \brief Test all station functions.
- * \ingroup test
- */
-
-#include "common/std.h"
-#include <fcntl.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include "lib/test.h"
-#include "host/station/station.h"
-
-extern uint32_t maximus_pending_isrs;
-
-/*void station_get_pipe_name_test_case(test_t t)
-{
- test_case_begin(t, "station_get_pipe_name");
-
- test_begin (t, "prefix = NULL")
- {
- test_fail_unless(
- (station_get_pipe_name(NULL, NULL, 0) == -1)
- && (errno == EINVAL));
- } test_end;
-
- test_begin(t, "buffer = NULL")
- {
- test_fail_unless(
- (station_get_pipe_name("in", NULL, 0) == -1)
- && (errno == EINVAL));
- } test_end;
-
- test_begin(t, "buffer too small")
- {
- char buffer[8];
- test_fail_unless(
- (station_get_pipe_name("in", buffer, 8) == -1)
- && (errno == ENOSPC));
- } test_end;
-
- test_begin(t, "check result")
- {
- char name_buffer[256], model_buffer[256];
- sprintf(model_buffer, "%s/%s_in_%d", STATION_PIPE_PATH, STATION_PIPE_PREFIX, getpid());
- test_fail_unless(
- (station_get_pipe_name("in", buffer, 256) == strlen(model_buffer))
- && !strcmp(name_buffer, model_buffer));
- } test_end;
-}*/
-
-void station_init_test_case(test_t t)
-{
- station_ctx_t station;
- char buffer[256];
-#ifndef STATION_SOCK
- struct stat my_stat;
-#endif
-
- test_case_begin(t, "init");
- station_init(&station);
-
- test_begin (t, "check vars")
- {
- test_fail_unless(
- (station.id == getpid())
-#ifdef STATION_SOCK
- && (station.sock_fd >= 0)
- && (station.sock_pair_fd >= 0)
-#else
- && (station.pipe_in_fd >= 0)
- && (station.pipe_out_fd >= 0)
-#endif
- && (station.pipe_log_fd >= 0)
- && (station.sci != NULL)
- && (station.log_level == STATION_LOG_WARNING)
- && (station.sci != NULL/*&_my_sci*/)
- && (station.netclock != NULL/*&_my_netclock*/)
- && (station.fcall != NULL/*&_my_fcall*/)
- && (station.probe != NULL/*&_my_probe*/)
- && (station.seed == 0)
- );
- } test_end;
-
- test_begin(t, "check pipe names")
- {
- /* check pipe names */
-#ifdef STATION_SOCK
- sprintf(buffer, "%s/%s_sock_%d", STATION_SOCK_PATH, STATION_SOCK_PREFIX, getpid());
- test_fail_if(strcmp(buffer, station.sock_name));
-#else
- sprintf(buffer, "%s/%s_in_%d", STATION_PIPE_PATH, STATION_PIPE_PREFIX, getpid());
- test_fail_if(strcmp(buffer, station.pipe_in_name));
- sprintf(buffer, "%s/%s_out_%d", STATION_PIPE_PATH, STATION_PIPE_PREFIX, getpid());
- test_fail_if(strcmp(buffer, station.pipe_out_name));
-#endif
- /*sprintf(buffer, "%s/%s_debug_%d", STATION_PIPE_PATH, STATION_PIPE_PREFIX, getpid());
- test_fail_if(strcmp(buffer, station->debug_out_name));*/
- } test_end;
-
-#ifndef STATION_SOCK
- test_begin(t, "check if pipes are created and open")
- {
- test_fail_unless(
- (stat(station.pipe_in_name, &my_stat) >= 0)
- && S_ISFIFO(my_stat.st_mode)
- && (fstat(station.pipe_in_fd, &my_stat) >= 0)
- && S_ISFIFO(my_stat.st_mode)
- && (stat(station.pipe_out_name, &my_stat) >= 0)
- && S_ISFIFO(my_stat.st_mode)
- && (fstat(station.pipe_out_fd, &my_stat) >= 0)
- && S_ISFIFO(my_stat.st_mode));
- } test_end;
-#endif
-
- station_down(&station);
-}
-
-void station_down_test_case(test_t t)
-{
- station_ctx_t station;
- int fd_in, fd_out;
-#ifndef STATION_SOCK
- char name_in[256], name_out[256];
-#endif
- struct stat my_stat;
-
- test_case_begin(t, "down");
-
- test_begin(t, "NULL station")
- {
- station_down(NULL); /* must not crash */
- test_fail_if(0);
- } test_end;
-
- station_init(&station);
-#ifdef STATION_SOCK
- fd_in = station.sock_fd;
- fd_out = station.sock_pair_fd;
-#else
- fd_in = station.pipe_in_fd;
- fd_out = station.pipe_out_fd;
- strcpy(name_in, station.pipe_in_name);
- strcpy(name_out, station.pipe_out_name);
-#endif
- station_down(&station);
-
-#ifdef STATION_SOCK
- test_begin(t, "socket is closed")
- {
- test_fail_unless(
- (fstat(fd_in, &my_stat) < 0)
- && (fstat(fd_out, &my_stat) < 0));
- } test_end;
-#else
- test_begin(t, "pipes are closed")
- {
- test_fail_unless(
- (fstat(fd_in, &my_stat) < 0)
- && (fstat(fd_out, &my_stat) < 0));
- } test_end;
-
- test_begin(t, "pipe filenames are removed")
- {
- test_fail_unless(
- (stat(name_in, &my_stat) < 0)
- && (stat(name_out, &my_stat) < 0));
- } test_end;
-#endif
-}
-
-void station_idle_test_case(test_t t)
-{
- station_ctx_t station;
- int fd_in, len;
- unsigned char buffer[SCI_MSG_MAX_SIZE];
- sci_msg_hdr_t *hdr;
- station_msg_hdr_t *my_station_hdr;
-
- test_case_begin(t, "idle");
- station_init(&station);
- //station.is_unit_test = 1;
-
- test_begin(t, "station = NULL")
- {
- test_fail_unless(
- (station_idle(NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "recv idle msg")
- {
-#ifdef STATION_SOCK
- test_fail_unless(
- ((fd_in = station.sock_pair_fd) >= 0)
- );
-#else
- test_fail_if(
- ((fd_in = open(station.pipe_out_name, O_RDONLY)) < 0)
- );
-#endif
- test_fail_unless(
- (station_idle(&station) >= 0)
- && ((len = read(fd_in, buffer, sizeof(sci_msg_hdr_t))) == sizeof(sci_msg_hdr_t))
- );
- hdr = (sci_msg_hdr_t *)buffer;
- test_fail_unless(
- (hdr->type == SCI_MSG_TYPE_SYSTEM)
- && (ntohs(hdr->station_id) == station.id));
- test_fail_if(
- ((len = read(fd_in, buffer + sizeof(sci_msg_hdr_t), htonl(hdr->length))) != sizeof(station_msg_hdr_t))
- );
- my_station_hdr = (station_msg_hdr_t *)(buffer + sizeof(sci_msg_hdr_t));
- test_fail_unless(
- (my_station_hdr->type == SYSTEM_TYPE_IDLE)
- );
- } test_end;
-
- station_down(&station);
- return;
-}
-
-void station_log_set_level_test_case(test_t t)
-{
- station_ctx_t station;
-
- test_case_begin(t, "log_set_level");
-
- test_begin(t, "log level out of range")
- {
- test_fail_unless(
- (station_log_set_level(&station, -1) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- test_fail_unless(
- (station_log_set_level(&station, STATION_LOG_NB) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check log_level")
- {
- station.log_level = STATION_LOG_WARNING;
- test_fail_unless(
- (station_log_set_level(&station, STATION_LOG_DEBUG) >= 0)
- && (station.log_level == STATION_LOG_DEBUG)
- );
- } test_end;
-
- return;
-}
-
-void station_test_suite(test_t t)
-{
- test_suite_begin(t, "station");
- station_init_test_case(t);
- station_down_test_case(t);
- station_idle_test_case(t);
- station_log_set_level_test_case(t);
-}
diff --git a/cesar/host/test/src/test_system.c b/cesar/host/test/src/test_system.c
deleted file mode 100644
index 58666363e5..0000000000
--- a/cesar/host/test/src/test_system.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test_system.c
- * \brief Test all system functions.
- * \ingroup test
- */
-
-#include <fcntl.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include "common/std.h"
-#include "host/system/system.h"
-#include "lib/test.h"
-
-extern char dump_buffer[];
-
-void system_init_test_case(test_t t)
-{
- system_ctx_t system;
- station_ctx_t station;
- sci_ctx_t sci;
-
- test_case_begin(t, "init");
-
- sci_init(&sci, &station);
-
- test_begin(t, "system = NULL")
- {
- test_fail_unless(
- (system_init(NULL, &sci) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "sci = NULL")
- {
- test_fail_unless(
- (system_init(&system, NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "check init")
- {
- test_fail_unless(
- (system_init(&system, &sci) >= 0)
- && (system.sci == &sci)
- && (strlen(system.station_name) == 0)
- );
- } test_end;
-
- return;
-}
-
-void system_recv_test_case(test_t t)
-{
- system_ctx_t system;
- station_ctx_t station;
- sci_ctx_t sci;
- sci_msg_t msg;
- unsigned char buffer[256];
- char station_name[] = "This is the station name\0";
- int fd_in;
-
- test_case_begin(t, "recv");
-
- station_init(&station);
- sci_init(&sci, &station);
- system_init(&system, &sci);
-
- test_begin(t, "init msg")
- {
- test_fail_unless(
- (0 == sci_msg_init(&msg, buffer, 256))
- && (EINVAL != errno)
- );
- } test_end;
-
- test_begin(t, "msg = NULL")
- {
- test_fail_unless(
- (system_recv(NULL, &system) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
- test_begin(t, "system = NULL")
- {
- test_fail_unless(
- (system_recv(&msg, NULL) < 0)
- && (errno == EINVAL)
- );
- // reset errno
- errno = 0;
- } test_end;
-
-#ifdef STATION_SOCK
- fd_in = station.sock_pair_fd;
-#else /* STATION_SOCK */
- fd_in = open(station.pipe_out_name, O_RDONLY);
-#endif /* STATION_SOCK */
-
- test_begin(t, "recv")
- {
- int r;
- /* fill sci data */
- test_fail_unless(
- 0 <= sci_msg_push (&msg, strlen (station_name) + 1)
- && (EINVAL != errno)
- && (ENOSPC != errno)
- );
- strcpy((char *)msg.data_begin, station_name);
-
- /* fill system header */
- test_fail_unless(
- 0 <= sci_msg_push (&msg, sizeof (station_msg_hdr_t))
- && (EINVAL != errno)
- && (ENOSPC != errno)
- );
- msg.hdr.station = (station_msg_hdr_t *)msg.data_begin;
- msg.hdr.station->version = SYSTEM_VERSION;
- msg.hdr.station->type = SYSTEM_TYPE_STATION_NAME;
- msg.hdr.station->flags = 0;
-
- test_fail_unless (0 <= sci_send (station.sci, &msg));
- r = read (fd_in, msg.data_begin, msg.length);
- test_fail_unless ((sci_size_t) r == msg.length);
- test_fail_unless(
- (system_recv(&msg, &system) >= 0)
- && !memcmp(station_name, system.station_name, strlen(station_name) + 1)
- );
- } test_end;
-
-#ifndef STATION_SOCK
- close(fd_in);
-#endif /* STATION_SOCK */
- station_down(&station);
-
- return;
-}
-
-void system_test_suite(test_t t)
-{
- test_suite_begin(t, "system");
- system_init_test_case(t);
- system_recv_test_case(t);
-}
diff --git a/cesar/mac/pbproc/test/int/src/test_pbproc.c b/cesar/mac/pbproc/test/int/src/test_pbproc.c
index 421e33be73..fec62542e7 100644
--- a/cesar/mac/pbproc/test/int/src/test_pbproc.c
+++ b/cesar/mac/pbproc/test/int/src/test_pbproc.c
@@ -504,9 +504,6 @@ cyg_user_start (void)
fcall = interface->fcall->fcall_ctx;
#else /* !CONFIG_FCALL_MME */
fcall = my_station.fcall;
- my_station.pipe_log_fd = 1;
- //my_station.log_level = STATION_LOG_DEBUG;
- //my_station.log_mask = STATION_LOGTYPE_FCALL;
#endif /* !CONFIG_FCALL_MME */
test_pbproc_init (&test_pbproc_global, fcall);
}
diff --git a/cesar/maximus/interface/station/inc/Station.h b/cesar/maximus/interface/station/inc/Station.h
index 9d75481ba2..59de4b402a 100644
--- a/cesar/maximus/interface/station/inc/Station.h
+++ b/cesar/maximus/interface/station/inc/Station.h
@@ -18,16 +18,26 @@
#include <iostream>
#include <set>
-#define STATION_PIPE_PATH "/tmp"
-#define STATION_PIPE_PREFIX "station"
-#define STATION_SOCK_PATH STATION_PIPE_PATH
-#define STATION_SOCK_PREFIX STATION_PIPE_PREFIX
-#define STATION_WAIT_LOOP_NB 10
-#define STATION_WAIT_TIMEOUT_MS 100
-#define STATION_MAX_SOCK_BUFFER_SIZE (256*1024)
-
typedef std::set<Sci_Msg_Station_Id> HiddenStationsList;
+enum {
+ PIPE_READ = 0,
+ PIPE_WRITE = 1,
+ PIPE_NB,
+};
+
+enum {
+ PIPE_STA2MAX = 0,
+ PIPE_MAX2STA = 1,
+ PIPE_WAY_NB,
+};
+
+enum {
+ SOCKET_MAXIMUS = 0,
+ SOCKET_STA = 1,
+ SOCKET_NB,
+};
+
class Station
{
private:
@@ -131,16 +141,12 @@ public:
private:
+ void check_fd (bool is_ok, const char *message);
+
void start_process (
const Network_Clock_Tick current_tick_value,
uint32_t seed = 0 );
- void open_socket ();
-
- void open_pipes ();
-
- void open_log ();
-
void stop_process ();
void child_process (
diff --git a/cesar/maximus/interface/station/src/Station.cpp b/cesar/maximus/interface/station/src/Station.cpp
index 9a00735833..d545ef437c 100644
--- a/cesar/maximus/interface/station/src/Station.cpp
+++ b/cesar/maximus/interface/station/src/Station.cpp
@@ -73,6 +73,17 @@ Station::~Station ()
}
void
+Station::check_fd (bool is_ok, const char *message)
+{
+ if (!is_ok)
+ {
+ Error e (__PRETTY_FUNCTION__, message, errno);
+ e.display ();
+ exit (EXIT_FAILURE);
+ }
+}
+
+void
Station::kill_child_only ()
{
if (mPid > 0)
@@ -210,128 +221,110 @@ Station::start_process (
{
logFunction ();
+ int fd_socket[PIPE_WAY_NB] = {-1, -1};
+ int fd_pipe[PIPE_WAY_NB][PIPE_NB] = {{-1, -1}, {-1, -1}};
+ int fd_err[PIPE_NB] = {-1, -1};
+ int r;
+
assert (!executable.empty ());
- mPid = fork ();
- if (mPid == 0)
- child_process (current_tick_value, seed);
+ /* For Maximus process, stdin, out, and err stay unchanged.
+ * For child process, we will use it to communicate with Maximus.
+ *
+ * User Maximus
+ * |----------|
+ * ----> stdin |
+ * <---- stdout |
+ * <---- stderr | Station
+ * | | |---------|
+ * | fd_out -----> stdin |
+ * | fd_in <----- stdout |
+ * | fd_log <----- stderr |
+ * | | |---------|
+ * |----------|
+ */
- assert (mPid != -1);
if (CONFIG_INTERFACE_STATION_SOCKET)
- open_socket ();
+ {
+ /* Socketpair is bidirectional. */
+ r = socketpair (AF_LOCAL, SOCK_STREAM, 0, fd_socket);
+ check_fd (r != -1, "Socket cannot be open");
+ }
else
- open_pipes ();
-
- open_log ();
-}
-
-inline void
-Station::open_socket ()
-{
- struct sockaddr_un sockaddr;
- int bufsize = STATION_MAX_SOCK_BUFFER_SIZE;
- int fd_status;
- int open_status;
- int loop;
- std::ostringstream oss;
-
- oss << STATION_SOCK_PATH
- << "/" << STATION_SOCK_PREFIX
- << "_sock_" << mPid;
-
- /* Open the socket. */
- fd_sta2max = socket (PF_UNIX, SOCK_STREAM, 0);
-
- assert (fd_sta2max >= 0);
-
- /* avoid other stations to inherit the socket. */
- fd_status = fcntl (fd_sta2max, F_GETFD);
- fcntl (fd_sta2max, F_SETFD, fd_status | FD_CLOEXEC);
-
- /* extend send buffer size. */
- open_status = setsockopt (fd_sta2max, SOL_SOCKET,
- SO_SNDBUF, &bufsize, sizeof (bufsize));
-
- assert (open_status >= 0);
- sockaddr.sun_family = AF_UNIX;
- strcpy (sockaddr.sun_path, oss.str ().c_str ());
-
- for (loop = 0; loop < STATION_WAIT_LOOP_NB; loop++)
{
- /* Connect to server. */
- if ((connect (fd_sta2max,
- (struct sockaddr *) &sockaddr,
- sizeof(sockaddr))) >= 0)
- {
- break;
- }
- usleep(STATION_WAIT_TIMEOUT_MS * 1000);
+ /* pipe is one way direction. */
+ r = pipe (fd_pipe[PIPE_STA2MAX]);
+ check_fd (r != -1, "sta2max pipe cannot be open");
+ r = pipe (fd_pipe[PIPE_MAX2STA]);
+ check_fd (r != -1, "max2sta pipe cannot be open");
}
- assert (loop < STATION_WAIT_LOOP_NB);
+ r = pipe (fd_err);
+ check_fd (r != -1, "log pipe cannot be open");
- fd_max2sta = fd_sta2max;
-}
+ mPid = fork ();
-inline void
-Station::open_pipes ()
-{
- int fd_status;
- int loop;
- std::ostringstream out, in;
-
- in << STATION_PIPE_PATH
- << "/" << STATION_PIPE_PREFIX
- << "_out_" << mPid;
- out << STATION_PIPE_PATH
- << "/" << STATION_PIPE_PREFIX
- << "_in_" << mPid;
-
- for (loop = 0; loop < STATION_WAIT_LOOP_NB; loop++)
+ if (mPid == -1)
{
- /* Connect to server. */
- fd_sta2max = open (in.str ().c_str (),
- O_RDONLY);
- if (fd_sta2max >= 0)
- break;
- usleep (STATION_WAIT_TIMEOUT_MS * 1000);
+ Error e (__PRETTY_FUNCTION__, "fork failed", errno);
+ e.display ();
+ exit (EXIT_FAILURE);
}
+ else if (mPid == 0)
+ {
+ /* Child process. */
+ if (CONFIG_INTERFACE_STATION_SOCKET)
+ {
+ close (fd_socket[SOCKET_MAXIMUS]);
- assert (loop < STATION_WAIT_LOOP_NB);
-
- /* avoid other stations to inherit the pipe. */
- fd_status = fcntl(fd_sta2max, F_GETFD);
- fcntl(fd_sta2max, F_SETFD, fd_status | FD_CLOEXEC);
-
- /* Open output pipe. */
- fd_max2sta = open (out.str ().c_str (),
- O_WRONLY);
- assert (fd_max2sta >= 0);
-
- /* avoid other stations to inherit the pipe. */
- fd_status = fcntl (fd_max2sta, F_GETFD);
- fcntl (fd_max2sta, F_SETFD, fd_status | FD_CLOEXEC);
-}
+ /* socket become stdout and stdin. */
+ dup2 (fd_socket[SOCKET_STA], 0);
+ dup2 (fd_socket[SOCKET_STA], 1);
+ close (fd_socket[SOCKET_STA]);
+ }
+ else
+ {
+ /* Child write on its stdout(1). */
+ close (fd_pipe[PIPE_STA2MAX][PIPE_READ]);
+ dup2 (fd_pipe[PIPE_STA2MAX][PIPE_WRITE], 1);
+ close (fd_pipe[PIPE_STA2MAX][PIPE_WRITE]);
+
+ /* Child read on its stdin(0). */
+ close (fd_pipe[PIPE_MAX2STA][PIPE_WRITE]);
+ dup2 (fd_pipe[PIPE_MAX2STA][PIPE_READ], 0);
+ close (fd_pipe[PIPE_MAX2STA][PIPE_READ]);
+ }
-inline void
-Station::open_log ()
-{
- std::ostringstream oss;
- int fd_status;
+ /* Log pipe become stderr. */
+ close (fd_err[PIPE_READ]);
+ dup2 (fd_err[PIPE_WRITE], 2);
+ close (fd_err[PIPE_WRITE]);
- /* Open log pipe. */
- oss << STATION_PIPE_PATH
- << "/" << STATION_PIPE_PREFIX
- << "_log_" << mPid;
+ child_process (current_tick_value, seed);
+ exit (EXIT_FAILURE);
+ }
+ else
+ {
+ /* Parent process. */
+ if (CONFIG_INTERFACE_STATION_SOCKET)
+ {
+ close (fd_socket[SOCKET_STA]);
+ fd_sta2max = fd_socket[SOCKET_MAXIMUS];
+ fd_max2sta = fd_socket[SOCKET_MAXIMUS];
+ }
+ else
+ {
+ close (fd_pipe[PIPE_MAX2STA][PIPE_READ]);
+ close (fd_pipe[PIPE_STA2MAX][PIPE_WRITE]);
- fd_log = open (oss.str ().c_str (),
- O_RDONLY | O_NONBLOCK);
- assert (fd_log >= 0);
+ fd_sta2max = fd_pipe[PIPE_STA2MAX][PIPE_READ];
+ fd_max2sta = fd_pipe[PIPE_MAX2STA][PIPE_WRITE];
+ }
- /* avoid other stations to inherit the pipe. */
- fd_status = fcntl (fd_log, F_GETFD);
- fcntl (fd_log, F_SETFD, fd_status | FD_CLOEXEC);
+ close (fd_err[PIPE_WRITE]);
+ fd_log = fd_err[PIPE_READ];
+ }
}
inline void
diff --git a/cesar/maximus/python/utest/stationtest/src/exception.c b/cesar/maximus/python/utest/stationtest/src/exception.c
index fe761b1a00..a2b812ad7f 100644
--- a/cesar/maximus/python/utest/stationtest/src/exception.c
+++ b/cesar/maximus/python/utest/stationtest/src/exception.c
@@ -37,8 +37,6 @@ void system_call_exception(cyg_addrword_t data, cyg_code_t number, cyg_addrword_
diag_printf("eCos: Exception Error (FPU)!!!\n");
break;
}
-// station_down(&my_station);
-// cyg_hal_sys_exit(1);
}
void cyg_user_start(void)
diff --git a/cesar/maximus/python/utest/stationtest/src/hello_world.c b/cesar/maximus/python/utest/stationtest/src/hello_world.c
index e393a5ff1f..e740d161a7 100644
--- a/cesar/maximus/python/utest/stationtest/src/hello_world.c
+++ b/cesar/maximus/python/utest/stationtest/src/hello_world.c
@@ -21,7 +21,6 @@ int main(void)
{
station_log_set_level(&my_station, STATION_LOG_NONE);
station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
- my_station.pipe_log_fd = 1;
diag_write_string("hello by eCos\n");
return 0;
}
diff --git a/cesar/maximus/python/utest/stationtest/src/main_example.c b/cesar/maximus/python/utest/stationtest/src/main_example.c
index fb86cfdc63..a2023dc761 100644
--- a/cesar/maximus/python/utest/stationtest/src/main_example.c
+++ b/cesar/maximus/python/utest/stationtest/src/main_example.c
@@ -362,7 +362,6 @@ int main (void)
{
station_log_set_level(&my_station, STATION_LOG_NONE);
station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
- my_station.pipe_log_fd = 1;
fcall_register(my_station.fcall, "function_1", (void*)&my_function1, NULL);
fcall_register(my_station.fcall, "function_2", (void*)&my_function2, NULL);
diff --git a/cesar/maximus/python/utest/stationtest/src/test_cb.c b/cesar/maximus/python/utest/stationtest/src/test_cb.c
index dc635369f4..2625d4fb5c 100644
--- a/cesar/maximus/python/utest/stationtest/src/test_cb.c
+++ b/cesar/maximus/python/utest/stationtest/src/test_cb.c
@@ -33,7 +33,6 @@ int main (void)
{
station_log_set_level(&my_station, STATION_LOG_NONE);
station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
- my_station.pipe_log_fd = 1;
fcall_register(my_station.fcall, "get_seg", (void*)&get_seg, NULL);
diff --git a/cesar/maximus/python/utest/stationtest/src/test_ether.c b/cesar/maximus/python/utest/stationtest/src/test_ether.c
index 9a425ad295..824ee01e76 100644
--- a/cesar/maximus/python/utest/stationtest/src/test_ether.c
+++ b/cesar/maximus/python/utest/stationtest/src/test_ether.c
@@ -186,7 +186,6 @@ main (void)
{
station_log_set_level (&my_station, STATION_LOG_NONE);
station_log_set_mask (&my_station, STATION_LOGTYPE_ALL);
- my_station.pipe_log_fd = 1;
fcall_register (my_station.fcall, "init_ether", (void*) &init_ether, NULL);
fcall_register (my_station.fcall, "uninit_ether", (void*) &uninit_ether,
diff --git a/cesar/maximus/python/utest/stationtest/src/test_false_alarm.c b/cesar/maximus/python/utest/stationtest/src/test_false_alarm.c
index 390baa4ac0..48ad76537f 100644
--- a/cesar/maximus/python/utest/stationtest/src/test_false_alarm.c
+++ b/cesar/maximus/python/utest/stationtest/src/test_false_alarm.c
@@ -148,7 +148,6 @@ int main (void)
{
station_log_set_level(&my_station, STATION_LOG_NONE);
station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
- my_station.pipe_log_fd = 1;
fcall_register(my_station.fcall, "init_phy", (void*)&init_phy, NULL);
fcall_register(my_station.fcall, "activate_rx", (void*)&activate_rx, NULL);
diff --git a/cesar/maximus/python/utest/stationtest/src/test_lib_cesar.c b/cesar/maximus/python/utest/stationtest/src/test_lib_cesar.c
index 4cf93c751d..93e57d1efa 100644
--- a/cesar/maximus/python/utest/stationtest/src/test_lib_cesar.c
+++ b/cesar/maximus/python/utest/stationtest/src/test_lib_cesar.c
@@ -140,7 +140,6 @@ main (void)
{
station_log_set_level (&my_station, STATION_LOG_NONE);
station_log_set_mask (&my_station, STATION_LOGTYPE_ALL);
- my_station.pipe_log_fd = 1;
maximus_phy_dur_init (&my_station);
diff --git a/cesar/maximus/python/utest/stationtest/src/test_log.c b/cesar/maximus/python/utest/stationtest/src/test_log.c
index 68ff126172..19233bcf81 100644
--- a/cesar/maximus/python/utest/stationtest/src/test_log.c
+++ b/cesar/maximus/python/utest/stationtest/src/test_log.c
@@ -155,7 +155,6 @@ int test_log (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg,
station_log_set_level(&my_station, STATION_LOG_NONE);
station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
- my_station.pipe_log_fd = 1;
station_log (&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_STATION,
"%s", min);
diff --git a/cesar/maximus/python/utest/stationtest/src/test_send.c b/cesar/maximus/python/utest/stationtest/src/test_send.c
index 93229544cf..2725390d41 100644
--- a/cesar/maximus/python/utest/stationtest/src/test_send.c
+++ b/cesar/maximus/python/utest/stationtest/src/test_send.c
@@ -217,7 +217,6 @@ int main (void)
{
station_log_set_level(&my_station, STATION_LOG_NONE);
station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
- my_station.pipe_log_fd = 1;
fcall_register(my_station.fcall, "set_tonemask", (void*)&set_tonemask, NULL);
fcall_register(my_station.fcall, "prepare_rx", (void*)&prepare_rx, NULL);
diff --git a/cesar/maximus/python/utest/stationtest/src/test_station.c b/cesar/maximus/python/utest/stationtest/src/test_station.c
index e0fa1305f7..716ac9315e 100644
--- a/cesar/maximus/python/utest/stationtest/src/test_station.c
+++ b/cesar/maximus/python/utest/stationtest/src/test_station.c
@@ -140,7 +140,6 @@ main (void)
{
station_log_set_level (&my_station, STATION_LOG_NONE);
station_log_set_mask (&my_station, STATION_LOGTYPE_ALL);
- my_station.pipe_log_fd = 1;
/* Initialize the HAL ipmbox. */
ctx = ipmbox_init ();
diff --git a/cesar/maximus/python/utest/stationtest/src/test_tx_rx.c b/cesar/maximus/python/utest/stationtest/src/test_tx_rx.c
index b6049a80a9..d97188a1ef 100644
--- a/cesar/maximus/python/utest/stationtest/src/test_tx_rx.c
+++ b/cesar/maximus/python/utest/stationtest/src/test_tx_rx.c
@@ -336,7 +336,6 @@ int main (void)
{
station_log_set_level(&my_station, STATION_LOG_NONE);
station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
- my_station.pipe_log_fd = 1;
fcall_register(my_station.fcall, "set_tonemask", (void*)&set_tonemask, NULL);
fcall_register(my_station.fcall, "prepare_rx", (void*)&prepare_rx, NULL);
diff --git a/cesar/maximus/sci/utest/server/src/TestSciServer.cpp b/cesar/maximus/sci/utest/server/src/TestSciServer.cpp
index 7d76ccf1f6..d21223c728 100644
--- a/cesar/maximus/sci/utest/server/src/TestSciServer.cpp
+++ b/cesar/maximus/sci/utest/server/src/TestSciServer.cpp
@@ -60,7 +60,7 @@ TestSciServer::test_pipe_bidir ()
server->register_current_tick_addr (&time);
Station *fake_sta = new Station (*max,
- "noexec", 0, SCI_MSG_MAX_SIZE);
+ "pipe", 0, SCI_MSG_MAX_SIZE);
sta_list.push_back (fake_sta);
PipoSciMsg *msg = NULL;
diff --git a/cesar/maximus/sci/utest/server/src/fake_Station.cpp b/cesar/maximus/sci/utest/server/src/fake_Station.cpp
index 64d76b6578..76ea919da7 100644
--- a/cesar/maximus/sci/utest/server/src/fake_Station.cpp
+++ b/cesar/maximus/sci/utest/server/src/fake_Station.cpp
@@ -38,39 +38,57 @@ Station::Station (
mStationStatus (MAXIMUS_STATION_STATUS_IDLE),
mStationIdleCounter (0)
{
- std::ostringstream pipe_max2sta, pipe_sta2max;
+ int fd_socket[PIPE_WAY_NB] = {-1, -1};
+ int fd_pipe[PIPE_WAY_NB][PIPE_NB] = {{-1, -1}, {-1, -1}};
+ bool is_socket;
- pipe_max2sta << STATION_PIPE_PATH;
- pipe_max2sta << "/" ;
- pipe_max2sta << STATION_PIPE_PREFIX;
- pipe_sta2max << pipe_max2sta.str ();
+ /* station_executable is equal to "pipe" or "socket". */
+ is_socket = (0 != station_executable.compare ("pipe") ?
+ true: false);
- pipe_sta2max << "_sta2max_";
- pipe_max2sta << "_max2sta_";
+ if (is_socket)
+ socketpair (AF_LOCAL, SOCK_STREAM, 0, fd_socket);
+ else
+ {
+ pipe (fd_pipe[PIPE_STA2MAX]);
+ pipe (fd_pipe[PIPE_MAX2STA]);
+ }
mPid = fork ();
- if (mPid == 0)
+ if (mPid == -1)
{
- /* child process. */
- mPid = getpid ();
- pipe_sta2max << std::dec << mPid;
- pipe_max2sta << std::dec << mPid;
-
- mknod (pipe_max2sta.str ().c_str (), 0770 | S_IFIFO, 0);
- mknod (pipe_sta2max.str ().c_str (), 0770 | S_IFIFO, 0);
-
- /* output pipe for a sta. */
- fd_sta2max = open (pipe_sta2max.str ().c_str (),
- O_WRONLY);
- if (fd_sta2max < 0)
- exit (EXIT_FAILURE);
+ Error e (__PRETTY_FUNCTION__, "fork failed", errno);
+ e.display ();
+ exit (EXIT_FAILURE);
+ }
+ else if (mPid == 0)
+ {
+ /* Child process. */
+ if (is_socket)
+ {
+ close (fd_socket[SOCKET_MAXIMUS]);
- /* Input pipe for a sta. */
- fd_max2sta = open (pipe_max2sta.str ().c_str (),
- O_RDONLY | O_CLOEXEC);;
- if (fd_max2sta < 0)
- exit (EXIT_FAILURE);
+ /* socket become stdout and stdin. */
+ dup2 (fd_socket[SOCKET_STA], 0);
+ dup2 (fd_socket[SOCKET_STA], 1);
+ close (fd_socket[SOCKET_STA]);
+ }
+ else
+ {
+ /* Child read on its stdin(0). */
+ close (fd_pipe[PIPE_MAX2STA][PIPE_WRITE]);
+ dup2 (fd_pipe[PIPE_MAX2STA][PIPE_READ], 0);
+ close (fd_pipe[PIPE_MAX2STA][PIPE_READ]);
+
+ /* Child write on its stdout(1). */
+ close (fd_pipe[PIPE_STA2MAX][PIPE_READ]);
+ dup2 (fd_pipe[PIPE_STA2MAX][PIPE_WRITE], 1);
+ close (fd_pipe[PIPE_STA2MAX][PIPE_WRITE]);
+ }
+
+ fd_max2sta = 0;
+ fd_sta2max = 1;
try
{
@@ -108,55 +126,30 @@ Station::Station (
/* Wait the SIGKILL. */
pause ();
+ exit (EXIT_FAILURE);
}
+ else
+ {
+ /* Parent process. */
+ if (is_socket)
+ {
+ close (fd_socket[SOCKET_STA]);
+ fd_sta2max = fd_socket[SOCKET_MAXIMUS];
+ fd_max2sta = fd_socket[SOCKET_MAXIMUS];
+ }
+ else
+ {
+ close (fd_pipe[PIPE_MAX2STA][PIPE_READ]);
+ close (fd_pipe[PIPE_STA2MAX][PIPE_WRITE]);
- assert (mPid >= 0);
-
- pipe_sta2max << std::dec << mPid;
- pipe_max2sta << std::dec << mPid;
-
- mknod (pipe_max2sta.str ().c_str (), 0770 | S_IFIFO, 0);
- mknod (pipe_sta2max.str ().c_str (), 0770 | S_IFIFO, 0);
-
- fd_sta2max = open (pipe_sta2max.str ().c_str (),
- O_RDONLY | O_CLOEXEC);;
- assert (fd_sta2max >= 0);
-
- fd_max2sta = open (pipe_max2sta.str ().c_str (),
- O_WRONLY);
- assert (fd_sta2max >= 0);
+ fd_sta2max = fd_pipe[PIPE_STA2MAX][PIPE_READ];
+ fd_max2sta = fd_pipe[PIPE_MAX2STA][PIPE_WRITE];
+ }
+ }
}
Station::~Station ()
{
- std::ostringstream pipe_max2sta, pipe_sta2max;
-
- pipe_max2sta << STATION_PIPE_PATH;
- pipe_max2sta << "/" ;
- pipe_max2sta << STATION_PIPE_PREFIX;
- pipe_sta2max << pipe_max2sta.str ();
-
- pipe_sta2max << "_sta2max_";
- pipe_max2sta << "_max2sta_";
-
- pipe_sta2max << std::dec << mPid;
- pipe_max2sta << std::dec << mPid;
-
- if (fd_max2sta >= 0)
- {
- close (fd_max2sta);
- fd_max2sta = 0;
- }
-
- if (fd_sta2max >= 0)
- {
- close (fd_sta2max);
- fd_sta2max = 0;
- }
-
- remove (pipe_sta2max.str ().c_str ());
- remove (pipe_max2sta.str ().c_str ());
-
kill (mPid, SIGKILL);
}
diff --git a/cesar/test_general/dataplane/src/test_dataplane.c b/cesar/test_general/dataplane/src/test_dataplane.c
index 0a0be360b8..f0b55ee9e9 100644
--- a/cesar/test_general/dataplane/src/test_dataplane.c
+++ b/cesar/test_general/dataplane/src/test_dataplane.c
@@ -192,7 +192,6 @@ test_dataplane_init (test_dataplane_t *ctx)
fcall = interface->fcall->fcall_ctx;
#else /* !CONFIG_FCALL_MME */
fcall = my_station.fcall;
- my_station.pipe_log_fd = 1;
#endif /* !CONFIG_FCALL_MME */
ca_test_fcall_beacon_period_init (&ctx->beacon_period, &ctx->config,
pbproc_get_phy (ctx->pbproc),
diff --git a/cesar/test_general/station/common/src/station.c b/cesar/test_general/station/common/src/station.c
index fedcc343b3..37578126df 100644
--- a/cesar/test_general/station/common/src/station.c
+++ b/cesar/test_general/station/common/src/station.c
@@ -146,10 +146,6 @@ cyg_user_start (void)
&fc_sta_trace_dump_all, NULL);
#endif
-#if !CONFIG_FCALL_MME
- my_station.pipe_log_fd = 1;
-#endif
-
#if CONFIG_STATS
lib_stats_set_stat_callback ("idemButCallback(u64)",
(lib_stats_cb_r_t) lib_stats_callback_test,
diff --git a/common/tests/tests b/common/tests/tests
index 0864bd07a1..2aa12f12f6 100644
--- a/common/tests/tests
+++ b/common/tests/tests
@@ -186,26 +186,10 @@ cesar/lib/test/seq_check:
make: make COV=y
cov test_seq_check: ./obj/test_seq_check
-cesar/hal/ipmbox/maximus/test:
-make: make COV=y
-cov test_maximus_hal: ./obj/test_maximus_hal > /dev/null
-
-cesar/hal/leon/maximus/test:
-make: make COV=y
-cov test_maximus_timer: ./obj/test_maximus_timer > /dev/null
-
-#cesar/hal/phy/maximus/test:
-#make: make COV=y
-#cov test_phy_maximus: ./obj/test_phy_maximus > /dev/null
-
cesar/hal/phy/maximus/dur/test:
make: make COV=y
cov test_dur: ./obj/test_dur
-cesar/host/test:
-make: make COV=y
-./obj/test_host
-
cesar/host/sci/cesar/test:
make: make COV=y
./obj/test_sci_cesar