summaryrefslogtreecommitdiff
path: root/cesar/maximus/coreengine/src/MaximusTest.cpp
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/coreengine/src/MaximusTest.cpp
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/coreengine/src/MaximusTest.cpp')
-rw-r--r--cesar/maximus/coreengine/src/MaximusTest.cpp505
1 files changed, 0 insertions, 505 deletions
diff --git a/cesar/maximus/coreengine/src/MaximusTest.cpp b/cesar/maximus/coreengine/src/MaximusTest.cpp
deleted file mode 100644
index 449c4a6d61..0000000000
--- a/cesar/maximus/coreengine/src/MaximusTest.cpp
+++ /dev/null
@@ -1,505 +0,0 @@
-
-#include "MaximusTest.h"
-
-#include "Maximus.h"
-#include "Msg.h"
-#include "Sta.h"
-#include "PhySciMsgPre.h"
-#include "PhySciMsgFc.h"
-#include "PhySciMsgMpdu.h"
-#include "EtherSciMsg.h"
-#include "Station.h"
-#include "ISystem.h"
-#include "CoreEngine.h"
-
-#include "Logger.h"
-
-#include "functioncall_types.h" // for 'PROBE_ID'
-
-#include <iostream>
-using namespace std;
-
-CPPUNIT_TEST_SUITE_REGISTRATION (MaximusTest);
-
-void phyCb (PhySciMsg & phy_sci_msg)
-{
-
-}
-
-void etherCb (EtherSciMsg & ether_sci_msg)
-{
-
-}
-
-
-void MaximusTest::setUp (void)
-{
- logTest();
-
- mpCoreEngine = new CoreEngine ();
- mpMaximus = new Maximus (mpCoreEngine);
-}
-
-
-void MaximusTest::tearDown (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- delete (mpMaximus);
- mpMaximus = NULL;
- }
-}
-
-
-void MaximusTest::init_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- //mpMaximus->init(argc, argv);
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::init_phy_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- mpMaximus->init_phy(&phyCb);
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::init_ether_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- CPPUNIT_ASSERT_MESSAGE ( "init_ether failed",
- -1 == mpMaximus->init_ether(&etherCb) );
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::process_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- mpMaximus->process();
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::create_sta_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- Sta sta = mpMaximus->create_sta();
-
- CPPUNIT_ASSERT_MESSAGE ( "create_sta failed",
- 0 != sta.getStationId() );
-
- sta.remove();
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::create_fc_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- Msg msg = mpMaximus->create_fc("function");
-
- CPPUNIT_ASSERT_MESSAGE ( "create_fc failed",
- 0 != msg.get_tx_msg_id() );
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::create_probe_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- Msg msg = mpMaximus->create_probe();
-
- CPPUNIT_ASSERT_MESSAGE ( "create_probe failed",
- 0 != msg.get_tx_msg_id() );
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::create_mpdu_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- PhySciMsgMpdu * pMpdu = mpMaximus->create_mpdu();
-
- CPPUNIT_ASSERT_MESSAGE ( "create_mpdu failed",
- NULL != pMpdu );
-
- delete (pMpdu);
- pMpdu = NULL;
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::send_mpdu_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- // create MPDU
- PhySciMsgMpdu * pMpdu = mpMaximus->create_mpdu();
- CPPUNIT_ASSERT_MESSAGE ( "PHY SCI message MPDU pointer is NULL", NULL != pMpdu );
-
- /* Configure MPDU. */
- unsigned long length = 5;
- unsigned char payload[length];
- memset(payload, 'P', length);
-
- pMpdu->setMpdu(length, payload);
-
- // create the transmitting station
- Sta staTx = mpMaximus->create_sta();
-
- // create the destination station
- Sta staRx = mpMaximus->create_sta();
-
- // set the destination station
- pMpdu->setSciMsgStationId(staRx.getStationId());
-
- // set FC
- uint32_t fc_av[4];
- memset(fc_av, 'A', 4*sizeof(uint32_t));
- uint32_t fc_10 = 10;
- pMpdu->setFc10(fc_10);
- pMpdu->setFcAv(fc_av);
-
- // set FC mode
- pMpdu->setFcMode(PHY_FC_MODE_HYBRID_1);
-
- // set short PPDU
- pMpdu->setShortPpdu(1);
-
- mpMaximus->send_mpdu(pMpdu);
-
- while (!pMpdu->isSent() && !pMpdu->getFc()->isSent())
- {
- mpMaximus->process();
- }
-
- if (NULL != pMpdu)
- {
- delete (pMpdu);
- pMpdu = NULL;
- }
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::create_ether_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- EtherSciMsg * pEther = mpMaximus->create_ether();
-
- CPPUNIT_ASSERT_MESSAGE ( "create_ether failed", NULL != pEther );
-
- delete (pEther);
- pEther = NULL;
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::send_ether_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- // create Ether SCI message
- EtherSciMsg * pEtherSciMsg = mpMaximus->create_ether();
-
- // create the destination station
- Sta staRx = mpMaximus->create_sta();
- mpMaximus->wait(5);
-
- /* Configure Ether SCI message. */
- pEtherSciMsg->setSpecializedSciMsgType(ETHERNET_TYPE_DATA);
- unsigned long length = 5;
- unsigned char payload[length];
- memset(payload, 'E', length);
- pEtherSciMsg->setSpecializedSciMsgDataLength(length);
- pEtherSciMsg->setSpecializedSciMsgData(payload);
- pEtherSciMsg->setSciMsgStationId(staRx.getStationId());
-
- // send Ether SCI message
- mpMaximus->send_ether(*pEtherSciMsg);
-
- // remove the destination station
- staRx.remove();
-
- if (NULL != pEtherSciMsg)
- {
- delete (pEtherSciMsg);
- pEtherSciMsg = NULL;
- }
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::wait_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- Sta sta = mpMaximus->create_sta();
- mpMaximus->wait(10);
- mpMaximus->wait();
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::disturb_channel_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- //mpMaximus->disturb_channel();
- //mpMaximus->disturb_channel(false);
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::get_date_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- tick_t date = mpMaximus->get_date();
- tick_t offset = 100;
- Sta sta = mpMaximus->create_sta();
- mpMaximus->wait(offset);
- CPPUNIT_ASSERT_MESSAGE ( "get_date failed", date + offset == mpMaximus->get_date() );
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::set_freq_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- Sta sta = mpMaximus->create_sta();
-
- float freq = 0;
- mpMaximus->set_freq(freq);
- CPPUNIT_ASSERT_MESSAGE ( "set_freq failed", freq == mpMaximus->get_freq() );
- mpMaximus->wait(100000);
-
- sta.remove();
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::activate_false_alarm_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- Sta sta = mpMaximus->create_sta();
-
- Network_Clock_Tick averageDuration = 10;
- float stdDeviation = 0.1;
- mpMaximus->activate_false_alarm(averageDuration, stdDeviation);
- mpMaximus->wait(2*averageDuration);
-
- sta.remove();
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::deactivate_false_alarm_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- Sta sta = mpMaximus->create_sta();
-
- mpMaximus->deactivate_false_alarm();
- mpMaximus->wait(1000);
-
- sta.remove();
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::is_station_idle_test (void)
-{
- logTest();
-
- if (NULL != mpMaximus)
- {
- Sta sta = mpMaximus->create_sta();
-
- CPPUNIT_ASSERT_MESSAGE ( "is_station_idle failed", !mpMaximus->is_station_idle(sta.getStationId()) );
- mpMaximus->wait(1);
- CPPUNIT_ASSERT_MESSAGE ( "is_station_idle failed", mpMaximus->is_station_idle(sta.getStationId()) );
-
- sta.remove();
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-
-
-void MaximusTest::hide_sta_test (void)
-{
- logTest ();
-
- if (NULL != mpMaximus)
- {
- Sta sta1 = mpMaximus->create_sta ();
- Sta sta2 = mpMaximus->create_sta ();
-
- mpMaximus->hide_sta (sta1, sta2, true);
-
- /* retrieve stations 1 and 2 */
- Station *pStation1 = NULL, *pStation2 = NULL;
- for (StationsList::const_iterator it = mpCoreEngine->getSystem ()->getListOfStations ()->begin ();
- it != mpCoreEngine->getSystem ()->getListOfStations ()->end (); ++it)
- {
- if (NULL != *it)
- {
- Sci_Msg_Station_Id id = (*it)->getStationId ();
- if (sta1.getStationId () == id)
- pStation1 = *it;
- else if (sta2.getStationId () == id)
- pStation2 = *it;
- }
- }
- CPPUNIT_ASSERT_MESSAGE ("Cannot retrieve stations",
- (pStation1 != NULL)
- && (pStation2 != NULL));
-
- set<Sci_Msg_Station_Id>::iterator it1, it2;
- /* check that station 2 is hidden from station 1 */
- it2 = pStation1->getHiddenStationsList ().find (sta2.getStationId ());
- CPPUNIT_ASSERT_MESSAGE ("hide_sta 2 from 1 failed", *it2 == sta2.getStationId ());
- /* check that station 1 is hidden from station 2 */
- it1 = pStation2->getHiddenStationsList ().find (sta1.getStationId ());
- CPPUNIT_ASSERT_MESSAGE ("hide_sta 1 from 2 failed", *it1 == sta1.getStationId ());
-
- mpMaximus->hide_sta (sta1, sta2, false);
- /* check that stations are visible from each other */
- it2 = pStation1->getHiddenStationsList ().find (sta2.getStationId ());
- CPPUNIT_ASSERT_MESSAGE ("hide_sta FALSE failed", it2 == pStation1->getHiddenStationsList ().end ());
- /* check that station 1 is hidden from station 2 */
- it1 = pStation2->getHiddenStationsList ().find (sta1.getStationId ());
- CPPUNIT_ASSERT_MESSAGE ("hide_sta FALSE failed", it1 == pStation2->getHiddenStationsList ().end ());
-
- /* clean */
- sta1.remove ();
- sta2.remove ();
- }
- else
- {
- CPPUNIT_FAIL ("Maximus pointer is NULL");
- }
-}
-