3
# Copyright 2012 the V8 project authors. All rights reserved.
4
# Redistribution and use in source and binary forms, with or without
5
# modification, are permitted provided that the following conditions are
8
# * Redistributions of source code must retain the above copyright
9
# notice, this list of conditions and the following disclaimer.
10
# * Redistributions in binary form must reproduce the above
11
# copyright notice, this list of conditions and the following
12
# disclaimer in the documentation and/or other materials provided
13
# with the distribution.
14
# * Neither the name of Google Inc. nor the names of its
15
# contributors may be used to endorse or promote products derived
16
# from this software without specific prior written permission.
18
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
# This is a convenience script to run the existing tools/test.py script
32
# when using the gyp/make based build.
33
# It is intended as a stop-gap rather than a long-term solution.
38
from os.path import join, dirname, abspath
43
PROGRESS_INDICATORS = ['verbose', 'dots', 'color', 'mono']
47
result = optparse.OptionParser()
49
# Flags specific to this wrapper script:
50
result.add_option("--arch-and-mode",
51
help='Architecture and mode in the format "arch.mode"',
53
result.add_option("--outdir",
54
help='Base output directory',
56
result.add_option("--no-presubmit",
57
help='Skip presubmit checks',
58
default=False, action="store_true")
59
result.add_option("--buildbot",
60
help='Adapt to path structure used on buildbots',
61
default=False, action="store_true")
63
# Flags this wrapper script handles itself:
64
result.add_option("-m", "--mode",
65
help="The test modes in which to run (comma-separated)",
66
default='release,debug')
67
result.add_option("--arch",
68
help='The architectures to run tests for (comma-separated)',
69
default='ia32,x64,arm')
71
# Flags that are passed on to the wrapped test.py script:
72
result.add_option("-v", "--verbose", help="Verbose output",
73
default=False, action="store_true")
74
result.add_option("-p", "--progress",
75
help="The style of progress indicator (verbose, dots, color, mono)",
76
choices=PROGRESS_INDICATORS, default="mono")
77
result.add_option("--report", help="Print a summary of the tests to be run",
78
default=False, action="store_true")
79
result.add_option("--download-data", help="Download missing test suite data",
80
default=False, action="store_true")
81
result.add_option("-s", "--suite", help="A test suite",
82
default=[], action="append")
83
result.add_option("-t", "--timeout", help="Timeout in seconds",
84
default=60, type="int")
85
result.add_option("--snapshot", help="Run the tests with snapshot turned on",
86
default=False, action="store_true")
87
result.add_option("--special-command", default=None)
88
result.add_option("--valgrind", help="Run tests through valgrind",
89
default=False, action="store_true")
90
result.add_option("--cat", help="Print the source of the tests",
91
default=False, action="store_true")
92
result.add_option("--warn-unused", help="Report unused rules",
93
default=False, action="store_true")
94
result.add_option("-j", help="The number of parallel tasks to run",
95
default=1, type="int")
96
result.add_option("--time", help="Print timing information after running",
97
default=False, action="store_true")
98
result.add_option("--suppress-dialogs",
99
help="Suppress Windows dialogs for crashing tests",
100
dest="suppress_dialogs", default=True, action="store_true")
101
result.add_option("--no-suppress-dialogs",
102
help="Display Windows dialogs for crashing tests",
103
dest="suppress_dialogs", action="store_false")
104
result.add_option("--isolates", help="Whether to test isolates",
105
default=False, action="store_true")
106
result.add_option("--store-unexpected-output",
107
help="Store the temporary JS files from tests that fails",
108
dest="store_unexpected_output", default=True, action="store_true")
109
result.add_option("--no-store-unexpected-output",
110
help="Deletes the temporary JS files from tests that fails",
111
dest="store_unexpected_output", action="store_false")
112
result.add_option("--stress-only",
113
help="Only run tests with --always-opt --stress-opt",
114
default=False, action="store_true")
115
result.add_option("--nostress",
116
help="Don't run crankshaft --always-opt --stress-op test",
117
default=False, action="store_true")
118
result.add_option("--shard-count",
119
help="Split testsuites into this number of shards",
120
default=1, type="int")
121
result.add_option("--shard-run",
122
help="Run this shard from the split up tests.",
123
default=1, type="int")
124
result.add_option("--noprof", help="Disable profiling support",
127
# Flags present in the original test.py that are unsupported in this wrapper:
128
# -S [-> scons_flags] (we build with gyp/make, not scons)
129
# --no-build (always true)
130
# --build-only (always false)
131
# --build-system (always 'gyp')
132
# --simulator (always true if arch==arm, always false otherwise)
133
# --shell (automatically chosen depending on arch and mode)
138
def ProcessOptions(options):
139
if options.arch_and_mode == ".":
143
if options.arch_and_mode != None and options.arch_and_mode != "":
144
tokens = options.arch_and_mode.split(".")
145
options.arch = tokens[0]
146
options.mode = tokens[1]
147
options.mode = options.mode.split(',')
148
options.arch = options.arch.split(',')
149
for mode in options.mode:
150
if not mode.lower() in ['debug', 'release']:
151
print "Unknown mode %s" % mode
153
for arch in options.arch:
154
if not arch in ['ia32', 'x64', 'arm', 'mipsel', 'android_arm',
156
print "Unknown architecture %s" % arch
159
# Buildbots run presubmit tests as a separate step.
160
options.no_presubmit = True
164
def PassOnOptions(options):
167
result += ['--verbose']
168
if options.progress != 'mono':
169
result += ['--progress=' + options.progress]
171
result += ['--report']
172
if options.download_data:
173
result += ['--download-data']
174
if options.suite != []:
175
for suite in options.suite:
176
result += ['--suite=../../test/' + suite]
177
if options.timeout != 60:
178
result += ['--timeout=%s' % options.timeout]
180
result += ['--snapshot']
181
if options.special_command:
182
result += ['--special-command="%s"' % options.special_command]
184
result += ['--valgrind']
187
if options.warn_unused:
188
result += ['--warn-unused']
190
result += ['-j%s' % options.j]
193
if not options.suppress_dialogs:
194
result += ['--no-suppress-dialogs']
196
result += ['--isolates']
197
if not options.store_unexpected_output:
198
result += ['--no-store-unexpected_output']
199
if options.stress_only:
200
result += ['--stress-only']
202
result += ['--nostress']
203
if options.shard_count != 1:
204
result += ['--shard-count=%s' % options.shard_count]
205
if options.shard_run != 1:
206
result += ['--shard-run=%s' % options.shard_run]
208
result += ['--noprof']
213
parser = BuildOptions()
214
(options, args) = parser.parse_args()
215
if not ProcessOptions(options):
219
workspace = abspath(join(dirname(sys.argv[0]), '..'))
222
if not options.no_presubmit:
223
print ">>> running presubmit tests"
224
returncodes += subprocess.call([sys.executable,
225
workspace + '/tools/presubmit.py'])
227
args_for_children = [sys.executable]
228
args_for_children += [workspace + '/tools/test.py'] + PassOnOptions(options)
229
args_for_children += ['--no-build', '--build-system=gyp']
231
args_for_children += [arg]
234
for mode in options.mode:
235
for arch in options.arch:
236
print ">>> running tests for %s.%s" % (arch, mode)
238
shellpath = workspace + '/' + options.outdir + '/' + mode
241
shellpath = workspace + '/' + options.outdir + '/' + arch + '.' + mode
242
env['LD_LIBRARY_PATH'] = shellpath + '/lib.target'
243
shell = shellpath + "/d8"
244
cmdline = ' '.join(args_for_children +
247
['--shell=' + shell])
248
child = subprocess.Popen(cmdline,
252
returncodes += child.wait()
254
if len(options.mode) == 0 and len(options.arch) == 0:
255
print ">>> running tests"
256
shellpath = workspace + '/' + options.outdir
257
env['LD_LIBRARY_PATH'] = shellpath + '/lib.target'
258
shell = shellpath + '/d8'
259
child = subprocess.Popen(' '.join(args_for_children +
260
['--shell=' + shell]),
264
returncodes = child.wait()
269
if __name__ == '__main__':