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. | |
void | DoNothing (unsigned int threadno) |
No-op function, records the thread that called it. | |
void | End () |
End the thread execution. | |
void | EventA (int a) |
Event A. | |
void | EventB (int b) |
Event B. | |
void | EventC (int c) |
Event C. | |
void | EventD (int d) |
Event D. | |
Public Member Functions inherited from ns3::TestCase | |
TestCase (const TestCase &)=delete | |
virtual | ~TestCase () |
Destructor. | |
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. | |
Public Attributes | |
uint64_t | m_a |
The value incremented when EventA is called. | |
uint64_t | m_b |
The value incremented when EventB is called. | |
uint64_t | m_c |
The value incremented when EventC is called. | |
uint64_t | m_d |
The value incremented when EventD is called. | |
std::string | m_error |
Error condition. | |
ObjectFactory | m_schedulerFactory |
Scheduler factory. | |
std::string | m_simulatorType |
Simulator type. | |
bool | m_stop |
Stop variable. | |
std::list< std::thread > | m_threadlist |
Thread list. | |
unsigned int | m_threads |
The number of threads. | |
bool | m_threadWaiting [MAXTHREADS] |
Threads waiting to be scheduled. | |
Private Member Functions | |
void | DoRun () override |
Implementation to actually run this TestCase. | |
void | DoSetup () override |
Implementation to do any local setup required for this TestCase. | |
void | DoTeardown () override |
Implementation to do any local setup required for this TestCase. | |
Additional Inherited Members | |
Public Types inherited from ns3::TestCase | |
enum class | Duration { QUICK = 1 , EXTENSIVE = 2 , TAKES_FOREVER = 3 } |
How long the test takes to execute. More... | |
Static Public Attributes inherited from ns3::TestCase | |
static constexpr auto | QUICK = Duration::QUICK |
Deprecated test duration simple enums. | |
static constexpr auto | EXTENSIVE = Duration::EXTENSIVE |
static constexpr auto | TAKES_FOREVER = Duration::TAKES_FOREVER |
Protected Member Functions inherited from ns3::TestCase | |
TestCase (std::string name) | |
Constructor. | |
void | AddTestCase (TestCase *testCase, Duration duration=Duration::QUICK) |
Add an individual child TestCase to this test suite. | |
TestCase * | GetParent () const |
Get the parent of this TestCase. | |
bool | IsStatusFailure () const |
Check if any tests failed. | |
bool | IsStatusSuccess () const |
Check if all tests passed. | |
void | SetDataDir (std::string directory) |
Set the data directory where reference trace files can be found. | |
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. | |
bool | MustAssertOnFailure () const |
Check if this run should assert on failure. | |
bool | MustContinueOnFailure () const |
Check if this run should continue on failure. | |
std::string | CreateDataDirFilename (std::string filename) |
Construct the full path to a file in the data directory. | |
std::string | CreateTempDirFilename (std::string filename) |
Construct the full path to a file in a temporary directory. | |
Check threaded event handling with various thread number, schedulers, and simulator types.
Definition at line 45 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 110 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 157 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 246 of file threaded-test-suite.cc.
References ns3::Simulator::Destroy(), 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, ns3::Simulator::Run(), ns3::Simulator::Schedule(), SchedulingThread(), ns3::Seconds(), and ns3::Simulator::SetScheduler().
|
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 225 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 238 of file threaded-test-suite.cc.
References m_threadlist, and ns3::Config::SetGlobal().
void ThreadedSimulatorEventsTestCase::End | ( | ) |
End the thread execution.
Definition at line 122 of file threaded-test-suite.cc.
References m_stop, and m_threadlist.
Referenced by DoRun().
void ThreadedSimulatorEventsTestCase::EventA | ( | int | a | ) |
Event A.
a | The Event parameter. |
Definition at line 167 of file threaded-test-suite.cc.
References EventB(), m_a, m_b, m_c, m_d, m_error, ns3::MicroSeconds(), ns3::Simulator::Schedule(), and ns3::Simulator::Stop().
Referenced by DoRun(), and EventD().
void ThreadedSimulatorEventsTestCase::EventB | ( | int | b | ) |
Event B.
b | The Event parameter. |
Definition at line 179 of file threaded-test-suite.cc.
References EventC(), m_a, m_b, m_c, m_d, m_error, ns3::MicroSeconds(), ns3::Simulator::Schedule(), and ns3::Simulator::Stop().
Referenced by EventA().
void ThreadedSimulatorEventsTestCase::EventC | ( | int | c | ) |
Event C.
c | The Event parameter. |
Definition at line 191 of file threaded-test-suite.cc.
References EventD(), m_a, m_b, m_c, m_d, m_error, ns3::MicroSeconds(), ns3::Simulator::Schedule(), and ns3::Simulator::Stop().
Referenced by EventB().
void ThreadedSimulatorEventsTestCase::EventD | ( | int | d | ) |
Event D.
d | The Event parameter. |
Definition at line 203 of file threaded-test-suite.cc.
References EventA(), m_a, m_b, m_c, m_d, m_error, m_stop, ns3::MicroSeconds(), ns3::Simulator::Schedule(), and ns3::Simulator::Stop().
Referenced by EventC().
|
static |
Schedule a thread.
context | The context. |
Definition at line 135 of file threaded-test-suite.cc.
References DoNothing(), m_stop, m_threadWaiting, ns3::MicroSeconds(), and ns3::Simulator::ScheduleWithContext().
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 101 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 98 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 102 of file threaded-test-suite.cc.
Referenced by DoRun(), DoTeardown(), and End().
unsigned int ThreadedSimulatorEventsTestCase::m_threads |
bool ThreadedSimulatorEventsTestCase::m_threadWaiting[MAXTHREADS] |
Threads waiting to be scheduled.
Definition at line 97 of file threaded-test-suite.cc.
Referenced by DoNothing(), and SchedulingThread().