doc/manual/source/enable-tests.rst
changeset 7153 f2d6fcd58673
child 9957 1a4d84a85bad
equal deleted inserted replaced
7152:f20b4cae997d 7153:f2d6fcd58673
       
     1 .. include:: replace.txt
       
     2 
       
     3 Enabling/disabling |ns3| Tests and Examples
       
     4 -------------------------------------------
       
     5 
       
     6 The |ns3| distribution includes many examples and tests that are used to validate the |ns3| system.  Users, however, may not always want these examples and tests to be run for their installation of |ns3|.
       
     7 
       
     8 This chapter discusses how to build |ns3| with or without its examples and tests.
       
     9 
       
    10 How to enable/disable examples and tests in |ns3|
       
    11 *************************************************
       
    12 
       
    13 There are 3 ways to enable/disable examples and tests in |ns3|:
       
    14 
       
    15 #. Using build.py when |ns3| is built for the first time
       
    16 #. Using waf once |ns3| has been built
       
    17 #. Using the |ns3| configuration file once |ns3| has been built
       
    18 
       
    19 Enable/disable examples and tests using build.py
       
    20 ++++++++++++++++++++++++++++++++++++++++++++++++
       
    21 
       
    22 You can use build.py to enable/disable examples and tests when |ns3| is built for the first time.
       
    23 
       
    24 By default, examples and tests are not built in |ns3|.  
       
    25 
       
    26 From the ns-3-allinone directory, you can build |ns3| without any
       
    27 examples or tests simply by doing: ::
       
    28 
       
    29   ./build.py
       
    30 
       
    31 Running test.py in the top level |ns3| directory now will cause no examples or tests to be run: ::
       
    32  
       
    33   0 of 0 tests passed (0 passed, 0 skipped, 0 failed, 0 crashed, 0 valgrind errors)
       
    34 
       
    35 If you would like build |ns3| with examples and tests, then do the following from the ns-3-allinone directory: ::
       
    36 
       
    37   ./build.py --enable-examples --enable-tests
       
    38 
       
    39 Running test.py in the top level |ns3| directory will cause all of the examples and tests to be run: ::
       
    40  
       
    41   170 of 170 tests passed (170 passed, 0 skipped, 0 failed, 0 crashed, 0 valgrind errors)
       
    42 
       
    43 Enable/disable examples and tests using waf
       
    44 +++++++++++++++++++++++++++++++++++++++++++
       
    45 
       
    46 You can use waf to enable/disable examples and tests once |ns3| has been built.
       
    47 
       
    48 By default, examples and tests are not built in |ns3|.  
       
    49 
       
    50 From the top level |ns3| directory, you can build |ns3| without any
       
    51 examples or tests simply by doing: ::
       
    52 
       
    53   ./waf configure
       
    54   ./waf build
       
    55 
       
    56 Running test.py now will cause no examples or tests to be run: ::
       
    57  
       
    58   0 of 0 tests passed (0 passed, 0 skipped, 0 failed, 0 crashed, 0 valgrind errors)
       
    59 
       
    60 If you would like build |ns3| with examples and tests, then do the following from the top level |ns3| directory: ::
       
    61 
       
    62   ./waf configure --enable-examples --enable-tests
       
    63   ./waf build
       
    64 
       
    65 Running test.py will cause all of the examples and tests to be run: ::
       
    66  
       
    67   170 of 170 tests passed (170 passed, 0 skipped, 0 failed, 0 crashed, 0 valgrind errors)
       
    68 
       
    69 Enable/disable examples and tests using the |ns3| configuration file
       
    70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       
    71 
       
    72 A configuration file, .ns3rc, has been added to |ns3| that allows users to specify whether examples and tests should be built or not.  You can use this file to enable/disable examples and tests once |ns3| has been built.
       
    73 
       
    74 When enabling disabling examples and tests, the precedence rules are as follows:
       
    75 
       
    76 #. the --enable-examples/--disable-examples configure strings override any .ns3rc file
       
    77 #. the --enable-tests/--disable-tests configure strings override any .ns3rc file
       
    78 #. the .ns3rc file in the top level |ns3| directory is next consulted, if present
       
    79 #. the system searches for ~/.ns3rc if the .ns3rc file was not found in the previous step
       
    80 
       
    81 If none of the above exists, then examples and tests will not be built.
       
    82 
       
    83 The maintained version of the .ns3rc file in the |ns3| source code repository resides in the ``utils`` directory.  The reason for this is if it were in the top-level directory of the repository, it would be prone to accidental checkins from maintainers that enable the modules they want to use.  Therefore, users need to manually copy the .ns3rc from the ``utils`` directory to their preferred place (top level directory or their home directory) to enable persistent enabling of examples and tests.
       
    84 
       
    85 Assuming that you are in the top level |ns3| directory, you can get a copy of the .ns3rc file that is in the ``utils`` directory as follows: ::
       
    86 
       
    87     cp utils/.ns3rc .
       
    88 
       
    89 The .ns3rc file should now be in your top level |ns3| directory, and it contains the following: ::
       
    90 
       
    91   #! /usr/bin/env python
       
    92   
       
    93   # A list of the modules that will be enabled when ns-3 is run.
       
    94   # Modules that depend on the listed modules will be enabled also.
       
    95   #
       
    96   # All modules can be enabled by choosing 'all_modules'.
       
    97   modules_enabled = ['all_modules']
       
    98   
       
    99   # Set this equal to true if you want examples to be run.
       
   100   examples_enabled = False
       
   101   
       
   102   # Set this equal to true if you want tests to be run.
       
   103   tests_enabled = False
       
   104 
       
   105 From the top level |ns3| directory, you can build |ns3| without any
       
   106 examples or tests simply by doing: ::
       
   107 
       
   108   ./waf configure
       
   109   ./waf build
       
   110 
       
   111 Running test.py now will cause no examples or tests to be run: ::
       
   112  
       
   113   0 of 0 tests passed (0 passed, 0 skipped, 0 failed, 0 crashed, 0 valgrind errors)
       
   114 
       
   115 If you would like build |ns3| with examples and tests, use your
       
   116 favorite editor to change the values in the .ns3rc file for
       
   117 examples_enabled and tests_enabled file to be True: ::
       
   118 
       
   119   #! /usr/bin/env python
       
   120   
       
   121   # A list of the modules that will be enabled when ns-3 is run.
       
   122   # Modules that depend on the listed modules will be enabled also.
       
   123   #
       
   124   # All modules can be enabled by choosing 'all_modules'.
       
   125   modules_enabled = ['all_modules']
       
   126   
       
   127   # Set this equal to true if you want examples to be run.
       
   128   examples_enabled = True
       
   129   
       
   130   # Set this equal to true if you want tests to be run.
       
   131   tests_enabled = True
       
   132 
       
   133 From the top level |ns3| directory, you can build |ns3| with examples
       
   134 and tests simply by doing: ::
       
   135 
       
   136   ./waf configure
       
   137   ./waf build
       
   138 
       
   139 Running test.py will cause all of the examples and tests to be run: ::
       
   140  
       
   141   170 of 170 tests passed (170 passed, 0 skipped, 0 failed, 0 crashed, 0 valgrind errors)