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"
46 void DoNothing (
unsigned int threadno);
47 static void SchedulingThread (std::pair<ThreadedSimulatorEventsTestCase *, unsigned int> context);
62 virtual void DoSetup (
void);
63 virtual void DoRun (
void);
64 virtual void DoTeardown (
void);
68 :
TestCase (
"Check that threaded event handling is working with " +
69 schedulerFactory.GetTypeId ().GetName () +
" in " + simulatorType),
71 m_schedulerFactory (schedulerFactory),
72 m_simulatorType (simulatorType)
89 unsigned int threadno = context.second;
94 Simulator::ScheduleWithContext (uint32_t (-1),
102 nanosleep (&ts, NULL);
111 m_error =
"Bad threaded scheduling";
124 Simulator::Schedule (MicroSeconds (10),
137 Simulator::Schedule (MicroSeconds (10),
150 Simulator::Schedule (MicroSeconds (10),
169 Simulator::Schedule (MicroSeconds (10),
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)
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)
Build bound Callbacks which take varying numbers of arguments, and potentially returning a value...
std::string m_simulatorType
void SetTypeId(TypeId tid)
bool m_threadWaiting[MAXTHREADS]
virtual void DoRun(void)
Implementation to actually run this TestCase.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
ThreadedSimulatorTestSuite()
std::list< Ptr< SystemThread > > m_threadlist
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
instantiate subclasses of ns3::Object.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
ObjectFactory m_schedulerFactory
ThreadedSimulatorEventsTestCase(ObjectFactory schedulerFactory, const std::string &simulatorType, unsigned int threads)
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
void SetGlobal(std::string name, const AttributeValue &value)
static void SchedulingThread(std::pair< ThreadedSimulatorEventsTestCase *, unsigned int > context)