A Discrete-Event Network Simulator
API
Ns2MobilityHelperTest Class Reference

Every test case is supposed to: More...

+ Inheritance diagram for Ns2MobilityHelperTest:
+ Collaboration diagram for Ns2MobilityHelperTest:

Classes

struct  ReferencePoint
 Single record in mobility reference. More...
 

Public Member Functions

 Ns2MobilityHelperTest (const std::string &name, Time timeLimit, uint32_t nodes=1)
 Create new test case. More...
 
 ~Ns2MobilityHelperTest () override
 Empty. More...
 
void AddReferencePoint (const char *id, double sec, const Vector &p, const Vector &v)
 Add next reference point. More...
 
void AddReferencePoint (const ReferencePoint &r)
 Add next reference point. More...
 
void SetTrace (const std::string &trace)
 Set NS-2 trace to read as single large string (don't forget to add \n and quote "'s) More...
 
- Public Member Functions inherited from ns3::TestCase
 TestCase (const TestCase &)=delete
 
virtual ~TestCase ()
 Destructor. More...
 
std::string GetName () const
 
TestCaseoperator= (const TestCase &)=delete
 

Private Member Functions

bool CheckInitialPositions ()
 Check that all initial positions are correct. More...
 
void CourseChange (std::string context, Ptr< const MobilityModel > mobility)
 Listen for course change events. More...
 
void CreateNodes () const
 Create and name nodes. More...
 
void DoRun () override
 Go. More...
 
void DoSetup () override
 Implementation to do any local setup required for this TestCase. More...
 
void DoTeardown () override
 Implementation to do any local setup required for this TestCase. More...
 
bool WriteTrace ()
 Dump NS-2 trace to tmp file. More...
 

Private Attributes

size_t m_nextRefPoint
 Next reference point to be checked. More...
 
uint32_t m_nodeCount
 Number of nodes used in the test. More...
 
std::vector< ReferencePointm_reference
 Reference mobility. More...
 
Time m_timeLimit
 Test time limit. More...
 
std::string m_trace
 Trace as string. More...
 
std::string m_traceFile
 TMP trace file name. More...
 

Additional Inherited Members

- Public Types inherited from ns3::TestCase
enum  TestDuration { QUICK = 1 , EXTENSIVE = 2 , TAKES_FOREVER = 3 }
 How long the test takes to execute. More...
 
- Protected Member Functions inherited from ns3::TestCase
 TestCase (std::string name)
 Constructor. More...
 
void AddTestCase (TestCase *testCase, TestDuration duration=QUICK)
 Add an individual child TestCase to this test suite. More...
 
TestCaseGetParent () const
 Get the parent of this TestCase. More...
 
bool IsStatusFailure () const
 Check if any tests failed. More...
 
bool IsStatusSuccess () const
 Check if all tests passed. More...
 
void SetDataDir (std::string directory)
 Set the data directory where reference trace files can be found. More...
 
void ReportTestFailure (std::string cond, std::string actual, std::string limit, std::string message, std::string file, int32_t line)
 Log the failure of this TestCase. More...
 
bool MustAssertOnFailure () const
 Check if this run should assert on failure. More...
 
bool MustContinueOnFailure () const
 Check if this run should continue on failure. More...
 
std::string CreateDataDirFilename (std::string filename)
 Construct the full path to a file in the data directory. More...
 
std::string CreateTempDirFilename (std::string filename)
 Construct the full path to a file in a temporary directory. More...
 

Detailed Description

Every test case is supposed to:

  1. Generate short mobility trace file
  2. Read it back using Ns2MobilityHelper
  3. Check initial node positions and speeds.
  4. Run simulation listening for all CourseChange events and compare actual mobility with the reference

Definition at line 87 of file ns2-mobility-helper-test-suite.cc.

Constructor & Destructor Documentation

◆ Ns2MobilityHelperTest()

Ns2MobilityHelperTest::Ns2MobilityHelperTest ( const std::string &  name,
Time  timeLimit,
uint32_t  nodes = 1 
)
inline

Create new test case.

To make it useful SetTrace () and AddReferencePoint () must be called

Parameters
nameShort description
timeLimitTest time limit
nodesNumber of nodes used in the test trace, 1 by default

Definition at line 132 of file ns2-mobility-helper-test-suite.cc.

◆ ~Ns2MobilityHelperTest()

Ns2MobilityHelperTest::~Ns2MobilityHelperTest ( )
inlineoverride

Empty.

Definition at line 141 of file ns2-mobility-helper-test-suite.cc.

Member Function Documentation

◆ AddReferencePoint() [1/2]

void Ns2MobilityHelperTest::AddReferencePoint ( const char *  id,
double  sec,
const Vector &  p,
const Vector &  v 
)
inline

Add next reference point.

Parameters
idreference point id
secreference point ime (in seconds)
preference point position
vreference point velocity

Definition at line 170 of file ns2-mobility-helper-test-suite.cc.

References ns3::Seconds().

+ Here is the call graph for this function:

◆ AddReferencePoint() [2/2]

void Ns2MobilityHelperTest::AddReferencePoint ( const ReferencePoint r)
inline

Add next reference point.

Parameters
rreference point to add

Definition at line 158 of file ns2-mobility-helper-test-suite.cc.

Referenced by Ns2MobilityHelperTestSuite::Ns2MobilityHelperTestSuite().

+ Here is the caller graph for this function:

◆ CheckInitialPositions()

bool Ns2MobilityHelperTest::CheckInitialPositions ( )
inlineprivate

◆ CourseChange()

void Ns2MobilityHelperTest::CourseChange ( std::string  context,
Ptr< const MobilityModel mobility 
)
inlineprivate

Listen for course change events.

Parameters
contextevent context
mobilitya pointer to the mobility model

Definition at line 255 of file ns2-mobility-helper-test-suite.cc.

References AreVectorsEqual(), ns3::Names::FindName(), ns3::Time::GetSeconds(), third::mobility, Ns2MobilityHelperTest::ReferencePoint::node, ns3::Simulator::Now(), NS_ASSERT, NS_TEST_EXPECT_MSG_EQ, NS_TEST_EXPECT_MSG_LT, Ns2MobilityHelperTest::ReferencePoint::pos, Ns2MobilityHelperTest::ReferencePoint::time, and Ns2MobilityHelperTest::ReferencePoint::vel.

Referenced by DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateNodes()

void Ns2MobilityHelperTest::CreateNodes ( ) const
inlineprivate

Create and name nodes.

Definition at line 205 of file ns2-mobility-helper-test-suite.cc.

References ns3::Names::Add(), ns3::NodeContainer::Create(), ns3::NodeContainer::Get(), and nodes.

+ Here is the call graph for this function:

◆ DoRun()

void Ns2MobilityHelperTest::DoRun ( void  )
inlineoverrideprivatevirtual

◆ DoSetup()

void Ns2MobilityHelperTest::DoSetup ( )
inlineoverrideprivatevirtual

Implementation to do any local setup required for this TestCase.

Subclasses should override this method to perform any costly per-test setup before DoRun is invoked.

Reimplemented from ns3::TestCase.

Definition at line 288 of file ns2-mobility-helper-test-suite.cc.

◆ DoTeardown()

void Ns2MobilityHelperTest::DoTeardown ( )
inlineoverrideprivatevirtual

Implementation to do any local setup required for this TestCase.

Subclasses should override this method to perform any costly per-test teardown

Reimplemented from ns3::TestCase.

Definition at line 293 of file ns2-mobility-helper-test-suite.cc.

References ns3::Names::Clear(), and ns3::Simulator::Destroy().

+ Here is the call graph for this function:

◆ SetTrace()

void Ns2MobilityHelperTest::SetTrace ( const std::string &  trace)
inline

Set NS-2 trace to read as single large string (don't forget to add \n and quote "'s)

Parameters
tracethe mobility trace

Definition at line 149 of file ns2-mobility-helper-test-suite.cc.

Referenced by Ns2MobilityHelperTestSuite::Ns2MobilityHelperTestSuite().

+ Here is the caller graph for this function:

◆ WriteTrace()

bool Ns2MobilityHelperTest::WriteTrace ( )
inlineprivate

Dump NS-2 trace to tmp file.

Returns
true on error.

Definition at line 194 of file ns2-mobility-helper-test-suite.cc.

References NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL.

Member Data Documentation

◆ m_nextRefPoint

size_t Ns2MobilityHelperTest::m_nextRefPoint
private

Next reference point to be checked.

Definition at line 185 of file ns2-mobility-helper-test-suite.cc.

◆ m_nodeCount

uint32_t Ns2MobilityHelperTest::m_nodeCount
private

Number of nodes used in the test.

Definition at line 179 of file ns2-mobility-helper-test-suite.cc.

◆ m_reference

std::vector<ReferencePoint> Ns2MobilityHelperTest::m_reference
private

Reference mobility.

Definition at line 183 of file ns2-mobility-helper-test-suite.cc.

◆ m_timeLimit

Time Ns2MobilityHelperTest::m_timeLimit
private

Test time limit.

Definition at line 177 of file ns2-mobility-helper-test-suite.cc.

◆ m_trace

std::string Ns2MobilityHelperTest::m_trace
private

Trace as string.

Definition at line 181 of file ns2-mobility-helper-test-suite.cc.

◆ m_traceFile

std::string Ns2MobilityHelperTest::m_traceFile
private

TMP trace file name.

Definition at line 187 of file ns2-mobility-helper-test-suite.cc.


The documentation for this class was generated from the following file: