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 () |
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 () 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 | |
void | DoRun () override |
Implementation to actually run this TestCase. More... | |
void | DoSetup () override |
Implementation to do any local setup required for this TestCase. More... | |
void | DoTeardown () override |
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 TestCase. More... | |
bool | IsStatusFailure () const |
Check if any tests failed. More... | |
bool | IsStatusSuccess () 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 () const |
Check if this run should assert on failure. More... | |
bool | MustContinueOnFailure () 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 121 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 168 of file threaded-test-suite.cc.
References m_error, and m_threadWaiting.
Referenced by SchedulingThread().
|
overrideprivatevirtual |
Implementation to actually run this TestCase.
Subclasses should override this method to conduct their tests.
Implements ns3::TestCase.
Definition at line 257 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().
|
overrideprivatevirtual |
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 236 of file threaded-test-suite.cc.
References m_a, m_b, m_c, m_d, m_error, m_simulatorType, and ns3::Config::SetGlobal().
|
overrideprivatevirtual |
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 249 of file threaded-test-suite.cc.
References m_threadlist, and ns3::Config::SetGlobal().
void ThreadedSimulatorEventsTestCase::End | ( | ) |
End the thread execution.
Definition at line 133 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 190 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 202 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 146 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 112 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 109 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 113 of file threaded-test-suite.cc.
Referenced by DoRun(), DoTeardown(), and End().
unsigned int ThreadedSimulatorEventsTestCase::m_threads |
The number of threads.
Definition at line 107 of file threaded-test-suite.cc.
Referenced by DoRun().
bool ThreadedSimulatorEventsTestCase::m_threadWaiting[MAXTHREADS] |
Threads waiting to be scheduled.
Definition at line 108 of file threaded-test-suite.cc.
Referenced by DoNothing(), and SchedulingThread().