summaryrefslogtreecommitdiff
path: root/cesar/maximus/sci/utest/scimsg
diff options
context:
space:
mode:
authorThierry Carré2012-10-16 12:45:48 +0200
committerThierry Carré2013-01-31 15:04:48 +0100
commit4452a8abe0d135b1f690b530a3bb4b1e495d7b65 (patch)
treeffa06423693d00cdaccd3d8a51d3c6c61ec2b2f3 /cesar/maximus/sci/utest/scimsg
parent83441de4ab01355295cfe6a6e389ad5bc66fd361 (diff)
cesar/maximus: C++ maximus refactoring, closes #3336, closes #3098
Feedback on new performance on tests inside: test_general/station Ratio = Test duration before this commit divided by new duration. |--------------------------------------------|-------| | Unit test | Ratio | |--------------------------------------------|-------| | maximus/py/sc01_long_simu.py | 6.5 | | maximus/py/sc02_long_simu.py | 4.5 | | scenario/av/py/sc01_assoc_auth.py | 3.3 | | scenario/av/py/sc02_stas_communication.py | 4.5 | | scenario/av/py/sc03_two_avln_coexisting.py | 2.1 | | scenario/av/py/sc04_cc_whoru.py | 2.1 | | scenario/av/py/sc05_cc_leave.py | 2.3 | | scenario/av/py/sc06_discover_procedure.py | 2.3 | | scenario/av/py/sc07_bridge.py | 2.2 | | scenario/av/py/sc08_bentry_change.py | 2.1 | | scenario/av/py/sc09_simple_connect.py | 2.2 | | scenario/av/py/sc10_short_messages.py | 5.7 | | scenario/av/py/sc11_cm_nw_info.py | 4.7 | | scenario/av/py/sc12_change_nmk.py | 5.5 | | scenario/av/py/sc14_igmp.py | 4.0 | | scenario/av/py/sc15_hide.py | 6.0 | | compliance/py/sc01_dut_as_a_cco.py | 5.8 | | tonemap/py/sc01_bl_initial.py | 2.3 | | tonemap/py/sc02_vs_get_tonemap.py | 2.3 | |--------------------------------------------|-------| | Average speed improvement of Maximus is | 4.9 | |--------------------------------------------|-------| Many tickets have been opened to continue the refactoring. Titles begin by "[Maximus][Refactoring]" in pessac's trac. For this reason #3336 is close. #3098 is really fixed.
Diffstat (limited to 'cesar/maximus/sci/utest/scimsg')
-rw-r--r--cesar/maximus/sci/utest/scimsg/Makefile23
-rw-r--r--cesar/maximus/sci/utest/scimsg/inc/TestClock.h52
-rw-r--r--cesar/maximus/sci/utest/scimsg/inc/TestEther.h50
-rw-r--r--cesar/maximus/sci/utest/scimsg/inc/TestFunctionCall.h51
-rw-r--r--cesar/maximus/sci/utest/scimsg/inc/TestPhy.h60
-rw-r--r--cesar/maximus/sci/utest/scimsg/inc/TestSystem.h50
-rw-r--r--cesar/maximus/sci/utest/scimsg/src/TestClock.cpp162
-rw-r--r--cesar/maximus/sci/utest/scimsg/src/TestEther.cpp161
-rw-r--r--cesar/maximus/sci/utest/scimsg/src/TestFunctionCall.cpp169
-rw-r--r--cesar/maximus/sci/utest/scimsg/src/TestPhy.cpp270
-rw-r--r--cesar/maximus/sci/utest/scimsg/src/TestSystem.cpp161
-rw-r--r--cesar/maximus/sci/utest/scimsg/src/fake_SciServer.cpp72
12 files changed, 1281 insertions, 0 deletions
diff --git a/cesar/maximus/sci/utest/scimsg/Makefile b/cesar/maximus/sci/utest/scimsg/Makefile
new file mode 100644
index 0000000000..1a95343723
--- /dev/null
+++ b/cesar/maximus/sci/utest/scimsg/Makefile
@@ -0,0 +1,23 @@
+BASE = ../../../..
+
+HOST_PROGRAMS = sci_msg_test
+
+sci_msg_test_SOURCES = TestClock.cpp TestPhy.cpp TestSystem.cpp \
+ TestEther.cpp TestFunctionCall.cpp
+sci_msg_test_MODULES = lib maximus/lib/test maximus/utils maximus/sci
+
+# class tested
+maximus_sci_MODULE_SOURCES = SciMsg.cpp \
+ ClockSciMsg.cpp \
+ PhySciMsg.cpp \
+ EtherSciMsg.cpp \
+ FunctionSciMsg.cpp \
+ SystemSciMsg.cpp
+
+# Modules stubbed for this unit test
+sci_msg_test_SOURCES += fake_SciServer.cpp
+
+EXTRA_HOST_CFLAGS := $(shell cppunit-config --cflags)
+EXTRA_HOST_LDLIBS := $(shell cppunit-config --libs)
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/maximus/sci/utest/scimsg/inc/TestClock.h b/cesar/maximus/sci/utest/scimsg/inc/TestClock.h
new file mode 100644
index 0000000000..c6efccbc65
--- /dev/null
+++ b/cesar/maximus/sci/utest/scimsg/inc/TestClock.h
@@ -0,0 +1,52 @@
+#ifndef maximus_sci_utest_scimsg_inc_testclock_h
+#define maximus_sci_utest_scimsg_inc_testclock_h
+/* Maximus project {{{
+ *
+ * Copyright (C) 2012 MStar Semiconductor
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file maximus/sci/utest/scimsg/inc/TestClock.h
+ * \ingroup maximus_sci_utest_scimsg
+ *
+ */
+#include "maximus/common/types.h"
+#include "maximus/interface/station/station.h"
+#include "maximus/sci/sci_msg.h"
+#include <sys/types.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+class TestClock : public CPPUNIT_NS::TestFixture
+{
+ CPPUNIT_TEST_SUITE (TestClock);
+ CPPUNIT_TEST (test_encode);
+ CPPUNIT_TEST (test_decode);
+ CPPUNIT_TEST_SUITE_END ();
+
+public:
+
+ void setUp ();
+ void tearDown ();
+
+private:
+
+ stations_list_t fake_sta_list;
+ Network_Clock_Tick time_base;
+ SciServer *fake_server;
+
+ void __build_clock_msg (
+ unsigned char *expected,
+ size_t msg_size,
+ size_t data_size,
+ Network_Clock_Type test_type,
+ Network_Clock_Id test_id,
+ Sci_Msg_Station_Id test_staid);
+
+ void test_encode ();
+ void test_decode ();
+};
+
+#endif /* maximus_sci_utest_scimsg_inc_testclock_h */
diff --git a/cesar/maximus/sci/utest/scimsg/inc/TestEther.h b/cesar/maximus/sci/utest/scimsg/inc/TestEther.h
new file mode 100644
index 0000000000..065c93c329
--- /dev/null
+++ b/cesar/maximus/sci/utest/scimsg/inc/TestEther.h
@@ -0,0 +1,50 @@
+#ifndef maximus_sci_utest_scimsg_inc_testether_h
+#define maximus_sci_utest_scimsg_inc_testether_h
+/* Maximus project {{{
+ *
+ * Copyright (C) 2012 MStar Semiconductor
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file maximus/sci/utest/scimsg/inc/TestEther.h
+ * \ingroup maximus_sci_utest_scimsg
+ *
+ */
+#include "maximus/common/types.h"
+#include "maximus/interface/station/station.h"
+#include "maximus/sci/sci_msg.h"
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+class TestEther : public CPPUNIT_NS::TestFixture
+{
+ CPPUNIT_TEST_SUITE (TestEther);
+ CPPUNIT_TEST (test_encode);
+ CPPUNIT_TEST (test_decode);
+ CPPUNIT_TEST_SUITE_END ();
+
+public:
+
+ void setUp ();
+ void tearDown ();
+
+private:
+
+ stations_list_t fake_sta_list;
+ Network_Clock_Tick time_base;
+ SciServer *fake_server;
+
+ void __build_ether_msg (
+ unsigned char *expected,
+ size_t msg_size,
+ size_t data_size,
+ Sci_Msg_Station_Id test_staid,
+ Ethernet_Type test_type);
+
+ void test_encode ();
+ void test_decode ();
+};
+
+#endif /* maximus_sci_utest_scimsg_inc_testether_h */
diff --git a/cesar/maximus/sci/utest/scimsg/inc/TestFunctionCall.h b/cesar/maximus/sci/utest/scimsg/inc/TestFunctionCall.h
new file mode 100644
index 0000000000..888a3c109a
--- /dev/null
+++ b/cesar/maximus/sci/utest/scimsg/inc/TestFunctionCall.h
@@ -0,0 +1,51 @@
+#ifndef maximus_sci_utest_scimsg_inc_testfunctioncall_h
+#define maximus_sci_utest_scimsg_inc_testfunctioncall_h
+/* Maximus project {{{
+ *
+ * Copyright (C) 2012 MStar Semiconductor
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file maximus/sci/utest/scimsg/inc/TestFunctionCall.h
+ * \ingroup maximus_sci_utest_scimsg
+ *
+ */
+#include "maximus/common/types.h"
+#include "maximus/sci/sci_msg.h"
+#include "maximus/interface/station/station.h"
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+class TestFunctionCall : public CPPUNIT_NS::TestFixture
+{
+ CPPUNIT_TEST_SUITE (TestFunctionCall);
+ CPPUNIT_TEST (test_encode);
+ CPPUNIT_TEST (test_decode);
+ CPPUNIT_TEST_SUITE_END ();
+
+public:
+
+ void setUp ();
+ void tearDown ();
+
+private:
+
+ stations_list_t fake_sta_list;
+ Network_Clock_Tick time_base;
+ SciServer *fake_server;
+
+ void __build_functioncall_msg (
+ unsigned char *expected,
+ size_t msg_size,
+ size_t data_size,
+ Sci_Msg_Station_Id test_staid,
+ Function_Call_Type test_type,
+ Function_Call_Msg_Id test_msg_id);
+
+ void test_encode ();
+ void test_decode ();
+};
+
+#endif /* maximus_sci_utest_scimsg_inc_testfunctioncall_h */
diff --git a/cesar/maximus/sci/utest/scimsg/inc/TestPhy.h b/cesar/maximus/sci/utest/scimsg/inc/TestPhy.h
new file mode 100644
index 0000000000..baa8763804
--- /dev/null
+++ b/cesar/maximus/sci/utest/scimsg/inc/TestPhy.h
@@ -0,0 +1,60 @@
+#ifndef maximus_sci_utest_scimsg_inc_testphy_h
+#define maximus_sci_utest_scimsg_inc_testphy_h
+/* Maximus project {{{
+ *
+ * Copyright (C) 2012 MStar Semiconductor
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file maximus/sci/utest/scimsg/inc/TestPhy.h
+ * \ingroup maximus_sci_utest_scimsg
+ *
+ */
+#include "maximus/common/types.h"
+#include "maximus/sci/sci_msg.h"
+#include "maximus/interface/station/station.h"
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+class TestPhy : public CPPUNIT_NS::TestFixture
+{
+ CPPUNIT_TEST_SUITE (TestPhy);
+ CPPUNIT_TEST (test_encode);
+ CPPUNIT_TEST (test_decode);
+ CPPUNIT_TEST_SUITE_END ();
+
+public:
+
+ void setUp ();
+ void tearDown ();
+
+private:
+
+ stations_list_t fake_sta_list;
+ Network_Clock_Tick time_base;
+ SciServer *fake_server;
+
+ void __build_phy_msg (
+ unsigned char *expected,
+ size_t msg_size,
+ size_t data_size,
+ Sci_Msg_Station_Id test_staid,
+ Phy_Type test_type,
+ Phy_Mpdu_Format test_mpdu_format,
+ Phy_Nb_Of_Pbs test_pb_nb,
+ Phy_Short_Ppdu test_short_ppdu,
+ Phy_Mod test_mod,
+ Phy_Fecrate test_fecrate,
+ Phy_Gil test_gil,
+ Phy_Tx_Id test_tx_id,
+ Phy_Flags test_flags,
+ uint32_t test_pb_measurement[MAC_MAX_PB_PER_MPDU],
+ uint32_t test_pb_header[MAC_MAX_PB_PER_MPDU]);
+
+ void test_encode ();
+ void test_decode ();
+};
+
+#endif /* maximus_sci_utest_scimsg_inc_testphy_h */
diff --git a/cesar/maximus/sci/utest/scimsg/inc/TestSystem.h b/cesar/maximus/sci/utest/scimsg/inc/TestSystem.h
new file mode 100644
index 0000000000..c95483cd75
--- /dev/null
+++ b/cesar/maximus/sci/utest/scimsg/inc/TestSystem.h
@@ -0,0 +1,50 @@
+#ifndef maximus_sci_utest_scimsg_inc_testsystem_h
+#define maximus_sci_utest_scimsg_inc_testsystem_h
+/* Maximus project {{{
+ *
+ * Copyright (C) 2012 MStar Semiconductor
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file maximus/sci/utest/scimsg/inc/TestSystem.h
+ * \ingroup maximus_sci_utest_scimsg
+ *
+ */
+#include "maximus/common/types.h"
+#include "maximus/sci/sci_msg.h"
+#include "maximus/interface/station/station.h"
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+class TestSystem : public CPPUNIT_NS::TestFixture
+{
+ CPPUNIT_TEST_SUITE (TestSystem);
+ CPPUNIT_TEST (test_encode);
+ CPPUNIT_TEST (test_decode);
+ CPPUNIT_TEST_SUITE_END ();
+
+public:
+
+ void setUp ();
+ void tearDown ();
+
+private:
+
+ stations_list_t fake_sta_list;
+ Network_Clock_Tick time_base;
+ SciServer *fake_server;
+
+ void __build_system_msg (
+ unsigned char *expected,
+ size_t msg_size,
+ size_t data_size,
+ Sci_Msg_Station_Id test_staid,
+ System_Type test_type);
+
+ void test_encode ();
+ void test_decode ();
+};
+
+#endif /* maximus_sci_utest_scimsg_inc_testsystem_h */
diff --git a/cesar/maximus/sci/utest/scimsg/src/TestClock.cpp b/cesar/maximus/sci/utest/scimsg/src/TestClock.cpp
new file mode 100644
index 0000000000..511c1851f2
--- /dev/null
+++ b/cesar/maximus/sci/utest/scimsg/src/TestClock.cpp
@@ -0,0 +1,162 @@
+/* Maximus project {{{
+ *
+ * Copyright (C) 2012 MStar Semiconductor
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file maximus/sci/utest/scimsg/src/TestClock.cpp
+ * \ingroup maximus_sci_utest_scimsg
+ *
+ */
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include "inc/TestClock.h"
+#include "maximus/sci/inc/ClockSciMsg.h"
+#include "maximus/sci/inc/SciServer.h"
+#include <sys/types.h>
+#include <string.h>
+#include <ostream>
+
+uint expected_msg_id = 0;
+CPPUNIT_TEST_SUITE_REGISTRATION (TestClock);
+
+void
+TestClock::setUp ()
+{
+ fake_server = new SciServer (fake_sta_list);
+ fake_server->register_current_tick_addr (&time_base);
+ time_base = 0xDEADBEAF;
+}
+
+void
+TestClock::tearDown ()
+{
+ delete fake_server;
+ fake_server = NULL;
+}
+
+inline void
+TestClock::__build_clock_msg (
+ unsigned char *expected,
+ size_t msg_size,
+ size_t data_size,
+ Network_Clock_Type test_type,
+ Network_Clock_Id test_id,
+ Sci_Msg_Station_Id test_staid)
+{
+ /* Build the expected buffer in network format. */
+ CPPUNIT_ASSERT (msg_size >= 42);
+
+ memset (expected, 0, msg_size);
+ size_t test_length = data_size + sizeof (Network_Clock_Header);
+
+ /* SciMsg Header from here. */
+ expected[0] = 'M';
+ expected[1] = 'A';
+ expected[2] = 'X';
+ expected[3] = 'I';
+ expected[4] = SCI_MSG_VERSION;
+ expected[5] = SCI_MSG_TYPE_NETWORK_CLOCK;
+ expected[6] = test_length >> 24;
+ expected[7] = test_length >> 16;
+ expected[8] = test_length >> 8;
+ expected[9] = test_length;
+ expected[10] = static_cast <uint16_t> (test_staid) >> 8;
+ expected[11] = static_cast <uint16_t> (test_staid);
+ expected[12] = expected_msg_id >> 8;
+ expected[13] = expected_msg_id;
+ expected[14] = time_base >> 56;
+ expected[15] = time_base >> 48;
+ expected[16] = time_base >> 40;
+ expected[17] = time_base >> 32;
+ expected[18] = time_base >> 24;
+ expected[19] = time_base >> 16;
+ expected[20] = time_base >> 8;
+ expected[21] = time_base;
+ /* Network_Clock Header from here. */
+ expected[26] = NETWORK_CLOCK_VERSION;
+ expected[27] = static_cast <uint8_t> (test_type);
+ expected[28] = static_cast <uint16_t> (test_id) >> 8;
+ expected[29] = static_cast <uint16_t> (test_id);
+ expected[34] = time_base >> 56;
+ expected[35] = time_base >> 48;
+ expected[36] = time_base >> 40;
+ expected[37] = time_base >> 32;
+ expected[38] = time_base >> 24;
+ expected[39] = time_base >> 16;
+ expected[40] = time_base >> 8;
+ expected[41] = time_base;
+}
+
+void
+TestClock::test_encode ()
+{
+ std::cout << "TestClock_encode" << std::endl;
+ const unsigned char *serial_msg;
+ const size_t msg_data_size = 0;
+ Network_Clock_Type type = NETWORK_CLOCK_TYPE_NB;
+ Network_Clock_Id id = 20;
+ Sci_Msg_Station_Id staid = 30;
+
+ const size_t msg_size = msg_data_size
+ + sizeof (Sci_Msg_Header)
+ + sizeof (Network_Clock_Header);
+ unsigned char *expected = new unsigned char [msg_size];
+ ++expected_msg_id;
+ __build_clock_msg (expected, msg_size, msg_data_size,
+ type, id, staid);
+
+ ClockSciMsg msg (msg_data_size);
+ msg.set_clock_type (type);
+ msg.set_clock_id (id);
+ msg.set_sci_stationid (staid);
+ msg.setup_and_send (*fake_server);
+ serial_msg = msg.get_sci_alloc_addr ();
+ CPPUNIT_ASSERT (serial_msg);
+ CPPUNIT_ASSERT (msg.get_sci_alloc_size ()
+ != (msg_data_size + sizeof (Network_Clock_Header)));
+
+ for (uint i = 0; i < msg_size; i++)
+ {
+ if (expected[i] != serial_msg[i])
+ {
+ std::ostringstream oss;
+ oss << "expected[" << i << "] = "
+ << (uint) expected[i]
+ << " != "
+ << (uint) serial_msg[i]
+ << " = serial_msg[" << i << "]";
+ CPPUNIT_FAIL (oss.str ().c_str ());
+ }
+ }
+ delete [] expected;
+}
+
+void
+TestClock::test_decode ()
+{
+ std::cout << "TestClock_decode" << std::endl;
+ const size_t msg_data_size = 10;
+ Network_Clock_Type type = NETWORK_CLOCK_TYPE_NONE;
+ Network_Clock_Id id = 42;
+ Sci_Msg_Station_Id staid = 99;
+
+ const size_t msg_size = msg_data_size
+ + sizeof (Sci_Msg_Header)
+ + sizeof (Network_Clock_Header);
+ unsigned char *expected = new unsigned char [msg_size];
+ __build_clock_msg (expected, msg_size, msg_data_size,
+ type, id, staid);
+
+ ClockSciMsg msg (*((struct Sci_Msg_Header *)expected), expected);
+
+ CPPUNIT_ASSERT (msg.get_sci_alloc_size () == msg_size);
+ CPPUNIT_ASSERT (msg.get_sci_alloc_addr () == expected);
+ CPPUNIT_ASSERT (msg.get_sci_data_addr () == (expected + sizeof (Sci_Msg_Header)));
+ CPPUNIT_ASSERT (msg.get_sci_datalength () == (msg_size - sizeof (Sci_Msg_Header)));
+ CPPUNIT_ASSERT (msg.get_sci_stationid () == staid);
+ CPPUNIT_ASSERT (msg.get_clock_type () == type);
+ CPPUNIT_ASSERT (msg.get_clock_id () == id);
+}
diff --git a/cesar/maximus/sci/utest/scimsg/src/TestEther.cpp b/cesar/maximus/sci/utest/scimsg/src/TestEther.cpp
new file mode 100644
index 0000000000..bd676426a7
--- /dev/null
+++ b/cesar/maximus/sci/utest/scimsg/src/TestEther.cpp
@@ -0,0 +1,161 @@
+/* Maximus project {{{
+ *
+ * Copyright (C) 2012 MStar Semiconductor
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file maximus/sci/utest/scimsg/src/TestEther.cpp
+ * \ingroup maximus_sci_utest_scimsg
+ *
+ */
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include "inc/TestEther.h"
+#include "maximus/sci/inc/EtherSciMsg.h"
+#include "maximus/sci/inc/SciServer.h"
+#include <sys/types.h>
+#include <string.h>
+#include <ostream>
+
+extern uint expected_msg_id;
+CPPUNIT_TEST_SUITE_REGISTRATION (TestEther);
+
+void
+TestEther::setUp ()
+{
+ fake_server = new SciServer (fake_sta_list);
+ fake_server->register_current_tick_addr (&time_base);
+ time_base = 0x1234567809123;
+}
+
+void
+TestEther::tearDown ()
+{
+ delete fake_server;
+ fake_server = NULL;
+}
+
+inline void
+TestEther::__build_ether_msg (
+ unsigned char *expected,
+ size_t msg_size,
+ size_t data_size,
+ Sci_Msg_Station_Id test_staid,
+ Ethernet_Type test_type)
+{
+ /* Build the expected buffer in network format. */
+
+ /* 30 = sizeof (Sci_Msg_Header) + sizeof (Ethernet_Header). */
+ CPPUNIT_ASSERT (msg_size >= 30);
+
+ memset (expected, 0, msg_size);
+ size_t test_length = data_size + sizeof (Ethernet_Header);
+
+ /* SciMsg Header from here. */
+ expected[0] = 'M';
+ expected[1] = 'A';
+ expected[2] = 'X';
+ expected[3] = 'I';
+ expected[4] = SCI_MSG_VERSION;
+ expected[5] = SCI_MSG_TYPE_ETHERNET;
+ expected[6] = test_length >> 24;
+ expected[7] = test_length >> 16;
+ expected[8] = test_length >> 8;
+ expected[9] = test_length;
+ expected[10] = static_cast <uint16_t> (test_staid) >> 8;
+ expected[11] = static_cast <uint16_t> (test_staid);
+ expected[12] = expected_msg_id >> 8;
+ expected[13] = expected_msg_id;
+ expected[14] = time_base >> 56;
+ expected[15] = time_base >> 48;
+ expected[16] = time_base >> 40;
+ expected[17] = time_base >> 32;
+ expected[18] = time_base >> 24;
+ expected[19] = time_base >> 16;
+ expected[20] = time_base >> 8;
+ expected[21] = time_base;
+ /* ether Header from here. */
+ expected[26] = SYSTEM_VERSION;
+ expected[27] = static_cast <uint8_t> (test_type);
+}
+
+void
+TestEther::test_encode ()
+{
+ std::cout << "TestEther_encode" << std::endl;
+ const unsigned char *serial_msg;
+ const size_t msg_data_size = 0;
+
+ Sci_Msg_Station_Id staid = 66;
+ Ethernet_Type type = ETHERNET_TYPE_MME;
+
+ const size_t msg_size = msg_data_size
+ + sizeof (Sci_Msg_Header)
+ + sizeof (Ethernet_Header);
+ unsigned char *expected = new unsigned char [msg_size];
+ ++expected_msg_id;
+ __build_ether_msg (
+ expected,
+ msg_size,
+ msg_data_size,
+ staid,
+ type);
+
+ EtherSciMsg msg (msg_data_size);
+ msg.set_sci_stationid (staid);
+ msg.set_ether_type (type);
+
+ msg.setup_and_send (*fake_server);
+ serial_msg = msg.get_sci_alloc_addr ();
+ CPPUNIT_ASSERT (serial_msg);
+ CPPUNIT_ASSERT (msg.get_sci_alloc_size ()
+ != (msg_data_size + sizeof (Ethernet_Header)));
+
+ for (uint i = 0; i < msg_size; i++)
+ {
+ if (expected[i] != serial_msg[i])
+ {
+ std::ostringstream oss;
+ oss << "expected[" << i << "] = "
+ << (uint) expected[i]
+ << " != "
+ << (uint) serial_msg[i]
+ << " = serial_msg[" << i << "]";
+ CPPUNIT_FAIL (oss.str ().c_str ());
+ }
+ }
+ delete [] expected;
+}
+
+void
+TestEther::test_decode ()
+{
+ std::cout << "TestEther_decode" << std::endl;
+ const size_t msg_data_size = 15;
+
+ Sci_Msg_Station_Id staid = 42;
+ Ethernet_Type type = ETHERNET_TYPE_DATA;
+
+ const size_t msg_size = msg_data_size
+ + sizeof (Sci_Msg_Header)
+ + sizeof (Ethernet_Header);
+ unsigned char *expected = new unsigned char [msg_size];
+ __build_ether_msg (
+ expected,
+ msg_size,
+ msg_data_size,
+ staid,
+ type);
+
+ EtherSciMsg msg (*((struct Sci_Msg_Header *)expected), expected);
+
+ CPPUNIT_ASSERT (msg.get_sci_alloc_size () == msg_size);
+ CPPUNIT_ASSERT (msg.get_sci_alloc_addr () == expected);
+ CPPUNIT_ASSERT (msg.get_sci_data_addr () == (expected + sizeof (Sci_Msg_Header)));
+ CPPUNIT_ASSERT (msg.get_sci_datalength () == (msg_size - sizeof (Sci_Msg_Header)));
+ CPPUNIT_ASSERT (msg.get_sci_stationid () == staid);
+
+ CPPUNIT_ASSERT (msg.get_ether_type () == type);
+}
diff --git a/cesar/maximus/sci/utest/scimsg/src/TestFunctionCall.cpp b/cesar/maximus/sci/utest/scimsg/src/TestFunctionCall.cpp
new file mode 100644
index 0000000000..a5ede75be9
--- /dev/null
+++ b/cesar/maximus/sci/utest/scimsg/src/TestFunctionCall.cpp
@@ -0,0 +1,169 @@
+/* Maximus project {{{
+ *
+ * Copyright (C) 2012 MStar Semiconductor
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file maximus/sci/utest/scimsg/src/TestFunctionCall.cpp
+ * \ingroup maximus_sci_utest_scimsg
+ *
+ */
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include "inc/TestFunctionCall.h"
+#include "maximus/sci/inc/FunctionSciMsg.h"
+#include "maximus/sci/inc/SciServer.h"
+#include <sys/types.h>
+#include <string.h>
+#include <ostream>
+
+extern uint expected_msg_id;
+CPPUNIT_TEST_SUITE_REGISTRATION (TestFunctionCall);
+
+void
+TestFunctionCall::setUp ()
+{
+ fake_server = new SciServer (fake_sta_list);
+ fake_server->register_current_tick_addr (&time_base);
+ time_base = 0xBEEFBEEFBEEFBEEFll;
+}
+
+void
+TestFunctionCall::tearDown ()
+{
+ delete fake_server;
+ fake_server = NULL;
+}
+
+inline void
+TestFunctionCall::__build_functioncall_msg (
+ unsigned char *expected,
+ size_t msg_size,
+ size_t data_size,
+ Sci_Msg_Station_Id test_staid,
+ Function_Call_Type test_type,
+ Function_Call_Msg_Id test_msg_id)
+{
+ /* Build the expected buffer in network format. */
+
+ /* 34 = sizeof (Sci_Msg_Header) + sizeof (Function_Call_Header). */
+ CPPUNIT_ASSERT (msg_size >= 34);
+
+ memset (expected, 0, msg_size);
+ size_t test_length = data_size + sizeof (Function_Call_Header);
+
+ /* SciMsg Header from here. */
+ expected[0] = 'M';
+ expected[1] = 'A';
+ expected[2] = 'X';
+ expected[3] = 'I';
+ expected[4] = SCI_MSG_VERSION;
+ expected[5] = SCI_MSG_TYPE_FUNCTION_CALL;
+ expected[6] = test_length >> 24;
+ expected[7] = test_length >> 16;
+ expected[8] = test_length >> 8;
+ expected[9] = test_length;
+ expected[10] = static_cast <uint16_t> (test_staid) >> 8;
+ expected[11] = static_cast <uint16_t> (test_staid);
+ expected[12] = expected_msg_id >> 8;
+ expected[13] = expected_msg_id;
+ expected[14] = time_base >> 56;
+ expected[15] = time_base >> 48;
+ expected[16] = time_base >> 40;
+ expected[17] = time_base >> 32;
+ expected[18] = time_base >> 24;
+ expected[19] = time_base >> 16;
+ expected[20] = time_base >> 8;
+ expected[21] = time_base;
+ /* functioncall Header from here. */
+ expected[26] = FUNCTION_CALL_VERSION;
+ expected[27] = static_cast <uint8_t> (test_type);
+ expected[28] = static_cast <uint16_t> (test_msg_id) >> 8;
+ expected[29] = static_cast <uint16_t> (test_msg_id);
+}
+
+void
+TestFunctionCall::test_encode ()
+{
+ std::cout << "TestFunctionCall_encode" << std::endl;
+ const unsigned char *serial_msg;
+ const size_t msg_data_size = 0;
+
+ Sci_Msg_Station_Id staid = 30;
+ Function_Call_Type type = FUNCTION_CALL_TYPE_REQ;
+ Function_Call_Msg_Id msg_id = 0x17;
+
+ const size_t msg_size = msg_data_size
+ + sizeof (Sci_Msg_Header)
+ + sizeof (Function_Call_Header);
+ unsigned char *expected = new unsigned char [msg_size];
+ ++expected_msg_id;
+ __build_functioncall_msg (
+ expected,
+ msg_size,
+ msg_data_size,
+ staid,
+ type,
+ msg_id);
+
+ FunctionSciMsg msg (msg_data_size);
+ msg.set_sci_stationid (staid);
+ msg.set_fc_msg_id (msg_id);
+
+ msg.setup_and_send (*fake_server);
+ serial_msg = msg.get_sci_alloc_addr ();
+ CPPUNIT_ASSERT (serial_msg);
+ CPPUNIT_ASSERT (msg.get_sci_alloc_size ()
+ != (msg_data_size + sizeof (Function_Call_Header)));
+
+ for (uint i = 0; i < msg_size; i++)
+ {
+ if (expected[i] != serial_msg[i])
+ {
+ std::ostringstream oss;
+ oss << "expected[" << i << "] = "
+ << (uint) expected[i]
+ << " != "
+ << (uint) serial_msg[i]
+ << " = serial_msg[" << i << "]";
+ CPPUNIT_FAIL (oss.str ().c_str ());
+ }
+ }
+ delete [] expected;
+}
+
+void
+TestFunctionCall::test_decode ()
+{
+ std::cout << "TestFunctionCall_decode" << std::endl;
+ const size_t msg_data_size = 15;
+
+ Sci_Msg_Station_Id staid = 42;
+ Function_Call_Type type = FUNCTION_CALL_TYPE_RSP;
+ Function_Call_Msg_Id msg_id = 0x37;
+
+ const size_t msg_size = msg_data_size
+ + sizeof (Sci_Msg_Header)
+ + sizeof (Function_Call_Header);
+ unsigned char *expected = new unsigned char [msg_size];
+ __build_functioncall_msg (
+ expected,
+ msg_size,
+ msg_data_size,
+ staid,
+ type,
+ msg_id);
+
+ FunctionSciMsg msg (*((struct Sci_Msg_Header *)expected), expected);
+
+ CPPUNIT_ASSERT (msg.get_sci_alloc_size () == msg_size);
+ CPPUNIT_ASSERT (msg.get_sci_alloc_addr () == expected);
+ CPPUNIT_ASSERT (msg.get_sci_data_addr () == (expected + sizeof (Sci_Msg_Header)));
+ CPPUNIT_ASSERT (msg.get_sci_datalength () == (msg_size - sizeof (Sci_Msg_Header)));
+ CPPUNIT_ASSERT (msg.get_sci_stationid () == staid);
+
+ CPPUNIT_ASSERT (msg.get_fc_type () == type);
+ CPPUNIT_ASSERT (msg.get_fc_msgid () == msg_id);
+}
diff --git a/cesar/maximus/sci/utest/scimsg/src/TestPhy.cpp b/cesar/maximus/sci/utest/scimsg/src/TestPhy.cpp
new file mode 100644
index 0000000000..0791d5cea4
--- /dev/null
+++ b/cesar/maximus/sci/utest/scimsg/src/TestPhy.cpp
@@ -0,0 +1,270 @@
+/* Maximus project {{{
+ *
+ * Copyright (C) 2012 MStar Semiconductor
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file maximus/sci/utest/scimsg/src/TestPhy.cpp
+ * \ingroup maximus_sci_utest_scimsg
+ *
+ */
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include "inc/TestPhy.h"
+#include "maximus/sci/inc/PhySciMsg.h"
+#include "maximus/sci/inc/SciServer.h"
+#include <sys/types.h>
+#include <string.h>
+#include <ostream>
+
+extern uint expected_msg_id;
+CPPUNIT_TEST_SUITE_REGISTRATION (TestPhy);
+
+void
+TestPhy::setUp ()
+{
+ fake_server = new SciServer (fake_sta_list);
+ fake_server->register_current_tick_addr (&time_base);
+ time_base = 0x1234567809123;
+}
+
+void
+TestPhy::tearDown ()
+{
+ delete fake_server;
+ fake_server = NULL;
+}
+
+inline void
+TestPhy::__build_phy_msg (
+ unsigned char *expected,
+ size_t msg_size,
+ size_t data_size,
+ Sci_Msg_Station_Id test_staid,
+ Phy_Type test_type,
+ Phy_Mpdu_Format test_mpdu_format,
+ Phy_Nb_Of_Pbs test_pb_nb,
+ Phy_Short_Ppdu test_short_ppdu,
+ Phy_Mod test_mod,
+ Phy_Fecrate test_fecrate,
+ Phy_Gil test_gil,
+ Phy_Tx_Id test_tx_id,
+ Phy_Flags test_flags,
+ uint32_t test_pb_measurement[MAC_MAX_PB_PER_MPDU],
+ uint32_t test_pb_header[MAC_MAX_PB_PER_MPDU])
+{
+ /* Build the expected buffer in network format. */
+
+ /* 1962 = sizeof (Sci_Msg_Header) + sizeof (Phy_Header). */
+ CPPUNIT_ASSERT (msg_size >= 1962);
+
+ memset (expected, 0, msg_size);
+ size_t test_length = data_size + sizeof (Phy_Header);
+
+ /* SciMsg Header from here. */
+ expected[0] = 'M';
+ expected[1] = 'A';
+ expected[2] = 'X';
+ expected[3] = 'I';
+ expected[4] = SCI_MSG_VERSION;
+ expected[5] = SCI_MSG_TYPE_PHY;
+ expected[6] = test_length >> 24;
+ expected[7] = test_length >> 16;
+ expected[8] = test_length >> 8;
+ expected[9] = test_length;
+ expected[10] = static_cast <uint16_t> (test_staid) >> 8;
+ expected[11] = static_cast <uint16_t> (test_staid);
+ expected[12] = expected_msg_id >> 8;
+ expected[13] = expected_msg_id;
+ expected[14] = time_base >> 56;
+ expected[15] = time_base >> 48;
+ expected[16] = time_base >> 40;
+ expected[17] = time_base >> 32;
+ expected[18] = time_base >> 24;
+ expected[19] = time_base >> 16;
+ expected[20] = time_base >> 8;
+ expected[21] = time_base;
+ /* phy Header from here. */
+ expected[26] = PHY_VERSION;
+ expected[27] = static_cast <uint8_t> (test_type);
+ expected[28] = static_cast <uint8_t> (test_mpdu_format);
+ expected[29] = static_cast <uint8_t> (test_pb_nb);
+ expected[30] = 1; /* msg_nb */
+ expected[31] = PHY_FC_MODE_NONE;
+ expected[32] = static_cast <uint8_t> (test_short_ppdu);
+ expected[33] = static_cast <uint8_t> (test_mod);
+ expected[34] = static_cast <uint8_t> (test_fecrate);
+ expected[35] = static_cast <uint8_t> (test_gil);
+ expected[38] = static_cast <uint16_t> (test_tx_id) >> 8;
+ expected[39] = static_cast <uint16_t> (test_tx_id);
+ expected[40] = static_cast <uint16_t> (test_flags) >> 8;
+ expected[41] = static_cast <uint16_t> (test_flags);
+
+ for (uint i = 0; i < MAC_MAX_PB_PER_MPDU; i++)
+ {
+ int index = 74 + i * sizeof (uint32_t);
+ expected[index + 0] = static_cast <uint32_t> (test_pb_measurement[i]) >> 24;
+ expected[index + 1] = static_cast <uint32_t> (test_pb_measurement[i]) >> 16;
+ expected[index + 2] = static_cast <uint32_t> (test_pb_measurement[i]) >> 8;
+ expected[index + 3] = static_cast <uint32_t> (test_pb_measurement[i]);
+ }
+ for (uint i = 0; i < MAC_MAX_PB_PER_MPDU; i++)
+ {
+ int index = 1018 + i * sizeof (uint32_t);
+ expected[index + 0] = static_cast <uint32_t> (test_pb_header[i]) >> 24;
+ expected[index + 1] = static_cast <uint32_t> (test_pb_header[i]) >> 16;
+ expected[index + 2] = static_cast <uint32_t> (test_pb_header[i]) >> 8;
+ expected[index + 3] = static_cast <uint32_t> (test_pb_header[i]);
+ }
+}
+
+void
+TestPhy::test_encode ()
+{
+ std::cout << "TestPhy_encode" << std::endl;
+ const unsigned char *serial_msg;
+ const size_t msg_data_size = 0;
+
+ Sci_Msg_Station_Id staid = 30;
+ Phy_Type type = PHY_TYPE_FC_AV_ONLY_MODE;
+ Phy_Mpdu_Format mpdu_format = PHY_MPDU_FORMAT_SOF;
+ Phy_Nb_Of_Pbs pb_nb = 20;
+ Phy_Short_Ppdu short_ppdu = true;
+ Phy_Mod mod = PHY_MOD_MINI_ROBO;
+ Phy_Fecrate fecrate = PHY_FEC_RATE_16_21;
+ Phy_Gil gil = PHY_GIL_3534;
+ Phy_Tx_Id tx_id = 0x35;
+ Phy_Flags flags = PHY_FLAG_CRC_OK;
+ uint32_t pb_measurement[MAC_MAX_PB_PER_MPDU];
+ uint32_t pb_header[MAC_MAX_PB_PER_MPDU];
+
+ memset (pb_measurement, 0xBC, sizeof (pb_measurement));
+ memset (pb_header, 0xDB, sizeof (pb_header));
+
+ const size_t msg_size = msg_data_size
+ + sizeof (Sci_Msg_Header)
+ + sizeof (Phy_Header);
+ unsigned char *expected = new unsigned char [msg_size];
+ ++expected_msg_id;
+ __build_phy_msg (
+ expected,
+ msg_size,
+ msg_data_size,
+ staid,
+ type,
+ mpdu_format,
+ pb_nb,
+ short_ppdu,
+ mod,
+ fecrate,
+ gil,
+ tx_id,
+ flags,
+ pb_measurement,
+ pb_header);
+
+ PhySciMsg msg (msg_data_size);
+ msg.set_sci_stationid (staid);
+ msg.set_phy_type (type);
+ msg.set_phy_MpduFormat (mpdu_format);
+ msg.set_phy_NbOfPbs (pb_nb);
+ msg.set_phy_mod (mod);
+ msg.set_phy_shortppdu (short_ppdu);
+ msg.set_phy_FecRate (fecrate);
+ msg.set_phy_gil (gil);
+ msg.set_phy_TxId (tx_id);
+ msg.set_phy_flags (flags);
+ msg.set_phy_PbMeasurement (pb_measurement);
+ msg.set_phy_PbHeaders (pb_header);
+
+ msg.setup_and_send (*fake_server, staid);
+ serial_msg = msg.get_sci_alloc_addr ();
+ CPPUNIT_ASSERT (serial_msg);
+ CPPUNIT_ASSERT (msg.get_sci_alloc_size ()
+ != (msg_data_size + sizeof (Phy_Header)));
+
+ for (uint i = 0; i < msg_size; i++)
+ {
+ if (expected[i] != serial_msg[i])
+ {
+ std::ostringstream oss;
+ oss << "expected[" << i << "] = "
+ << (uint) expected[i]
+ << " != "
+ << (uint) serial_msg[i]
+ << " = serial_msg[" << i << "]";
+ CPPUNIT_FAIL (oss.str ().c_str ());
+ }
+ }
+ delete [] expected;
+}
+
+void
+TestPhy::test_decode ()
+{
+ std::cout << "TestPhy_decode" << std::endl;
+ const size_t msg_data_size = 10;
+
+ Sci_Msg_Station_Id staid = 30;
+ Phy_Type type = PHY_TYPE_FC_AV_ONLY_MODE;
+ Phy_Mpdu_Format mpdu_format = PHY_MPDU_FORMAT_SOF;
+ Phy_Nb_Of_Pbs pb_nb = 20;
+ Phy_Short_Ppdu short_ppdu = true;
+ Phy_Mod mod = PHY_MOD_MINI_ROBO;
+ Phy_Fecrate fecrate = PHY_FEC_RATE_16_21;
+ Phy_Gil gil = PHY_GIL_3534;
+ Phy_Tx_Id tx_id = 0x35;
+ Phy_Flags flags = PHY_FLAG_CRC_OK;
+ uint32_t pb_measurement[MAC_MAX_PB_PER_MPDU];
+ uint32_t pb_header[MAC_MAX_PB_PER_MPDU];
+
+ memset (pb_measurement, 0xBC, sizeof (pb_measurement));
+ memset (pb_header, 0xDB, sizeof (pb_header));
+
+ const size_t msg_size = msg_data_size
+ + sizeof (Sci_Msg_Header)
+ + sizeof (Phy_Header);
+ unsigned char *expected = new unsigned char [msg_size];
+ __build_phy_msg (
+ expected,
+ msg_size,
+ msg_data_size,
+ staid,
+ type,
+ mpdu_format,
+ pb_nb,
+ short_ppdu,
+ mod,
+ fecrate,
+ gil,
+ tx_id,
+ flags,
+ pb_measurement,
+ pb_header);
+
+ PhySciMsg msg (*((struct Sci_Msg_Header *)expected), expected);
+
+ CPPUNIT_ASSERT (msg.get_sci_alloc_size () == msg_size);
+ CPPUNIT_ASSERT (msg.get_sci_alloc_addr () == expected);
+ CPPUNIT_ASSERT (msg.get_sci_data_addr () == (expected + sizeof (Sci_Msg_Header)));
+ CPPUNIT_ASSERT (msg.get_sci_datalength () == (msg_size - sizeof (Sci_Msg_Header)));
+ CPPUNIT_ASSERT (msg.get_sci_stationid () == staid);
+
+ CPPUNIT_ASSERT (msg.get_phy_type () == type);
+ CPPUNIT_ASSERT (msg.get_phy_MpduFormat () == mpdu_format);
+ CPPUNIT_ASSERT (msg.get_phy_NbOfPbs () == pb_nb);
+ CPPUNIT_ASSERT (msg.get_phy_shortppdu () == short_ppdu);
+ CPPUNIT_ASSERT (msg.get_phy_mod () == mod);
+ CPPUNIT_ASSERT (msg.get_phy_FecRate () == fecrate);
+ CPPUNIT_ASSERT (msg.get_phy_gil () == gil);
+ CPPUNIT_ASSERT (msg.get_phy_TxId () == tx_id);
+ CPPUNIT_ASSERT (msg.get_phy_flags () == flags);
+
+ for (uint i = 0; i < MAC_MAX_PB_PER_MPDU; i++)
+ CPPUNIT_ASSERT (msg.get_phy_PbMeasurement ()[i] == pb_measurement[i]);
+
+ for (uint i = 0; i < MAC_MAX_PB_PER_MPDU; i++)
+ CPPUNIT_ASSERT (msg.get_phy_PbHeaders ()[i] == pb_header[i]);
+}
diff --git a/cesar/maximus/sci/utest/scimsg/src/TestSystem.cpp b/cesar/maximus/sci/utest/scimsg/src/TestSystem.cpp
new file mode 100644
index 0000000000..cf8b459c52
--- /dev/null
+++ b/cesar/maximus/sci/utest/scimsg/src/TestSystem.cpp
@@ -0,0 +1,161 @@
+/* Maximus project {{{
+ *
+ * Copyright (C) 2012 MStar Semiconductor
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file maximus/sci/utest/scimsg/src/TestSystem.cpp
+ * \ingroup maximus_sci_utest_scimsg
+ *
+ */
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include "inc/TestSystem.h"
+#include "maximus/sci/inc/SystemSciMsg.h"
+#include "maximus/sci/inc/SciServer.h"
+#include <sys/types.h>
+#include <string.h>
+#include <ostream>
+
+extern uint expected_msg_id;
+CPPUNIT_TEST_SUITE_REGISTRATION (TestSystem);
+
+void
+TestSystem::setUp ()
+{
+ fake_server = new SciServer (fake_sta_list);
+ fake_server->register_current_tick_addr (&time_base);
+ time_base = 0x1234567809123;
+}
+
+void
+TestSystem::tearDown ()
+{
+ delete fake_server;
+ fake_server = NULL;
+}
+
+inline void
+TestSystem::__build_system_msg (
+ unsigned char *expected,
+ size_t msg_size,
+ size_t data_size,
+ Sci_Msg_Station_Id test_staid,
+ System_Type test_type)
+{
+ /* Build the expected buffer in network format. */
+
+ /* 30 = sizeof (Sci_Msg_Header) + sizeof (System_Header). */
+ CPPUNIT_ASSERT (msg_size >= 30);
+
+ memset (expected, 0, msg_size);
+ size_t test_length = data_size + sizeof (System_Header);
+
+ /* SciMsg Header from here. */
+ expected[0] = 'M';
+ expected[1] = 'A';
+ expected[2] = 'X';
+ expected[3] = 'I';
+ expected[4] = SCI_MSG_VERSION;
+ expected[5] = SCI_MSG_TYPE_SYSTEM;
+ expected[6] = test_length >> 24;
+ expected[7] = test_length >> 16;
+ expected[8] = test_length >> 8;
+ expected[9] = test_length;
+ expected[10] = static_cast <uint16_t> (test_staid) >> 8;
+ expected[11] = static_cast <uint16_t> (test_staid);
+ expected[12] = expected_msg_id >> 8;
+ expected[13] = expected_msg_id;
+ expected[14] = time_base >> 56;
+ expected[15] = time_base >> 48;
+ expected[16] = time_base >> 40;
+ expected[17] = time_base >> 32;
+ expected[18] = time_base >> 24;
+ expected[19] = time_base >> 16;
+ expected[20] = time_base >> 8;
+ expected[21] = time_base;
+ /* system Header from here. */
+ expected[26] = SYSTEM_VERSION;
+ expected[27] = static_cast <uint8_t> (test_type);
+}
+
+void
+TestSystem::test_encode ()
+{
+ std::cout << "TestSystem_encode" << std::endl;
+ const unsigned char *serial_msg;
+ const size_t msg_data_size = 0;
+
+ Sci_Msg_Station_Id staid = 30;
+ System_Type type = SYSTEM_TYPE_STATION_NAME;
+
+ const size_t msg_size = msg_data_size
+ + sizeof (Sci_Msg_Header)
+ + sizeof (System_Header);
+ unsigned char *expected = new unsigned char [msg_size];
+ ++expected_msg_id;
+ __build_system_msg (
+ expected,
+ msg_size,
+ msg_data_size,
+ staid,
+ type);
+
+ SystemSciMsg msg (msg_data_size);
+ msg.set_sci_stationid (staid);
+ msg.set_system_type (type);
+
+ msg.setup_and_send (*fake_server);
+ serial_msg = msg.get_sci_alloc_addr ();
+ CPPUNIT_ASSERT (serial_msg);
+ CPPUNIT_ASSERT (msg.get_sci_alloc_size ()
+ != (msg_data_size + sizeof (System_Header)));
+
+ for (uint i = 0; i < msg_size; i++)
+ {
+ if (expected[i] != serial_msg[i])
+ {
+ std::ostringstream oss;
+ oss << "expected[" << i << "] = "
+ << (uint) expected[i]
+ << " != "
+ << (uint) serial_msg[i]
+ << " = serial_msg[" << i << "]";
+ CPPUNIT_FAIL (oss.str ().c_str ());
+ }
+ }
+ delete [] expected;
+}
+
+void
+TestSystem::test_decode ()
+{
+ std::cout << "TestSystem_decode" << std::endl;
+ const size_t msg_data_size = 15;
+
+ Sci_Msg_Station_Id staid = 42;
+ System_Type type = SYSTEM_TYPE_IDLE;
+
+ const size_t msg_size = msg_data_size
+ + sizeof (Sci_Msg_Header)
+ + sizeof (System_Header);
+ unsigned char *expected = new unsigned char [msg_size];
+ __build_system_msg (
+ expected,
+ msg_size,
+ msg_data_size,
+ staid,
+ type);
+
+ SystemSciMsg msg (*((struct Sci_Msg_Header *)expected), expected);
+
+ CPPUNIT_ASSERT (msg.get_sci_alloc_size () == msg_size);
+ CPPUNIT_ASSERT (msg.get_sci_alloc_addr () == expected);
+ CPPUNIT_ASSERT (msg.get_sci_data_addr () == (expected + sizeof (Sci_Msg_Header)));
+ CPPUNIT_ASSERT (msg.get_sci_datalength () == (msg_size - sizeof (Sci_Msg_Header)));
+ CPPUNIT_ASSERT (msg.get_sci_stationid () == staid);
+
+ CPPUNIT_ASSERT (msg.get_system_type () == type);
+}
diff --git a/cesar/maximus/sci/utest/scimsg/src/fake_SciServer.cpp b/cesar/maximus/sci/utest/scimsg/src/fake_SciServer.cpp
new file mode 100644
index 0000000000..35938403af
--- /dev/null
+++ b/cesar/maximus/sci/utest/scimsg/src/fake_SciServer.cpp
@@ -0,0 +1,72 @@
+/* Maximus project {{{
+ *
+ * Copyright (C) 2012 MStar Semiconductor
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file maximus/sci/utest/scimsg/src/fake_sciserver.cpp
+ * \ingroup maximus_sci_utest_scimsg
+ *
+ */
+#include "maximus/sci/inc/SciServer.h"
+#include "maximus/utils/inc/Error.h"
+
+SciServer::SciServer (stations_list_t &ref1):
+ sta_list (ref1)
+{
+}
+
+SciServer::~SciServer ()
+{
+}
+
+void
+SciServer::process () const
+{
+}
+
+void
+SciServer::log () const
+{
+}
+
+void
+SciServer::send_SciMsg_to_Station (
+ const SciMsg &sci_msg,
+ Station &dsta) const
+{
+}
+
+void
+SciServer::sendSciMsg (
+ const SciMsg &sci_msg_to_send,
+ const Sci_Msg_Station_Id station_id) const
+{
+}
+
+bool
+SciServer::sendSciMsgToAllActiveStations (
+ SciMsg &sci_msg_to_send) const
+{
+ return false;
+}
+
+void
+SciServer::register_processor (
+ const Sci_Msg_Type sci_msg_type,
+ Processor *client)
+{
+}
+
+void
+SciServer::unregister_processor (
+ const Sci_Msg_Type sci_msg_type)
+{
+}
+
+void
+SciServer::check_if_server_ready ()
+{
+}