A Discrete-Event Network Simulator
API
test-test.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
3 #
4 # Copyright (c) 2014 Siddharth Santurkar
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 2 as
8 # published by the Free Software Foundation;
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 #
19 
20 # NOTE: Run this script with the Python3 interpreter if the python3 compatibility
21 # of the ns-3 unit test runner needs to be tested.
22 
23 # The following options of test.py are being tested for poratability by this script.
24 # To see the options supported by this script, run with the -h option on the command line
25 #
26 # -h, --help show this help message and exit
27 # -b BUILDPATH, --buildpath=BUILDPATH
28 # specify the path where ns-3 was built (defaults to the
29 # build directory for the current variant)
30 # -c KIND, --constrain=KIND
31 # constrain the test-runner by kind of test
32 # -d, --duration print the duration of each test suite and example
33 # -e EXAMPLE, --example=EXAMPLE
34 # specify a single example to run (no relative path is
35 # needed)
36 # -u, --update-data If examples use reference data files, get them to re-
37 # generate them
38 # -f FULLNESS, --fullness=FULLNESS
39 # choose the duration of tests to run: QUICK, EXTENSIVE,
40 # or TAKES_FOREVER, where EXTENSIVE includes QUICK and
41 # TAKES_FOREVER includes QUICK and EXTENSIVE (only QUICK
42 # tests are run by default)
43 # -g, --grind run the test suites and examples using valgrind
44 # -k, --kinds print the kinds of tests available
45 # -l, --list print the list of known tests
46 # -m, --multiple report multiple failures from test suites and test
47 # cases
48 # -n, --nowaf do not run waf before starting testing
49 # -p PYEXAMPLE, --pyexample=PYEXAMPLE
50 # specify a single python example to run (with relative
51 # path)
52 # -r, --retain retain all temporary files (which are normally
53 # deleted)
54 # -s TEST-SUITE, --suite=TEST-SUITE
55 # specify a single test suite to run
56 # -t TEXT-FILE, --text=TEXT-FILE
57 # write detailed test results into TEXT-FILE.txt
58 # -v, --verbose print progress and informational messages
59 # -w HTML-FILE, --web=HTML-FILE, --html=HTML-FILE
60 # write detailed test results into HTML-FILE.html
61 # -x XML-FILE, --xml=XML-FILE
62 # write detailed test results into XML-FILE.xml
63 
64 
65 
66 from __future__ import print_function
67 from TestBase import TestBaseClass
68 import sys
69 
70 def main(argv):
71  """
72  Prepares test cases and executes
73  """
74  test_cases = [
75  '',
76  '-h',
77  '--help',
78  '-b build/',
79  '--buildpath=build/',
80  '-c performance',
81  '--constrain=performance',
82  '-d',
83  '--duration',
84  '-e socket-options-ipv6',
85  '--example=socket-options-ipv6',
86  '-u',
87  '--update-data',
88  '-f EXTENSIVE --fullness=EXTENSIVE'
89  '-g',
90  '--grind',
91  '-l',
92  '--list',
93  '-m',
94  '--multiple',
95  '-n',
96  '--nowaf',
97  '-p first',
98  '--pyexample=first',
99  '-r',
100  '--retain',
101  '-s ns3-tcp-interoperability',
102  '--suite=ns3-tcp-interoperability',
103  '-t t_opt.txt',
104  '--text=t_opt.txt && rm -rf t_opt.txt',
105  '-v',
106  '--verbose',
107  '-w t_opt.html && rm -rf t_opt.html',
108  '--web=t_opt.html && rm -rf t_opt.html',
109  '--html=t_opt.html && rm -rf t_opt.html',
110  '-x t_opt.xml && rm -rf t_opt.xml',
111  '--xml=t_opt.xml && rm -rf t_opt.xml',
112  ]
113 
114  configure_string = sys.executable + ' waf configure --enable-tests --enable-examples'
115  clean_string = sys.executable + ' waf clean'
116  cmd_execute_list = [ '%s && %s test.py %s && %s' % (configure_string, sys.executable, option, clean_string) for option in test_cases]
117  runner = TestBaseClass(argv[1:], "Test suite for the ns-3 unit test runner" , 'test-py')
118  return runner.runtests(cmd_execute_list)
119 
120 if __name__ == '__main__':
121  sys.exit(main(sys.argv))
TestBaseClass class.
Definition: TestBase.py:53