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 (threadno,
102 nanosleep (&ts, NULL);
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)
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)