build elf-loader by default, improve test-case to cover pthread/ucontext, dlm/cooja, with vdl/no-vdl
authorHajime Tazaki <tazaki@nict.go.jp>
Thu, 20 Sep 2012 11:17:36 +0900
changeset 275 9055b93b8b08
parent 274 d45e93cd80f0
child 276 990d4aae7530
build elf-loader by default, improve test-case to cover pthread/ucontext, dlm/cooja, with vdl/no-vdl
test/dce-manager-test.cc
test/test-tcp-socket.cc
utils/clone_and_compile_ns3_dce.sh
utils/test-dce.sh
wscript
--- a/test/dce-manager-test.cc	Wed Sep 19 14:39:24 2012 +0200
+++ b/test/dce-manager-test.cc	Thu Sep 20 11:17:36 2012 +0900
@@ -25,7 +25,8 @@
 class DceManagerTestCase : public TestCase
 {
 public:
-  DceManagerTestCase (std::string filename, Time maxDuration, std::string stdinFilename, bool useNet, bool useK);
+  DceManagerTestCase (std::string filename, Time maxDuration, std::string stdinFilename, 
+                      bool useNet, bool useK);
 private:
   virtual void DoRun (void);
   static void Finished (int *pstatus, uint16_t pid, int status);
@@ -37,9 +38,16 @@
   bool m_useNet;
 };
 
-DceManagerTestCase::DceManagerTestCase (std::string filename, Time maxDuration, std::string stdin, bool useNet, bool useK)
-  : TestCase ("Check that process \"" + filename + "\" completes correctly."),
-    m_filename (filename), m_stdinFilename ( stdin), m_maxDuration ( maxDuration ), m_useKernel (useK), m_useNet (useNet)
+DceManagerTestCase::DceManagerTestCase (std::string filename, Time maxDuration, 
+                                        std::string stdin, bool useNet, bool useK)
+  : TestCase ("Check that process \"" + filename +
+              (useK ? " (kernel" : " (ns3)") + 
+              "\" completes correctly."),
+    m_filename (filename), 
+    m_stdinFilename (stdin),
+    m_maxDuration (maxDuration),
+    m_useKernel (useK),
+    m_useNet (useNet)
 {
 //  mtrace ();
 }
@@ -83,7 +91,6 @@
           apps = dce.Install (nodes.Get (0));
           apps.Start (Seconds (3.0));
 
-          //dceManager.SetTaskManagerAttribute( "FiberManagerType", StringValue ( "UcontextFiberManager" ) );
         } else
         {
           dceManager.Install (nodes);
@@ -164,7 +171,7 @@
       {  "test-random", 0, "", false },
       {  "test-local-socket", 0, "", false },
       {  "test-poll", 3200, "", true },
-      //      {  "test-tcp-socket", 320, "", true },
+      {  "test-tcp-socket", 320, "", true },
       {  "test-exec", 0, "" , false},
       /* {  "test-raw-socket", 320, "", true },*/
       {  "test-iperf", 0, "" , false},
@@ -194,7 +201,10 @@
 
   for (unsigned int i = 0; i < sizeof(tests)/sizeof(testPair); i++)
     {
-      AddTestCase (new DceManagerTestCase (tests[i].name,  Seconds (tests[i].duration), tests[i].stdinfile, tests[i].useNet, useKernel () ) );
+      AddTestCase (new DceManagerTestCase (tests[i].name,  Seconds (tests[i].duration), 
+                                           tests[i].stdinfile, 
+                                           tests[i].useNet, 
+                                           useKernel ()));
     }
 }
 
--- a/test/test-tcp-socket.cc	Wed Sep 19 14:39:24 2012 +0200
+++ b/test/test-tcp-socket.cc	Thu Sep 20 11:17:36 2012 +0900
@@ -188,6 +188,7 @@
 
   printf ("Client2: end \n \n ");
 
+  sleep (3);
   return arg;
 }
 
@@ -1301,6 +1302,7 @@
   fflush (stdout);
   fflush (stderr);
   sleep (1); // TEMPOFUR if removed can crash :(
+  printf ("launch ended\n\n ");
 }
 
 int LongCompare (const void *A, const void *B)
--- a/utils/clone_and_compile_ns3_dce.sh	Wed Sep 19 14:39:24 2012 +0200
+++ b/utils/clone_and_compile_ns3_dce.sh	Thu Sep 20 11:17:36 2012 +0900
@@ -1,10 +1,8 @@
 #!/bin/bash
 # this script checkout NS3 and DCE sources, and build them.
 USE_KERNEL=NO
-USE_VDL=NO
 USE_MPI=NO
 USE_OPT=NO
-WAF_VDL=
 args=("$@")
 NB=$#
 for (( i=0;i<$NB;i++)); do
@@ -13,10 +11,6 @@
        USE_KERNEL=YES
        WGET=wget
     fi
-    if [ ${args[${i}]} = '-v' ]
-    then 
-       USE_VDL=YES
-    fi
     if [ ${args[${i}]} = '-m' ]
     then 
        USE_MPI=YES
@@ -46,6 +40,10 @@
 #hg clone http://code.nsnam.org/furbani/ns-3-dce
 echo clone readversiondef
 hg clone http://code.nsnam.org/mathieu/readversiondef
+
+echo clone elf-loader
+hg clone -r d7ef4732dccc http://code.nsnam.org/mathieu/elf-loader/
+
 if [ "YES" == "$USE_KERNEL" ]
 then
 	echo clone ns-3-linux
@@ -71,10 +69,19 @@
 export PATH=$SAVE_PATH:`pwd`/build/bin
 export LD_LIBRARY_PATH=$SAVE_LDLP:`pwd`/build/lib
 export PKG_CONFIG_PATH=$SAVE_PKG:`pwd`/build/lib/pkgconfig
+# build readversiondef
 cd readversiondef/
 make 
 make install PREFIX=`pwd`/../build/
 cd ..
+# build elf-loader
+cd elf-loader
+make vdl-config.h
+make
+make test
+cp libvdl.so ../build/lib
+cd ..
+
 if [ "YES" == "$USE_KERNEL" ]
 then
 	cd ns-3-linux/
@@ -93,23 +100,12 @@
 	ln -s ../../../iproute2-2.6.38/ip/ip
 	cd ../..
 fi
-if [ "YES" == "$USE_VDL" ]
-then
-	hg clone -r d7ef4732dccc http://code.nsnam.org/mathieu/elf-loader/
-	cd elf-loader
-	make vdl-config.h
-	make
-	make test
-	cp libvdl.so ../build/lib
-	cd ..
-	WAF_VDL="--enable-vdl-loader"
-fi	
 cd ns-3-dce/
 if [ "YES" == "$USE_KERNEL" ]
 then
     WAF_KERNEL=--enable-kernel-stack=`pwd`/../ns-3-linux
 fi
-./waf configure --prefix=`pwd`/../build --verbose $WAF_KERNEL $WAF_VDL $MPI_SWITCH $OPT_SWITCH
+./waf configure --prefix=`pwd`/../build --verbose $WAF_KERNEL $MPI_SWITCH $OPT_SWITCH
 ./waf
 ./waf install
 export LD_LIBRARY_PATH=$SAVE_LDLP:`pwd`/build/lib:`pwd`/build/bin:`pwd`/../build/lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/utils/test-dce.sh	Thu Sep 20 11:17:36 2012 +0900
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+. ./utils/setenv.sh
+#VERBOSE=""
+
+echo -n "Cooja (non-vdl) + Pthread:  "
+NS_ATTRIBUTE_DEFAULT='ns3::TaskManager::FiberManagerType=PthreadFiberManager' ./build/bin/ns3test-dce $VERBOSE
+echo -n "Cooja (non-vdl) + Ucontext: "
+NS_ATTRIBUTE_DEFAULT='ns3::TaskManager::FiberManagerType=UcontextFiberManager' ./build/bin/ns3test-dce $VERBOSE
+
+echo -n "Cooja (vdl) + Pthread:      "
+NS_ATTRIBUTE_DEFAULT='ns3::DceManagerHelper::LoaderFactory=ns3::CoojaLoaderFactory[];ns3::TaskManager::FiberManagerType=PthreadFiberManager' ./build/bin/ns3test-dce-vdl $VERBOSE
+
+echo -n "Cooja (vdl) + Ucontext:     "
+NS_ATTRIBUTE_DEFAULT='ns3::DceManagerHelper::LoaderFactory=ns3::CoojaLoaderFactory[];ns3::TaskManager::FiberManagerType=UcontextFiberManager' ./build/bin/ns3test-dce-vdl $VERBOSE
+
+echo -n "Dlm (vdl) + Pthread:        "
+NS_ATTRIBUTE_DEFAULT='ns3::DceManagerHelper::LoaderFactory=ns3::DlmLoaderFactory[];ns3::TaskManager::FiberManagerType=PthreadFiberManager' ./build/bin/ns3test-dce-vdl $VERBOSE
+echo -n "Dlm (vdl) + Ucontext:       "
+NS_ATTRIBUTE_DEFAULT='ns3::DceManagerHelper::LoaderFactory=ns3::DlmLoaderFactory[];ns3::TaskManager::FiberManagerType=UcontextFiberManager' ./build/bin/ns3test-dce-vdl $VERBOSE
--- a/wscript	Wed Sep 19 14:39:24 2012 +0200
+++ b/wscript	Thu Sep 20 11:17:36 2012 +0900
@@ -14,10 +14,6 @@
                    help=('Path to the prefix where the kernel wrapper headers are installed'),
                    default=None,
                    dest='kernel_stack', type="string")
-    opt.add_option('--enable-vdl-loader',
-                   help=('Enable the build of dce-runner.'),
-                   dest='enable_vdl_loader', action='store_true',
-                   default=False)               
     opt.add_option('--enable-mpi',
                    help=('Enable MPI and distributed simulation support'),
                    dest='enable_mpi', action='store_true',
@@ -110,14 +106,7 @@
 
     conf_myscripts(conf)
     
-    # Decide if VDL
-    if Options.options.enable_vdl_loader:
-        # Tests were explicitly enabled. 
-        conf.env['ENABLE_VDL'] = True
-    	conf.recurse(os.path.join('utils'))
-    else:
-        # Tests were explicitly disabled. 
-        conf.env['ENABLE_VDL'] = False
+    conf.recurse(os.path.join('utils'))
     ns3waf.print_feature_summary(conf)
     
 def build_netlink(bld):
@@ -162,8 +151,12 @@
 def build_dce_tests(module, kern):
     if kern:
         module.add_runner_test(needed=['core', 'dce', 'internet'],  source=['test/dce-manager-test.cc', 'test/with-kernel.cc'])
+        module.add_runner_test(needed=['core', 'dce', 'internet'],  source=['test/dce-manager-test.cc', 'test/with-kernel.cc'],
+                               linkflags = ['-Wl,--dynamic-linker=' + os.path.abspath ('../build/lib/ldso')], name='vdl')
     else:
         module.add_runner_test(needed=['core', 'dce', 'internet'], source=['test/dce-manager-test.cc','test/without-kernel.cc'])
+        module.add_runner_test(needed=['core', 'dce', 'internet'], source=['test/dce-manager-test.cc','test/without-kernel.cc'],
+                               linkflags = ['-Wl,--dynamic-linker=' + os.path.abspath ('../build/lib/ldso')], name='vdl')
     	    
     module.add_test(features='cxx cxxshlib', source=['test/test-macros.cc'], 
                     target='lib/test', linkflags=['-Wl,-soname=libtest.so'])
@@ -505,5 +498,4 @@
                          '-Wl,--version-script=' + os.path.join('model', 'librt.version'),
                          '-Wl,-soname=librt.so.1'])
 
-    if bld.env['ENABLE_VDL']:                     
-        bld.add_subdirs(['utils'])
+    bld.add_subdirs(['utils'])