summaryrefslogtreecommitdiff
path: root/cesar/cl/test/functional
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/cl/test/functional')
-rw-r--r--cesar/cl/test/functional/Makefile11
-rw-r--r--cesar/cl/test/functional/host-Makefile14
-rw-r--r--cesar/cl/test/functional/host-ecos.ecc.sh5
-rw-r--r--cesar/cl/test/functional/sparc-Makefile21
-rw-r--r--cesar/cl/test/functional/sparc-ecos.ecc.sh14
-rw-r--r--cesar/cl/test/functional/src/cl.c432
6 files changed, 497 insertions, 0 deletions
diff --git a/cesar/cl/test/functional/Makefile b/cesar/cl/test/functional/Makefile
new file mode 100644
index 0000000000..ae11fd2af6
--- /dev/null
+++ b/cesar/cl/test/functional/Makefile
@@ -0,0 +1,11 @@
+all: sparc host
+
+sparc: sparc-Makefile sparc-Config
+ make -f sparc-Makefile
+
+host: host-Makefile host-Config
+ make -f host-Makefile
+
+clean: sparc-Makefile host-Makefile
+ make -f sparc-Makefile clean
+ make -f host-Makefile clean
diff --git a/cesar/cl/test/functional/host-Makefile b/cesar/cl/test/functional/host-Makefile
new file mode 100644
index 0000000000..6103dde3f1
--- /dev/null
+++ b/cesar/cl/test/functional/host-Makefile
@@ -0,0 +1,14 @@
+BASE = ../../..
+
+ECOS = y
+VARIANT= host
+
+TARGET_PROGRAMS = cl
+
+cl_SOURCES = cl.c
+cl_MODULES = lib cl mac/common hal/phy \
+ mac/sar/stub
+
+hal_phy_MODULE_SOURCES=bridgedma_soft.c
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/cl/test/functional/host-ecos.ecc.sh b/cesar/cl/test/functional/host-ecos.ecc.sh
new file mode 100644
index 0000000000..2443d0e40f
--- /dev/null
+++ b/cesar/cl/test/functional/host-ecos.ecc.sh
@@ -0,0 +1,5 @@
+config=${1:-ecos-gen.ecc}
+ecosconfig --config=$config new linux default
+cat >> $config <<'EOF'
+EOF
+ecosconfig --config=$config check
diff --git a/cesar/cl/test/functional/sparc-Makefile b/cesar/cl/test/functional/sparc-Makefile
new file mode 100644
index 0000000000..4186924be4
--- /dev/null
+++ b/cesar/cl/test/functional/sparc-Makefile
@@ -0,0 +1,21 @@
+BASE = ../../..
+
+ECOS = y
+TARGET = sparc
+VARIANT= sparc
+
+TARGET_PROGRAMS = cl
+
+cl_SOURCES = cl.c
+cl_MODULES = lib cl mac/common hal \
+ mac/sar/stub
+
+include $(BASE)/common/make/top.mk
+
+all: $(TARGET_PROGRAMS:%=obj/$(VARIANT)/%.dis) $(TARGET_PROGRAMS:%=obj/$(VARIANT)/%.hex)
+
+%.dis: %.elf
+ $(CROSS_COMPILE_sparc)objdump -DSht $< > $@
+
+%.hex: %.elf
+ $(CROSS_COMPILE_sparc)objcopy -SO ihex $< $@
diff --git a/cesar/cl/test/functional/sparc-ecos.ecc.sh b/cesar/cl/test/functional/sparc-ecos.ecc.sh
new file mode 100644
index 0000000000..53c27b36a6
--- /dev/null
+++ b/cesar/cl/test/functional/sparc-ecos.ecc.sh
@@ -0,0 +1,14 @@
+config=${1:-ecos-gen.ecc}
+ecosconfig --config=$config new sparc_leon default
+cat >> $config <<'EOF'
+cdl_option CYGNUM_HAL_SYSTEM_CLOCK_FREQ {
+ user_value 150
+}
+cdl_option CYGNUM_HAL_UART_TRACE_FREQ {
+ user_value 50
+}
+cdl_option CYGNUM_KERNEL_SYNCH_MBOX_QUEUE_SIZE {
+ user_value 100
+}
+EOF
+ecosconfig --config=$config check
diff --git a/cesar/cl/test/functional/src/cl.c b/cesar/cl/test/functional/src/cl.c
new file mode 100644
index 0000000000..51eb3a058e
--- /dev/null
+++ b/cesar/cl/test/functional/src/cl.c
@@ -0,0 +1,432 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/cl_data_tx.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include "lib/test.h"
+#include "lib/bitstream.h"
+
+#include "mac/common/store.h"
+#include "mac/common/ntb.h"
+
+#include "cl/cl.h"
+#include "cl/cl_mactotei.h"
+
+#include <cyg/kernel/kapi.h>
+#include <cyg/hal/hal_arch.h>
+#include <string.h>
+
+#ifdef __sparc__
+static u8 buffer[2048] __attribute__((section(".private")));
+#else
+static u8 buffer[2048];
+#endif
+
+
+static cl_t *cl = NULL;
+static uint tei = 0;
+static uint lid = 0;
+
+static bool data_recv_cb = false;
+static bool mme_recv_cb = false;
+
+static u8 *cl_mme_buffer = NULL;
+static u8 *cl_data_buffer = NULL;
+
+/* Callbacks. */
+void
+cl_data_send_done_cb (void *user, u8 *buffer)
+{
+}
+
+void
+cl_data_recv_cb (void *user, u8 *buffer, uint length)
+{
+ data_recv_cb = true;
+}
+
+void
+cl_mme_recv_cb (void *user, u8 *buffer, uint length)
+{
+ mme_recv_cb = true;
+}
+
+void
+cl_mme_buffer_add_cb (void *user_data, u8 *buffer)
+{
+}
+
+/* TEST Functions */
+
+void
+cl_data_tx_send (test_t test)
+{
+ mac_store_t *mac_store;
+ mac_config_t mac_config;
+ uint sar;
+ uint phy;
+
+ /* Initialise the test. */
+ memset (&mac_config, 0, sizeof (mac_config_t));
+ mac_store = mac_store_init ();
+
+ cl = cl_init (mac_store, (sar_t *) &sar, &mac_config);
+ cl_data_send_done_init (cl, cl_data_send_done_cb, NULL);
+
+ mac_ntb_init ((phy_t *) &phy, &mac_config);
+
+ test_case_begin (test, "Data send");
+
+ test_begin (test, "not authenticated")
+ {
+ /* Configure the buffer. */
+ bitstream_direct_write_large (buffer, 0, 0x123456789ABCull, 48);
+ bitstream_direct_write_large (buffer, 48, 0x123456789ABCull, 48);
+
+ tei = 0;
+ lid = 0;
+ cl_data_send (cl, buffer, 106, 0);
+
+ test_fail_unless (tei == MAC_TEI_UNASSOCIATED);
+ test_fail_unless (lid == 0);
+ }
+ test_end;
+
+ test_begin (test, "Send data")
+ {
+ mfs_tx_t *mfs;
+
+ /* Configure the buffer. */
+ bitstream_direct_write_large (buffer, 0, 0x123456789ABCull, 48);
+ bitstream_direct_write_large (buffer, 48, 0x123456789ABCull, 48);
+ mac_config.tei = 1;
+ mac_config.authenticated = true;
+
+ cl_data_send (cl, buffer, 106, 0);
+
+ test_fail_unless (tei == MAC_TEI_BCAST);
+ test_fail_unless (lid == 1);
+
+ /* Remove the mfs. */
+ mfs = mac_store_mfs_get_tx (mac_store, true, false, lid, tei);
+ mac_store_mfs_remove (mac_store, (mfs_t *) mfs);
+ blk_release (mfs);
+ }
+ test_end;
+
+ test_begin (test, "Send data to a sta")
+ {
+ cl_mactotei_blk_t *table;
+ mfs_tx_t *mfs;
+
+ /* Configure the buffer. */
+ bitstream_direct_write_large (buffer, 0, 0x123456789ABCull, 48);
+ bitstream_direct_write_large (buffer, 48, 0x123456789ABCull, 48);
+ mac_config.tei = 1;
+ mac_config.authenticated = true;
+
+ /* Add the address to the mac_to_tei table. */
+ table = cl_mactotei_new ();
+ cl_mactotei_addr_add (table, 0x123456789ABCull, 2, 1);
+ cl_mactotei_use_table (cl, table);
+
+ cl_data_send (cl, buffer, 106, 0);
+
+ test_fail_unless (tei == 2);
+ test_fail_unless (lid == 1);
+
+ /* Remove the mfs. */
+ mfs = mac_store_mfs_get_tx (mac_store, false, false, lid, tei);
+ mac_store_mfs_remove (mac_store, (mfs_t *) mfs);
+ blk_release (mfs);
+ dbg_check (mac_store_sta_remove (mac_store, tei));
+ }
+ test_end;
+
+ /* Uninit. */
+ cl_uninit (cl);
+ mac_store_uninit (mac_store);
+}
+
+void
+cl_data_rx_recv (test_t test)
+{
+ uint mac_config = 0;
+ uint sar = 0;
+ uint mac_store = 0;
+ uint mfs;
+
+ /* Initialise the test. */
+ cl = cl_init ((mac_store_t *) &mac_store,
+ (sar_t *) &sar,
+ (mac_config_t *) &mac_config);
+
+ cl_data_recv_init (cl, cl_data_recv_cb, NULL);
+
+ test_case_begin (test, "Rx");
+
+ test_begin (test, "Received frame")
+ {
+ data_recv_cb = true;
+ cl_data_recv (cl, buffer, 106, (mfs_rx_t *) &mfs);
+
+ test_fail_unless (data_recv_cb == true);
+ }
+ test_end;
+
+ /* Uninit. */
+ cl_uninit (cl);
+}
+
+void
+cl_buffers (test_t test)
+{
+ uint mac_config = 0;
+ uint sar = 0;
+ uint mac_store = 0;
+
+ /* Initialise the test. */
+ cl_mme_buffer = NULL;
+ cl = cl_init ((mac_store_t *) &mac_store,
+ (sar_t *) &sar,
+ (mac_config_t *) &mac_config);
+
+ test_case_begin (test, "CL buffers add");
+
+ test_begin (test, "MME buffer")
+ {
+ test_fail_unless (cl_mme_buffer != NULL);
+ test_fail_unless (cl_mme_buffer != buffer);
+ }
+ test_end;
+
+ test_begin (test, "Data buffer")
+ {
+ cl_data_buffer = NULL;
+ cl_data_buffer_add (cl, buffer);
+ test_fail_unless (cl_data_buffer != NULL);
+ test_fail_unless (cl_data_buffer == buffer);
+ }
+ test_end;
+
+ /* Uninit. */
+ cl_uninit (cl);
+}
+
+void
+cl_mme_tx_send (test_t test)
+{
+ mac_store_t *mac_store;
+ mac_config_t mac_config;
+ uint sar;
+ uint phy;
+
+ /* Initialise the test. */
+ memset (&mac_config, 0, sizeof (mac_config_t));
+ mac_store = mac_store_init ();
+
+ cl = cl_init (mac_store, (sar_t *) &sar, &mac_config);
+ cl_mme_init_buffer_add_cb (cl, cl_mme_buffer_add_cb, NULL);
+
+ mac_ntb_init ((phy_t *) &phy, &mac_config);
+
+ test_case_begin (test, "MMe send");
+
+ test_begin (test, "MME to PWL not authenticated")
+ {
+ mfs_tx_t *mfs;
+ bitstream_direct_write_large (buffer, 0, 0x123456789ABCull, 48);
+ bitstream_direct_write_large (buffer, 48, 0x123456789ABCull, 48);
+
+ tei = 0;
+ lid = 0;
+ cl_mme_send (cl, buffer, 106, 1);
+
+ test_fail_unless (tei == 1);
+ test_fail_unless (lid == MAC_LID_NONE);
+
+ mfs = mac_store_mfs_get_tx (mac_store, false, true, lid, tei);
+ mac_store_mfs_remove (mac_store, (mfs_t *) mfs);
+ blk_release (mfs);
+
+ dbg_check (mac_store_sta_remove (mac_store, tei));
+ }
+ test_end;
+
+ test_begin (test, "MME to PWL authenticated")
+ {
+ cl_mactotei_blk_t *table;
+ mfs_tx_t *mfs;
+
+ bitstream_direct_write_large (buffer, 0, 0x123456789ABCull, 48);
+ bitstream_direct_write_large (buffer, 48, 0x123456789ABCull, 48);
+
+ mac_config.tei = 1;
+ mac_config.authenticated = true;
+
+ /* Add the address to the mac_to_tei table. */
+ table = cl_mactotei_new ();
+ cl_mactotei_addr_add (table, 0x123456789ABCull, 2, 1);
+ cl_mactotei_use_table (cl, table);
+
+ tei = 0;
+ lid = 0;
+ cl_mme_send (cl, buffer, 106, 2);
+
+ test_fail_unless (tei == 2);
+ test_fail_unless (lid == MAC_LID_NONE);
+
+ /* Remove the mfs. */
+ mfs = mac_store_mfs_get_tx (mac_store, false, true, MAC_LID_NONE, tei);
+ mac_store_mfs_remove (mac_store, (mfs_t *) mfs);
+ blk_release (mfs);
+ dbg_check (mac_store_sta_remove (mac_store, tei));
+ }
+ test_end;
+
+
+ test_begin (test, "MME to PWL, TEI Foreign")
+ {
+ cl_mactotei_blk_t *table;
+ mfs_tx_t *mfs;
+
+ bitstream_direct_write_large (buffer, 0, 0x123456789ABCull, 48);
+ bitstream_direct_write_large (buffer, 48, 0x123456789ABCull, 48);
+
+ mac_config.tei = 1;
+ mac_config.authenticated = true;
+
+ /* Add the address to the mac_to_tei table. */
+ table = cl_mactotei_new ();
+ cl_mactotei_addr_add (table, 0x123456789ABCull, 2, 1);
+ cl_mactotei_use_table (cl, table);
+
+ tei = 0;
+ lid = 0;
+ cl_mme_send (cl, buffer, 106, MAC_TEI_FOREIGN);
+
+ test_fail_unless (tei == 2);
+ test_fail_unless (lid == 0);
+
+ /* Remove the mfs. */
+ mfs = mac_store_mfs_get_tx (mac_store, false, false, lid, tei);
+ mac_store_mfs_remove (mac_store, (mfs_t *) mfs);
+ blk_release (mfs);
+ dbg_check (mac_store_sta_remove (mac_store, tei));
+
+ }
+ test_end;
+
+ test_begin (test, "MME to HLE, TEI FOREIGN")
+ {
+ cl_mactotei_release_table (cl);
+ cl_mme_init_ul_as_data (cl, cl_mme_recv_cb, NULL);
+
+ bitstream_direct_write_large (buffer, 0, 0x123456789ABCull, 48);
+ bitstream_direct_write_large (buffer, 48, 0x123456789ABCull, 48);
+
+ mac_config.tei = 1;
+ mac_config.authenticated = true;
+
+ /* Add the address to the mac_to_tei table. */
+ tei = 0;
+ lid = 0;
+ mme_recv_cb = false;
+ cl_mme_send (cl, buffer, 106, MAC_TEI_FOREIGN);
+
+ test_fail_unless (tei == 0);
+ test_fail_unless (lid == 0);
+ test_fail_unless (mme_recv_cb == true);
+ }
+ test_end;
+
+ /* Uninit. */
+ cl_uninit (cl);
+ mac_store_uninit (mac_store);
+}
+
+void
+cyg_user_start (cyg_addrword_t addr)
+{
+ test_t test;
+
+ test_init (test, 0, NULL);
+
+ cl_data_tx_send (test);
+ cl_data_rx_recv (test);
+
+ cl_buffers (test);
+
+ cl_mme_tx_send (test);
+
+ test_case_begin (test, "Memory");
+ test_begin (test, "leaks")
+ {
+ test_fail_unless (blk_check_memory () == true);
+ }
+ test_end;
+
+ test_result (test);
+
+#ifndef __sparc__
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+#endif
+}
+
+/* Stubs. */
+
+#ifndef __sparc__
+u32
+phy_date (phy_t *phy)
+{
+ return 0;
+}
+#endif
+
+void
+sar_msdu_add (sar_t *ctx, u8 *buffer, u16 length, u32 ats_confounder,
+ mfs_tx_t *mfs, void *user_data)
+{
+ dbg_assert (ctx);
+ dbg_assert (mfs);
+ dbg_assert (buffer);
+ dbg_assert (length);
+
+ tei = mfs->common.tei;
+ lid = mfs->common.lid;
+
+ /* Simulate the end of the segmentation. */
+ cl_data_send_done (cl, buffer, user_data);
+}
+
+
+void
+sar_mfs_add (sar_t *ctx, mfs_t *mfs)
+{
+ dbg_assert (mfs);
+}
+
+bool
+sar_buffer_add (sar_t *ctx, u8 *buffer, bool data)
+{
+ dbg_assert (ctx);
+ dbg_assert (buffer);
+
+ if (data)
+ cl_data_buffer = buffer;
+ else
+ cl_mme_buffer = buffer;
+
+ return true;
+}