View | Details | Raw Unified | Return to bug 1982
Collapse All | Expand All

(-)a/src/stats/test/double-probe-test-suite.cc (-5 / +7 lines)
 Lines 56-62    Link Here 
56
  double aux;
56
  double aux;
57
};
57
};
58
58
59
Ptr<SampleEmitter> s = CreateObject<SampleEmitter> ();
60
59
61
TypeId
60
TypeId
62
SampleEmitter::GetTypeId (void)
61
SampleEmitter::GetTypeId (void)
 Lines 81-86    Link Here 
81
  void TraceSink (std::string context, double oldValue, double newValue);
80
  void TraceSink (std::string context, double oldValue, double newValue);
82
  uint32_t m_objectProbed;
81
  uint32_t m_objectProbed;
83
  uint32_t m_pathProbed;
82
  uint32_t m_pathProbed;
83
  Ptr<SampleEmitter> m_s;
84
};
84
};
85
85
86
ProbeTestCase1::ProbeTestCase1 ()
86
ProbeTestCase1::ProbeTestCase1 ()
 Lines 100-106    Link Here 
100
  NS_TEST_ASSERT_MSG_GT (Simulator::Now (), Seconds (100), "Probed a value outside of the time window");
100
  NS_TEST_ASSERT_MSG_GT (Simulator::Now (), Seconds (100), "Probed a value outside of the time window");
101
  NS_TEST_ASSERT_MSG_LT (Simulator::Now (), Seconds (200), "Probed a value outside of the time window");
101
  NS_TEST_ASSERT_MSG_LT (Simulator::Now (), Seconds (200), "Probed a value outside of the time window");
102
102
103
  NS_TEST_ASSERT_MSG_EQ_TOL (s->GetValue (), newValue, 0.00001, "Value probed different than value in the variable");
103
  NS_TEST_ASSERT_MSG_EQ_TOL (m_s->GetValue (), newValue, 0.00001, "Value probed different than value in the variable");
104
104
105
  if (context == "testProbe")
105
  if (context == "testProbe")
106
    {
106
    {
 Lines 115-137    Link Here 
115
void
115
void
116
ProbeTestCase1::DoRun (void)
116
ProbeTestCase1::DoRun (void)
117
{
117
{
118
  // Defer creation of this until here because it is a random variable
119
  m_s = CreateObject<SampleEmitter> ();
118
  // Test that all instances of probe data are between time window specified
120
  // Test that all instances of probe data are between time window specified
119
  // Check also that probes can be hooked to sources by Object and by path
121
  // Check also that probes can be hooked to sources by Object and by path
120
122
121
  Ptr<DoubleProbe> p = CreateObject<DoubleProbe> ();
123
  Ptr<DoubleProbe> p = CreateObject<DoubleProbe> ();
122
  p->SetName ("testProbe");
124
  p->SetName ("testProbe");
123
125
124
  Simulator::Schedule (Seconds (1), &SampleEmitter::Start, s);
126
  Simulator::Schedule (Seconds (1), &SampleEmitter::Start, m_s);
125
  p->SetAttribute ("Start", TimeValue (Seconds (100.0)));
127
  p->SetAttribute ("Start", TimeValue (Seconds (100.0)));
126
  p->SetAttribute ("Stop", TimeValue (Seconds (200.0)));
128
  p->SetAttribute ("Stop", TimeValue (Seconds (200.0)));
127
  Simulator::Stop (Seconds (300));
129
  Simulator::Stop (Seconds (300));
128
130
129
  // Register our emitter object so we can fetch it by using the Config
131
  // Register our emitter object so we can fetch it by using the Config
130
  // namespace
132
  // namespace
131
  Names::Add ("/Names/SampleEmitter", s);
133
  Names::Add ("/Names/SampleEmitter", m_s);
132
134
133
  // Hook probe to the emitter.
135
  // Hook probe to the emitter.
134
  p->ConnectByObject ("Emitter", s);
136
  p->ConnectByObject ("Emitter", m_s);
135
137
136
  // Hook our test function to the probe trace source
138
  // Hook our test function to the probe trace source
137
  p->TraceConnect ("Output", p->GetName (), MakeCallback (&ProbeTestCase1::TraceSink, this));
139
  p->TraceConnect ("Output", p->GetName (), MakeCallback (&ProbeTestCase1::TraceSink, this));

Return to bug 1982