summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Carré2013-02-15 15:51:17 +0100
committerThierry Carré2013-02-22 16:43:26 +0100
commit69d0bd54035dcccc67853e3e9112b67082c04e29 (patch)
tree5c24a154c71b6666574c865b46666fb2809d0539
parentb53003945b3452b796aadf0fb62d1b79bf7b4882 (diff)
cesar/hal/ipmbox/maximus/test: destroy dirty utests, refs #2979
Ticket #3780 created to rebuild correctly this unit test module.
-rw-r--r--cesar/hal/ipmbox/maximus/test/Config2
-rw-r--r--cesar/hal/ipmbox/maximus/test/Makefile8
-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.c79
-rw-r--r--cesar/hal/ipmbox/maximus/test/src/test_maximus_ipmbox.c355
-rw-r--r--common/tests/tests4
7 files changed, 0 insertions, 1154 deletions
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 ba10b4ae0c..0000000000
--- a/cesar/hal/ipmbox/maximus/test/Makefile
+++ /dev/null
@@ -1,8 +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
-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 302c61be9d..0000000000
--- a/cesar/hal/ipmbox/maximus/test/src/test_maximus_hal.c
+++ /dev/null
@@ -1,79 +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;
-
- fd = open (station->pipe_out_name, O_RDONLY);
-
- return fd;
-}
-
-void
-maximus_ether_close (int fd)
-{
- close (fd);
-}
-
-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/common/tests/tests b/common/tests/tests
index 39585480ec..72a5ded4c3 100644
--- a/common/tests/tests
+++ b/common/tests/tests
@@ -162,10 +162,6 @@ 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