21 #include "ns3/simulator.h"
22 #include "ns3/list-scheduler.h"
23 #include "ns3/heap-scheduler.h"
24 #include "ns3/map-scheduler.h"
25 #include "ns3/calendar-scheduler.h"
26 #include "ns3/config.h"
27 #include "ns3/string.h"
28 #include "ns3/system-thread.h"
48 void DoNothing (
unsigned int threadno);
49 static void SchedulingThread (std::pair<ThreadedSimulatorEventsTestCase *, unsigned int> context);
64 virtual void DoSetup (
void);
65 virtual void DoRun (
void);
66 virtual void DoTeardown (
void);
70 :
TestCase (
"Check threaded event handling with " +
71 std::to_string (threads) +
" threads, " +
72 schedulerFactory.GetTypeId ().GetName () +
" scheduler, in " +
75 m_schedulerFactory (schedulerFactory),
76 m_simulatorType (simulatorType)
92 unsigned int threadno = context.second;
97 Simulator::ScheduleWithContext (threadno,
102 std::this_thread::sleep_for (std::chrono::nanoseconds (500));
111 m_error =
"Bad threaded scheduling";
189 for (
unsigned int i = 0; i <
m_threads; ++i)
194 std::pair<ThreadedSimulatorEventsTestCase *, unsigned int> (
this,i) )) );
220 Simulator::Destroy ();
234 std::string simulatorTypes[] = {
236 "ns3::RealtimeSimulatorImpl",
238 "ns3::DefaultSimulatorImpl"
240 std::string schedulerTypes[] = {
241 "ns3::ListScheduler",
242 "ns3::HeapScheduler",
244 "ns3::CalendarScheduler"
246 unsigned int threadcounts[] = {
254 for (
unsigned int i = 0; i < (
sizeof(simulatorTypes) /
sizeof(simulatorTypes[0])); ++i)
256 for (
unsigned int j = 0; j < (
sizeof(threadcounts) /
sizeof(threadcounts[0])); ++j)
258 for (
unsigned int k = 0;
k < (
sizeof(schedulerTypes) /
sizeof(schedulerTypes[0])); ++
k)
static void SchedulingThread(std::pair< ThreadedSimulatorEventsTestCase *, unsigned int > context)
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
ThreadedSimulatorEventsTestCase(ObjectFactory schedulerFactory, const std::string &simulatorType, unsigned int threads)
ObjectFactory m_schedulerFactory
bool m_threadWaiting[MAXTHREADS]
virtual void DoRun(void)
Implementation to actually run this TestCase.
std::string m_simulatorType
std::list< Ptr< SystemThread > > m_threadlist
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
void DoNothing(unsigned int threadno)
ThreadedSimulatorTestSuite()
Instantiate subclasses of ns3::Object.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
void SetGlobal(std::string name, const AttributeValue &value)
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ThreadedSimulatorTestSuite g_threadedSimulatorTestSuite