test test
authorCraig Dowell <craigdo@ee.washington.edu>
Mon, 31 Mar 2008 18:14:47 -0700
changeset 2861 18930dcd33e0
parent 2860 9105a5cf6535
child 2862 b6ef2bfe89da
test test
examples/simple-alternate-routing.cc
examples/simple-error-model.cc
examples/simple-global-routing.cc
regression/regression.py
regression/tests/test-simple-error-model.py
regression/tests/test-simple-global-routing.py
--- a/examples/simple-alternate-routing.cc	Mon Mar 31 17:48:21 2008 -0700
+++ b/examples/simple-alternate-routing.cc	Mon Mar 31 18:14:47 2008 -0700
@@ -54,32 +54,12 @@
 #if 0 
   LogComponentEnable("GlobalRouteManager", LOG_LOGIC);
   LogComponentEnable("GlobalRouter", LOG_LOGIC);
-  LogComponentEnable("Object", LOG_LEVEL_ALL);
-  LogComponentEnable("Queue", LOG_LEVEL_ALL);
-  LogComponentEnable("DropTailQueue", LOG_LEVEL_ALL);
-  LogComponentEnable("Channel", LOG_LEVEL_ALL);
-  LogComponentEnable("CsmaChannel", LOG_LEVEL_ALL);
-  LogComponentEnable("NetDevice", LOG_LEVEL_ALL);
-  LogComponentEnable("CsmaNetDevice", LOG_LEVEL_ALL);
-  LogComponentEnable("Ipv4L3Protocol", LOG_LEVEL_ALL);
-  LogComponentEnable("PacketSocket", LOG_LEVEL_ALL);
-  LogComponentEnable("Socket", LOG_LEVEL_ALL);
-  LogComponentEnable("UdpSocket", LOG_LEVEL_ALL);
-  LogComponentEnable("UdpL4Protocol", LOG_LEVEL_ALL);
-  LogComponentEnable("Ipv4L3Protocol", LOG_LEVEL_ALL);
-  LogComponentEnable("Ipv4StaticRouting", LOG_LEVEL_ALL);
-  LogComponentEnable("Ipv4Interface", LOG_LEVEL_ALL);
-  LogComponentEnable("ArpIpv4Interface", LOG_LEVEL_ALL);
-  LogComponentEnable("Ipv4LoopbackInterface", LOG_LEVEL_ALL);
-  LogComponentEnable("OnOffApplication", LOG_LEVEL_ALL);
-  LogComponentEnable("PacketSinkApplication", LOG_LEVEL_ALL);
-  LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_ALL);
-  LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_ALL);
 #endif
-  // Set up some default values for the simulation.  Use the 
-  // DefaultValue::Bind () technique to tell the system what subclass of 
-  // Queue to use, and what the queue limit is
 
+  //
+  // Make the random number generators generate reproducible results.
+  //
+  RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
 
   Config::SetDefault ("ns3::OnOffApplication::PacketSize", Uinteger (210));
   Config::SetDefault ("ns3::OnOffApplication::DataRate", DataRate ("300b/s"));
--- a/examples/simple-error-model.cc	Mon Mar 31 17:48:21 2008 -0700
+++ b/examples/simple-error-model.cc	Mon Mar 31 18:14:47 2008 -0700
@@ -58,6 +58,11 @@
   LogComponentEnable ("SimplePointToPointExample", LOG_LEVEL_INFO);
 #endif
 
+  //
+  // Make the random number generators generate reproducible results.
+  //
+  RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
+
   // Set a few parameters
   Config::SetDefault ("ns3::RateErrorModel::ErrorRate", Double (0.01));
   Config::SetDefault ("ns3::RateErrorModel::ErrorUnit", String ("EU_PKT"));
--- a/examples/simple-global-routing.cc	Mon Mar 31 17:48:21 2008 -0700
+++ b/examples/simple-global-routing.cc	Mon Mar 31 18:14:47 2008 -0700
@@ -58,31 +58,14 @@
   // for selected modules; the below lines suggest how to do this
 #if 0 
   LogComponentEnable ("SimpleGlobalRoutingExample", LOG_LEVEL_INFO);
+#endif
 
-  LogComponentEnable("Object", LOG_LEVEL_ALL);
-  LogComponentEnable("Queue", LOG_LEVEL_ALL);
-  LogComponentEnable("DropTailQueue", LOG_LEVEL_ALL);
-  LogComponentEnable("Channel", LOG_LEVEL_ALL);
-  LogComponentEnable("CsmaChannel", LOG_LEVEL_ALL);
-  LogComponentEnable("NetDevice", LOG_LEVEL_ALL);
-  LogComponentEnable("CsmaNetDevice", LOG_LEVEL_ALL);
-  LogComponentEnable("Ipv4L3Protocol", LOG_LEVEL_ALL);
-  LogComponentEnable("PacketSocket", LOG_LEVEL_ALL);
-  LogComponentEnable("Socket", LOG_LEVEL_ALL);
-  LogComponentEnable("UdpSocket", LOG_LEVEL_ALL);
-  LogComponentEnable("UdpL4Protocol", LOG_LEVEL_ALL);
-  LogComponentEnable("Ipv4L3Protocol", LOG_LEVEL_ALL);
-  LogComponentEnable("Ipv4StaticRouting", LOG_LEVEL_ALL);
-  LogComponentEnable("Ipv4Interface", LOG_LEVEL_ALL);
-  LogComponentEnable("ArpIpv4Interface", LOG_LEVEL_ALL);
-  LogComponentEnable("Ipv4LoopbackInterface", LOG_LEVEL_ALL);
-  LogComponentEnable("OnOffApplication", LOG_LEVEL_ALL);
-  LogComponentEnable("PacketSinkApplication", LOG_LEVEL_ALL);
-  LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_ALL);
-  LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_ALL);
-#endif
+  //
+  // Make the random number generators generate reproducible results.
+  //
+  RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
+
   // Set up some default values for the simulation.  Use the 
-
   Config::SetDefault ("ns3::OnOffApplication::PacketSize", Uinteger (210));
   Config::SetDefault ("ns3::OnOffApplication::DataRate", DataRate ("448kb/s"));
 
--- a/regression/regression.py	Mon Mar 31 17:48:21 2008 -0700
+++ b/regression/regression.py	Mon Mar 31 18:14:47 2008 -0700
@@ -48,6 +48,8 @@
     userName = "craigdo/"
     repoName = "ns-3-ref-traces/"
 
+    print "Synchronizing reference traces."
+    
     if not os.path.exists(repoName):
         cloneCmd = "hg clone http://code.nsnam.org/" + userName + repoName + " >& /dev/null"
         os.system(cloneCmd)
@@ -57,6 +59,8 @@
         os.system(pullCmd)
         os.chdir("..")
 
+    print "Done."
+
     bad = []
 
     if not testdir:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/regression/tests/test-simple-error-model.py	Mon Mar 31 18:14:47 2008 -0700
@@ -0,0 +1,41 @@
+#! /usr/bin/env python
+
+"""Generic trace-comparison-type regression test."""
+
+import os
+import shutil
+
+def run(verbose, generate):
+    """Execute a test."""
+
+    testName = "simple-error-model"
+    repoName = "ns-3-ref-traces/"
+    refDirName = testName + ".ref"
+
+    if not os.path.exists(repoName):
+        print"No reference trace repository"
+        return 1
+
+    if generate:
+        if not os.path.exists(repoName + refDirName):
+            print "creating new " + repoName + refDirName
+            os.mkdir(repoName + refDirName)
+
+        os.system("./waf --cwd regression/" + repoName + refDirName +
+            " --run " + testName + " >& /dev/null")
+
+        print "Remember to commit " + repoName + refDirName
+        return 0
+    else:
+        if not os.path.exists(repoName + refDirName):
+            print "Cannot locate reference traces"
+            return 1
+
+        shutil.rmtree("traces");
+        os.mkdir("traces")
+        
+        os.system("./waf --cwd regression/traces --run " +
+          testName + " >& /dev/null")
+        
+        return os.system("diff -q traces " + repoName + refDirName +
+         " >& /dev/null")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/regression/tests/test-simple-global-routing.py	Mon Mar 31 18:14:47 2008 -0700
@@ -0,0 +1,41 @@
+#! /usr/bin/env python
+
+"""Generic trace-comparison-type regression test."""
+
+import os
+import shutil
+
+def run(verbose, generate):
+    """Execute a test."""
+
+    testName = "simple-global-routing"
+    repoName = "ns-3-ref-traces/"
+    refDirName = testName + ".ref"
+
+    if not os.path.exists(repoName):
+        print"No reference trace repository"
+        return 1
+
+    if generate:
+        if not os.path.exists(repoName + refDirName):
+            print "creating new " + repoName + refDirName
+            os.mkdir(repoName + refDirName)
+
+        os.system("./waf --cwd regression/" + repoName + refDirName +
+            " --run " + testName + " >& /dev/null")
+
+        print "Remember to commit " + repoName + refDirName
+        return 0
+    else:
+        if not os.path.exists(repoName + refDirName):
+            print "Cannot locate reference traces"
+            return 1
+
+        shutil.rmtree("traces");
+        os.mkdir("traces")
+        
+        os.system("./waf --cwd regression/traces --run " +
+          testName + " >& /dev/null")
+        
+        return os.system("diff -q traces " + repoName + refDirName +
+         " >& /dev/null")