A Discrete-Event Network Simulator
API
config-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) 2008 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  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #include "ns3/config.h"
21 #include "ns3/test.h"
22 #include "ns3/integer.h"
23 #include "ns3/traced-value.h"
24 #include "ns3/trace-source-accessor.h"
25 #include "ns3/callback.h"
26 
27 #include "ns3/singleton.h"
28 #include "ns3/object.h"
29 #include "ns3/object-vector.h"
30 #include "ns3/names.h"
31 #include "ns3/pointer.h"
32 #include "ns3/log.h"
33 #include "ns3/unused.h"
34 
35 
36 #include <sstream>
37 
51 namespace ns3 {
52 
53  namespace tests {
54 
55 
60 class ConfigTestObject : public Object
61 {
62 public:
67  static TypeId GetTypeId (void);
68 
79 
90 
95  int8_t GetA (void) const;
100  int8_t GetB (void) const;
101 
102 private:
103  std::vector<Ptr<ConfigTestObject> > m_nodesA;
104  std::vector<Ptr<ConfigTestObject> > m_nodesB;
107  int8_t m_a;
108  int8_t m_b;
110 };
111 
112 TypeId
114 {
115  static TypeId tid = TypeId ("ConfigTestObject")
116  .SetParent<Object> ()
117  .AddAttribute ("NodesA", "",
120  MakeObjectVectorChecker<ConfigTestObject> ())
121  .AddAttribute ("NodesB", "",
124  MakeObjectVectorChecker<ConfigTestObject> ())
125  .AddAttribute ("NodeA", "",
126  PointerValue (),
128  MakePointerChecker<ConfigTestObject> ())
129  .AddAttribute ("NodeB", "",
130  PointerValue (),
132  MakePointerChecker<ConfigTestObject> ())
133  .AddAttribute ("A", "",
134  IntegerValue (10),
136  MakeIntegerChecker<int8_t> ())
137  .AddAttribute ("B", "",
138  IntegerValue (9),
140  MakeIntegerChecker<int8_t> ())
141  .AddAttribute ("Source", "XX",
142  IntegerValue (-1),
144  MakeIntegerChecker<int16_t> ())
145  .AddTraceSource ("Source", "XX",
147  "ns3::TracedValueCallback::Int16")
148  ;
149  return tid;
150 }
151 
152 void
154 {
155  m_nodeA = a;
156 }
157 
158 void
160 {
161  m_nodeB = b;
162 }
163 
164 void
166 {
167  m_nodesA.push_back (a);
168 }
169 
170 void
172 {
173  m_nodesB.push_back (b);
174 }
175 
176 int8_t
178 {
179  return m_a;
180 }
181 
182 int8_t
184 {
185  return m_b;
186 }
187 
193 {
194 public:
199  static TypeId GetTypeId (void);
203  virtual ~DerivedConfigTestObject (void) {}
204 };
205 
206 TypeId
208 {
209  static TypeId tid = TypeId ("DerivedConfigTestObject")
211  ;
212  return tid;
213 }
214 
219 class BaseConfigObject : public Object
220 {
221 public:
226  static TypeId GetTypeId (void);
228  BaseConfigObject (void) : m_x(15) {}
230  virtual ~BaseConfigObject (void) {}
231 private:
232  int8_t m_x;
233 
234  void Increment (void) { m_x++; }
235 };
236 
237 TypeId
239 {
240  static TypeId tid = TypeId ("BaseConfigObject")
241  .SetParent<Object> ()
242  .AddAttribute ("X", "",
243  IntegerValue (10),
245  MakeIntegerChecker<int8_t> ())
246  ;
247  return tid;
248 }
249 
255 {
256 public:
261  static TypeId GetTypeId (void);
265  virtual ~DerivedConfigObject (void) {}
266 };
267 
268 TypeId
270 {
271  static TypeId tid = TypeId ("DerivedConfigObject")
273  ;
274  return tid;
275 }
276 
277 
283 {
284 public:
289 
290 private:
291  virtual void DoRun (void);
292 };
293 
295  : TestCase ("Check ability to register a root namespace and use it")
296 {
297 }
298 
299 void
301 {
302  IntegerValue iv;
303  //
304  // Create an object and register its attributes directly in the root
305  // namespace.
306  //
307  Ptr<ConfigTestObject> root = CreateObject<ConfigTestObject> ();
309 
310  //
311  // We should find the default values there.
312  //
313  root->GetAttribute ("A", iv);
314  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" not initialized as expected");
315 
316  //
317  // Now use the config mechanism to set the attribute; and we should find the
318  // new value.
319  //
320  Config::Set ("/A", IntegerValue (1));
321  root->GetAttribute ("A", iv);
322  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 1, "Object Attribute \"A\" not set correctly");
323 
324  //
325  // We should find the default values of "B" too.
326  //
327  root->GetAttribute ("B", iv);
328  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 9, "Object Attribute \"B\" not initialized as expected");
329 
330  //
331  // Now use the config mechanism to set the attribute; and we should find the
332  // new value.
333  //
334  Config::Set ("/B", IntegerValue (-1));
335  root->GetAttribute ("B", iv);
336  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -1, "Object Attribute \"B\" not set correctly");
337 }
338 
344 {
345 public:
350 
351 private:
352  virtual void DoRun (void);
353 };
354 
356  : TestCase ("Check ability to register an object under the root namespace and use it")
357 {
358 }
359 
360 void
362 {
363  IntegerValue iv;
364  //
365  // Create an object and register its attributes directly in the root
366  // namespace.
367  //
368  Ptr<ConfigTestObject> root = CreateObject<ConfigTestObject> ();
370 
371  Ptr<ConfigTestObject> a = CreateObject<ConfigTestObject> ();
372  root->SetNodeA (a);
373 
374  //
375  // We should find the default values there.
376  //
377  a->GetAttribute ("A", iv);
378  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" not initialized as expected");
379 
380  //
381  // Now use the config mechanism to set the attribute; and we should find the
382  // new value.
383  //
384  Config::Set ("/NodeA/A", IntegerValue (1));
385  a->GetAttribute ("A", iv);
386  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 1, "Object Attribute \"A\" not set correctly");
387 
388 
389  //
390  // We should find the default values of "B" too.
391  //
392  a->GetAttribute ("B", iv);
393  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 9, "Object Attribute \"B\" not initialized as expected");
394 
395  //
396  // Now use the config mechanism to set the attribute; and we should find the
397  // new value.
398  //
399  Config::Set ("/NodeA/B", IntegerValue (-1));
400  a->GetAttribute ("B", iv);
401  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -1, "Object Attribute \"B\" not set correctly");
402 
403  //
404  // Try and set through a nonexistent path. Should do nothing.
405  //
406  Config::Set ("/NodeB/A", IntegerValue (1234));
407  a->GetAttribute ("A", iv);
408  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 1, "Object Attribute \"A\" unexpectedly set via bad path");
409 
410  Config::Set ("/NodeB/B", IntegerValue (1234));
411  a->GetAttribute ("B", iv);
412  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -1, "Object Attribute \"B\" unexpectedly set via bad path");
413 
414  //
415  // Step down one level of recursion and try again
416  //
417  Ptr<ConfigTestObject> b = CreateObject<ConfigTestObject> ();
418 
419  //
420  // We should find the default values there.
421  //
422  b->GetAttribute ("A", iv);
423  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" not initialized as expected");
424  b->GetAttribute ("B", iv);
425  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 9, "Object Attribute \"B\" not initialized as expected");
426 
427  //
428  // Now tell A that it has a B; and we should be able to set this new object's
429  // Attributes.
430  //
431  a->SetNodeB (b);
432 
433  Config::Set ("/NodeA/NodeB/A", IntegerValue (4));
434  Config::Set ("/NodeA/NodeB/B", IntegerValue (-4));
435  b->GetAttribute ("A", iv);
436  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 4, "Object Attribute \"A\" not set as expected");
437  b->GetAttribute ("B", iv);
438  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -4, "Object Attribute \"B\" not set as expected");
439 
440 
441  //
442  // Try '*' for attributes
443  //
444  Config::Set ("/*/A", IntegerValue (2));
445  a->GetAttribute ("A", iv);
446  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 2, "Object Attribute \"A\" not set correctly");
447  b->GetAttribute ("A", iv);
448  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 4, "Object Attribute \"A\" not set correctly");
449 }
450 
456 {
457 public:
462 
463 private:
464  virtual void DoRun (void);
465 };
466 
468  : TestCase ("Check ability to configure vectors of Object using regular expressions")
469 {
470 }
471 
472 void
474 {
475  IntegerValue iv;
476 
477  //
478  // Create a root namespace object
479  //
480  Ptr<ConfigTestObject> root = CreateObject<ConfigTestObject> ();
482 
483  //
484  // Create an object under the root.
485  //
486  Ptr<ConfigTestObject> a = CreateObject<ConfigTestObject> ();
487  root->SetNodeA (a);
488 
489  //
490  // Create an object one level down.
491  //
492  Ptr<ConfigTestObject> b = CreateObject<ConfigTestObject> ();
493  a->SetNodeB (b);
494 
495  //
496  // Add four objects to the ObjectVector Attribute at the bottom of the
497  // object hierarchy. By this point, we believe that the Attributes
498  // will be initialized correctly.
499  //
500  Ptr<ConfigTestObject> obj0 = CreateObject<ConfigTestObject> ();
501  Ptr<ConfigTestObject> obj1 = CreateObject<ConfigTestObject> ();
502  Ptr<ConfigTestObject> obj2 = CreateObject<ConfigTestObject> ();
503  Ptr<ConfigTestObject> obj3 = CreateObject<ConfigTestObject> ();
504  b->AddNodeB (obj0);
505  b->AddNodeB (obj1);
506  b->AddNodeB (obj2);
507  b->AddNodeB (obj3);
508 
509  //
510  // Set an Attribute of the zeroth Object in the vector by explicitly writing
511  // the '0' and make sure that only the one thing changed.
512  //
513  Config::Set ("/NodeA/NodeB/NodesB/0/A", IntegerValue (-11));
514  obj0->GetAttribute ("A", iv);
515  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -11, "Object Attribute \"A\" not set as expected");
516 
517  obj1->GetAttribute ("A", iv);
518  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
519 
520  obj2->GetAttribute ("A", iv);
521  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
522 
523  obj3->GetAttribute ("A", iv);
524  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
525 
526  //
527  // Start using regular expression-like syntax to set Attributes. First try
528  // the OR syntax. Make sure that the two objects changed and nothing else
529  //
530  Config::Set ("/NodeA/NodeB/NodesB/0|1/A", IntegerValue (-12));
531  obj0->GetAttribute ("A", iv);
532  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -12, "Object Attribute \"A\" not set as expected");
533 
534  obj1->GetAttribute ("A", iv);
535  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -12, "Object Attribute \"A\" not set as expected");
536 
537  obj2->GetAttribute ("A", iv);
538  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
539 
540  obj3->GetAttribute ("A", iv);
541  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
542 
543  //
544  // Make sure that extra '|' are allowed at the start and end of the regular expression
545  //
546  Config::Set ("/NodeA/NodeB/NodesB/|0|1|/A", IntegerValue (-13));
547  obj0->GetAttribute ("A", iv);
548  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -13, "Object Attribute \"A\" not set as expected");
549 
550  obj1->GetAttribute ("A", iv);
551  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -13, "Object Attribute \"A\" not set as expected");
552 
553  obj2->GetAttribute ("A", iv);
554  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
555 
556  obj3->GetAttribute ("A", iv);
557  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
558 
559  //
560  // Try the [x-y] syntax
561  //
562  Config::Set ("/NodeA/NodeB/NodesB/[0-2]/A", IntegerValue (-14));
563  obj0->GetAttribute ("A", iv);
564  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, "Object Attribute \"A\" not set as expected");
565 
566  obj1->GetAttribute ("A", iv);
567  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, "Object Attribute \"A\" not set as expected");
568 
569  obj2->GetAttribute ("A", iv);
570  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, "Object Attribute \"A\" not set as expected");
571 
572  obj3->GetAttribute ("A", iv);
573  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 10, "Object Attribute \"A\" unexpectedly set");
574 
575  //
576  // Try the [x-y] syntax at the other limit
577  //
578  Config::Set ("/NodeA/NodeB/NodesB/[1-3]/A", IntegerValue (-15));
579  obj0->GetAttribute ("A", iv);
580  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -14, "Object Attribute \"A\" unexpectedly set");
581 
582  obj1->GetAttribute ("A", iv);
583  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, "Object Attribute \"A\" not set as expected");
584 
585  obj2->GetAttribute ("A", iv);
586  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, "Object Attribute \"A\" not set as expected");
587 
588  obj3->GetAttribute ("A", iv);
589  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, "Object Attribute \"A\" not set as expected");
590 
591  //
592  // Combine the [x-y] syntax and the OR sntax
593  //
594  Config::Set ("/NodeA/NodeB/NodesB/[0-1]|3/A", IntegerValue (-16));
595  obj0->GetAttribute ("A", iv);
596  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -16, "Object Attribute \"A\" not set as expected");
597 
598  obj1->GetAttribute ("A", iv);
599  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -16, "Object Attribute \"A\" not set as expected");
600 
601  obj2->GetAttribute ("A", iv);
602  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -15, "Object Attribute \"A\" unexpectedly set");
603 
604  obj3->GetAttribute ("A", iv);
605  NS_TEST_ASSERT_MSG_EQ (iv.Get (), -16, "Object Attribute \"A\" not set as expected");
606 }
607 
613 {
614 public:
619 
625  void Trace (int16_t oldValue, int16_t newValue)
626  {
627  NS_UNUSED (oldValue);
628  m_newValue = newValue;
629  }
636  void TraceWithPath (std::string path, int16_t old, int16_t newValue)
637  {
638  NS_UNUSED (old);
639  m_newValue = newValue;
640  m_path = path;
641  }
642 
643 private:
644  virtual void DoRun (void);
645 
646  int16_t m_newValue;
647  std::string m_path;
648 };
649 
651  : TestCase ("Check ability to trace connect through vectors of Object using regular expressions")
652 {
653 }
654 
655 void
657 {
658  IntegerValue iv;
659 
660  //
661  // Create a root namespace object
662  //
663  Ptr<ConfigTestObject> root = CreateObject<ConfigTestObject> ();
665 
666  //
667  // Create an object under the root.
668  //
669  Ptr<ConfigTestObject> a = CreateObject<ConfigTestObject> ();
670  root->SetNodeA (a);
671 
672  //
673  // Create an object one level down.
674  //
675  Ptr<ConfigTestObject> b = CreateObject<ConfigTestObject> ();
676  a->SetNodeB (b);
677 
678  //
679  // Add four objects to the ObjectVector Attribute at the bottom of the
680  // object hierarchy. By this point, we believe that the Attributes
681  // will be initialized correctly.
682  //
683  Ptr<ConfigTestObject> obj0 = CreateObject<ConfigTestObject> ();
684  Ptr<ConfigTestObject> obj1 = CreateObject<ConfigTestObject> ();
685  Ptr<ConfigTestObject> obj2 = CreateObject<ConfigTestObject> ();
686  Ptr<ConfigTestObject> obj3 = CreateObject<ConfigTestObject> ();
687  b->AddNodeB (obj0);
688  b->AddNodeB (obj1);
689  b->AddNodeB (obj2);
690  b->AddNodeB (obj3);
691 
692  //
693  // Do a trace connect to some of the sources. We already checked parsing of
694  // the regular expressions, so we'll concentrate on the tracing part of the
695  // puzzle here.
696  //
697  Config::ConnectWithoutContext ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
699 
700  //
701  // If we bug the trace source referred to by index '0' above, we should see
702  // the trace fire.
703  //
704  m_newValue = 0;
705  obj0->SetAttribute ("Source", IntegerValue (-1));
706  NS_TEST_ASSERT_MSG_EQ (m_newValue, -1, "Trace 0 did not fire as expected");
707 
708  //
709  // If we bug the trace source referred to by index '1' above, we should see
710  // the trace fire.
711  //
712  m_newValue = 0;
713  obj1->SetAttribute ("Source", IntegerValue (-2));
714  NS_TEST_ASSERT_MSG_EQ (m_newValue, -2, "Trace 1 did not fire as expected");
715 
716  //
717  // If we bug the trace source referred to by index '2' which is skipped above,
718  // we should not see the trace fire.
719  //
720  m_newValue = 0;
721  obj2->SetAttribute ("Source", IntegerValue (-3));
722  NS_TEST_ASSERT_MSG_EQ (m_newValue, 0, "Trace 2 fired unexpectedly");
723 
724  //
725  // If we bug the trace source referred to by index '3' above, we should see
726  // the trace fire.
727  //
728  m_newValue = 0;
729  obj3->SetAttribute ("Source", IntegerValue (-4));
730  NS_TEST_ASSERT_MSG_EQ (m_newValue, -4, "Trace 3 did not fire as expected");
731 
732  //
733  // Do a trace connect (with context) to some of the sources.
734  //
735  Config::Connect ("/NodeA/NodeB/NodesB/[0-1]|3/Source",
737 
738  //
739  // If we bug the trace source referred to by index '0' above, we should see
740  // the trace fire with the expected context path.
741  //
742  m_newValue = 0;
743  m_path = "";
744  obj0->SetAttribute ("Source", IntegerValue (-1));
745  NS_TEST_ASSERT_MSG_EQ (m_newValue, -1, "Trace 0 did not fire as expected");
746  NS_TEST_ASSERT_MSG_EQ (m_path, "/NodeA/NodeB/NodesB/0/Source", "Trace 0 did not provide expected context");
747 
748  //
749  // If we bug the trace source referred to by index '1' above, we should see
750  // the trace fire with the expected context path.
751  //
752  m_newValue = 0;
753  m_path = "";
754  obj1->SetAttribute ("Source", IntegerValue (-2));
755  NS_TEST_ASSERT_MSG_EQ (m_newValue, -2, "Trace 1 did not fire as expected");
756  NS_TEST_ASSERT_MSG_EQ (m_path, "/NodeA/NodeB/NodesB/1/Source", "Trace 1 did not provide expected context");
757 
758  //
759  // If we bug the trace source referred to by index '2' which is skipped above,
760  // we should not see the trace fire.
761  //
762  m_newValue = 0;
763  m_path = "";
764  obj2->SetAttribute ("Source", IntegerValue (-3));
765  NS_TEST_ASSERT_MSG_EQ (m_newValue, 0, "Trace 2 fired unexpectedly");
766 
767  //
768  // If we bug the trace source referred to by index '3' above, we should see
769  // the trace fire with the expected context path.
770  //
771  m_newValue = 0;
772  m_path = "";
773  obj3->SetAttribute ("Source", IntegerValue (-4));
774  NS_TEST_ASSERT_MSG_EQ (m_newValue, -4, "Trace 3 did not fire as expected");
775  NS_TEST_ASSERT_MSG_EQ (m_path, "/NodeA/NodeB/NodesB/1/Source", "Trace 1 did not provide expected context");
776 }
777 
787 {
788 public:
793 
794 private:
795  virtual void DoRun (void);
796 
797 };
798 
800  : TestCase ("Check that attributes of base class are searchable from paths including objects of derived class")
801 {
802 }
803 
804 void
806 {
807  IntegerValue iv;
808  //
809  // Create a root namespace object that doesn't have attributes but
810  // whose parent class has 'NodeA' attribute
811  //
812  Ptr<DerivedConfigTestObject> root = CreateObject<DerivedConfigTestObject> ();
814 
815  //
816  // Instantiate /NodeA
817  //
818  Ptr<DerivedConfigTestObject> a = CreateObject<DerivedConfigTestObject> ();
819  root->SetNodeA (a);
820 
821  //
822  // BaseConfigObject has attribute X, but we aggregate DerivedConfigObject
823  // instead
824  //
825  Ptr<DerivedConfigObject> derived = CreateObject<DerivedConfigObject> ();
826  a->AggregateObject (derived);
827  Config::Set ("/NodeA/$DerivedConfigObject/X", IntegerValue (42));
828  derived->GetAttribute ("X", iv);
829  NS_TEST_ASSERT_MSG_EQ (iv.Get (), 42, "Object Attribute \"X\" not settable in derived class");
830 
831 }
832 
838 {
839 public:
841  ConfigTestSuite ();
842 };
843 
845  : TestSuite ("config")
846 {
851 }
852 
858 
859 
860  } // namespace tests
861 
862 } // namespace ns3
863 
static TypeId GetTypeId(void)
Get the type ID.
static TypeId GetTypeId(void)
Get the type ID.
void TraceWithPath(std::string path, int16_t old, int16_t newValue)
Trace callback with context path.
Test for the ability to register and use a root namespace.
void AddNodeA(Ptr< ConfigTestObject > a)
Add node A function.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
BaseConfigObject(void)
Constructor.
virtual ~BaseConfigObject(void)
Destructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~RootNamespaceConfigTestCase()
Destructor.
static TypeId GetTypeId(void)
Get the type ID.
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:777
A suite of tests to run.
Definition: test.h:1342
static TypeId GetTypeId(void)
Get the type ID.
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Definition: object-vector.h:81
static ConfigTestSuite g_configTestSuite
ConfigTestSuite instance variable.
Hold a signed integer type.
Definition: integer.h:44
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
void SetNodeA(Ptr< ConfigTestObject > a)
Set node A function.
Test for the ability to search attributes of parent classes when Resolver searches for attributes in ...
Test for the ability to trace configure with vectors of objects.
encapsulates test code
Definition: test.h:1155
virtual ~ObjectVectorConfigTestCase()
Destructor.
void RegisterRootNamespaceObject(Ptr< Object > obj)
Definition: config.cc:860
Ptr< ConfigTestObject > m_nodeB
NodeB attribute target.
virtual void DoRun(void)
Implementation to actually run this TestCase.
int8_t GetA(void) const
Get node A function.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
int8_t m_a
A attribute target.
The Test Suite that glues all of the Test Cases together.
Test for the ability to add an object under the root namespace.
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: integer.h:45
int64_t Get(void) const
Definition: integer.cc:35
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: pointer.h:220
virtual void DoRun(void)
Implementation to actually run this TestCase.
std::vector< Ptr< ConfigTestObject > > m_nodesA
NodesA attribute target.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
Ptr< ConfigTestObject > m_nodeA
NodeA attribute target.
TracedValue< int16_t > m_trace
Source TraceSource target.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition: test.h:168
void SetNodeB(Ptr< ConfigTestObject > b)
Set node b function.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:832
virtual ~DerivedConfigObject(void)
Destructor.
void AddNodeB(Ptr< ConfigTestObject > b)
Add node B function.
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:843
An object with some attributes that we can play with using config.
void Increment(void)
Silence unused variable warning.
int8_t m_b
B attribute target.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr<T>.
Definition: pointer.h:36
std::vector< Ptr< ConfigTestObject > > m_nodesB
NodesB attribute target.
int8_t GetB(void) const
Get node b function.
int8_t m_x
X attribute target.
int16_t m_newValue
Flag to detect tracing result.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~DerivedConfigTestObject(void)
Destructor.
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual void DoRun(void)
Implementation to actually run this TestCase.
Container for a set of ns3::Object pointers.
Test for the ability to deal configure with vectors of objects.
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
void Trace(int16_t oldValue, int16_t newValue)
Trace callback without context.