43 #if defined(NS3_ENABLE_EXAMPLES) && !defined (__win32__)
46 const std::string program,
47 const std::string dataDir,
48 const std::string args )
57 ExampleAsTestCase::~ExampleAsTestCase (
void)
63 ExampleAsTestCase::GetCommandTemplate (
void)
const
66 std::string command (
"%s ");
72 ExampleAsTestCase::GetPostProcessingCommand (
void)
const
75 std::string command (
"");
80 ExampleAsTestCase::DoRun (
void)
84 SetDataDir (m_dataDir);
85 std::string refFile = CreateDataDirFilename (GetName () +
".reflog");
86 std::string testFile = CreateTempDirFilename (GetName () +
".reflog");
91 ss <<
"bash -c './ns3 run " << m_program
92 <<
" --no-build --command-template=\"" << GetCommandTemplate () <<
"\""
99 <<
" | grep -v 'Waf:' "
100 << GetPostProcessingCommand ()
104 <<
"; exit ${PIPESTATUS[0]}'";
106 int status = std::system (ss.str ().c_str ());
108 std::cout <<
"command: " << ss.str () <<
"\n"
109 <<
"status: " << status <<
"\n"
110 <<
"refFile: " << refFile <<
"\n"
111 <<
"testFile: " << testFile <<
"\n"
113 std::cout <<
"testFile contents:" << std::endl;
115 std::ifstream logF (testFile);
117 while (getline (logF, line))
119 std::cout << line <<
"\n";
127 const char * envVar = std::getenv (
"NS_COMMANDLINE_INTROSPECTION");
128 if (envVar != 0 && std::strlen (envVar) != 0)
137 ExampleAsTestSuite::ExampleAsTestSuite (
const std::string name,
138 const std::string program,
139 const std::string dataDir,
140 const std::string args ,
141 const TestDuration duration )
142 : TestSuite (name, EXAMPLE)
144 NS_LOG_FUNCTION (
this << name << program << dataDir << args << duration);
145 AddTestCase (
new ExampleAsTestCase (name, program, dataDir, args), duration);
#define NS_ASCII_TEST_EXPECT_EQ(gotFilename, expectedFilename)
Test that a pair of new/reference ascii files are equal.
NS_ASSERT() and NS_ASSERT_MSG() macro definitions.
ExampleAsTestCase(const std::string name, const std::string program, const std::string dataDir, const std::string args="")
Constructor.
Enable examples to be run as meaningful tests.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Every class exported by the ns3 library is enclosed in the ns3 namespace.