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)
93 unsigned int threadno = context.second;
98 Simulator::ScheduleWithContext (threadno,
103 std::this_thread::sleep_for(std::chrono::nanoseconds(500));
112 m_error =
"Bad threaded scheduling";
190 for (
unsigned int i=0; i <
m_threads; ++i)
195 std::pair<ThreadedSimulatorEventsTestCase *, unsigned int>(
this,i) )) );
221 Simulator::Destroy ();
235 std::string simulatorTypes[] = {
237 "ns3::RealtimeSimulatorImpl",
239 "ns3::DefaultSimulatorImpl" 241 std::string schedulerTypes[] = {
242 "ns3::ListScheduler",
243 "ns3::HeapScheduler",
245 "ns3::CalendarScheduler" 247 unsigned int threadcounts[] = {
255 for (
unsigned int i=0; i < (
sizeof(simulatorTypes) /
sizeof(simulatorTypes[0])); ++i)
257 for (
unsigned int j=0; j < (
sizeof(threadcounts) /
sizeof(threadcounts[0])); ++j)
259 for (
unsigned int k=0; k < (
sizeof(schedulerTypes) /
sizeof(schedulerTypes[0])); ++k)
void DoNothing(unsigned int threadno)
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
ThreadedSimulatorTestSuite g_threadedSimulatorTestSuite
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
std::string m_simulatorType
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
bool m_threadWaiting[MAXTHREADS]
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
ThreadedSimulatorTestSuite()
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::list< Ptr< SystemThread > > m_threadlist
Instantiate subclasses of ns3::Object.
void SetGlobal(std::string name, const AttributeValue &value)
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
Time Seconds(double value)
Construct a Time in the indicated unit.
ObjectFactory m_schedulerFactory
ThreadedSimulatorEventsTestCase(ObjectFactory schedulerFactory, const std::string &simulatorType, unsigned int threads)
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
static void SchedulingThread(std::pair< ThreadedSimulatorEventsTestCase *, unsigned int > context)