Container for all tests. More...
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 | |
Singleton< TestRunnerImpl > & | operator= (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::TestDuration 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 TestRunnerImpl * | Get () |
Get a pointer to the singleton instance. | |
Protected Member Functions inherited from ns3::Singleton< TestRunnerImpl > | |
Singleton () | |
Constructor. | |
virtual | ~Singleton () |
Destructor. | |
Container for all tests.
|
private |
ns3::TestRunnerImpl::TestRunnerImpl | ( | ) |
void ns3::TestRunnerImpl::AddTestSuite | ( | TestSuite * | testSuite | ) |
Add a new top-level TestSuite.
[in] | testSuite | The new TestSuite. |
Definition at line 527 of file test.cc.
References m_suites, and NS_LOG_FUNCTION.
Referenced by ns3::TestSuite::TestSuite().
|
private |
Generate the list of tests matching the constraints.
Test name and type constraints are or'ed. The duration constraint is and'ed.
[in] | testName | Include a specific test by name. |
[in] | testType | Include all tests of give type. |
[in] | maximumTestDuration | Restrict to tests shorter than this. |
Definition at line 834 of file test.cc.
References ns3::TestSuite::ALL, ns3::TestCase::m_duration, m_suites, and NS_LOG_FUNCTION.
Referenced by Run().
std::string ns3::TestRunnerImpl::GetTempDir | ( | ) | const |
Get the path to temporary directory.
Definition at line 555 of file test.cc.
References m_tempDir, and NS_LOG_FUNCTION.
Referenced by ns3::TestCase::CreateTempDirFilename().
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".
Definition at line 590 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().
|
private |
Check if this is the root of the source tree.
[in] | path | The path to test. |
true
if path is the root. Definition at line 562 of file test.cc.
References NS_LOG_FUNCTION, and ns3::SystemPath::ReadFiles().
Referenced by GetTopLevelSourceDir().
bool ns3::TestRunnerImpl::MustAssertOnFailure | ( | ) | const |
Check if this run should assert on failure.
true
if we should assert on failure. Definition at line 534 of file test.cc.
References m_assertOnFailure, and NS_LOG_FUNCTION.
Referenced by ns3::TestCase::MustAssertOnFailure().
bool ns3::TestRunnerImpl::MustContinueOnFailure | ( | ) | const |
Check if this run should continue on failure.
true
if we should continue on failure. Definition at line 541 of file test.cc.
References m_continueOnFailure, and NS_LOG_FUNCTION.
Referenced by ns3::TestCase::MustContinueOnFailure().
bool ns3::TestRunnerImpl::MustUpdateData | ( | ) | const |
Check if this run should update the reference data.
true
if we should update the reference data. Definition at line 548 of file test.cc.
References m_updateData, and NS_LOG_FUNCTION.
Referenced by ns3::TestCase::CreateTempDirFilename().
|
private |
Print the help text.
[in] | programName | The name of the invoking program. |
Definition at line 754 of file test.cc.
References NS_LOG_FUNCTION.
Referenced by Run().
|
private |
Print the test report.
[in] | test | The TestCase to print. |
[in,out] | os | The output stream. |
[in] | xml | Generate XML output if true . |
[in] | level | Indentation level. |
Definition at line 681 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().
|
private |
Print the list of all requested test suites.
[in] | begin | Iterator to the first TestCase to print. |
[in] | end | Iterator to the end of the list. |
[in] | printTestType | Prepend the test type label if true . |
Definition at line 792 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().
|
private |
Print the list of test types.
Definition at line 818 of file test.cc.
References NS_LOG_FUNCTION.
Referenced by Run().
|
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 |
---|---|
'<' | "<" |
'>' | ">" |
'&' | "&" |
'"' | "&39;" |
'\' | """ |
[in] | xml | The raw string. |
Definition at line 614 of file test.cc.
References NS_LOG_FUNCTION.
Referenced by PrintReport().
int ns3::TestRunnerImpl::Run | ( | int | argc, |
char * | argv[] | ||
) |
Run the requested suite of tests, according to the given command line arguments.
[in] | argc | The number of elements in argv |
[in] | argv | The vector of command line arguments |
Definition at line 885 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().
|
private |
true
if we should assert on failure.
Definition at line 249 of file test.cc.
Referenced by MustAssertOnFailure(), and Run().
|
private |
true
if we should continue on failure.
Definition at line 250 of file test.cc.
Referenced by MustContinueOnFailure(), and Run().
|
private |
The list of tests.
Definition at line 246 of file test.cc.
Referenced by AddTestSuite(), and FilterTests().
|
private |
The temporary directory.
Definition at line 247 of file test.cc.
Referenced by GetTempDir(), and Run().
|
private |
true
if we should update reference data.
Definition at line 251 of file test.cc.
Referenced by MustUpdateData(), and Run().
|
private |
Produce verbose output.
Definition at line 248 of file test.cc.
Referenced by PrintReport(), and Run().