A Discrete-Event Network Simulator
API
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ns3::TestRunnerImpl Class Reference

Container for all tests. More...

+ Inheritance diagram for ns3::TestRunnerImpl:

Public Member Functions

 TestRunnerImpl ()
 Constructor. More...
 
void AddTestSuite (TestSuite *testSuite)
 Add a new top-level TestSuite. More...
 
std::string GetTempDir (void) const
 Get the path to temporary directory. More...
 
std::string GetTopLevelSourceDir (void) const
 Get the path to the root of the source tree. More...
 
bool MustAssertOnFailure (void) const
 Check if this run should assert on failure.
More...
 
bool MustContinueOnFailure (void) const
 Check if this run should continue on failure.
More...
 
bool MustUpdateData (void) const
 Check if this run should update the reference data. More...
 
int Run (int argc, char *argv[])
 Run the requested suite of tests, according to the given command line arguments.
More...
 

Private Types

typedef std::vector< TestSuite * > TestSuiteVector
 Container type for the test. More...
 

Private Member Functions

std::list< TestCase * > FilterTests (std::string testName, enum TestSuite::Type testType, enum TestCase::TestDuration maximumTestDuration)
 Generate the list of tests matching the constraints. More...
 
bool IsTopLevelSourceDir (std::string path) const
 Check if this is the root of the source tree. More...
 
void PrintHelp (const char *programName) const
 Print the help text. More...
 
void PrintReport (TestCase *test, std::ostream *os, bool xml, int level)
 Print the test report. More...
 
void PrintTestNameList (std::list< TestCase *>::const_iterator begin, std::list< TestCase *>::const_iterator end, bool printTestType) const
 Print the list of all requested test suites. More...
 
void PrintTestTypeList (void) const
 Print the list of test types. More...
 
std::string ReplaceXmlSpecialCharacters (std::string xml) const
 Clean up characters not allowed in XML. More...
 

Private Attributes

bool m_assertOnFailure
 true if we should assert on failure. More...
 
bool m_continueOnFailure
 true if we should continue on failure. More...
 
TestSuiteVector m_suites
 The list of tests. More...
 
std::string m_tempDir
 The temporary directory. More...
 
bool m_updateData
 true if we should update reference data. More...
 
bool m_verbose
 Produce verbose output. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ns3::Singleton< TestRunnerImpl >
static TestRunnerImplGet (void)
 Get a pointer to the singleton instance. More...
 

Detailed Description

Container for all tests.

Todo:
Move TestRunnerImpl to separate file.

Definition at line 138 of file test.cc.

Member Typedef Documentation

◆ TestSuiteVector

typedef std::vector<TestSuite *> ns3::TestRunnerImpl::TestSuiteVector
private

Container type for the test.

Definition at line 246 of file test.cc.

Constructor & Destructor Documentation

◆ TestRunnerImpl()

ns3::TestRunnerImpl::TestRunnerImpl ( )

Constructor.

Definition at line 504 of file test.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ AddTestSuite()

void ns3::TestRunnerImpl::AddTestSuite ( TestSuite testSuite)

Add a new top-level TestSuite.

Parameters
[in]testSuiteThe new TestSuite.

Definition at line 514 of file test.cc.

References m_suites, and NS_LOG_FUNCTION.

Referenced by ns3::TestSuite::TestSuite().

◆ FilterTests()

std::list< TestCase * > ns3::TestRunnerImpl::FilterTests ( std::string  testName,
enum TestSuite::Type  testType,
enum TestCase::TestDuration  maximumTestDuration 
)
private

Generate the list of tests matching the constraints.

Test name and type constraints are or'ed. The duration constraint is and'ed.

Parameters
[in]testNameInclude a specific test by name.
[in]testTypeInclude all tests of give type.
[in]maximumTestDurationRestrict to tests shorter than this.
Returns
The list of tests matching the filter constraints.

Definition at line 812 of file test.cc.

References m_suites, and NS_LOG_FUNCTION.

Referenced by Run().

◆ GetTempDir()

std::string ns3::TestRunnerImpl::GetTempDir ( void  ) const

Get the path to temporary directory.

Returns
The temporary directory path.

Definition at line 541 of file test.cc.

References m_tempDir, and NS_LOG_FUNCTION.

Referenced by ns3::TestCase::CreateTempDirFilename().

◆ GetTopLevelSourceDir()

std::string ns3::TestRunnerImpl::GetTopLevelSourceDir ( void  ) const

Get the path to the root of the source tree.

The root directory is defined by the presence of two files: "VERSION" and "LICENSE".

Returns
The path to the root.

Definition at line 575 of file test.cc.

References ns3::SystemPath::FindSelfDirectory(), IsTopLevelSourceDir(), ns3::SystemPath::Join(), NS_FATAL_ERROR, NS_LOG_FUNCTION, and ns3::SystemPath::Split().

Referenced by ns3::TestCase::CreateDataDirFilename().

◆ IsTopLevelSourceDir()

bool ns3::TestRunnerImpl::IsTopLevelSourceDir ( std::string  path) const
private

Check if this is the root of the source tree.

Parameters
[in]pathThe path to test.
Returns
true if path is the root.

Definition at line 547 of file test.cc.

References NS_LOG_FUNCTION, and ns3::SystemPath::ReadFiles().

Referenced by GetTopLevelSourceDir().

◆ MustAssertOnFailure()

bool ns3::TestRunnerImpl::MustAssertOnFailure ( void  ) const

Check if this run should assert on failure.

Returns
true if we should assert on failure.

Definition at line 522 of file test.cc.

References m_assertOnFailure, and NS_LOG_FUNCTION.

Referenced by ns3::TestCase::MustAssertOnFailure().

◆ MustContinueOnFailure()

bool ns3::TestRunnerImpl::MustContinueOnFailure ( void  ) const

Check if this run should continue on failure.

Returns
true if we should continue on failure.

Definition at line 528 of file test.cc.

References m_continueOnFailure, and NS_LOG_FUNCTION.

Referenced by ns3::TestCase::MustContinueOnFailure().

◆ MustUpdateData()

bool ns3::TestRunnerImpl::MustUpdateData ( void  ) const

Check if this run should update the reference data.

Returns
true if we should update the reference data.

Definition at line 535 of file test.cc.

References m_updateData, and NS_LOG_FUNCTION.

Referenced by ns3::TestCase::CreateTempDirFilename().

◆ PrintHelp()

void ns3::TestRunnerImpl::PrintHelp ( const char *  programName) const
private

Print the help text.

Parameters
[in]programNameThe name of the invoking program.

Definition at line 735 of file test.cc.

References NS_LOG_FUNCTION.

Referenced by Run().

◆ PrintReport()

void ns3::TestRunnerImpl::PrintReport ( TestCase test,
std::ostream *  os,
bool  xml,
int  level 
)
private

Print the test report.

Parameters
[in]testThe TestCase to print.
[in,out]osThe output stream.
[in]xmlGenerate XML output if true.
[in]levelIndentation level.

Definition at line 662 of file test.cc.

◆ PrintTestNameList()

void ns3::TestRunnerImpl::PrintTestNameList ( std::list< TestCase *>::const_iterator  begin,
std::list< TestCase *>::const_iterator  end,
bool  printTestType 
) const
private

Print the list of all requested test suites.

Parameters
[in]beginIterator to the first TestCase to print.
[in]endIterator to the end of the list.
[in]printTestTypePreprend the test type label if true.

Definition at line 772 of file test.cc.

References ns3::TestSuite::ALL, ns3::TestSuite::BVT, ns3::TestSuite::EXAMPLE, NS_LOG_FUNCTION, ns3::TestSuite::PERFORMANCE, ns3::TestSuite::SYSTEM, and ns3::TestSuite::UNIT.

Referenced by Run().

◆ PrintTestTypeList()

void ns3::TestRunnerImpl::PrintTestTypeList ( void  ) const
private

Print the list of test types.

Definition at line 799 of file test.cc.

References NS_LOG_FUNCTION.

Referenced by Run().

◆ ReplaceXmlSpecialCharacters()

std::string ns3::TestRunnerImpl::ReplaceXmlSpecialCharacters ( std::string  xml) const
private

Clean up characters not allowed in XML.

XML files have restrictions on certain characters that may be present in data. We need to replace these characters with their alternate representation on the way into the XML file.

Specifically, we make these replacements:

Raw Source Replacement
'<' "&lt;"
'>' "&gt;"
'&' "&amp;"
'"' "&39;"
'\' "&quot;"
Parameters
[in]xmlThe raw string.
Returns
The sanitized string.

Definition at line 598 of file test.cc.

References NS_LOG_FUNCTION.

◆ Run()

int ns3::TestRunnerImpl::Run ( int  argc,
char *  argv[] 
)

Run the requested suite of tests, according to the given command line arguments.

Parameters
[in]argcThe number of elements in argv
[in]argvThe vector of command line arguments
Returns
Success status

Definition at line 864 of file test.cc.

References ns3::TestSuite::ALL, ns3::TestSuite::BVT, ns3::TestSuite::EXAMPLE, ns3::TestCase::EXTENSIVE, FilterTests(), m_assertOnFailure, m_continueOnFailure, m_tempDir, m_updateData, m_verbose, ns3::SystemPath::MakeTemporaryDirectoryName(), NS_LOG_FUNCTION, ns3::TestSuite::PERFORMANCE, PrintHelp(), PrintTestNameList(), PrintTestTypeList(), ns3::TestCase::QUICK, ns3::TestSuite::SYSTEM, ns3::TestCase::TAKES_FOREVER, and ns3::TestSuite::UNIT.

Referenced by ns3::TestRunner::Run().

Member Data Documentation

◆ m_assertOnFailure

bool ns3::TestRunnerImpl::m_assertOnFailure
private

true if we should assert on failure.

Definition at line 251 of file test.cc.

Referenced by MustAssertOnFailure(), and Run().

◆ m_continueOnFailure

bool ns3::TestRunnerImpl::m_continueOnFailure
private

true if we should continue on failure.

Definition at line 252 of file test.cc.

Referenced by MustContinueOnFailure(), and Run().

◆ m_suites

TestSuiteVector ns3::TestRunnerImpl::m_suites
private

The list of tests.

Definition at line 248 of file test.cc.

Referenced by AddTestSuite(), and FilterTests().

◆ m_tempDir

std::string ns3::TestRunnerImpl::m_tempDir
private

The temporary directory.

Definition at line 249 of file test.cc.

Referenced by GetTempDir(), and Run().

◆ m_updateData

bool ns3::TestRunnerImpl::m_updateData
private

true if we should update reference data.

Definition at line 253 of file test.cc.

Referenced by MustUpdateData(), and Run().

◆ m_verbose

bool ns3::TestRunnerImpl::m_verbose
private

Produce verbose output.

Definition at line 250 of file test.cc.

Referenced by Run().


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