A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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.
 
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
 
TestCaseoperator= (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.
 
TestCaseGetParent () 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.
 

Detailed Description

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

Definition at line 45 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 110 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 157 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 ( )
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().

+ Here is the call graph for this function:

◆ DoSetup()

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

+ Here is the call graph for this function:

◆ DoTeardown()

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

+ Here is the call graph for this function:

◆ End()

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

+ Here is the caller graph for this function:

◆ EventA()

void ThreadedSimulatorEventsTestCase::EventA ( int a)

Event A.

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

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

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

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

+ 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 135 of file threaded-test-suite.cc.

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

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 92 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 93 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 94 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 95 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 101 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 99 of file threaded-test-suite.cc.

Referenced by DoRun().

◆ m_simulatorType

std::string ThreadedSimulatorEventsTestCase::m_simulatorType

Simulator type.

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

Referenced by DoSetup().

◆ m_stop

bool ThreadedSimulatorEventsTestCase::m_stop

Stop variable.

Definition at line 98 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 102 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 96 of file threaded-test-suite.cc.

Referenced by DoRun().

◆ m_threadWaiting

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


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