A Discrete-Event Network Simulator
API
ThreadedSimulatorEventsTestCase Class Reference

Check threaded event handling with various thread number, schedulers, and simulator types. More...

+ Inheritance diagram for ThreadedSimulatorEventsTestCase:
+ Collaboration diagram for ThreadedSimulatorEventsTestCase:

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
 
TestCaseoperator= (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...
 
TestCaseGetParent () 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...
 

Detailed Description

Check threaded event handling with various thread number, schedulers, and simulator types.

Definition at line 56 of file threaded-test-suite.cc.

Constructor & Destructor Documentation

◆ ThreadedSimulatorEventsTestCase()

ThreadedSimulatorEventsTestCase::ThreadedSimulatorEventsTestCase ( ObjectFactory  schedulerFactory,
const std::string &  simulatorType,
unsigned int  threads 
)

Constructor.

Parameters
schedulerFactoryThe scheduler factory.
simulatorTypeThe simulator type.
threadsThe number of threads.

Definition at line 119 of file threaded-test-suite.cc.

Member Function Documentation

◆ DoNothing()

void ThreadedSimulatorEventsTestCase::DoNothing ( unsigned int  threadno)

No-op function, records the thread that called it.

Parameters
threadnoThe thread number.

Definition at line 160 of file threaded-test-suite.cc.

References m_error, and m_threadWaiting.

Referenced by SchedulingThread().

+ Here is the caller graph for this function:

◆ DoRun()

void ThreadedSimulatorEventsTestCase::DoRun ( void  )
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().

+ Here is the call graph for this function:

◆ DoSetup()

void ThreadedSimulatorEventsTestCase::DoSetup ( void  )
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().

+ Here is the call graph for this function:

◆ DoTeardown()

void ThreadedSimulatorEventsTestCase::DoTeardown ( void  )
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().

+ Here is the call graph for this function:

◆ End()

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().

+ Here is the caller graph for this function:

◆ EventA()

void ThreadedSimulatorEventsTestCase::EventA ( int  a)

Event A.

Parameters
aThe Event parameter.

Definition at line 169 of file threaded-test-suite.cc.

References EventB(), m_a, m_b, m_c, m_d, m_error, and ns3::MicroSeconds().

Referenced by DoRun(), and EventD().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EventB()

void ThreadedSimulatorEventsTestCase::EventB ( int  b)

Event B.

Parameters
bThe 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EventC()

void ThreadedSimulatorEventsTestCase::EventC ( int  c)

Event C.

Parameters
cThe 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EventD()

void ThreadedSimulatorEventsTestCase::EventD ( int  d)

Event D.

Parameters
dThe Event parameter.

Definition at line 208 of file threaded-test-suite.cc.

References EventA(), m_a, m_b, m_c, m_d, m_error, m_stop, and ns3::MicroSeconds().

Referenced by EventC().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SchedulingThread()

void ThreadedSimulatorEventsTestCase::SchedulingThread ( std::pair< ThreadedSimulatorEventsTestCase *, unsigned int >  context)
static

Schedule a thread.

Parameters
contextThe context.

Definition at line 142 of file threaded-test-suite.cc.

References DoNothing(), m_stop, m_threadWaiting, and ns3::MicroSeconds().

Referenced by DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_a

uint64_t ThreadedSimulatorEventsTestCase::m_a

The value incremented when EventA is called.

Definition at line 101 of file threaded-test-suite.cc.

Referenced by DoRun(), DoSetup(), EventA(), EventB(), EventC(), and EventD().

◆ m_b

uint64_t ThreadedSimulatorEventsTestCase::m_b

The value incremented when EventB is called.

Definition at line 102 of file threaded-test-suite.cc.

Referenced by DoRun(), DoSetup(), EventA(), EventB(), EventC(), and EventD().

◆ m_c

uint64_t ThreadedSimulatorEventsTestCase::m_c

The value incremented when EventC is called.

Definition at line 103 of file threaded-test-suite.cc.

Referenced by DoRun(), DoSetup(), EventA(), EventB(), EventC(), and EventD().

◆ m_d

uint64_t ThreadedSimulatorEventsTestCase::m_d

The value incremented when EventD is called.

Definition at line 104 of file threaded-test-suite.cc.

Referenced by DoRun(), DoSetup(), EventA(), EventB(), EventC(), and EventD().

◆ m_error

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().

◆ m_schedulerFactory

ObjectFactory ThreadedSimulatorEventsTestCase::m_schedulerFactory

Scheduler factory.

Definition at line 108 of file threaded-test-suite.cc.

Referenced by DoRun().

◆ m_simulatorType

std::string ThreadedSimulatorEventsTestCase::m_simulatorType

Simulator type.

Definition at line 109 of file threaded-test-suite.cc.

Referenced by DoSetup().

◆ m_stop

bool ThreadedSimulatorEventsTestCase::m_stop

Stop variable.

Definition at line 107 of file threaded-test-suite.cc.

Referenced by DoRun(), End(), EventD(), and SchedulingThread().

◆ m_threadlist

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().

◆ m_threads

unsigned int ThreadedSimulatorEventsTestCase::m_threads

The number of threads.

Definition at line 105 of file threaded-test-suite.cc.

Referenced by DoRun().

◆ m_threadWaiting

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().


The documentation for this class was generated from the following file: