doc/testing/testing-framework.texi
author Craig Dowell <craigdo@ee.washington.edu>
Mon, 12 Oct 2009 14:01:36 -0700
changeset 5412 00d7fe69d024
parent 5371 6020e8d86ffa
child 5882 00057b346f87
permissions -rw-r--r--
refalgamize temporary files in test.py
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     1
@c ========================================================================
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
@c Testing framework
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
@c ========================================================================
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     4
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
     5
@unnumbered Part I:  Testing
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
     6
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     7
@node TestingFramework
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     8
@chapter Testing Framework
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     9
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    10
ns-3 consists of a simulation core engine, a set of models, example programs, 
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    11
and tests.  Over time, new contributors contribute models, tests, and 
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    12
examples.  A Python test program @samp{test.py} serves as the test
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    13
execution manager; @code{test.py} can run test code and examples to
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    14
look for regressions, can output the results into a number of forms, and
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    15
can manage code coverage analysis tools.  On top of this, we layer 
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    16
@samp{Buildbots} that are automated build robots that perform
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    17
robustness testing by running the test framework on different systems
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    18
and with different configuration options.
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    19
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    20
@cartouche
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    21
Insert figure showing the components here
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    22
@end cartouche
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    23
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    24
@node BuildBots
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    25
@section Buildbots
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    26
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    27
At the highest level of ns-3 testing are the buildbots (build robots).  
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    28
If you are unfamiliar with
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    29
this system look at @uref{http://djmitche.github.com/buildbot/docs/0.7.11/}.  
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    30
This is an open-source automated system that allows @command{ns-3} to be rebuilt
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    31
and tested each time something has changed.  By running the buildbots on a number
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    32
of different systems we can ensure that @command{ns-3} builds and executes
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    33
properly on all of its supported systems.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    34
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    35
Users (and developers) typically will not interact with the buildbot system other 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    36
than to read its messages regarding test results.  If a failure is detected in 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    37
one of the automated build and test jobs, the buildbot will send an email to the
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    38
@emph{ns-developers} mailing list.  This email will look something like:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    39
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    40
@smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    41
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    42
  The Buildbot has detected a new failure of osx-ppc-g++-4.2 on NsNam.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    43
  Full details are available at:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    44
   http://ns-regression.ee.washington.edu:8010/builders/osx-ppc-g%2B%2B-4.2/builds/0
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    45
  
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    46
  Buildbot URL: http://ns-regression.ee.washington.edu:8010/
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    47
  
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    48
  Buildslave for this Build: darwin-ppc
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    49
  
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    50
  Build Reason: The web-page 'force build' button was pressed by 'ww': ww
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    51
  
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    52
  Build Source Stamp: HEAD
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    53
  Blamelist: 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    54
  
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    55
  BUILD FAILED: failed shell_5 shell_6 shell_7 shell_8 shell_9 shell_10 shell_11 shell_12 
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    56
  
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    57
  sincerely,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    58
  -The Buildbot
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    59
@end verbatim
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    60
@end smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    61
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    62
In the full details URL shown in the email, one can search for the keyword 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    63
@code{failed} and select the @code{stdio} link for the corresponding step to see
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    64
the reason for the failure.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    65
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    66
The buildbot will do its job quietly if there are no errors, and the system will
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    67
undergo build and test cycles every day to verify that all is well.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    68
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    69
@node Testpy
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    70
@section Test.py
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    71
The buildbots use a Python program, @command{test.py}, that is reponsible for 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    72
running all of the tests and collecting the resulting reports into a human-
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    73
readable form.  This program is also available for use by users and developers
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    74
as well.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    75
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    76
@command{test.py} is very flexible in allowing the user to specify the number
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    77
and kind of tests to run; and also the amount and kind of output to generate.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    78
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    79
By default, @command{test.py} will run all available tests and report status
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    80
back in a very concise form.  Running the command,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    81
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    82
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    83
  ./test.py
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    84
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    85
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    86
will result in a number of @code{PASS}, @code{FAIL}, @code{CRASH} or @code{SKIP}
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    87
indications followed by the kind of test that was run and its display name.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    88
 
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
    89
@smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    90
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    91
  Waf: Entering directory `/home/craigdo/repos/ns-3-allinone-test/ns-3-dev/build'
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    92
  Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone-test/ns-3-dev/build'
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    93
  'build' finished successfully (0.939s)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    94
  FAIL: TestSuite ns3-wifi-propagation-loss-models
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    95
  PASS: TestSuite object-name-service
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    96
  PASS: TestSuite pcap-file-object
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    97
  PASS: TestSuite ns3-tcp-cwnd
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    98
  ...
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    99
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   100
  PASS: TestSuite ns3-tcp-interoperability
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   101
  PASS: Example csma-broadcast
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   102
  PASS: Example csma-multicast
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   103
@end verbatim
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   104
@end smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   105
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   106
This mode is indented to be used by users who are interested in determining if
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   107
their distribution is working correctly, and by developers who are interested
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   108
in determining if changes they have made have caused any regressions.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   109
5412
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   110
There are a number of options available to control the behavir of @code{test.py}.
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   111
if you run @code{test.py --help} you should see a command summary like:
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   112
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   113
@verbatim
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   114
  Usage: test.py [options]
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   115
  
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   116
  Options:
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   117
    -h, --help            show this help message and exit
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   118
    -c KIND, --constrain=KIND
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   119
                          constrain the test-runner by kind of test
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   120
    -e EXAMPLE, --example=EXAMPLE
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   121
                          specify a single example to run
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   122
    -g, --grind           run the test suites and examples using valgrind
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   123
    -k, --kinds           print the kinds of tests available
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   124
    -l, --list            print the list of known tests
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   125
    -m, --multiple        report multiple failures from test suites and test
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   126
                          cases
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   127
    -n, --nowaf           do not run waf before starting testing
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   128
    -s TEST-SUITE, --suite=TEST-SUITE
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   129
                          specify a single test suite to run
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   130
    -v, --verbose         print progress and informational messages
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   131
    -w HTML-FILE, --web=HTML-FILE, --html=HTML-FILE
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   132
                          write detailed test results into HTML-FILE.html
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   133
    -r, --retain          retain all temporary files (which are normally
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   134
                          deleted)
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   135
    -t TEXT-FILE, --text=TEXT-FILE
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   136
                          write detailed test results into TEXT-FILE.txt
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   137
    -x XML-FILE, --xml=XML-FILE
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   138
                          write detailed test results into XML-FILE.xml
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   139
@end verbatim
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   140
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   141
If one specifies an optional output style, one can generate detailed descriptions
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   142
of the tests and status.  Available styles are @command{text} and @command{HTML}.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   143
The buildbots will select the HTML option to generate HTML test reports for the
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   144
nightly builds using,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   145
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   146
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   147
  ./test.py --html=nightly.html
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   148
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   149
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   150
In this case, an HTML file named ``nightly.html'' would be created with a pretty
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   151
summary of the testing done.  A ``human readable'' format is available for users
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   152
interested in the details.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   153
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   154
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   155
  ./test.py --text=results.txt
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   156
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   157
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   158
In the example above, the test suite checking the @command{ns-3} wireless
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   159
device propagation loss models failed.  By default no further information is
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   160
provided.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   161
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   162
To further explore the failure, @command{test.py} allows a single test suite
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   163
to be specified.  Running the command,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   164
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   165
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   166
  ./test.py --suite=ns3-wifi-propagation-loss-models
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   167
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   168
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   169
results in that single test suite being run.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   170
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   171
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   172
  FAIL: TestSuite ns3-wifi-propagation-loss-models
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   173
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   174
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   175
To find detailed information regarding the failure, one must specify the kind
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   176
of output desired.  For example, most people will probably be interested in
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   177
a text file:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   178
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   179
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   180
  ./test.py --suite=ns3-wifi-propagation-loss-models --text=results.txt
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   181
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   182
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   183
This will result in that single test suite being run with the test status written to 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   184
the file ``results.txt''.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   185
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   186
You should find something similar to the following in that file:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   187
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   188
@smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   189
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   190
FAIL: Test Suite ``ns3-wifi-propagation-loss-models'' (real 0.02 user 0.01 system 0.00)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   191
  PASS: Test Case "Check ... Friis ... model ..." (real 0.01 user 0.00 system 0.00)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   192
  FAIL: Test Case "Check ... Log Distance ... model" (real 0.01 user 0.01 system 0.00)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   193
    Details:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   194
      Message:   Got unexpected SNR value
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   195
      Condition: [long description of what actually failed]
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   196
      Actual:    176.395
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   197
      Limit:     176.407 +- 0.0005
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   198
      File:      ../src/test/ns3wifi/propagation-loss-models-test-suite.cc
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   199
      Line:      360
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   200
@end verbatim
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   201
@end smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   202
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   203
Notice that the Test Suite is composed of two Test Cases.  The first test case
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   204
checked the Friis propagation loss model and passed.  The second test case 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   205
failed checking the Log Distance propagation model.  In this case, an SNR of
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   206
176.395 was found, and the test expected a value of 176.407 correct to three
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   207
decimal places.  The file which implemented the failing test is listed as well
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   208
as the line of code which triggered the failure.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   209
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   210
If you desire, you could just as easily have written an HTML file using the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   211
@code{--html} option as described above.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   212
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   213
Typically a user will run all tests at least once after downloading 
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   214
@command{ns-3} to ensure that his or her environment has been built correctly
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   215
and is generating correct results according to the test suites.  Developers
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   216
will typically run the test suites before and after making a change to ensure
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   217
that they have not introduced a regression with their changes.  In this case,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   218
developers may not want to run all tests, but only a subset.  For example,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   219
the developer might only want to run the unit tests periodically while making
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   220
changes to a repository.  In this case, @code{test.py} can be told to constrain
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   221
the types of tests being run to a particular class of tests.  The following
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   222
command will result in only the unit tests being run:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   223
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   224
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   225
  ./test.py --constrain=unit
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   226
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   227
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   228
Similarly, the following command will result in only the example smoke tests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   229
being run:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   230
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   231
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   232
  ./test.py --constrain=unit
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   233
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   234
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   235
To see a quick list of the legal kinds of constraints, you can ask for them
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   236
to be listed.  The following command
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   237
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   238
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   239
  ./test.py --kinds
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   240
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   241
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   242
will result in the following list being displayed:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   243
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   244
@smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   245
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   246
  Waf: Entering directory `/home/craigdo/repos/ns-3-allinone-test/ns-3-dev/build'
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   247
  Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone-test/ns-3-dev/build'
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   248
  'build' finished successfully (0.939s)Waf: Entering directory `/home/craigdo/repos/ns-3-allinone-test/ns-3-dev/build'
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   249
  bvt:         Build Verification Tests (to see if build completed successfully)
5371
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   250
  core:        Run all TestSuite-based tests (exclude examples)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   251
  example:     Examples (to see if example programs run successfully)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   252
  performance: Performance Tests (check to see if the system is as fast as expected)
5371
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   253
  system:      System Tests (spans modules to check integration of modules)
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   254
  unit:        Unit Tests (within modules to check basic functionality)
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   255
@end verbatim
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   256
@end smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   257
5371
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   258
Any of these kinds of test can be provided as a constraint using the @code{--constraint} 
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   259
option.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   260
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   261
To see a quick list of all of the test suites available, you can ask for them
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   262
to be listed.  The following command,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   263
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   264
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   265
  ./test.py --list
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   266
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   267
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   268
will result in a list of the test suite being displayed, similar to :
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   269
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   270
@smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   271
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   272
  Waf: Entering directory `/home/craigdo/repos/ns-3-allinone-test/ns-3-dev/build'
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   273
  Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone-test/ns-3-dev/build'
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   274
  'build' finished successfully (0.939s)
5371
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   275
  histogram
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   276
  ns3-wifi-interference
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   277
  ns3-tcp-cwnd
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   278
  ns3-tcp-interoperability
5371
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   279
  sample
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   280
  devices-mesh-flame
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   281
  devices-mesh-dot11s
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   282
  devices-mesh
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   283
  ...
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   284
  object-name-service
5371
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   285
  callback
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   286
  attributes
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   287
  config
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   288
  global-value
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   289
  command-line
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   290
  basic-random-number
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   291
  object
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   292
@end verbatim
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   293
@end smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   294
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   295
Any of these listed suites can be selected to be run by itself using the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   296
@code{--suite} option as shown above.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   297
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   298
Similarly to test suites, one can run a single example program using the @code{--example}
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   299
option.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   300
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   301
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   302
  ./test.py --example=udp-echo
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   303
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   304
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   305
results in that single example being run.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   306
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   307
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   308
  PASS: Example udp-echo
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   309
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   310
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   311
Normally when example programs are executed, they write a large amount of trace 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   312
file data.  This is normally saved to the base directory of the distribution 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   313
(e.g., /home/user/ns-3-dev).  When @command{test.py} runs an example, it really
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   314
is completely unconcerned with the trace files.  It just wants to to determine
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   315
if the example can be built and run without error.  Since this is the case, the
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   316
trace files are written into a @code{/tmp/unchecked-traces} directory.  If you 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   317
run the above example, you should be able to find the associated 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   318
@code{udp-echo.tr} and @code{udp-echo-n-1.pcap} files there.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   319
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   320
The list of available examples is defined by the contents of the ``examples''
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   321
directory in the distribution.  If you select an example for execution using
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   322
the @code{--example} option, @code{test.py} will not make any attempt to decide
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   323
if the example has been configured or not, it will just try to run it and
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   324
report the result of the attempt.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   325
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   326
When @command{test.py} runs, by default it will first ensure that the system has
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   327
been completely built.  This can be defeated by selecting the @code{--nowaf}
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   328
option.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   329
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   330
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   331
  ./test.py --list --nowaf
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   332
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   333
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   334
will result in a list of the currently built test suites being displayed, similar to :
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   335
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   336
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   337
  ns3-wifi-propagation-loss-models
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   338
  ns3-tcp-cwnd
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   339
  ns3-tcp-interoperability
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   340
  pcap-file-object
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   341
  object-name-service
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   342
  random-number-generators
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   343
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   344
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   345
Note the absence of the @command{Waf} build messages.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   346
5371
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   347
@code{test.py} also supports running the test suites and examples under valgrind.
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   348
Valgrind is a flexible program for debugging and profiling Linux executables.  By
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   349
default, valgrind runs a tool called memcheck, which performs a range of memory-
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   350
checking functions, including detecting accesses to uninitialised memory, misuse 
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   351
of allocated memory (double frees, access after free, etc.) and detecting memory 
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   352
leaks.  This can be selected by using the @code{--grind} option.
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   353
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   354
@verbatim
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   355
  ./test.py --grind
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   356
@end verbatim
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   357
5412
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   358
As it runs, @code{test.py} and the programs that it runs indirectly, generate large
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   359
numbers of temporary files.  Usually, the content of these files is not interesting,
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   360
however in some cases it can be useful (for debugging purposes) to view these files.
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   361
@code{test.py} provides a @command{--retain} option which will cause these temporary
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   362
files to be kept after the run is completed.  The files are saved in a directory 
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   363
named @code{testpy} under a subdirectory named according to the current Coordinated
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   364
Universal Time (also known as Greenwich Mean Time).
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   365
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   366
@verbatim
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   367
  ./test.py --retain
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   368
@end verbatim
00d7fe69d024 refalgamize temporary files in test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5371
diff changeset
   369
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   370
Finally, @code{test.py} provides a @command{--verbose} option which will print
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   371
large amounts of information about its progress.  It is not expected that this
5371
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   372
will be terribly useful unless there is an error.  In this case, you can get
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   373
access to the standard output and standard error reported by running test suites
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   374
and examples.  Select verbose in the following way:
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   375
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   376
@verbatim
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   377
  ./test.py --verbose
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   378
@end verbatim
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   379
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   380
All of these options can be mixed and matched.  For example, to run all of the 
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   381
ns-3 core test suites under valgrind, in verbose mode, while generating an HTML
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   382
output file, one would do:
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   383
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   384
@verbatim
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   385
  ./test.py --verbose --grind --constrain=core --html=results.html 
6020e8d86ffa update test.py documentation
Craig Dowell <craigdo@ee.washington.edu>
parents: 5358
diff changeset
   386
@end verbatim
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   387
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   388
@node TestTaxonomy
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   389
@section Test Taxonomy
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   390
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   391
As mentioned above, tests are grouped into a number of broadly defined 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   392
classifications to allow users to selectively run tests to address the different
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   393
kinds of testing that need to be done.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   394
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   395
@itemize @bullet
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   396
@item Build Verification Tests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   397
@item Unit Tests 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   398
@item System Tests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   399
@item Examples
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   400
@item Performance Tests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   401
@end itemize
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   402
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   403
@node BuildVerificationTests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   404
@subsection Build Verification Tests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   405
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   406
These are relatively simple tests that are built along with the distribution
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   407
and are used to make sure that the build is pretty much working.  Our
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   408
current unit tests live in the source files of the code they test and are
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   409
built into the ns-3 modules; and so fit the description of BVTs.  BVTs live
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   410
in the same source code that is built into the ns-3 code.  Our current tests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   411
are examples of this kind of test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   412
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   413
@node UnitTests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   414
@subsection Unit Tests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   415
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   416
Unit tests are more involved tests that go into detail to make sure that a
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   417
piece of code works as advertised in isolation.  There is really no reason
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   418
for this kind of test to be built into an ns-3 module.  It turns out, for
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   419
example, that the unit tests for the object name service are about the same
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   420
size as the object name service code itself.  Unit tests are tests that
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   421
check a single bit of functionality that are not built into the ns-3 code,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   422
but live in the same directory as the code it tests.  It is possible that
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   423
these tests check integration of multiple implementation files in a module
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   424
as well.  The file src/core/names-test-suite.cc is an example of this kind
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   425
of test.  The file src/common/pcap-file-test-suite.cc is another example
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   426
that uses a known good pcap file as a test vector file.  This file is stored
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   427
locally in the src/common directory.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   428
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   429
@node SystemTests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   430
@subsection System Tests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   431
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   432
System tests are those that involve more than one module in the system.  We
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   433
have lots of this kind of test running in our current regression framework,
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   434
but they are typically overloaded examples.  We provide a new place 
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   435
for this kind of test in the directory ``src/test''.  The file
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   436
src/test/ns3tcp/ns3-interop-test-suite.cc is an example of this kind of
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   437
test.  It uses NSC TCP to test the ns-3 TCP implementation.  Often there
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   438
will be test vectors required for this kind of test, and they are stored in
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   439
the directory where the test lives.  For example,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   440
ns3tcp-interop-response-vectors.pcap is a file consisting of a number of TCP
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   441
headers that are used as the expected responses of the ns-3 TCP under test
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   442
to a stimulus generated by the NSC TCP which is used as a ``known good''
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   443
implementation.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   444
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   445
@node Examples
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   446
@subsection Examples
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   447
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   448
The examples are tested by the framework to make sure they built and will
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   449
run.  Nothing is checked, and currently the pcap files are just written off
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   450
into /tmp to be discarded.  If the examples run (don't crash) they pass this
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   451
smoke test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   452
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   453
@node PerformanceTests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   454
@subsection Performance Tests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   455
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   456
Performance tests are those which exercise a particular part of the system
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   457
and determine if the tests have executed to completion in a reasonable time.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   458
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   459
@node RunningTests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   460
@section Running Tests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   461
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   462
Tests are typically run using the high level @code{test.py} program.  They
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   463
can also be run ``manually'' using a low level test-runner executable directly
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   464
from @code{waf}.  
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   465
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   466
@node RunningTestsUnderTestRunnerExecutable
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   467
@section Running Tests Under the Test Runner Executable
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   468
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   469
The test-runner is the bridge from generic Python code to @command{ns-3} code.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   470
It is written in C++ and uses the automatic test discovery process in the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   471
@command{ns-3} code to find and allow execution of all of the various tests.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   472
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   473
Although it may not be used directly very often, it is good to understand how
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   474
@code{test.py} actually runs the various tests.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   475
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   476
In order to execute the test-runner, you run it like any other ns-3 executable
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   477
-- using @code{waf}.  To get a list of available options, you can type:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   478
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   479
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   480
  ./waf --run "test-runner --help"
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   481
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   482
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   483
You should see something like the following:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   484
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   485
@smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   486
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   487
  Waf: Entering directory `/home/craigdo/repos/ns-3-allinone-test/ns-3-dev/build'
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   488
  Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone-test/ns-3-dev/build'
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   489
  'build' finished successfully (0.353s)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   490
  --basedir=dir:          Set the base directory (where to find src) to ``dir''
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   491
  --constrain=test-type:  Constrain checks to test suites of type ``test-type''
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   492
  --help:                 Print this message
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   493
  --kinds:                List all of the available kinds of tests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   494
  --list:                 List all of the test suites (optionally constrained by test-type)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   495
  --out=file-name:        Set the test status output file to ``file-name''
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   496
  --suite=suite-name:     Run the test suite named ``suite-name''
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   497
  --verbose:              Turn on messages in the run test suites
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   498
@end verbatim
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   499
@end smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   500
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   501
There are a number of things available to you which will be familiar to you if
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   502
you have looked at @command{test.py}.  This should be expected since the test-
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   503
runner is just an interface between @code{test.py} and @command{ns-3}.  You 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   504
may notice that example-related commands are missing here.  That is because 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   505
the examples are really not @command{ns-3} tests.  @command{test.py} runs them
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   506
as if they were to present a unified testing environment, but they are really
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   507
completely different and not to be found here.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   508
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   509
One new option that appears here is the @code{--basedir} option.  It turns out
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   510
that the tests may need to reference the source directory of the @code{ns-3} 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   511
distribution to find local data, so a base directory is always required to run
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   512
a test.  To run one of the tests directly from the test-runner, you will need
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   513
to specify the test suite to run along with the base directory.  So you could do,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   514
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   515
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   516
  ./waf --run "test-runner --basedir=`pwd` --suite=pcap-file-object"
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   517
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   518
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   519
Note the ``backward'' quotation marks on the @code{pwd} command.  This will run
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   520
the @code{pcap-file-object} test quietly.  The only indication that
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   521
you will get that the test passed is the @emph{absence} of a message from 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   522
@code{waf} saying that the program returned something other than a zero 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   523
exit code.  To get some output from the test, you need to specify an output
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   524
file to which the tests will write their XML status using the @code{--out}
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   525
option.  You need to be careful interpreting the results because the test 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   526
suites will @emph{append} results onto this file.  Try,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   527
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   528
@smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   529
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   530
  ./waf --run "test-runner --basedir=`pwd` --suite=pcap-file-object --out=myfile.xml''
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   531
@end verbatim
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   532
@end smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   533
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   534
If you look at the file @code{myfile.xml} you should see something like,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   535
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   536
@smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   537
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   538
<TestSuite>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   539
  <SuiteName>pcap-file-object</SuiteName>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   540
  <TestCase>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   541
    <CaseName>Check to see that PcapFile::Open with mode ``w'' works</CaseName>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   542
    <CaseResult>PASS</CaseResult>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   543
    <CaseTime>real 0.00 user 0.00 system 0.00</CaseTime>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   544
  </TestCase>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   545
  <TestCase>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   546
    <CaseName>Check to see that PcapFile::Open with mode ``r'' works</CaseName>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   547
    <CaseResult>PASS</CaseResult>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   548
    <CaseTime>real 0.00 user 0.00 system 0.00</CaseTime>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   549
  </TestCase>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   550
  <TestCase>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   551
    <CaseName>Check to see that PcapFile::Open with mode ``a'' works</CaseName>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   552
    <CaseResult>PASS</CaseResult>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   553
    <CaseTime>real 0.00 user 0.00 system 0.00</CaseTime>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   554
  </TestCase>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   555
  <TestCase>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   556
    <CaseName>Check to see that PcapFileHeader is managed correctly</CaseName>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   557
    <CaseResult>PASS</CaseResult>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   558
    <CaseTime>real 0.00 user 0.00 system 0.00</CaseTime>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   559
  </TestCase>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   560
  <TestCase>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   561
    <CaseName>Check to see that PcapRecordHeader is managed correctly</CaseName>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   562
    <CaseResult>PASS</CaseResult>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   563
    <CaseTime>real 0.00 user 0.00 system 0.00</CaseTime>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   564
  </TestCase>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   565
  <TestCase>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   566
    <CaseName>Check to see that PcapFile can read out a known good pcap file</CaseName>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   567
    <CaseResult>PASS</CaseResult>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   568
    <CaseTime>real 0.00 user 0.00 system 0.00</CaseTime>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   569
  </TestCase>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   570
  <SuiteResult>PASS</SuiteResult>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   571
  <SuiteTime>real 0.00 user 0.00 system 0.00</SuiteTime>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   572
</TestSuite>
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   573
@end verbatim
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   574
@end smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   575
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   576
If you are familiar with XML this should be fairly self-explanatory.  It is 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   577
also not a complete XML file since test suites are designed to have their
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   578
output appended to a master XML status file as described in the @command{test.py}
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   579
section.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   580
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   581
@node ClassTestRunner
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   582
@section Class TestRunner
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   583
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   584
The executables that run dedicated test programs use a TestRunner class.  This
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   585
class provides for automatic test registration and listing, as well as a way to
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   586
execute the individual tests.  Individual test suites use C++ global 
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   587
constructors
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   588
to add themselves to a collection of test suites managed by the test runner.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   589
The test runner is used to list all of the available tests and to select a test
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   590
to be run.  This is a quite simple class that provides three static methods to
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   591
provide or Adding and Getting test suites to a collection of tests.  See the 
5245
3e601e88101d Testing document edits
Tom Henderson <tomh@tomh.org>
parents: 4772
diff changeset
   592
doxygen for class @code{ns3::TestRunner} for details.
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   593
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   594
@node TestSuite
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   595
@section Test Suite
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   596
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   597
All @command{ns-3} tests are classified into Test Suites and Test Cases.  A 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   598
test suite is a collection of test cases that completely exercise a given kind
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   599
of functionality.  As described above, test suites can be classified as,
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   600
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   601
@itemize @bullet
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   602
@item Build Verification Tests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   603
@item Unit Tests 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   604
@item System Tests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   605
@item Examples
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   606
@item Performance Tests
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   607
@end itemize
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   608
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   609
This classification is exported from the TestSuite class.  This class is quite
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   610
simple, existing only as a place to export this type and to accumulate test
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   611
cases.  From a user perspective, in order to create a new TestSuite in the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   612
system one only has to define a new class that inherits from class @code{TestSuite}
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   613
and perform these two duties.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   614
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   615
The following code will define a new class that can be run by @code{test.py}
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   616
as a ``unit'' test with the display name, ``my-test-suite-name''.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   617
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   618
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   619
  class MySuite : public TestSuite
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   620
  {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   621
  public:
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   622
    MyTestSuite ();
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   623
  };
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   624
  
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   625
  MyTestSuite::MyTestSuite ()
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   626
    : TestSuite ("my-test-suite-name", UNIT)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   627
  {
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   628
    AddTestCase (new MyTestCase);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   629
  }
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   630
  
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   631
  MyTestSuite myTestSuite;
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   632
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   633
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   634
The base class takes care of all of the registration and reporting required to
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   635
be a good citizen in the test framework.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   636
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   637
@node TestCase
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   638
@section Test Case
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   639
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   640
Individual tests are created using a TestCase class.  Common models for the use
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   641
of a test case include "one test case per feature", and "one test case per method."
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   642
Mixtures of these models may be used.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   643
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   644
In order to create a new test case in the system, all one has to do is to inherit
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   645
from the  @code{TestCase} base class, override the constructor to give the test 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   646
case a name and override the @code{DoRun} method to run the test.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   647
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   648
@verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   649
class MyTestCase : public TestCase
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   650
{
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   651
  MyTestCase ();
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   652
  virtual bool DoRun (void);
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   653
};
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   654
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   655
MyTestCase::MyTestCase ()
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   656
  : TestCase ("Check some bit of functionality")
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   657
{
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   658
}
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   659
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   660
bool
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   661
MyTestCase::DoRun (void)
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   662
{
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   663
  NS_TEST_ASSERT_MSG_EQ (true, true, "Some failure message");
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   664
  return GetErrorStatus ();
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   665
}
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   666
@end verbatim
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   667
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   668
@node Utilities
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   669
@section Utilities
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   670
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   671
There are a number of utilities of various kinds that are also part of the 
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   672
testing framework.  Examples include a generalized pcap file useful for
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   673
storing test vectors; a generic container useful for transient storage of
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   674
test vectors during test execution; and tools for generating presentations
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   675
based on validation and verification testing results.
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   676
5358
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   677
@node Debugging test suite failures
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   678
@section Debugging test suite failures
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   679
5358
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   680
To debug test crashes, such as:
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   681
@verbatim 
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   682
CRASH: TestSuite ns3-wifi-interference
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   683
@end verbatim
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   684
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   685
You can access the underlying test-runner program via gdb as follows, and
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   686
then pass the "--basedir=`pwd`" argument to run (you can also pass other
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   687
arguments as needed, but basedir is the minimum needed)::
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   688
@smallformat
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   689
@verbatim
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   690
./waf --command-template="gdb %s" --run "test-runner"
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   691
5358
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   692
Waf: Entering directory `/home/tomh/hg/sep09/ns-3-allinone/ns-3-dev-678/build'
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   693
Waf: Leaving directory `/home/tomh/hg/sep09/ns-3-allinone/ns-3-dev-678/build'
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   694
'build' finished successfully (0.380s)
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   695
GNU gdb 6.8-debian
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   696
Copyright (C) 2008 Free Software Foundation, Inc.
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   697
L cense GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   698
This is free software: you are free to change and redistribute it.
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   699
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   700
and "show warranty" for details.
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   701
This GDB was configured as "x86_64-linux-gnu"...
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   702
(gdb) r --basedir=`pwd`
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   703
Starting program: <..>/build/debug/utils/test-runner --basedir=`pwd`
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   704
[Thread debugging using libthread_db enabled]
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   705
assert failed. file=../src/core/type-id.cc, line=138, cond="uid <= m_information.size () && uid != 0"
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   706
...
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   707
@end verbatim
7db10ef6e556 document how to use gdb with test framework
Tom Henderson <tomh@tomh.org>
parents: 5245
diff changeset
   708
@end smallformat
4772
7b6ae6bf0055 add test and validation framework
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   709