A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
simulator-test-suite.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #include "ns3/test.h"
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 
27 using namespace ns3;
28 
30 {
31 public:
32  SimulatorEventsTestCase (ObjectFactory schedulerFactory);
33  virtual void DoRun (void);
34  void EventA (int a);
35  void EventB (int b);
36  void EventC (int c);
37  void EventD (int d);
38  void Eventfoo0 (void);
39  uint64_t NowUs (void);
40  void destroy (void);
41  bool m_b;
42  bool m_a;
43  bool m_c;
44  bool m_d;
46  bool m_destroy;
49 };
50 
52  : TestCase ("Check that basic event handling is working with " +
53  schedulerFactory.GetTypeId ().GetName ()),
54  m_schedulerFactory (schedulerFactory)
55 {
56 }
57 uint64_t
59 {
60  uint64_t ns = Now ().GetNanoSeconds ();
61  return ns / 1000;
62 }
63 
64 void
66 {
67  m_a = false;
68 }
69 
70 void
72 {
73  if (b != 2 || NowUs () != 11)
74  {
75  m_b = false;
76  }
77  else
78  {
79  m_b = true;
80  }
81  Simulator::Remove (m_idC);
82  Simulator::Schedule (MicroSeconds (10), &SimulatorEventsTestCase::EventD, this, 4);
83 }
84 
85 void
87 {
88  m_c = false;
89 }
90 
91 void
93 {
94  if (d != 4 || NowUs () != (11+10))
95  {
96  m_d = false;
97  }
98  else
99  {
100  m_d = true;
101  }
102 }
103 
104 void
106 {}
107 
108 void
110 {
111  if (m_destroyId.IsExpired ())
112  {
113  m_destroy = true;
114  }
115 }
116 void
118 {
119  m_a = true;
120  m_b = false;
121  m_c = true;
122  m_d = false;
123 
124  Simulator::SetScheduler (m_schedulerFactory);
125 
126  EventId a = Simulator::Schedule (MicroSeconds (10), &SimulatorEventsTestCase::EventA, this, 1);
127  Simulator::Schedule (MicroSeconds (11), &SimulatorEventsTestCase::EventB, this, 2);
128  m_idC = Simulator::Schedule (MicroSeconds (12), &SimulatorEventsTestCase::EventC, this, 3);
129 
130  NS_TEST_EXPECT_MSG_EQ (!m_idC.IsExpired (), true, "");
131  NS_TEST_EXPECT_MSG_EQ (!a.IsExpired (), true, "");
132  Simulator::Cancel (a);
133  NS_TEST_EXPECT_MSG_EQ (a.IsExpired (), true, "");
134  Simulator::Run ();
135  NS_TEST_EXPECT_MSG_EQ (m_a, true, "Event A did not run ?");
136  NS_TEST_EXPECT_MSG_EQ (m_b, true, "Event B did not run ?");
137  NS_TEST_EXPECT_MSG_EQ (m_c, true, "Event C did not run ?");
138  NS_TEST_EXPECT_MSG_EQ (m_d, true, "Event D did not run ?");
139 
140  EventId anId = Simulator::ScheduleNow (&SimulatorEventsTestCase::Eventfoo0, this);
141  EventId anotherId = anId;
142  NS_TEST_EXPECT_MSG_EQ (!(anId.IsExpired () || anotherId.IsExpired ()), true, "Event should not have expired yet.");
143 
144  Simulator::Remove (anId);
145  NS_TEST_EXPECT_MSG_EQ (anId.IsExpired (), true, "Event was removed: it is now expired");
146  NS_TEST_EXPECT_MSG_EQ (anotherId.IsExpired (), true, "Event was removed: it is now expired");
147 
148  m_destroy = false;
149  m_destroyId = Simulator::ScheduleDestroy (&SimulatorEventsTestCase::destroy, this);
150  NS_TEST_EXPECT_MSG_EQ (!m_destroyId.IsExpired (), true, "Event should not have expired yet");
151  m_destroyId.Cancel ();
152  NS_TEST_EXPECT_MSG_EQ (m_destroyId.IsExpired (), true, "Event was canceled: should have expired now");
153 
154  m_destroyId = Simulator::ScheduleDestroy (&SimulatorEventsTestCase::destroy, this);
155  NS_TEST_EXPECT_MSG_EQ (!m_destroyId.IsExpired (), true, "Event should not have expired yet");
156  Simulator::Remove (m_destroyId);
157  NS_TEST_EXPECT_MSG_EQ (m_destroyId.IsExpired (), true, "Event was canceled: should have expired now");
158 
159  m_destroyId = Simulator::ScheduleDestroy (&SimulatorEventsTestCase::destroy, this);
160  NS_TEST_EXPECT_MSG_EQ (!m_destroyId.IsExpired (), true, "Event should not have expired yet");
161 
162  Simulator::Run ();
163  NS_TEST_EXPECT_MSG_EQ (!m_destroyId.IsExpired (), true, "Event should not have expired yet");
164  NS_TEST_EXPECT_MSG_EQ (!m_destroy, true, "Event should not have run");
165 
166  Simulator::Destroy ();
167  NS_TEST_EXPECT_MSG_EQ (m_destroyId.IsExpired (), true, "Event should have expired now");
168  NS_TEST_EXPECT_MSG_EQ (m_destroy, true, "Event should have run");
169 }
170 
172 {
173 public:
175  // only here for testing of Ptr<>
176  void Ref (void) const {}
177  void Unref (void) const {}
178 private:
179  virtual void DoRun (void);
180 
181  void bar0 (void) {}
182  void bar1 (int) {}
183  void bar2 (int, int) {}
184  void bar3 (int, int, int) {}
185  void bar4 (int, int, int, int) {}
186  void bar5 (int, int, int, int, int) {}
187  void baz1 (int &) {}
188  void baz2 (int &, int &) {}
189  void baz3 (int &, int &, int &) {}
190  void baz4 (int &, int &, int &, int &) {}
191  void baz5 (int &, int &, int &, int &, int &) {}
192  void cbaz1 (const int &) {}
193  void cbaz2 (const int &, const int &) {}
194  void cbaz3 (const int &, const int &, const int &) {}
195  void cbaz4 (const int &, const int &, const int &, const int &) {}
196  void cbaz5 (const int &, const int &, const int &, const int &, const int &) {}
197 
198  void bar0c (void) const {}
199  void bar1c (int) const {}
200  void bar2c (int, int) const {}
201  void bar3c (int, int, int) const {}
202  void bar4c (int, int, int, int) const {}
203  void bar5c (int, int, int, int, int) const {}
204  void baz1c (int &) const {}
205  void baz2c (int &, int &) const {}
206  void baz3c (int &, int &, int &) const {}
207  void baz4c (int &, int &, int &, int &) const {}
208  void baz5c (int &, int &, int &, int &, int &) const {}
209  void cbaz1c (const int &) const {}
210  void cbaz2c (const int &, const int &) const {}
211  void cbaz3c (const int &, const int &, const int &) const {}
212  void cbaz4c (const int &, const int &, const int &, const int &) const {}
213  void cbaz5c (const int &, const int &, const int &, const int &, const int &) const {}
214 
215 };
216 
217 static void foo0 (void)
218 {}
219 static void foo1 (int)
220 {}
221 static void foo2 (int, int)
222 {}
223 static void foo3 (int, int, int)
224 {}
225 static void foo4 (int, int, int, int)
226 {}
227 static void foo5 (int, int, int, int, int)
228 {}
229 static void ber1 (int &)
230 {}
231 static void ber2 (int &, int &)
232 {}
233 static void ber3 (int &, int &, int &)
234 {}
235 static void ber4 (int &, int &, int &, int &)
236 {}
237 static void ber5 (int &, int &, int &, int &, int &)
238 {}
239 static void cber1 (const int &)
240 {}
241 static void cber2 (const int &, const int &)
242 {}
243 static void cber3 (const int &, const int &, const int &)
244 {}
245 static void cber4 (const int &, const int &, const int &, const int &)
246 {}
247 static void cber5 (const int &, const int &, const int &, const int &, const int &)
248 {}
249 
251  : TestCase ("Check that all templates are instanciated correctly. This is a compilation test, it cannot fail at runtime.")
252 {
253 }
254 void
256 {
257  // Test schedule of const methods
258  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar0c, this);
259  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar1c, this, 0);
260  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar2c, this, 0, 0);
261  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar3c, this, 0, 0, 0);
262  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar4c, this, 0, 0, 0, 0);
263  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar5c, this, 0, 0, 0, 0, 0);
264  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz1c, this, 0);
265  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz2c, this, 0, 0);
266  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz3c, this, 0, 0, 0);
267  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz4c, this, 0, 0, 0, 0);
268  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz5c, this, 0, 0, 0, 0, 0);
269  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar0c, this);
270  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar1c, this, 0);
271  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar2c, this, 0, 0);
272  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar3c, this, 0, 0, 0);
273  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar4c, this, 0, 0, 0, 0);
274  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar5c, this, 0, 0, 0, 0, 0);
275  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz1c, this, 0);
276  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz2c, this, 0, 0);
277  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz3c, this, 0, 0, 0);
278  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz4c, this, 0, 0, 0, 0);
279  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz5c, this, 0, 0, 0, 0, 0);
280  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar0c, this);
281  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar1c, this, 0);
282  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar2c, this, 0, 0);
283  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar3c, this, 0, 0, 0);
284  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar4c, this, 0, 0, 0, 0);
285  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar5c, this, 0, 0, 0, 0, 0);
286  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz1c, this, 0);
287  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz2c, this, 0, 0);
288  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz3c, this, 0, 0, 0);
289  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz4c, this, 0, 0, 0, 0);
290  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz5c, this, 0, 0, 0, 0, 0);
291  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz1c, this, 0);
292  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz2c, this, 0, 0);
293  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz3c, this, 0, 0, 0);
294  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz4c, this, 0, 0, 0, 0);
295  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz5c, this, 0, 0, 0, 0, 0);
296  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz1c, this, 0);
297  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz2c, this, 0, 0);
298  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz3c, this, 0, 0, 0);
299  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz4c, this, 0, 0, 0, 0);
300  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz5c, this, 0, 0, 0, 0, 0);
301  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz1c, this, 0);
302  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz2c, this, 0, 0);
303  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz3c, this, 0, 0, 0);
304  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz4c, this, 0, 0, 0, 0);
305  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz5c, this, 0, 0, 0, 0, 0);
306 
307  // Test of schedule const methods with Ptr<> pointers
308  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar0c, Ptr<const SimulatorTemplateTestCase> (this));
309  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar1c, Ptr<const SimulatorTemplateTestCase> (this), 0);
310  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar2c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0);
311  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar3c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0);
312  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar4c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0, 0);
313  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar5c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0, 0, 0);
315  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar1c, Ptr<const SimulatorTemplateTestCase> (this), 0);
316  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar2c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0);
317  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar3c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0);
318  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar4c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0, 0);
319  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar5c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0, 0, 0);
320  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar0c, Ptr<const SimulatorTemplateTestCase> (this));
321  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar1c, Ptr<const SimulatorTemplateTestCase> (this), 0);
322  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar2c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0);
323  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar3c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0);
324  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar4c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0, 0);
325  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar5c, Ptr<const SimulatorTemplateTestCase> (this), 0, 0, 0, 0, 0);
326 
327 
328  // Test schedule of raw functions
329  Simulator::Schedule (Seconds (0.0), &foo0);
330  Simulator::Schedule (Seconds (0.0), &foo1, 0);
331  Simulator::Schedule (Seconds (0.0), &foo2, 0, 0);
332  Simulator::Schedule (Seconds (0.0), &foo3, 0, 0, 0);
333  Simulator::Schedule (Seconds (0.0), &foo4, 0, 0, 0, 0);
334  Simulator::Schedule (Seconds (0.0), &foo5, 0, 0, 0, 0, 0);
335  Simulator::Schedule (Seconds (0.0), &cber1, 0);
336  Simulator::Schedule (Seconds (0.0), &cber2, 0, 0);
337  Simulator::Schedule (Seconds (0.0), &cber3, 0, 0, 0);
338  Simulator::Schedule (Seconds (0.0), &cber4, 0, 0, 0, 0);
339  Simulator::Schedule (Seconds (0.0), &cber5, 0, 0, 0, 0, 0);
340  Simulator::ScheduleNow (&foo0);
341  Simulator::ScheduleNow (&foo1, 0);
342  Simulator::ScheduleNow (&foo2, 0, 0);
343  Simulator::ScheduleNow (&foo3, 0, 0, 0);
344  Simulator::ScheduleNow (&foo4, 0, 0, 0, 0);
345  Simulator::ScheduleNow (&foo5, 0, 0, 0, 0, 0);
346  Simulator::ScheduleNow (&cber1, 0);
347  Simulator::ScheduleNow (&cber2, 0, 0);
348  Simulator::ScheduleNow (&cber3, 0, 0, 0);
349  Simulator::ScheduleNow (&cber4, 0, 0, 0, 0);
350  Simulator::ScheduleNow (&cber5, 0, 0, 0, 0, 0);
351  Simulator::ScheduleDestroy (&foo0);
352  Simulator::ScheduleDestroy (&foo1, 0);
353  Simulator::ScheduleDestroy (&foo2, 0, 0);
354  Simulator::ScheduleDestroy (&foo3, 0, 0, 0);
355  Simulator::ScheduleDestroy (&foo4, 0, 0, 0, 0);
356  Simulator::ScheduleDestroy (&foo5, 0, 0, 0, 0, 0);
357  Simulator::ScheduleDestroy (&cber1, 0);
358  Simulator::ScheduleDestroy (&cber2, 0, 0);
359  Simulator::ScheduleDestroy (&cber3, 0, 0, 0);
360  Simulator::ScheduleDestroy (&cber4, 0, 0, 0, 0);
361  Simulator::ScheduleDestroy (&cber5, 0, 0, 0, 0, 0);
362 
363 
364  // Test schedule of normal member methods
365  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar0, this);
366  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar1, this, 0);
367  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar2, this, 0, 0);
368  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar3, this, 0, 0, 0);
369  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar4, this, 0, 0, 0, 0);
370  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar5, this, 0, 0, 0, 0, 0);
371  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz1, this, 0);
372  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz2, this, 0, 0);
373  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz3, this, 0, 0, 0);
374  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz4, this, 0, 0, 0, 0);
375  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::cbaz5, this, 0, 0, 0, 0, 0);
376  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar0, this);
377  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar1, this, 0);
378  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar2, this, 0, 0);
379  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar3, this, 0, 0, 0);
380  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar4, this, 0, 0, 0, 0);
381  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar5, this, 0, 0, 0, 0, 0);
382  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz1, this, 0);
383  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz2, this, 0, 0);
384  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz3, this, 0, 0, 0);
385  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz4, this, 0, 0, 0, 0);
386  Simulator::ScheduleNow (&SimulatorTemplateTestCase::cbaz5, this, 0, 0, 0, 0, 0);
387  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar0, this);
388  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar1, this, 0);
389  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar2, this, 0, 0);
390  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar3, this, 0, 0, 0);
391  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar4, this, 0, 0, 0, 0);
392  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar5, this, 0, 0, 0, 0, 0);
393  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz1, this, 0);
394  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz2, this, 0, 0);
395  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz3, this, 0, 0, 0);
396  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz4, this, 0, 0, 0, 0);
397  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::cbaz5, this, 0, 0, 0, 0, 0);
398 
399 
400  // test schedule of normal methods with Ptr<> pointers
401  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar0, Ptr<SimulatorTemplateTestCase> (this));
402  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar1, Ptr<SimulatorTemplateTestCase> (this), 0);
403  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar2, Ptr<SimulatorTemplateTestCase> (this), 0, 0);
404  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar3, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0);
405  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar4, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0, 0);
406  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::bar5, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0, 0, 0);
407  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar0, Ptr<SimulatorTemplateTestCase> (this));
408  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar1, Ptr<SimulatorTemplateTestCase> (this), 0);
409  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar2, Ptr<SimulatorTemplateTestCase> (this), 0, 0);
410  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar3, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0);
411  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar4, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0, 0);
412  Simulator::ScheduleNow (&SimulatorTemplateTestCase::bar5, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0, 0, 0);
413  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar0, Ptr<SimulatorTemplateTestCase> (this));
414  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar1, Ptr<SimulatorTemplateTestCase> (this), 0);
415  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar2, Ptr<SimulatorTemplateTestCase> (this), 0, 0);
416  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar3, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0);
417  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar4, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0, 0);
418  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::bar5, Ptr<SimulatorTemplateTestCase> (this), 0, 0, 0, 0, 0);
419 
420 
421  // the code below does not compile, as expected.
422  //Simulator::Schedule (Seconds (0.0), &cber1, 0.0);
423 
424 
425  // This code appears to be duplicate test code.
426  Simulator::Schedule (Seconds (0.0), &ber1, 0);
427  Simulator::Schedule (Seconds (0.0), &ber2, 0, 0);
428  Simulator::Schedule (Seconds (0.0), &ber3, 0, 0, 0);
429  Simulator::Schedule (Seconds (0.0), &ber4, 0, 0, 0, 0);
430  Simulator::Schedule (Seconds (0.0), &ber5, 0, 0, 0, 0, 0);
431  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz1, this, 0);
432  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz2, this, 0, 0);
433  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz3, this, 0, 0, 0);
434  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz4, this, 0, 0, 0, 0);
435  Simulator::Schedule (Seconds (0.0), &SimulatorTemplateTestCase::baz5, this, 0, 0, 0, 0, 0);
436  Simulator::ScheduleNow (&ber1, 0);
437  Simulator::ScheduleNow (&ber2, 0, 0);
438  Simulator::ScheduleNow (&ber3, 0, 0, 0);
439  Simulator::ScheduleNow (&ber4, 0, 0, 0, 0);
440  Simulator::ScheduleNow (&ber5, 0, 0, 0, 0, 0);
441  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz1, this, 0);
442  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz2, this, 0, 0);
443  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz3, this, 0, 0, 0);
444  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz4, this, 0, 0, 0, 0);
445  Simulator::ScheduleNow (&SimulatorTemplateTestCase::baz5, this, 0, 0, 0, 0, 0);
446  Simulator::ScheduleDestroy (&ber1, 0);
447  Simulator::ScheduleDestroy (&ber2, 0, 0);
448  Simulator::ScheduleDestroy (&ber3, 0, 0, 0);
449  Simulator::ScheduleDestroy (&ber4, 0, 0, 0, 0);
450  Simulator::ScheduleDestroy (&ber5, 0, 0, 0, 0, 0);
451  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz1, this, 0);
452  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz2, this, 0, 0);
453  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz3, this, 0, 0, 0);
454  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz4, this, 0, 0, 0, 0);
455  Simulator::ScheduleDestroy (&SimulatorTemplateTestCase::baz5, this, 0, 0, 0, 0, 0);
456 
457 
458  Simulator::Run ();
459  Simulator::Destroy ();
460 }
461 
463 {
464 public:
466  : TestSuite ("simulator")
467  {
468  ObjectFactory factory;
469  factory.SetTypeId (ListScheduler::GetTypeId ());
470 
471  AddTestCase (new SimulatorEventsTestCase (factory), TestCase::QUICK);
472  factory.SetTypeId (MapScheduler::GetTypeId ());
473  AddTestCase (new SimulatorEventsTestCase (factory), TestCase::QUICK);
474  factory.SetTypeId (HeapScheduler::GetTypeId ());
475  AddTestCase (new SimulatorEventsTestCase (factory), TestCase::QUICK);
476  factory.SetTypeId (CalendarScheduler::GetTypeId ());
477  AddTestCase (new SimulatorEventsTestCase (factory), TestCase::QUICK);
478  }
static void ber5(int &, int &, int &, int &, int &)
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
static void cber4(const int &, const int &, const int &, const int &)
void bar4(int, int, int, int)
static void ber4(int &, int &, int &, int &)
void bar3c(int, int, int) const
void baz3(int &, int &, int &)
static void foo5(int, int, int, int, int)
A suite of tests to run.
Definition: test.h:1105
static void cber5(const int &, const int &, const int &, const int &, const int &)
void baz5(int &, int &, int &, int &, int &)
void SetTypeId(TypeId tid)
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:265
void baz3c(int &, int &, int &) const
SimulatorEventsTestCase(ObjectFactory schedulerFactory)
encapsulates test code
Definition: test.h:929
void cbaz5c(const int &, const int &, const int &, const int &, const int &) const
static void foo0(void)
virtual void DoRun(void)
Implementation to actually run this TestCase.
static void ber3(int &, int &, int &)
static void foo3(int, int, int)
void bar5c(int, int, int, int, int) const
void bar4c(int, int, int, int) const
void cbaz5(const int &, const int &, const int &, const int &, const int &)
static void foo1(int)
static void ber1(int &)
void baz4c(int &, int &, int &, int &) const
void baz4(int &, int &, int &, int &)
void cbaz1c(const int &) const
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:184
virtual void DoRun(void)
Implementation to actually run this TestCase.
void baz2c(int &, int &) const
static void cber3(const int &, const int &, const int &)
void bar5(int, int, int, int, int)
int64_t GetNanoSeconds(void) const
Definition: nstime.h:297
SimulatorTestSuite g_simulatorTestSuite
instantiate subclasses of ns3::Object.
void baz5c(int &, int &, int &, int &, int &) const
static void cber1(const int &)
void cbaz2c(const int &, const int &) const
void cbaz4c(const int &, const int &, const int &, const int &) const
an identifier for simulation events.
Definition: event-id.h:46
void cbaz4(const int &, const int &, const int &, const int &)
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
void cbaz3c(const int &, const int &, const int &) const
static void ber2(int &, int &)
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
Definition: event-id.cc:47
static void foo2(int, int)
static void cber2(const int &, const int &)
void cbaz3(const int &, const int &, const int &)
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::isExpired method.
Definition: event-id.cc:53
void cbaz2(const int &, const int &)
static void foo4(int, int, int, int)