Every test case is supposed to: More...
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. | |
~Ns2MobilityHelperTest () override | |
Empty. | |
void | AddReferencePoint (const char *id, double sec, const Vector &p, const Vector &v) |
Add next reference point. | |
void | AddReferencePoint (const ReferencePoint &r) |
Add next reference point. | |
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) | |
Public Member Functions inherited from ns3::TestCase | |
TestCase (const TestCase &)=delete | |
virtual | ~TestCase () |
Destructor. | |
std::string | GetName () const |
TestCase & | operator= (const TestCase &)=delete |
Private Member Functions | |
bool | CheckInitialPositions () |
Check that all initial positions are correct. | |
void | CourseChange (std::string context, Ptr< const MobilityModel > mobility) |
Listen for course change events. | |
void | CreateNodes () const |
Create and name nodes. | |
void | DoRun () override |
Go. | |
void | DoSetup () override |
Implementation to do any local setup required for this TestCase. | |
void | DoTeardown () override |
Implementation to do any local setup required for this TestCase. | |
bool | WriteTrace () |
Dump NS-2 trace to tmp file. | |
Private Attributes | |
size_t | m_nextRefPoint |
Next reference point to be checked. | |
uint32_t | m_nodeCount |
Number of nodes used in the test. | |
std::vector< ReferencePoint > | m_reference |
Reference mobility. | |
Time | m_timeLimit |
Test time limit. | |
std::string | m_trace |
Trace as string. | |
std::string | m_traceFile |
TMP trace file name. | |
Additional Inherited Members | |
Public Types inherited from ns3::TestCase | |
enum class | Duration { QUICK = 1 , EXTENSIVE = 2 , TAKES_FOREVER = 3 } |
How long the test takes to execute. More... | |
Static Public Attributes inherited from ns3::TestCase | |
static constexpr auto | QUICK = Duration::QUICK |
Deprecated test duration simple enums. | |
static constexpr auto | EXTENSIVE = Duration::EXTENSIVE |
static constexpr auto | TAKES_FOREVER = Duration::TAKES_FOREVER |
Protected Member Functions inherited from ns3::TestCase | |
TestCase (std::string name) | |
Constructor. | |
void | AddTestCase (TestCase *testCase, Duration duration=Duration::QUICK) |
Add an individual child TestCase to this test suite. | |
TestCase * | GetParent () const |
Get the parent of this TestCase. | |
bool | IsStatusFailure () const |
Check if any tests failed. | |
bool | IsStatusSuccess () const |
Check if all tests passed. | |
void | SetDataDir (std::string directory) |
Set the data directory where reference trace files can be found. | |
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. | |
bool | MustAssertOnFailure () const |
Check if this run should assert on failure. | |
bool | MustContinueOnFailure () const |
Check if this run should continue on failure. | |
std::string | CreateDataDirFilename (std::string filename) |
Construct the full path to a file in the data directory. | |
std::string | CreateTempDirFilename (std::string filename) |
Construct the full path to a file in a temporary directory. | |
Every test case is supposed to:
Definition at line 76 of file ns2-mobility-helper-test-suite.cc.
|
inline |
Create new test case.
To make it useful SetTrace () and AddReferencePoint () must be called
name | Short description |
timeLimit | Test time limit |
nodes | Number of nodes used in the test trace, 1 by default |
Definition at line 121 of file ns2-mobility-helper-test-suite.cc.
|
inlineoverride |
Empty.
Definition at line 130 of file ns2-mobility-helper-test-suite.cc.
|
inline |
Add next reference point.
id | reference point id |
sec | reference point ime (in seconds) |
p | reference point position |
v | reference point velocity |
Definition at line 159 of file ns2-mobility-helper-test-suite.cc.
References AddReferencePoint(), and ns3::Seconds().
|
inline |
Add next reference point.
r | reference point to add |
Definition at line 147 of file ns2-mobility-helper-test-suite.cc.
References m_reference.
Referenced by Ns2MobilityHelperTestSuite::Ns2MobilityHelperTestSuite(), and AddReferencePoint().
|
inlineprivate |
Check that all initial positions are correct.
Definition at line 210 of file ns2-mobility-helper-test-suite.cc.
References AreVectorsEqual(), ns3::Names::Find(), ns3::TestCase::IsStatusFailure(), m_nextRefPoint, m_reference, Ns2MobilityHelperTest::ReferencePoint::node, NS_TEST_ASSERT_MSG_NE_RETURNS_BOOL, NS_TEST_EXPECT_MSG_EQ, Ns2MobilityHelperTest::ReferencePoint::pos, ns3::Seconds(), and Ns2MobilityHelperTest::ReferencePoint::vel.
Referenced by DoRun().
|
inlineprivate |
Listen for course change events.
context | event context |
mobility | a pointer to the mobility model |
Definition at line 244 of file ns2-mobility-helper-test-suite.cc.
References AreVectorsEqual(), ns3::Names::FindName(), ns3::Time::GetSeconds(), m_nextRefPoint, m_reference, 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().
|
inlineprivate |
Create and name nodes.
Definition at line 194 of file ns2-mobility-helper-test-suite.cc.
References ns3::Names::Add(), ns3::NodeContainer::Create(), ns3::NodeContainer::Get(), m_nodeCount, and nodes.
Referenced by DoSetup().
|
inlineoverrideprivatevirtual |
Go.
Implements ns3::TestCase.
Definition at line 289 of file ns2-mobility-helper-test-suite.cc.
References CheckInitialPositions(), ns3::Config::Connect(), CourseChange(), m_reference, m_timeLimit, m_trace, m_traceFile, ns3::MakeCallback(), NS_TEST_ASSERT_MSG_EQ, ns3::Simulator::Run(), ns3::Simulator::Stop(), and WriteTrace().
|
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 277 of file ns2-mobility-helper-test-suite.cc.
References CreateNodes().
|
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 282 of file ns2-mobility-helper-test-suite.cc.
References ns3::Names::Clear(), and ns3::Simulator::Destroy().
|
inline |
Set NS-2 trace to read as single large string (don't forget to add \n and quote "'s)
trace | the mobility trace |
Definition at line 138 of file ns2-mobility-helper-test-suite.cc.
References m_trace.
Referenced by Ns2MobilityHelperTestSuite::Ns2MobilityHelperTestSuite().
|
inlineprivate |
Dump NS-2 trace to tmp file.
Definition at line 183 of file ns2-mobility-helper-test-suite.cc.
References ns3::TestCase::CreateTempDirFilename(), m_trace, m_traceFile, and NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL.
Referenced by DoRun().
|
private |
Next reference point to be checked.
Definition at line 174 of file ns2-mobility-helper-test-suite.cc.
Referenced by CheckInitialPositions(), and CourseChange().
|
private |
Number of nodes used in the test.
Definition at line 168 of file ns2-mobility-helper-test-suite.cc.
Referenced by CreateNodes().
|
private |
Reference mobility.
Definition at line 172 of file ns2-mobility-helper-test-suite.cc.
Referenced by AddReferencePoint(), CheckInitialPositions(), CourseChange(), and DoRun().
|
private |
Test time limit.
Definition at line 166 of file ns2-mobility-helper-test-suite.cc.
Referenced by DoRun().
|
private |
Trace as string.
Definition at line 170 of file ns2-mobility-helper-test-suite.cc.
Referenced by DoRun(), SetTrace(), and WriteTrace().
|
private |
TMP trace file name.
Definition at line 176 of file ns2-mobility-helper-test-suite.cc.
Referenced by DoRun(), and WriteTrace().