Check threaded event handling with various thread number, schedulers, and simulator types. More...
Public Member Functions | |
ThreadedSimulatorEventsTestCase (ObjectFactory schedulerFactory, const std::string &simulatorType, unsigned int threads) | |
Constructor. More... | |
void | DoNothing (unsigned int threadno) |
No-op function, records the thread that called it. More... | |
void | End (void) |
End the thread execution. More... | |
void | EventA (int a) |
Event A. More... | |
void | EventB (int b) |
Event B. More... | |
void | EventC (int c) |
Event C. More... | |
void | EventD (int d) |
Event D. More... | |
Public Member Functions inherited from ns3::TestCase | |
TestCase (const TestCase &)=delete | |
virtual | ~TestCase () |
Destructor. More... | |
std::string | GetName (void) const |
TestCase & | operator= (const TestCase &)=delete |
Static Public Member Functions | |
static void | SchedulingThread (std::pair< ThreadedSimulatorEventsTestCase *, unsigned int > context) |
Schedule a thread. More... | |
Public Attributes | |
uint64_t | m_a |
The value incremented when EventA is called. More... | |
uint64_t | m_b |
The value incremented when EventB is called. More... | |
uint64_t | m_c |
The value incremented when EventC is called. More... | |
uint64_t | m_d |
The value incremented when EventD is called. More... | |
std::string | m_error |
Error condition. More... | |
ObjectFactory | m_schedulerFactory |
Scheduler factory. More... | |
std::string | m_simulatorType |
Simulator type. More... | |
bool | m_stop |
Stop variable. More... | |
std::list< std::thread > | m_threadlist |
Thread list. More... | |
unsigned int | m_threads |
The number of threads. More... | |
bool | m_threadWaiting [MAXTHREADS] |
Threads waiting to be scheduled. More... | |
Private Member Functions | |
virtual void | DoRun (void) |
Implementation to actually run this TestCase. More... | |
virtual void | DoSetup (void) |
Implementation to do any local setup required for this TestCase. More... | |
virtual void | DoTeardown (void) |
Implementation to do any local setup required for this TestCase. More... | |
Additional Inherited Members | |
Public Types inherited from ns3::TestCase | |
enum | TestDuration { QUICK = 1 , EXTENSIVE = 2 , TAKES_FOREVER = 3 } |
How long the test takes to execute. More... | |
Protected Member Functions inherited from ns3::TestCase | |
TestCase (std::string name) | |
Constructor. More... | |
void | AddTestCase (TestCase *testCase, TestDuration duration=QUICK) |
Add an individual child TestCase to this test suite. More... | |
TestCase * | GetParent () const |
Get the parent of this TestCsse. More... | |
bool | IsStatusFailure (void) const |
Check if any tests failed. More... | |
bool | IsStatusSuccess (void) const |
Check if all tests passed. More... | |
void | SetDataDir (std::string directory) |
Set the data directory where reference trace files can be found. More... | |
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. 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... | |
std::string | CreateDataDirFilename (std::string filename) |
Construct the full path to a file in the data directory. More... | |
std::string | CreateTempDirFilename (std::string filename) |
Construct the full path to a file in a temporary directory. More... | |
Check threaded event handling with various thread number, schedulers, and simulator types.
Definition at line 56 of file threaded-test-suite.cc.
ThreadedSimulatorEventsTestCase::ThreadedSimulatorEventsTestCase | ( | ObjectFactory | schedulerFactory, |
const std::string & | simulatorType, | ||
unsigned int | threads | ||
) |
Constructor.
schedulerFactory | The scheduler factory. |
simulatorType | The simulator type. |
threads | The number of threads. |
Definition at line 119 of file threaded-test-suite.cc.
void ThreadedSimulatorEventsTestCase::DoNothing | ( | unsigned int | threadno | ) |
No-op function, records the thread that called it.
threadno | The thread number. |
Definition at line 160 of file threaded-test-suite.cc.
References m_error, and m_threadWaiting.
Referenced by SchedulingThread().
|
privatevirtual |
Implementation to actually run this TestCase.
Subclasses should override this method to conduct their tests.
Implements ns3::TestCase.
Definition at line 250 of file threaded-test-suite.cc.
References End(), EventA(), m_a, m_b, m_c, m_d, m_error, m_schedulerFactory, m_stop, m_threadlist, m_threads, ns3::MicroSeconds(), NS_TEST_EXPECT_MSG_EQ, SchedulingThread(), and ns3::Seconds().
|
privatevirtual |
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 228 of file threaded-test-suite.cc.
References m_a, m_b, m_c, m_d, m_error, m_simulatorType, and ns3::Config::SetGlobal().
|
privatevirtual |
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 243 of file threaded-test-suite.cc.
References m_threadlist, and ns3::Config::SetGlobal().
void ThreadedSimulatorEventsTestCase::End | ( | void | ) |
End the thread execution.
Definition at line 130 of file threaded-test-suite.cc.
References m_stop, and m_threadlist.
Referenced by DoRun().
void ThreadedSimulatorEventsTestCase::EventA | ( | int | a | ) |
void ThreadedSimulatorEventsTestCase::EventB | ( | int | b | ) |
Event B.
b | The Event parameter. |
Definition at line 182 of file threaded-test-suite.cc.
References EventC(), m_a, m_b, m_c, m_d, m_error, and ns3::MicroSeconds().
Referenced by EventA().
void ThreadedSimulatorEventsTestCase::EventC | ( | int | c | ) |
Event C.
c | The Event parameter. |
Definition at line 195 of file threaded-test-suite.cc.
References EventD(), m_a, m_b, m_c, m_d, m_error, and ns3::MicroSeconds().
Referenced by EventB().
void ThreadedSimulatorEventsTestCase::EventD | ( | int | d | ) |
|
static |
Schedule a thread.
context | The context. |
Definition at line 142 of file threaded-test-suite.cc.
References DoNothing(), m_stop, m_threadWaiting, and ns3::MicroSeconds().
Referenced by DoRun().
uint64_t ThreadedSimulatorEventsTestCase::m_a |
uint64_t ThreadedSimulatorEventsTestCase::m_b |
uint64_t ThreadedSimulatorEventsTestCase::m_c |
uint64_t ThreadedSimulatorEventsTestCase::m_d |
std::string ThreadedSimulatorEventsTestCase::m_error |
Error condition.
Definition at line 110 of file threaded-test-suite.cc.
Referenced by DoNothing(), DoRun(), DoSetup(), EventA(), EventB(), EventC(), and EventD().
ObjectFactory ThreadedSimulatorEventsTestCase::m_schedulerFactory |
std::string ThreadedSimulatorEventsTestCase::m_simulatorType |
bool ThreadedSimulatorEventsTestCase::m_stop |
Stop variable.
Definition at line 107 of file threaded-test-suite.cc.
Referenced by DoRun(), End(), EventD(), and SchedulingThread().
std::list<std::thread> ThreadedSimulatorEventsTestCase::m_threadlist |
Thread list.
Definition at line 111 of file threaded-test-suite.cc.
Referenced by DoRun(), DoTeardown(), and End().
unsigned int ThreadedSimulatorEventsTestCase::m_threads |
The number of threads.
Definition at line 105 of file threaded-test-suite.cc.
Referenced by DoRun().
bool ThreadedSimulatorEventsTestCase::m_threadWaiting[MAXTHREADS] |
Threads waiting to be scheduled.
Definition at line 106 of file threaded-test-suite.cc.
Referenced by DoNothing(), and SchedulingThread().