A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
test-waf.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 waf 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
# build : executes the build (pre: configure, post: clean)
27
# check : run the equivalent of the old ns-3 unit tests using test.py
28
# clean : cleans the project
29
# configure: configures the project (pore: None, post: distclean)
30
# dist : makes a tarball for redistributing the sources (pre:none )
31
# distcheck: checks if the project compiles (tarball from 'dist') (pre: dist, post: rm -rf ns-3*.tar.bz2)
32
# docs : build all the documentation: doxygen, manual, tutorial, models (pre: configure; post: distclean)
33
# doxygen : do a full build, generate the introspected doxygen and then the doxygen
34
# install : installs the targets on the system (pre: configure, post: uninstall )
35
# list : lists the targets to execute (pre: configure)
36
# shell : run a shell with an environment suitably modified to run locally built programs (pre:configure)
37
# sphinx : build the Sphinx documentation: manual, tutorial, models
38
# step : executes tasks in a step-by-step fashion, for debugging (pre: configure)
39
# uninstall: removes the targets installed (pre: install, post uninstall)
40
# *update : updates the plugins from the *waflib/extras* directory
41
42
43
44
45
from
__future__
import
print_function
46
from
TestBase
import
TestBaseClass
47
import
sys
48
49
def
replace
(pre, post, main_cmd_list):
50
if
pre:
51
pre = pre +
' && '
52
else
:
53
pre =
''
54
if
post:
55
post =
' && '
+ post
56
else
:
57
post =
''
58
return
[ pre + main_cmd + post
for
main_cmd
in
main_cmd_list ]
59
60
def
main(argv):
61
"""
62
Prepares test cases and executes
63
"""
64
runner =
TestBaseClass
(argv[1:],
"Test suite for the ns-3 Waf build system"
,
'waf'
)
65
in_cmds = runner.override_cmds()
66
if
in_cmds:
67
cmds = in_cmds.split(
','
)
68
else
:
69
cmds = [
'basic'
,
'build'
,
'configure'
,
'step'
,
'clean'
,
'dist'
,
'list'
]
70
71
config_test_cases = [
72
"--enable-gcov"
,
73
"--enable-sudo"
,
74
"--enable-sudo"
,
75
"--enable-tests"
,
76
"--disable-tests"
,
77
"--enable-examples"
,
78
"--disable-examples"
,
79
"--doxygen-no-build"
,
80
"--enable-static"
,
81
"--enable-mpi"
,
82
"--enable-rpath"
,
83
"--enable-modules=build/utils/test-runner.cc.1.o"
,
84
"--boost-static"
,
85
"--boost-mt"
,
86
"--boost-linkage_autodetect"
,
87
"--boost-python=33"
,
88
"--disable-gtk"
,
89
"--int64x64=cairo"
,
90
"--disable-pthread"
,
91
"--force-planetlab"
,
92
"--nopyc"
,
93
"--nopyo"
,
94
"--disable-python"
,
95
"--apiscan=all"
,
96
"--with-python=/usr/bin/python2.7"
,
97
"--no32bit-scan"
,
98
"-o test_out && rm -rf test_out"
,
99
"--out=test_out && rm -rf test_out"
,
100
"-t test_top && rm -rf test_top"
,
101
"--top=test_top && rm -rf test_top"
,
102
"--download"
,
103
"--check-c-compiler=gc"
,
104
"--check-cxx-compiler=g++"
,
105
]
106
107
basic_test_cases = [
108
"--version"
,
109
"-h"
,
110
"--help"
,
111
]
112
113
build_test_cases = [
114
"-j10"
,
115
"--jobs=10"
,
116
"-d optimized"
,
117
"-d debug"
,
118
"-d release"
,
119
"--build-profile optimized"
,
120
"--build-profile debug"
,
121
"--build-profile release"
,
122
"-p"
,
123
"--progress"
,
124
]
125
126
step_test_cases = [
127
"--files=\"*/main.c,*/test/main.o\""
,
128
]
129
130
install_test_cases = [
131
"-f"
,
132
"--force"
,
133
"--prefix=./test-prefix && rm -rf ./test-prefix"
,
134
"--exec-prefix=."
,
135
"--bindir=./test-prefix/bin --sbindir=./test-prefix/sbin --libexecdir=./test-prefix/libexec --sysconfdir=./test-prefix/etc --sharedstatedir=./test-prefix/com --localstatedir=./test-prefix/var --libdir=./test-prefix/lib --includedir=./test-prefix/include --oldincludedir=./test-prefix/usr/include --datarootdir=./test-prefix/share --datadir=./test-prefix/share_root --infodir=./test-prefix/info --localedir=./test-prefix/locale --mandir=./test-prefix/man --docdir=./test-prefix/doc/package --htmldir=./test-prefix/doc --dvidir=./test-prefix/doc --pdfdir=./test-prefix/doc --psdir=./test-prefix/doc && rm -rf ./test-prefix"
,
136
]
137
138
common_test_cases = [
139
""
,
140
"-k"
,
141
"--keep"
,
142
"-v"
,
143
"--verbose"
,
144
"--nocache"
,
145
"--zones=task_gen"
,
146
"--zones=deps"
,
147
"--zones=tasks"
,
148
"--no-task-lines"
,
149
]
150
151
test_case_mappings = {
152
'basic'
: basic_test_cases,
153
'configure'
: config_test_cases,
154
'build'
: build_test_cases,
155
'step'
: step_test_cases,
156
'install'
: install_test_cases,
157
}
158
159
waf_string = sys.executable +
' waf'
160
cmd_execute_list = []
161
for
cmd
in
cmds:
162
if
cmd ==
'basic'
:
163
cmd_list = []
164
else
:
165
cmd_list = [
'%s %s %s'
% (waf_string, cmd, option)
for
option
in
common_test_cases ]
166
if
cmd
in
test_case_mappings:
167
cmd_list += [
'%s %s %s'
% (waf_string, cmd, option)
for
option
in
test_case_mappings[cmd] ]
168
if
cmd ==
'basic'
:
169
cmd_list.append(
'%s configure && %s build && %s --run scratch/myfirst'
% tuple([waf_string]*3))
170
cmd_list.append(
'%s configure && %s build && %s --pyrun scratch/myfirst.py'
% tuple([waf_string]*3))
171
if
cmd ==
'build'
:
172
cmd_list =
replace
(waf_string+
' configure'
, waf_string+
' clean'
, cmd_list)
173
cmd_list.append(
'%s configure --enable-gcov && %s build --lcov-report && %s clean'
% tuple([waf_string]*3))
174
elif
cmd ==
'configure'
:
175
cmd_list =
replace
(
None
, waf_string+
' distclean'
, cmd_list)
176
elif
cmd ==
'distcheck'
:
177
cmd_list =
replace
(waf_string+
' dist'
,
'rm -rf ns-3*.tar.bz2'
, cmd_list)
178
elif
cmd ==
'docs'
:
179
cmd_list =
replace
(waf_string+
' configure'
, waf_string+
' distclean'
, cmd_list)
180
elif
cmd ==
'install'
:
181
cmd_list =
replace
(waf_string+
' configure'
, waf_string+
' uninstall'
, cmd_list)
182
elif
cmd ==
'list'
:
183
cmd_list =
replace
(waf_string+
' configure'
, waf_string +
' distclean'
, cmd_list)
184
elif
cmd ==
'shell'
:
185
cmd_list =
replace
(waf_string+
' configure'
, waf_string+
' distclean'
, cmd_list)
186
elif
cmd ==
'step'
:
187
cmd_list =
replace
(waf_string+
' configure'
, waf_string+
' distclean'
, cmd_list)
188
elif
cmd ==
'uninstall'
:
189
cmd_list =
replace
(waf_string+
' install'
,
None
, cmd_list)
190
cmd_execute_list += cmd_list
191
192
return
runner.runtests(cmd_execute_list)
193
194
if
__name__ ==
'__main__'
:
195
sys.exit(main(sys.argv))
test-waf.replace
def replace(pre, post, main_cmd_list)
Definition:
test-waf.py:49
TestBase.TestBaseClass
TestBaseClass class.
Definition:
TestBase.py:53
utils
tests
test-waf.py
Generated on Wed Mar 21 2018 14:24:37 for ns-3 by
1.8.9.1