A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::TestRunnerImpl Class Reference

Container for all tests. More...

+ Inheritance diagram for ns3::TestRunnerImpl:
+ Collaboration diagram for ns3::TestRunnerImpl:

Public Member Functions

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

Private Types

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

Private Member Functions

std::list< TestCase * > FilterTests (std::string testName, TestSuite::Type testType, TestCase::Duration maximumTestDuration)
 Generate the list of tests matching the constraints.
 
bool IsTopLevelSourceDir (std::string path) const
 Check if this is the root of the source tree.
 
void PrintHelp (const char *programName) const
 Print the help text.
 
void PrintReport (TestCase *test, std::ostream *os, bool xml, int level)
 Print the test report.
 
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.
 
void PrintTestTypeList () const
 Print the list of test types.
 
std::string ReplaceXmlSpecialCharacters (std::string xml) const
 Clean up characters not allowed in XML.
 

Private Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from ns3::Singleton< TestRunnerImpl >
static TestRunnerImplGet ()
 Get a pointer to the singleton instance.
 
- Protected Member Functions inherited from ns3::Singleton< TestRunnerImpl >
 Singleton ()
 Constructor.
 
virtual ~Singleton ()
 Destructor.
 

Detailed Description

Container for all tests.

Todo
Move TestRunnerImpl to separate file.

Definition at line 129 of file test.cc.

Member Typedef Documentation

◆ TestSuiteVector

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

Container type for the test.

Definition at line 235 of file test.cc.

Constructor & Destructor Documentation

◆ TestRunnerImpl()

ns3::TestRunnerImpl::TestRunnerImpl ( )

Constructor.

Definition at line 511 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 521 of file test.cc.

References m_suites, and NS_LOG_FUNCTION.

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

+ Here is the caller graph for this function:

◆ FilterTests()

std::list< TestCase * > ns3::TestRunnerImpl::FilterTests ( std::string testName,
TestSuite::Type testType,
TestCase::Duration 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 828 of file test.cc.

References ns3::TestSuite::ALL, ns3::TestCase::m_duration, m_suites, and NS_LOG_FUNCTION.

Referenced by Run().

+ Here is the caller graph for this function:

◆ GetTempDir()

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

Get the path to temporary directory.

Returns
The temporary directory path.

Definition at line 549 of file test.cc.

References m_tempDir, and NS_LOG_FUNCTION.

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

+ Here is the caller graph for this function:

◆ GetTopLevelSourceDir()

std::string ns3::TestRunnerImpl::GetTopLevelSourceDir ( ) 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 584 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().

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

◆ 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 556 of file test.cc.

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

Referenced by GetTopLevelSourceDir().

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

◆ MustAssertOnFailure()

bool ns3::TestRunnerImpl::MustAssertOnFailure ( ) const

Check if this run should assert on failure.

Returns
true if we should assert on failure.

Definition at line 528 of file test.cc.

References m_assertOnFailure, and NS_LOG_FUNCTION.

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

+ Here is the caller graph for this function:

◆ MustContinueOnFailure()

bool ns3::TestRunnerImpl::MustContinueOnFailure ( ) const

Check if this run should continue on failure.

Returns
true if we should continue on failure.

Definition at line 535 of file test.cc.

References m_continueOnFailure, and NS_LOG_FUNCTION.

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

+ Here is the caller graph for this function:

◆ MustUpdateData()

bool ns3::TestRunnerImpl::MustUpdateData ( ) const

Check if this run should update the reference data.

Returns
true if we should update the reference data.

Definition at line 542 of file test.cc.

References m_updateData, and NS_LOG_FUNCTION.

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

+ Here is the caller graph for this function:

◆ 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 748 of file test.cc.

References NS_LOG_FUNCTION.

Referenced by Run().

+ Here is the caller graph for this function:

◆ 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 675 of file test.cc.

References ns3::TestCaseFailure::actual, ns3::TestCaseFailure::cond, ns3::TestCaseFailure::file, ns3::TestCaseFailure::limit, ns3::TestCaseFailure::line, m_verbose, ns3::TestCaseFailure::message, NS_LOG_FUNCTION, PrintReport(), and ReplaceXmlSpecialCharacters().

Referenced by PrintReport(), and Run().

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

◆ 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]printTestTypePrepend the test type label if true.

Definition at line 786 of file test.cc.

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

Referenced by Run().

+ Here is the caller graph for this function:

◆ PrintTestTypeList()

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

Print the list of test types.

Definition at line 812 of file test.cc.

References NS_LOG_FUNCTION.

Referenced by Run().

+ Here is the caller graph for this function:

◆ 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 608 of file test.cc.

References NS_LOG_FUNCTION.

Referenced by PrintReport().

+ Here is the caller graph for this 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 878 of file test.cc.

References ns3::TestSuite::ALL, ns3::TestSuite::EXAMPLE, ns3::TestCase::EXTENSIVE, FilterTests(), ns3::Singleton< DesMetrics >::Get(), ns3::DesMetrics::Initialize(), m_assertOnFailure, m_continueOnFailure, m_tempDir, m_updateData, m_verbose, ns3::SystemPath::MakeTemporaryDirectoryName(), NS_LOG_FUNCTION, ns3::TestSuite::PERFORMANCE, PrintHelp(), PrintReport(), PrintTestNameList(), PrintTestTypeList(), ns3::TestCase::QUICK, ns3::SystemPath::Split(), ns3::TestSuite::SYSTEM, ns3::TestCase::TAKES_FOREVER, and ns3::TestSuite::UNIT.

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

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

Member Data Documentation

◆ m_assertOnFailure

bool ns3::TestRunnerImpl::m_assertOnFailure
private

true if we should assert on failure.

Definition at line 240 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 241 of file test.cc.

Referenced by MustContinueOnFailure(), and Run().

◆ m_suites

TestSuiteVector ns3::TestRunnerImpl::m_suites
private

The list of tests.

Definition at line 237 of file test.cc.

Referenced by AddTestSuite(), and FilterTests().

◆ m_tempDir

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

The temporary directory.

Definition at line 238 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 242 of file test.cc.

Referenced by MustUpdateData(), and Run().

◆ m_verbose

bool ns3::TestRunnerImpl::m_verbose
private

Produce verbose output.

Definition at line 239 of file test.cc.

Referenced by PrintReport(), and Run().


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