Bug 606 testcase. Now routing-aodv-regression should crash until bug will be fixed.
authorPavel Boyko <boyko@iitp.ru>
Fri, 11 Dec 2009 11:19:49 +0300
changeset 5847 e6a70e535416
parent 5846 f7a4e1b3f632
child 5848 ee2c83ed68cf
Bug 606 testcase. Now routing-aodv-regression should crash until bug will be fixed.
examples/routing/aodv.cc
src/routing/aodv/test/aodv-regression.cc
src/routing/aodv/test/aodv-regression.h
--- a/examples/routing/aodv.cc	Thu Dec 10 12:42:20 2009 +0100
+++ b/examples/routing/aodv.cc	Fri Dec 11 11:19:49 2009 +0300
@@ -204,8 +204,8 @@
   
   ApplicationContainer p = ping.Install (nodes.Get (0));
   p.Start (Seconds (0));
-  p.Stop (Seconds (totalTime));
-
+  p.Stop (Seconds (totalTime) - Seconds(0.001));
+  
   // move node away
   Ptr<Node> node = nodes.Get (size/2);
   Ptr<MobilityModel> mob = node->GetObject<MobilityModel> ();
--- a/src/routing/aodv/test/aodv-regression.cc	Thu Dec 10 12:42:20 2009 +0100
+++ b/src/routing/aodv/test/aodv-regression.cc	Fri Dec 11 11:19:49 2009 +0300
@@ -38,6 +38,7 @@
 #include "ns3/aodv-helper.h"
 #include "ns3/v4ping-helper.h"
 #include "ns3/nqos-wifi-mac-helper.h"
+#include "ns3/config.h"
 #include <sstream>
 
 /// Set to true to rewrite reference traces, leave false to run regression tests
@@ -53,7 +54,10 @@
 public:
   AodvRegressionTestSuite () : TestSuite ("routing-aodv-regression", SYSTEM) 
   {
-    AddTestCase (new ChainRegressionTest);
+    // General RREQ-RREP-RRER test case
+    AddTestCase (new ChainRegressionTest ("aodv-chain-regression-test"));
+    // Bug 606 test case, should crash if bug is not fixed
+    AddTestCase (new ChainRegressionTest ("bug-606-test", Seconds (10), 3, Seconds (1)));
   }
 } g_aodvRegressionTestSuite;
  
@@ -61,14 +65,14 @@
 //-----------------------------------------------------------------------------
 // ChainRegressionTest
 //-----------------------------------------------------------------------------
-/// Unique PCAP files prefix for this test
-const char * const ChainRegressionTest::PREFIX = "aodv-chain-regression-test";
-
-ChainRegressionTest::ChainRegressionTest () : TestCase ("AODV chain regression test"),
+ChainRegressionTest::ChainRegressionTest (const char * const prefix, Time t, uint32_t size, Time arpAliveTimeout) : 
+  TestCase ("AODV chain regression test"),
   m_nodes (0),
-  m_time (Seconds (10)),
-  m_size (5),
-  m_step (120)
+  m_prefix (prefix),
+  m_time (t),
+  m_size (size),
+  m_step (120),
+  m_arpAliveTimeout (arpAliveTimeout)
 {
 }
 
@@ -81,6 +85,8 @@
 ChainRegressionTest::DoRun ()
 {
   SeedManager::SetSeed(12345);
+  Config::SetDefault ("ns3::ArpCache::AliveTimeout", TimeValue (m_arpAliveTimeout));
+  
   CreateNodes ();
   CreateDevices ();
   
@@ -146,7 +152,7 @@
   p.Stop (m_time);
   
   // 4. write PCAP
-  std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : GetTempDir ()) + PREFIX;
+  std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : GetTempDir ()) + m_prefix;
   wifiPhy.EnablePcapAll (prefix);
 }
 
@@ -157,8 +163,8 @@
     {
       std::ostringstream os1, os2;
       // File naming conventions are hard-coded here.
-      os1 << NS_TEST_SOURCEDIR << PREFIX << "-" << i << "-0.pcap";
-      os2 << GetTempDir () << PREFIX << "-" << i << "-0.pcap";
+      os1 << NS_TEST_SOURCEDIR << m_prefix << "-" << i << "-0.pcap";
+      os2 << GetTempDir () << m_prefix << "-" << i << "-0.pcap";
       
       uint32_t sec(0), usec(0);
       bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec);
--- a/src/routing/aodv/test/aodv-regression.h	Thu Dec 10 12:42:20 2009 +0100
+++ b/src/routing/aodv/test/aodv-regression.h	Fri Dec 11 11:19:49 2009 +0300
@@ -154,20 +154,31 @@
 class ChainRegressionTest : public TestCase
 {
 public:
-  ChainRegressionTest ();
+  /**
+   * Create test case
+   * 
+   * \param prefix              Unique file names prefix
+   * \param size                Number of nodes in the chain
+   * \param time                Simulation time
+   * \param arpAliveTimeout     ARP alive timeout, this is used to check that ARP and routing do not interfere
+   */
+  ChainRegressionTest (const char * const prefix, Time time = Seconds (10), uint32_t size = 5, Time arpAliveTimeout = Seconds (120));
   ~ChainRegressionTest ();  
+  
 private:
-  /// Unique PCAP files prefix for this test
-  static const char * const PREFIX;
   /// XXX It is important to have pointers here
   NodeContainer * m_nodes;
   
+  /// PCAP file names prefix
+  const std::string m_prefix;
   /// Total simulation time
   const Time m_time;
   /// Chain size
   const uint32_t m_size;
   /// Chain step, meters
   const double m_step;
+  /// ARP alive timeout
+  const Time m_arpAliveTimeout;
   
   /// Create test topology
   void CreateNodes ();