Make tests not be built by default
authorMitch Watrous <watrous@u.washington.edu>
Wed, 06 Apr 2011 10:13:04 -0700
changeset 6998 1c2b8cfb71d2
parent 6997 00c8ea8e9e40
child 6999 dd78264fda2d
child 7000 c115b78dab0c
Make tests not be built by default
doc/build.txt
doc/manual/source/attributes.rst
doc/manual/source/click.rst
doc/manual/source/distributed.rst
doc/manual/source/openflow-switch.rst
doc/manual/source/tcp.rst
doc/release_steps.txt
doc/testing/source/testing-framework.rst
doc/tutorial/source/conceptual-overview.rst
doc/tutorial/source/getting-started.rst
src/tap-bridge/examples/wscript
wscript
--- a/doc/build.txt	Tue Apr 05 21:39:39 2011 +0200
+++ b/doc/build.txt	Wed Apr 06 10:13:04 2011 -0700
@@ -36,8 +36,8 @@
 
 Other waf usages include:
 
- 1. ./waf --check
-    Runs the unit tests
+ 1. ./waf configure --enable-tests
+    Turn on unit tests.
 
  2. ./waf --doxygen
     Run doxygen to generate documentation
--- a/doc/manual/source/attributes.rst	Tue Apr 05 21:39:39 2011 +0200
+++ b/doc/manual/source/attributes.rst	Wed Apr 06 10:13:04 2011 -0700
@@ -768,7 +768,7 @@
     sudo apt-get install libgtk2.0-0 libgtk2.0-dev
 
 To check whether it is configured or not, check the output of the
-./waf configure step:::
+./waf configure --enable-tests step:::
 
     ---- Summary of optional NS-3 features:
     Threading Primitives          : enabled
@@ -776,7 +776,7 @@
     GtkConfigStore                : not enabled (library 'gtk+-2.0 >= 2.12' not found)
 
 In the above example, it was not enabled, so it cannot be used until a suitable
-version is installed and ./waf configure; ./waf is rerun.
+version is installed and ./waf configure --enable-tests; ./waf is rerun.
 
 Usage is almost the same as the non-GTK-based version, but there
 are no ConfigStore attributes involved:::
--- a/doc/manual/source/click.rst	Tue Apr 05 21:39:39 2011 +0200
+++ b/doc/manual/source/click.rst	Wed Apr 06 10:13:04 2011 -0700
@@ -73,7 +73,7 @@
 Once Click has been built successfully, change into the ns-3 directory and 
 configure ns-3 with Click Integration support::
 
-  $: ./waf configure --with-nsclick=/path/to/click/source
+  $: ./waf configure --enable-tests --with-nsclick=/path/to/click/source
 
 If it says 'enabled' beside 'NS-3 Click Integration Support', then you're good to go.
 
--- a/doc/manual/source/distributed.rst	Tue Apr 05 21:39:39 2011 +0200
+++ b/doc/manual/source/distributed.rst	Wed Apr 06 10:13:04 2011 -0700
@@ -118,7 +118,7 @@
 
 Configure |ns3| with the --enable-mpi option:::
 
-    ./waf -d debug configure --enable-mpi
+    ./waf -d debug configure --enable-tests --enable-mpi
 
 Ensure that MPI is enabled by checking the optional features shown from the
 output of configure.
--- a/doc/manual/source/openflow-switch.rst	Tue Apr 05 21:39:39 2011 +0200
+++ b/doc/manual/source/openflow-switch.rst	Wed Apr 06 10:13:04 2011 -0700
@@ -143,7 +143,7 @@
 link to an ns-3 build with this OpenFlow switch module, run from the ns-3-dev
 (or whatever you have named your distribution):::
 
-  $ ./waf configure --with-openflow=path/to/openflow
+  $ ./waf configure --enable-tests --with-openflow=path/to/openflow
 
 #3 Under ``---- Summary of optional NS-3 features:`` you should see:::
 
--- a/doc/manual/source/tcp.rst	Tue Apr 05 21:39:39 2011 +0200
+++ b/doc/manual/source/tcp.rst	Wed Apr 06 10:13:04 2011 -0700
@@ -164,7 +164,7 @@
 default unless the platform does not support it. To disable it when building
 |ns3|, type:::
 
-./waf configure --disable-nsc
+./waf configure --enable-tests --disable-nsc
 
 Building and validating
 +++++++++++++++++++++++
--- a/doc/release_steps.txt	Tue Apr 05 21:39:39 2011 +0200
+++ b/doc/release_steps.txt	Wed Apr 06 10:13:04 2011 -0700
@@ -48,7 +48,7 @@
    - cd ns-3.x
    - ./test.py
    - ./test.py -g
-   - ./waf -d optimized configure
+   - ./waf -d optimized --enable-tests configure
    - ./waf
    - ./test.py
    - ./test.py -g
--- a/doc/testing/source/testing-framework.rst	Tue Apr 05 21:39:39 2011 +0200
+++ b/doc/testing/source/testing-framework.rst	Wed Apr 06 10:13:04 2011 -0700
@@ -64,6 +64,13 @@
 ``test.py`` is very flexible in allowing the user to specify the number
 and kind of tests to run; and also the amount and kind of output to generate.
 
+Before running ``test.py``, make sure that ns3's tests have been built by doing the following
+
+::
+
+  ./waf configure --enable-tests
+  ./waf
+
 By default, ``test.py`` will run all available tests and report status
 back in a very concise form.  Running the command
 
@@ -88,7 +95,7 @@
   PASS: Example csma-broadcast
   PASS: Example csma-multicast
 
-This mode is indented to be used by users who are interested in determining if
+This mode is intended to be used by users who are interested in determining if
 their distribution is working correctly, and by developers who are interested
 in determining if changes they have made have caused any regressions.
 
--- a/doc/tutorial/source/conceptual-overview.rst	Tue Apr 05 21:39:39 2011 +0200
+++ b/doc/tutorial/source/conceptual-overview.rst	Wed Apr 06 10:13:04 2011 -0700
@@ -249,10 +249,10 @@
 
 ::
 
-  ./waf -d debug configure
+  ./waf -d debug --enable-tests configure
 
-in order to configure the project to perform debug builds.  You will also have
-done a
+in order to configure the project to perform debug builds that include 
+tests.  You will also have done a
 
 ::
 
--- a/doc/tutorial/source/getting-started.rst	Tue Apr 05 21:39:39 2011 +0200
+++ b/doc/tutorial/source/getting-started.rst	Wed Apr 06 10:13:04 2011 -0700
@@ -264,7 +264,12 @@
 
 ::
 
-  ./build.py
+  ./build.py --enable-tests
+
+Because we are working with tests in this tutorial, and because they
+are not built by default in |ns3|, the argument for build.py tells it
+to build them for us.  In the future you can build |ns3| without tests
+if you wish.
 
 You will see lots of typical compiler output messages displayed as the build
 script builds the various pieces you downloaded.  Eventually you should see the
@@ -293,13 +298,14 @@
 detour and look at how to make changes to the configuration of the project.
 Probably the most useful configuration change you can make will be to 
 build the optimized version of the code.  By default you have configured
-your project to build the debug version.  Let's tell the project to do
+your project to build the debug version.  Let's tell the project to 
 make an optimized build.  To explain to Waf that it should do optimized
-builds you will need to execute the following command,
+builds that include the tests, you will need to execute the 
+following command,
 
 ::
 
-  ./waf -d optimized configure
+  ./waf -d optimized --enable-tests configure
 
 This runs Waf out of the local directory (which is provided as a convenience
 for you).  As the build system checks for various dependencies you should see
@@ -373,11 +379,11 @@
 a feature to use the program ``sudo`` to set the suid bit of certain programs.
 This is not enabled by default and so this feature is reported as "not enabled."
 
-Now go ahead and switch back to the debug build.
+Now go ahead and switch back to the debug build that includes the tests.
 
 ::
 
-  ./waf -d debug configure
+  ./waf -d debug --enable-tests configure
 
 The build system is now configured and you can build the debug versions of 
 the |ns3| programs by simply typing,
@@ -388,13 +394,13 @@
 
 Some waf commands are meaningful during the build phase and some commands are valid
 in the configuration phase.  For example, if you wanted to use the emulation 
-features of |ns3| you might want to enable setting the suid bit using
+features of |ns3|, you might want to enable setting the suid bit using
 sudo as described above.  This turns out to be a configuration-time command, and so 
-you could reconfigure using the following command
+you could reconfigure using the following command that also includes the tests
 
 ::
 
-  ./waf -d debug --enable-sudo configure
+  ./waf -d debug --enable-sudo --enable-tests configure
 
 If you do this, waf will have run sudo to change the socket creator programs of the
 emulation code to run as root.  There are many other configure- and build-time options
@@ -493,11 +499,11 @@
 
 ::
 
-  ./waf -d debug configure
+  ./waf -d debug --enable-tests configure
 
 to tell ``waf`` to build the debug versions of the |ns3| 
-programs.  You must still build the actual debug version of the code by
-typing,
+programs that includes the tests.  You must still build 
+the actual debug version of the code by typing,
 
 ::
 
--- a/src/tap-bridge/examples/wscript	Tue Apr 05 21:39:39 2011 +0200
+++ b/src/tap-bridge/examples/wscript	Wed Apr 06 10:13:04 2011 -0700
@@ -3,7 +3,7 @@
 def build(bld):
     env = bld.env_of_name('default')
     if env['ENABLE_TAP']:
-        obj = bld.create_ns3_program('tap-csma', ['csma', 'tap-bridge', 'internet'])
+        obj = bld.create_ns3_program('tap-csma', ['csma', 'tap-bridge', 'internet', 'wifi'])
         obj.source = 'tap-csma.cc'
         obj = bld.create_ns3_program('tap-csma-virtual-machine', ['csma', 'tap-bridge', 'internet'])
         obj.source = 'tap-csma-virtual-machine.cc'
--- a/wscript	Tue Apr 05 21:39:39 2011 +0200
+++ b/wscript	Wed Apr 06 10:13:04 2011 -0700
@@ -157,6 +157,13 @@
                    help=('Use sudo to setup suid bits on ns3 executables.'),
                    dest='enable_sudo', action='store_true',
                    default=False)
+    opt.add_option('--enable-tests',
+                   help=('Build the ns-3 tests.'),
+                   dest='enable_tests', action='store_true',
+                   default=False)
+    opt.add_option('--disable-tests',
+                   help=('Do not build the ns-3 tests.'),
+                   dest='enable_tests', action='store_false')
     opt.add_option('--enable-examples',
                    help=('Build the ns-3 examples and samples.'),
                    dest='enable_examples', action='store_true',
@@ -334,6 +341,15 @@
 
     conf.report_optional_feature("ENABLE_SUDO", "Use sudo to set suid bit", env['ENABLE_SUDO'], why_not_sudo)
 
+    if Options.options.enable_tests:
+        env['ENABLE_TESTS'] = True
+        why_not_tests = "option --enable-tests selected"
+    else:
+        env['ENABLE_TESTS'] = False
+        why_not_tests = "defaults to disabled"
+
+    conf.report_optional_feature("ENABLE_TESTS", "Build tests", env['ENABLE_TESTS'], why_not_tests)
+
     if Options.options.enable_examples:
         env['ENABLE_EXAMPLES'] = True
         why_not_examples = "defaults to enabled"
@@ -587,10 +603,12 @@
         env['NS3_ENABLED_MODULES'] = modules
         #print "Modules to build:", modules
 
-        # Set the list of the enabled module test libraries.
-        for (mod, testlib) in bld.env['NS3_MODULES_WITH_TEST_LIBRARIES']:
-            if mod in bld.env['NS3_ENABLED_MODULES']:
-                bld.env.append_value('NS3_ENABLED_MODULE_TEST_LIBRARIES', testlib)
+        # If tests are being built, then set the list of the enabled
+        # module test libraries.
+        if env['ENABLE_TESTS']:
+            for (mod, testlib) in bld.env['NS3_MODULES_WITH_TEST_LIBRARIES']:
+                if mod in bld.env['NS3_ENABLED_MODULES']:
+                    bld.env.append_value('NS3_ENABLED_MODULE_TEST_LIBRARIES', testlib)
 
     # Process this subfolder here after the lists of enabled modules
     # and module test libraries have been set.
@@ -647,8 +665,9 @@
                 exclude_taskgen(bld, obj) # kill the module
 
             # disable the module test libraries
-            if hasattr(obj, "is_ns3_module_test_library") and obj.module_name not in modules:
-                exclude_taskgen(bld, obj) # kill the module test library
+            if hasattr(obj, "is_ns3_module_test_library"):
+                if not env['ENABLE_TESTS'] or (obj.module_name not in modules):
+                    exclude_taskgen(bld, obj) # kill the module test library
 
             # disable the ns3header_taskgen
             if type(obj).__name__ == 'ns3header_taskgen':