blob: 2dc61f62835c8df2d9043c5c57677e0b9b5b4878 [file] [log] [blame]
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001"""
2A simple testing framework for lldb using python's unit testing framework.
3
4Tests for lldb are written as python scripts which take advantage of the script
5bridging provided by LLDB.framework to interact with lldb core.
6
7A specific naming pattern is followed by the .py script to be recognized as
8a module which implements a test scenario, namely, Test*.py.
9
10To specify the directories where "Test*.py" python test scripts are located,
11you need to pass in a list of directory names. By default, the current
12working directory is searched if nothing is specified on the command line.
13
14Type:
15
16./dotest.py -h
17
18for available options.
19"""
20
Zachary Turnerc1b7cd72015-11-05 19:22:28 +000021from __future__ import absolute_import
Zachary Turnerc432c8f2015-10-28 17:43:26 +000022from __future__ import print_function
Zachary Turnerc1b7cd72015-11-05 19:22:28 +000023
24# System modules
Zachary Turnerc432c8f2015-10-28 17:43:26 +000025import atexit
Zachary Turnerc432c8f2015-10-28 17:43:26 +000026import os
Zachary Turnerc432c8f2015-10-28 17:43:26 +000027import errno
Tim Hammerquist84858212017-03-17 18:10:58 +000028import logging
Zachary Turnerc432c8f2015-10-28 17:43:26 +000029import platform
Francis Ricci69517072016-09-23 21:32:47 +000030import re
Zachary Turnerc432c8f2015-10-28 17:43:26 +000031import signal
32import socket
33import subprocess
34import sys
Zachary Turnerc432c8f2015-10-28 17:43:26 +000035
Zachary Turnerc1b7cd72015-11-05 19:22:28 +000036# Third-party modules
Zachary Turnerc432c8f2015-10-28 17:43:26 +000037import six
Zachary Turnerc1b7cd72015-11-05 19:22:28 +000038import unittest2
39
40# LLDB Modules
41import lldbsuite
Zachary Turner606e3a52015-12-08 01:15:30 +000042from . import configuration
Zachary Turnerc1b7cd72015-11-05 19:22:28 +000043from . import dotest_args
44from . import lldbtest_config
45from . import test_categories
Todd Fiala49d3c152016-04-20 16:27:27 +000046from lldbsuite.test_event import formatter
Zachary Turnerb4733e62015-12-08 01:15:44 +000047from . import test_result
Todd Fiala49d3c152016-04-20 16:27:27 +000048from lldbsuite.test_event.event_builder import EventBuilder
Zachary Turnerc1b7cd72015-11-05 19:22:28 +000049from ..support import seven
Zachary Turnerc432c8f2015-10-28 17:43:26 +000050
Kate Stoneb9c1b512016-09-06 20:57:50 +000051
Zachary Turnerc432c8f2015-10-28 17:43:26 +000052def is_exe(fpath):
53 """Returns true if fpath is an executable."""
54 return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
55
Kate Stoneb9c1b512016-09-06 20:57:50 +000056
Zachary Turnerc432c8f2015-10-28 17:43:26 +000057def which(program):
58 """Returns the full path to a program; None otherwise."""
59 fpath, fname = os.path.split(program)
60 if fpath:
61 if is_exe(program):
62 return program
63 else:
64 for path in os.environ["PATH"].split(os.pathsep):
65 exe_file = os.path.join(path, program)
66 if is_exe(exe_file):
67 return exe_file
68 return None
69
Kate Stoneb9c1b512016-09-06 20:57:50 +000070
Zachary Turnerc432c8f2015-10-28 17:43:26 +000071class _WritelnDecorator(object):
72 """Used to decorate file-like objects with a handy 'writeln' method"""
Kate Stoneb9c1b512016-09-06 20:57:50 +000073
74 def __init__(self, stream):
Zachary Turnerc432c8f2015-10-28 17:43:26 +000075 self.stream = stream
76
77 def __getattr__(self, attr):
78 if attr in ('stream', '__getstate__'):
79 raise AttributeError(attr)
Kate Stoneb9c1b512016-09-06 20:57:50 +000080 return getattr(self.stream, attr)
Zachary Turnerc432c8f2015-10-28 17:43:26 +000081
82 def writeln(self, arg=None):
83 if arg:
84 self.write(arg)
Kate Stoneb9c1b512016-09-06 20:57:50 +000085 self.write('\n') # text-mode streams translate to \r\n if needed
Zachary Turnerc432c8f2015-10-28 17:43:26 +000086
87#
88# Global variables:
89#
Kate Stoneb9c1b512016-09-06 20:57:50 +000090
91
Zachary Turnerc432c8f2015-10-28 17:43:26 +000092def usage(parser):
93 parser.print_help()
Zachary Turner606e3a52015-12-08 01:15:30 +000094 if configuration.verbose > 0:
Zachary Turnerc432c8f2015-10-28 17:43:26 +000095 print("""
96Examples:
97
98This is an example of using the -f option to pinpoint to a specific test class
99and test method to be run:
100
101$ ./dotest.py -f ClassTypesTestCase.test_with_dsym_and_run_command
102----------------------------------------------------------------------
103Collected 1 test
104
105test_with_dsym_and_run_command (TestClassTypes.ClassTypesTestCase)
106Test 'frame variable this' when stopped on a class constructor. ... ok
107
108----------------------------------------------------------------------
109Ran 1 test in 1.396s
110
111OK
112
113And this is an example of using the -p option to run a single file (the filename
114matches the pattern 'ObjC' and it happens to be 'TestObjCMethods.py'):
115
116$ ./dotest.py -v -p ObjC
117----------------------------------------------------------------------
118Collected 4 tests
119
120test_break_with_dsym (TestObjCMethods.FoundationTestCase)
121Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'. ... ok
122test_break_with_dwarf (TestObjCMethods.FoundationTestCase)
123Test setting objc breakpoints using '_regexp-break' and 'breakpoint set'. ... ok
124test_data_type_and_expr_with_dsym (TestObjCMethods.FoundationTestCase)
125Lookup objective-c data types and evaluate expressions. ... ok
126test_data_type_and_expr_with_dwarf (TestObjCMethods.FoundationTestCase)
127Lookup objective-c data types and evaluate expressions. ... ok
128
129----------------------------------------------------------------------
130Ran 4 tests in 16.661s
131
132OK
133
134Running of this script also sets up the LLDB_TEST environment variable so that
135individual test cases can locate their supporting files correctly. The script
136tries to set up Python's search paths for modules by looking at the build tree
137relative to this script. See also the '-i' option in the following example.
138
139Finally, this is an example of using the lldb.py module distributed/installed by
140Xcode4 to run against the tests under the 'forward' directory, and with the '-w'
141option to add some delay between two tests. It uses ARCH=x86_64 to specify that
142as the architecture and CC=clang to specify the compiler used for the test run:
143
144$ PYTHONPATH=/Xcode4/Library/PrivateFrameworks/LLDB.framework/Versions/A/Resources/Python ARCH=x86_64 CC=clang ./dotest.py -v -w -i forward
145
146Session logs for test failures/errors will go into directory '2010-11-11-13_56_16'
147----------------------------------------------------------------------
148Collected 2 tests
149
150test_with_dsym_and_run_command (TestForwardDeclaration.ForwardDeclarationTestCase)
151Display *bar_ptr when stopped on a function with forward declaration of struct bar. ... ok
152test_with_dwarf_and_run_command (TestForwardDeclaration.ForwardDeclarationTestCase)
153Display *bar_ptr when stopped on a function with forward declaration of struct bar. ... ok
154
155----------------------------------------------------------------------
156Ran 2 tests in 5.659s
157
158OK
159
160The 'Session ...' verbiage is recently introduced (see also the '-s' option) to
161notify the directory containing the session logs for test failures or errors.
162In case there is any test failure/error, a similar message is appended at the
163end of the stderr output for your convenience.
164
165ENABLING LOGS FROM TESTS
166
167Option 1:
168
169Writing logs into different files per test case::
170
171This option is particularly useful when multiple dotest instances are created
172by dosep.py
173
174$ ./dotest.py --channel "lldb all"
175
176$ ./dotest.py --channel "lldb all" --channel "gdb-remote packets"
177
178These log files are written to:
179
180<session-dir>/<test-id>-host.log (logs from lldb host process)
181<session-dir>/<test-id>-server.log (logs from debugserver/lldb-server)
182<session-dir>/<test-id>-<test-result>.log (console logs)
183
184By default, logs from successful runs are deleted. Use the --log-success flag
185to create reference logs for debugging.
186
187$ ./dotest.py --log-success
188
189Option 2: (DEPRECATED)
190
191The following options can only enable logs from the host lldb process.
192Only categories from the "lldb" or "gdb-remote" channels can be enabled
193They also do not automatically enable logs in locally running debug servers.
194Also, logs from all test case are written into each log file
195
196o LLDB_LOG: if defined, specifies the log file pathname for the 'lldb' subsystem
197 with a default option of 'event process' if LLDB_LOG_OPTION is not defined.
198
199o GDB_REMOTE_LOG: if defined, specifies the log file pathname for the
200 'process.gdb-remote' subsystem with a default option of 'packets' if
201 GDB_REMOTE_LOG_OPTION is not defined.
202
203""")
204 sys.exit(0)
205
Kate Stoneb9c1b512016-09-06 20:57:50 +0000206
Francis Ricci69517072016-09-23 21:32:47 +0000207def parseExclusion(exclusion_file):
208 """Parse an exclusion file, of the following format, where
209 'skip files', 'skip methods', 'xfail files', and 'xfail methods'
210 are the possible list heading values:
211
212 skip files
213 <file name>
214 <file name>
215
216 xfail methods
217 <method name>
218 """
219 excl_type = None
Francis Ricci69517072016-09-23 21:32:47 +0000220
221 with open(exclusion_file) as f:
222 for line in f:
Francis Riccif833f172016-10-04 18:48:00 +0000223 line = line.strip()
Francis Ricci69517072016-09-23 21:32:47 +0000224 if not excl_type:
Francis Riccif833f172016-10-04 18:48:00 +0000225 excl_type = line
Francis Ricci69517072016-09-23 21:32:47 +0000226 continue
227
Francis Ricci69517072016-09-23 21:32:47 +0000228 if not line:
229 excl_type = None
Francis Riccif833f172016-10-04 18:48:00 +0000230 elif excl_type == 'skip':
231 if not configuration.skip_tests:
232 configuration.skip_tests = []
233 configuration.skip_tests.append(line)
234 elif excl_type == 'xfail':
235 if not configuration.xfail_tests:
236 configuration.xfail_tests = []
237 configuration.xfail_tests.append(line)
Francis Ricci69517072016-09-23 21:32:47 +0000238
239
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000240def parseOptionsAndInitTestdirs():
241 """Initialize the list of directories containing our unittest scripts.
242
243 '-h/--help as the first option prints out usage info and exit the program.
244 """
245
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000246 do_help = False
247
248 platform_system = platform.system()
249 platform_machine = platform.machine()
250
251 parser = dotest_args.create_parser()
252 args = dotest_args.parse_args(parser, sys.argv[1:])
253
254 if args.unset_env_varnames:
255 for env_var in args.unset_env_varnames:
256 if env_var in os.environ:
257 # From Python Doc: When unsetenv() is supported, deletion of items in os.environ
Kate Stoneb9c1b512016-09-06 20:57:50 +0000258 # is automatically translated into a corresponding call to
259 # unsetenv().
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000260 del os.environ[env_var]
Kate Stoneb9c1b512016-09-06 20:57:50 +0000261 # os.unsetenv(env_var)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000262
263 if args.set_env_vars:
264 for env_var in args.set_env_vars:
265 parts = env_var.split('=', 1)
266 if len(parts) == 1:
267 os.environ[parts[0]] = ""
268 else:
269 os.environ[parts[0]] = parts[1]
270
271 # only print the args if being verbose (and parsable is off)
272 if args.v and not args.q:
273 print(sys.argv)
274
275 if args.h:
276 do_help = True
277
Pavel Labath6de25ec2017-03-15 08:51:59 +0000278 if args.compiler:
Tim Hammerquist84858212017-03-17 18:10:58 +0000279 configuration.compiler = os.path.realpath(args.compiler)
280 if not is_exe(configuration.compiler):
281 logging.error(
282 '%s is not a valid compiler executable; aborting...',
283 args.compiler)
284 sys.exit(-1)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000285 else:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000286 # Use a compiler appropriate appropriate for the Apple SDK if one was
287 # specified
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000288 if platform_system == 'Darwin' and args.apple_sdk:
Pavel Labath6de25ec2017-03-15 08:51:59 +0000289 configuration.compiler = seven.get_command_output(
290 'xcrun -sdk "%s" -find clang 2> /dev/null' %
291 (args.apple_sdk))
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000292 else:
293 # 'clang' on ubuntu 14.04 is 3.4 so we try clang-3.5 first
294 candidateCompilers = ['clang-3.5', 'clang', 'gcc']
295 for candidate in candidateCompilers:
296 if which(candidate):
Pavel Labath6de25ec2017-03-15 08:51:59 +0000297 configuration.compiler = candidate
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000298 break
299
300 if args.channels:
301 lldbtest_config.channels = args.channels
302
303 if args.log_success:
304 lldbtest_config.log_success = args.log_success
305
306 # Set SDKROOT if we are using an Apple SDK
307 if platform_system == 'Darwin' and args.apple_sdk:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000308 os.environ['SDKROOT'] = seven.get_command_output(
309 'xcrun --sdk "%s" --show-sdk-path 2> /dev/null' %
310 (args.apple_sdk))
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000311
Pavel Labath6de25ec2017-03-15 08:51:59 +0000312 if args.arch:
313 configuration.arch = args.arch
314 if configuration.arch.startswith(
315 'arm') and platform_system == 'Darwin' and not args.apple_sdk:
316 os.environ['SDKROOT'] = seven.get_command_output(
317 'xcrun --sdk iphoneos.internal --show-sdk-path 2> /dev/null')
318 if not os.path.exists(os.environ['SDKROOT']):
Kate Stoneb9c1b512016-09-06 20:57:50 +0000319 os.environ['SDKROOT'] = seven.get_command_output(
Pavel Labath6de25ec2017-03-15 08:51:59 +0000320 'xcrun --sdk iphoneos --show-sdk-path 2> /dev/null')
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000321 else:
Pavel Labath6de25ec2017-03-15 08:51:59 +0000322 configuration.arch = platform_machine
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000323
324 if args.categoriesList:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000325 configuration.categoriesList = set(
326 test_categories.validate(
327 args.categoriesList, False))
Zachary Turner606e3a52015-12-08 01:15:30 +0000328 configuration.useCategories = True
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000329 else:
Zachary Turner606e3a52015-12-08 01:15:30 +0000330 configuration.categoriesList = []
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000331
332 if args.skipCategories:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000333 configuration.skipCategories = test_categories.validate(
334 args.skipCategories, False)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000335
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000336 if args.E:
337 cflags_extras = args.E
338 os.environ['CFLAGS_EXTRAS'] = cflags_extras
339
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000340 if args.d:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000341 sys.stdout.write(
342 "Suspending the process %d to wait for debugger to attach...\n" %
343 os.getpid())
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000344 sys.stdout.flush()
345 os.kill(os.getpid(), signal.SIGSTOP)
346
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000347 if args.f:
348 if any([x.startswith('-') for x in args.f]):
349 usage(parser)
Zachary Turner606e3a52015-12-08 01:15:30 +0000350 configuration.filters.extend(args.f)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000351 # Shut off multiprocessing mode when additional filters are specified.
352 # The rational is that the user is probably going after a very specific
353 # test and doesn't need a bunch of parallel test runners all looking for
354 # it in a frenzy. Also, '-v' now spits out all test run output even
355 # on success, so the standard recipe for redoing a failing test (with -v
356 # and a -f to filter to the specific test) now causes all test scanning
357 # (in parallel) to print results for do-nothing runs in a very distracting
358 # manner. If we really need filtered parallel runs in the future, consider
359 # adding a --no-output-on-success that prevents -v from setting
360 # output-on-success.
Zachary Turner606e3a52015-12-08 01:15:30 +0000361 configuration.no_multiprocess_test_runner = True
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000362
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000363 if args.l:
Zachary Turner606e3a52015-12-08 01:15:30 +0000364 configuration.skip_long_running_test = False
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000365
366 if args.framework:
Zachary Turner606e3a52015-12-08 01:15:30 +0000367 configuration.lldbFrameworkPath = args.framework
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000368
369 if args.executable:
Tim Hammerquist84858212017-03-17 18:10:58 +0000370 # lldb executable is passed explicitly
Francis Riccicef04a22016-04-25 20:36:22 +0000371 lldbtest_config.lldbExec = os.path.realpath(args.executable)
Tim Hammerquist84858212017-03-17 18:10:58 +0000372 if not is_exe(lldbtest_config.lldbExec):
373 logging.error(
374 '%s is not a valid executable to test; aborting...',
375 args.executable)
376 sys.exit(-1)
377
Chris Bieneman265ca532017-03-14 20:04:46 +0000378 if args.server:
379 os.environ['LLDB_DEBUGSERVER_PATH'] = args.server
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000380
Francis Ricci69517072016-09-23 21:32:47 +0000381 if args.excluded:
Francis Riccif833f172016-10-04 18:48:00 +0000382 for excl_file in args.excluded:
383 parseExclusion(excl_file)
Francis Ricci69517072016-09-23 21:32:47 +0000384
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000385 if args.p:
386 if args.p.startswith('-'):
387 usage(parser)
Zachary Turner606e3a52015-12-08 01:15:30 +0000388 configuration.regexp = args.p
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000389
390 if args.q:
Zachary Turner606e3a52015-12-08 01:15:30 +0000391 configuration.parsable = True
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000392
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000393 if args.s:
394 if args.s.startswith('-'):
395 usage(parser)
Zachary Turner606e3a52015-12-08 01:15:30 +0000396 configuration.sdir_name = args.s
Zachary Turner8d4d1512016-05-17 18:02:34 +0000397 configuration.session_file_format = args.session_file_format
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000398
399 if args.t:
400 os.environ['LLDB_COMMAND_TRACE'] = 'YES'
401
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000402 if args.v:
Zachary Turner606e3a52015-12-08 01:15:30 +0000403 configuration.verbose = 2
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000404
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000405 # argparse makes sure we have a number
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000406 if args.sharp:
Zachary Turner606e3a52015-12-08 01:15:30 +0000407 configuration.count = args.sharp
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000408
409 if sys.platform.startswith('win32'):
Kate Stoneb9c1b512016-09-06 20:57:50 +0000410 os.environ['LLDB_DISABLE_CRASH_DIALOG'] = str(
411 args.disable_crash_dialog)
Zachary Turner80310c22015-12-10 18:51:02 +0000412 os.environ['LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE'] = str(True)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000413
Kate Stoneb9c1b512016-09-06 20:57:50 +0000414 if do_help:
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000415 usage(parser)
416
417 if args.no_multiprocess:
Zachary Turner606e3a52015-12-08 01:15:30 +0000418 configuration.no_multiprocess_test_runner = True
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000419
420 if args.inferior:
Zachary Turner606e3a52015-12-08 01:15:30 +0000421 configuration.is_inferior_test_runner = True
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000422
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000423 if args.num_threads:
Zachary Turner606e3a52015-12-08 01:15:30 +0000424 configuration.num_threads = args.num_threads
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000425
426 if args.test_subdir:
Zachary Turner606e3a52015-12-08 01:15:30 +0000427 configuration.multiprocess_test_subdir = args.test_subdir
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000428
429 if args.test_runner_name:
Zachary Turner606e3a52015-12-08 01:15:30 +0000430 configuration.test_runner_name = args.test_runner_name
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000431
432 # Capture test results-related args.
Todd Fialacee6a6a2015-11-09 18:51:04 +0000433 if args.curses and not args.inferior:
434 # Act as if the following args were set.
Todd Fiala49d3c152016-04-20 16:27:27 +0000435 args.results_formatter = "lldbsuite.test_event.formatter.curses.Curses"
Todd Fialacee6a6a2015-11-09 18:51:04 +0000436 args.results_file = "stdout"
437
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000438 if args.results_file:
Zachary Turner606e3a52015-12-08 01:15:30 +0000439 configuration.results_filename = args.results_file
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000440
441 if args.results_port:
Zachary Turner606e3a52015-12-08 01:15:30 +0000442 configuration.results_port = args.results_port
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000443
444 if args.results_file and args.results_port:
445 sys.stderr.write(
446 "only one of --results-file and --results-port should "
447 "be specified\n")
448 usage(args)
449
450 if args.results_formatter:
Zachary Turner606e3a52015-12-08 01:15:30 +0000451 configuration.results_formatter_name = args.results_formatter
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000452 if args.results_formatter_options:
Zachary Turner606e3a52015-12-08 01:15:30 +0000453 configuration.results_formatter_options = args.results_formatter_options
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000454
Todd Fialab68dbfa22015-12-11 22:29:34 +0000455 # Default to using the BasicResultsFormatter if no formatter is specified
456 # and we're not a test inferior.
457 if not args.inferior and configuration.results_formatter_name is None:
458 configuration.results_formatter_name = (
Todd Fiala49d3c152016-04-20 16:27:27 +0000459 "lldbsuite.test_event.formatter.results_formatter.ResultsFormatter")
Todd Fialab68dbfa22015-12-11 22:29:34 +0000460
Todd Fiala93153922015-12-12 19:26:56 +0000461 # rerun-related arguments
462 configuration.rerun_all_issues = args.rerun_all_issues
Todd Fiala685a7572015-12-14 21:28:46 +0000463 configuration.rerun_max_file_threshold = args.rerun_max_file_threshold
Todd Fiala93153922015-12-12 19:26:56 +0000464
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000465 if args.lldb_platform_name:
Zachary Turner606e3a52015-12-08 01:15:30 +0000466 configuration.lldb_platform_name = args.lldb_platform_name
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000467 if args.lldb_platform_url:
Zachary Turner606e3a52015-12-08 01:15:30 +0000468 configuration.lldb_platform_url = args.lldb_platform_url
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000469 if args.lldb_platform_working_dir:
Zachary Turner606e3a52015-12-08 01:15:30 +0000470 configuration.lldb_platform_working_dir = args.lldb_platform_working_dir
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000471
472 if args.event_add_entries and len(args.event_add_entries) > 0:
473 entries = {}
474 # Parse out key=val pairs, separated by comma
475 for keyval in args.event_add_entries.split(","):
476 key_val_entry = keyval.split("=")
477 if len(key_val_entry) == 2:
478 (key, val) = key_val_entry
479 val_parts = val.split(':')
480 if len(val_parts) > 1:
481 (val, val_type) = val_parts
482 if val_type == 'int':
483 val = int(val)
484 entries[key] = val
485 # Tell the event builder to create all events with these
486 # key/val pairs in them.
487 if len(entries) > 0:
Todd Fiala49d3c152016-04-20 16:27:27 +0000488 EventBuilder.add_entries_to_all_events(entries)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000489
490 # Gather all the dirs passed on the command line.
491 if len(args.args) > 0:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000492 configuration.testdirs = list(
493 map(lambda x: os.path.realpath(os.path.abspath(x)), args.args))
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000494 # Shut off multiprocessing mode when test directories are specified.
Zachary Turner606e3a52015-12-08 01:15:30 +0000495 configuration.no_multiprocess_test_runner = True
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000496
Chris Bieneman7ba55812016-10-21 22:13:55 +0000497 lldbtest_config.codesign_identity = args.codesign_identity
498
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000499 #print("testdirs:", testdirs)
500
Kate Stoneb9c1b512016-09-06 20:57:50 +0000501
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000502def getXcodeOutputPaths(lldbRootDirectory):
503 result = []
504
505 # These are for xcode build directories.
506 xcode3_build_dir = ['build']
507 xcode4_build_dir = ['build', 'lldb', 'Build', 'Products']
508
Kate Stoneb9c1b512016-09-06 20:57:50 +0000509 configurations = [
510 ['Debug'],
511 ['DebugClang'],
512 ['Release'],
513 ['BuildAndIntegration']]
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000514 xcode_build_dirs = [xcode3_build_dir, xcode4_build_dir]
515 for configuration in configurations:
516 for xcode_build_dir in xcode_build_dirs:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000517 outputPath = os.path.join(
518 lldbRootDirectory, *(xcode_build_dir + configuration))
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000519 result.append(outputPath)
520
521 return result
522
523
524def createSocketToLocalPort(port):
525 def socket_closer(s):
526 """Close down an opened socket properly."""
527 s.shutdown(socket.SHUT_RDWR)
528 s.close()
529
530 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
531 sock.connect(("localhost", port))
532 return (sock, lambda: socket_closer(sock))
533
534
535def setupTestResults():
536 """Sets up test results-related objects based on arg settings."""
Todd Fiala51831472015-12-09 06:45:43 +0000537 # Setup the results formatter configuration.
Todd Fiala49d3c152016-04-20 16:27:27 +0000538 formatter_config = formatter.FormatterConfig()
Todd Fiala51831472015-12-09 06:45:43 +0000539 formatter_config.filename = configuration.results_filename
540 formatter_config.formatter_name = configuration.results_formatter_name
541 formatter_config.formatter_options = (
542 configuration.results_formatter_options)
543 formatter_config.port = configuration.results_port
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000544
Todd Fialade029392015-12-08 00:53:56 +0000545 # Create the results formatter.
Todd Fiala49d3c152016-04-20 16:27:27 +0000546 formatter_spec = formatter.create_results_formatter(
Todd Fiala51831472015-12-09 06:45:43 +0000547 formatter_config)
Todd Fialade029392015-12-08 00:53:56 +0000548 if formatter_spec is not None and formatter_spec.formatter is not None:
Zachary Turner606e3a52015-12-08 01:15:30 +0000549 configuration.results_formatter_object = formatter_spec.formatter
Todd Fiala194913f2015-12-02 21:12:17 +0000550
Todd Fiala49d3c152016-04-20 16:27:27 +0000551 # Send an initialize message to the formatter.
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000552 initialize_event = EventBuilder.bare_event("initialize")
553 if isMultiprocessTestRunner():
Todd Fiala51831472015-12-09 06:45:43 +0000554 if (configuration.test_runner_name is not None and
555 configuration.test_runner_name == "serial"):
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000556 # Only one worker queue here.
557 worker_count = 1
558 else:
559 # Workers will be the number of threads specified.
Zachary Turner606e3a52015-12-08 01:15:30 +0000560 worker_count = configuration.num_threads
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000561 else:
562 worker_count = 1
563 initialize_event["worker_count"] = worker_count
564
Todd Fialade029392015-12-08 00:53:56 +0000565 formatter_spec.formatter.handle_event(initialize_event)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000566
Todd Fialade029392015-12-08 00:53:56 +0000567 # Make sure we clean up the formatter on shutdown.
568 if formatter_spec.cleanup_func is not None:
569 atexit.register(formatter_spec.cleanup_func)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000570
571
572def getOutputPaths(lldbRootDirectory):
573 """
574 Returns typical build output paths for the lldb executable
575
576 lldbDirectory - path to the root of the lldb svn/git repo
577 """
578 result = []
579
580 if sys.platform == 'darwin':
581 result.extend(getXcodeOutputPaths(lldbRootDirectory))
582
583 # cmake builds? look for build or build/host folder next to llvm directory
584 # lldb is located in llvm/tools/lldb so we need to go up three levels
Kate Stoneb9c1b512016-09-06 20:57:50 +0000585 llvmParentDir = os.path.abspath(
586 os.path.join(
587 lldbRootDirectory,
588 os.pardir,
589 os.pardir,
590 os.pardir))
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000591 result.append(os.path.join(llvmParentDir, 'build', 'bin'))
592 result.append(os.path.join(llvmParentDir, 'build', 'host', 'bin'))
593
Kate Stoneb9c1b512016-09-06 20:57:50 +0000594 # some cmake developers keep their build directory beside their lldb
595 # directory
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000596 lldbParentDir = os.path.abspath(os.path.join(lldbRootDirectory, os.pardir))
597 result.append(os.path.join(lldbParentDir, 'build', 'bin'))
598 result.append(os.path.join(lldbParentDir, 'build', 'host', 'bin'))
599
600 return result
601
Kate Stoneb9c1b512016-09-06 20:57:50 +0000602
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000603def setupSysPath():
604 """
605 Add LLDB.framework/Resources/Python to the search paths for modules.
606 As a side effect, we also discover the 'lldb' executable and export it here.
607 """
608
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000609 # Get the directory containing the current script.
610 if "DOTEST_PROFILE" in os.environ and "DOTEST_SCRIPT_DIR" in os.environ:
611 scriptPath = os.environ["DOTEST_SCRIPT_DIR"]
612 else:
613 scriptPath = os.path.dirname(os.path.realpath(__file__))
614 if not scriptPath.endswith('test'):
615 print("This script expects to reside in lldb's test directory.")
616 sys.exit(-1)
617
Zachary Turner6a188e62015-12-11 19:21:34 +0000618 os.environ["LLDB_TEST"] = scriptPath
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000619
620 # Set up the LLDB_SRC environment variable, so that the tests can locate
621 # the LLDB source code.
622 os.environ["LLDB_SRC"] = lldbsuite.lldb_root
623
624 pluginPath = os.path.join(scriptPath, 'plugins')
625 toolsLLDBMIPath = os.path.join(scriptPath, 'tools', 'lldb-mi')
626 toolsLLDBServerPath = os.path.join(scriptPath, 'tools', 'lldb-server')
627
Kate Stoneb9c1b512016-09-06 20:57:50 +0000628 # Insert script dir, plugin dir, lldb-mi dir and lldb-server dir to the
629 # sys.path.
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000630 sys.path.insert(0, pluginPath)
Kate Stoneb9c1b512016-09-06 20:57:50 +0000631 # Adding test/tools/lldb-mi to the path makes it easy
632 sys.path.insert(0, toolsLLDBMIPath)
633 # to "import lldbmi_testcase" from the MI tests
634 # Adding test/tools/lldb-server to the path makes it easy
635 sys.path.insert(0, toolsLLDBServerPath)
636 # to "import lldbgdbserverutils" from the lldb-server tests
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000637
638 # This is the root of the lldb git/svn checkout
639 # When this changes over to a package instead of a standalone script, this
640 # will be `lldbsuite.lldb_root`
641 lldbRootDirectory = lldbsuite.lldb_root
642
643 # Some of the tests can invoke the 'lldb' command directly.
644 # We'll try to locate the appropriate executable right here.
645
646 # The lldb executable can be set from the command line
647 # if it's not set, we try to find it now
648 # first, we try the environment
649 if not lldbtest_config.lldbExec:
650 # First, you can define an environment variable LLDB_EXEC specifying the
651 # full pathname of the lldb executable.
652 if "LLDB_EXEC" in os.environ:
653 lldbtest_config.lldbExec = os.environ["LLDB_EXEC"]
654
655 if not lldbtest_config.lldbExec:
656 outputPaths = getOutputPaths(lldbRootDirectory)
657 for outputPath in outputPaths:
658 candidatePath = os.path.join(outputPath, 'lldb')
659 if is_exe(candidatePath):
660 lldbtest_config.lldbExec = candidatePath
661 break
662
663 if not lldbtest_config.lldbExec:
664 # Last, check the path
665 lldbtest_config.lldbExec = which('lldb')
666
667 if lldbtest_config.lldbExec and not is_exe(lldbtest_config.lldbExec):
Kate Stoneb9c1b512016-09-06 20:57:50 +0000668 print(
669 "'{}' is not a path to a valid executable".format(
670 lldbtest_config.lldbExec))
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000671 lldbtest_config.lldbExec = None
672
673 if not lldbtest_config.lldbExec:
674 print("The 'lldb' executable cannot be located. Some of the tests may not be run as a result.")
675 sys.exit(-1)
676
Kate Stoneb9c1b512016-09-06 20:57:50 +0000677 # confusingly, this is the "bin" directory
678 lldbLibDir = os.path.dirname(lldbtest_config.lldbExec)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000679 os.environ["LLDB_LIB_DIR"] = lldbLibDir
Kate Stoneb9c1b512016-09-06 20:57:50 +0000680 lldbImpLibDir = os.path.join(
681 lldbLibDir,
682 '..',
683 'lib') if sys.platform.startswith('win32') else lldbLibDir
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000684 os.environ["LLDB_IMPLIB_DIR"] = lldbImpLibDir
Zachary Turner35a76102015-12-09 20:48:42 +0000685 print("LLDB library dir:", os.environ["LLDB_LIB_DIR"])
686 print("LLDB import library dir:", os.environ["LLDB_IMPLIB_DIR"])
687 os.system('%s -v' % lldbtest_config.lldbExec)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000688
689 # Assume lldb-mi is in same place as lldb
690 # If not found, disable the lldb-mi tests
Chris Bieneman35e54572016-10-12 20:15:46 +0000691 # TODO: Append .exe on Windows
692 # - this will be in a separate commit in case the mi tests fail horribly
693 lldbDir = os.path.dirname(lldbtest_config.lldbExec)
694 lldbMiExec = os.path.join(lldbDir, "lldb-mi")
695 if is_exe(lldbMiExec):
696 os.environ["LLDBMI_EXEC"] = lldbMiExec
697 else:
Zachary Turnerb4733e62015-12-08 01:15:44 +0000698 if not configuration.shouldSkipBecauseOfCategories(["lldb-mi"]):
Kate Stoneb9c1b512016-09-06 20:57:50 +0000699 print(
700 "The 'lldb-mi' executable cannot be located. The lldb-mi tests can not be run as a result.")
Zachary Turner606e3a52015-12-08 01:15:30 +0000701 configuration.skipCategories.append("lldb-mi")
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000702
Kate Stoneb9c1b512016-09-06 20:57:50 +0000703 lldbPythonDir = None # The directory that contains 'lldb/__init__.py'
Chris Bieneman5d51a762016-10-31 22:06:52 +0000704 if not configuration.lldbFrameworkPath and os.path.exists(os.path.join(lldbLibDir, "LLDB.framework")):
705 configuration.lldbFrameworkPath = os.path.join(lldbLibDir, "LLDB.framework")
Zachary Turner606e3a52015-12-08 01:15:30 +0000706 if configuration.lldbFrameworkPath:
Chris Bienemanbd6d6992016-10-31 04:48:10 +0000707 lldbtest_config.lldbFrameworkPath = configuration.lldbFrameworkPath
Kate Stoneb9c1b512016-09-06 20:57:50 +0000708 candidatePath = os.path.join(
709 configuration.lldbFrameworkPath, 'Resources', 'Python')
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000710 if os.path.isfile(os.path.join(candidatePath, 'lldb/__init__.py')):
711 lldbPythonDir = candidatePath
712 if not lldbPythonDir:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000713 print(
714 'Resources/Python/lldb/__init__.py was not found in ' +
715 configuration.lldbFrameworkPath)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000716 sys.exit(-1)
717 else:
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000718 # If our lldb supports the -P option, use it to find the python path:
719 init_in_python_dir = os.path.join('lldb', '__init__.py')
720
Kate Stoneb9c1b512016-09-06 20:57:50 +0000721 lldb_dash_p_result = subprocess.check_output(
722 [lldbtest_config.lldbExec, "-P"], stderr=subprocess.STDOUT, universal_newlines=True)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000723
Kate Stoneb9c1b512016-09-06 20:57:50 +0000724 if lldb_dash_p_result and not lldb_dash_p_result.startswith(
725 ("<", "lldb: invalid option:")) and not lldb_dash_p_result.startswith("Traceback"):
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000726 lines = lldb_dash_p_result.splitlines()
727
728 # Workaround for readline vs libedit issue on FreeBSD. If stdout
729 # is not a terminal Python executes
730 # rl_variable_bind ("enable-meta-key", "off");
731 # This produces a warning with FreeBSD's libedit because the
732 # enable-meta-key variable is unknown. Not an issue on Apple
733 # because cpython commit f0ab6f9f0603 added a #ifndef __APPLE__
734 # around the call. See http://bugs.python.org/issue19884 for more
735 # information. For now we just discard the warning output.
Kate Stoneb9c1b512016-09-06 20:57:50 +0000736 if len(lines) >= 1 and lines[0].startswith(
737 "bind: Invalid command"):
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000738 lines.pop(0)
739
740 # Taking the last line because lldb outputs
741 # 'Cannot read termcap database;\nusing dumb terminal settings.\n'
742 # before the path
Kate Stoneb9c1b512016-09-06 20:57:50 +0000743 if len(lines) >= 1 and os.path.isfile(
744 os.path.join(lines[-1], init_in_python_dir)):
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000745 lldbPythonDir = lines[-1]
746 if "freebsd" in sys.platform or "linux" in sys.platform:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000747 os.environ['LLDB_LIB_DIR'] = os.path.join(
748 lldbPythonDir, '..', '..')
749
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000750 if not lldbPythonDir:
751 if platform.system() == "Darwin":
752 python_resource_dir = ['LLDB.framework', 'Resources', 'Python']
Saleem Abdulrasool81eadde2016-05-16 03:13:05 +0000753 outputPaths = getXcodeOutputPaths(lldbRootDirectory)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000754 for outputPath in outputPaths:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000755 candidatePath = os.path.join(
756 outputPath, *python_resource_dir)
757 if os.path.isfile(
758 os.path.join(
759 candidatePath,
760 init_in_python_dir)):
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000761 lldbPythonDir = candidatePath
762 break
763
764 if not lldbPythonDir:
Saleem Abdulrasool0eadc532016-05-16 03:13:12 +0000765 print("lldb.py is not found, some tests may fail.")
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000766 else:
Kate Stoneb9c1b512016-09-06 20:57:50 +0000767 print(
768 "Unable to load lldb extension module. Possible reasons for this include:")
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000769 print(" 1) LLDB was built with LLDB_DISABLE_PYTHON=1")
Kate Stoneb9c1b512016-09-06 20:57:50 +0000770 print(
771 " 2) PYTHONPATH and PYTHONHOME are not set correctly. PYTHONHOME should refer to")
772 print(
773 " the version of Python that LLDB built and linked against, and PYTHONPATH")
774 print(
775 " should contain the Lib directory for the same python distro, as well as the")
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000776 print(" location of LLDB\'s site-packages folder.")
Kate Stoneb9c1b512016-09-06 20:57:50 +0000777 print(
778 " 3) A different version of Python than that which was built against is exported in")
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000779 print(" the system\'s PATH environment variable, causing conflicts.")
Kate Stoneb9c1b512016-09-06 20:57:50 +0000780 print(
781 " 4) The executable '%s' could not be found. Please check " %
782 lldbtest_config.lldbExec)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000783 print(" that it exists and is executable.")
784
785 if lldbPythonDir:
786 lldbPythonDir = os.path.normpath(lldbPythonDir)
Kate Stoneb9c1b512016-09-06 20:57:50 +0000787 # Some of the code that uses this path assumes it hasn't resolved the Versions... link.
788 # If the path we've constructed looks like that, then we'll strip out
789 # the Versions/A part.
790 (before, frameWithVersion, after) = lldbPythonDir.rpartition(
791 "LLDB.framework/Versions/A")
792 if frameWithVersion != "":
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000793 lldbPythonDir = before + "LLDB.framework" + after
794
795 lldbPythonDir = os.path.abspath(lldbPythonDir)
796
797 # If tests need to find LLDB_FRAMEWORK, now they can do it
Kate Stoneb9c1b512016-09-06 20:57:50 +0000798 os.environ["LLDB_FRAMEWORK"] = os.path.dirname(
799 os.path.dirname(lldbPythonDir))
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000800
Kate Stoneb9c1b512016-09-06 20:57:50 +0000801 # This is to locate the lldb.py module. Insert it right after
802 # sys.path[0].
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000803 sys.path[1:1] = [lldbPythonDir]
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000804
Todd Fiala7c5f7ca2016-05-13 21:36:26 +0000805
806def visit_file(dir, name):
807 # Try to match the regexp pattern, if specified.
808 if configuration.regexp:
Todd Fiala7c5f7ca2016-05-13 21:36:26 +0000809 if not re.search(configuration.regexp, name):
810 # We didn't match the regex, we're done.
811 return
812
Francis Riccif833f172016-10-04 18:48:00 +0000813 if configuration.skip_tests:
814 for file_regexp in configuration.skip_tests:
Francis Ricci69517072016-09-23 21:32:47 +0000815 if re.search(file_regexp, name):
816 return
817
Todd Fiala7c5f7ca2016-05-13 21:36:26 +0000818 # We found a match for our test. Add it to the suite.
819
820 # Update the sys.path first.
821 if not sys.path.count(dir):
822 sys.path.insert(0, dir)
823 base = os.path.splitext(name)[0]
824
825 # Thoroughly check the filterspec against the base module and admit
826 # the (base, filterspec) combination only when it makes sense.
827 filterspec = None
828 for filterspec in configuration.filters:
829 # Optimistically set the flag to True.
830 filtered = True
831 module = __import__(base)
832 parts = filterspec.split('.')
833 obj = module
834 for part in parts:
835 try:
836 parent, obj = obj, getattr(obj, part)
837 except AttributeError:
838 # The filterspec has failed.
839 filtered = False
840 break
841
842 # If filtered, we have a good filterspec. Add it.
843 if filtered:
844 # print("adding filter spec %s to module %s" % (filterspec, module))
845 configuration.suite.addTests(
Kate Stoneb9c1b512016-09-06 20:57:50 +0000846 unittest2.defaultTestLoader.loadTestsFromName(
847 filterspec, module))
Todd Fiala7c5f7ca2016-05-13 21:36:26 +0000848 continue
849
850 # Forgo this module if the (base, filterspec) combo is invalid
851 if configuration.filters and not filtered:
852 return
853
854 if not filterspec or not filtered:
855 # Add the entire file's worth of tests since we're not filtered.
856 # Also the fail-over case when the filterspec branch
857 # (base, filterspec) combo doesn't make sense.
Kate Stoneb9c1b512016-09-06 20:57:50 +0000858 configuration.suite.addTests(
859 unittest2.defaultTestLoader.loadTestsFromName(base))
Todd Fiala7c5f7ca2016-05-13 21:36:26 +0000860
861
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000862def visit(prefix, dir, names):
863 """Visitor function for os.path.walk(path, visit, arg)."""
864
Zachary Turner50671582015-12-08 20:36:22 +0000865 dir_components = set(dir.split(os.sep))
866 excluded_components = set(['.svn', '.git'])
867 if dir_components.intersection(excluded_components):
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000868 return
869
Todd Fiala7c5f7ca2016-05-13 21:36:26 +0000870 # Gather all the Python test file names that follow the Test*.py pattern.
871 python_test_files = [
872 name
873 for name in names
874 if name.endswith('.py') and name.startswith(prefix)]
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000875
Todd Fiala7c5f7ca2016-05-13 21:36:26 +0000876 # Visit all the python test files.
877 for name in python_test_files:
878 try:
879 # Ensure we error out if we have multiple tests with the same
880 # base name.
881 # Future improvement: find all the places where we work with base
882 # names and convert to full paths. We have directory structure
883 # to disambiguate these, so we shouldn't need this constraint.
Zachary Turner606e3a52015-12-08 01:15:30 +0000884 if name in configuration.all_tests:
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000885 raise Exception("Found multiple tests with the name %s" % name)
Zachary Turner606e3a52015-12-08 01:15:30 +0000886 configuration.all_tests.add(name)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000887
Todd Fiala7c5f7ca2016-05-13 21:36:26 +0000888 # Run the relevant tests in the python file.
889 visit_file(dir, name)
890 except Exception as ex:
891 # Convert this exception to a test event error for the file.
892 test_filename = os.path.abspath(os.path.join(dir, name))
893 if configuration.results_formatter_object is not None:
894 # Grab the backtrace for the exception.
895 import traceback
896 backtrace = traceback.format_exc()
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000897
Todd Fiala7c5f7ca2016-05-13 21:36:26 +0000898 # Generate the test event.
899 configuration.results_formatter_object.handle_event(
900 EventBuilder.event_for_job_test_add_error(
901 test_filename, ex, backtrace))
902 raise
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000903
904
905def disabledynamics():
906 import lldb
907 ci = lldb.DBG.GetCommandInterpreter()
908 res = lldb.SBCommandReturnObject()
Kate Stoneb9c1b512016-09-06 20:57:50 +0000909 ci.HandleCommand(
910 "setting set target.prefer-dynamic-value no-dynamic-values",
911 res,
912 False)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000913 if not res.Succeeded():
914 raise Exception('disabling dynamic type support failed')
915
Kate Stoneb9c1b512016-09-06 20:57:50 +0000916
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000917def lldbLoggings():
918 import lldb
919 """Check and do lldb loggings if necessary."""
920
921 # Turn on logging for debugging purposes if ${LLDB_LOG} environment variable is
922 # defined. Use ${LLDB_LOG} to specify the log file.
923 ci = lldb.DBG.GetCommandInterpreter()
924 res = lldb.SBCommandReturnObject()
925 if ("LLDB_LOG" in os.environ):
926 open(os.environ["LLDB_LOG"], 'w').close()
927 if ("LLDB_LOG_OPTION" in os.environ):
928 lldb_log_option = os.environ["LLDB_LOG_OPTION"]
929 else:
930 lldb_log_option = "event process expr state api"
931 ci.HandleCommand(
Kate Stoneb9c1b512016-09-06 20:57:50 +0000932 "log enable -n -f " +
933 os.environ["LLDB_LOG"] +
934 " lldb " +
935 lldb_log_option,
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000936 res)
937 if not res.Succeeded():
938 raise Exception('log enable failed (check LLDB_LOG env variable)')
939
940 if ("LLDB_LINUX_LOG" in os.environ):
941 open(os.environ["LLDB_LINUX_LOG"], 'w').close()
942 if ("LLDB_LINUX_LOG_OPTION" in os.environ):
943 lldb_log_option = os.environ["LLDB_LINUX_LOG_OPTION"]
944 else:
945 lldb_log_option = "event process expr state api"
946 ci.HandleCommand(
Kate Stoneb9c1b512016-09-06 20:57:50 +0000947 "log enable -n -f " +
948 os.environ["LLDB_LINUX_LOG"] +
949 " linux " +
950 lldb_log_option,
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000951 res)
952 if not res.Succeeded():
Kate Stoneb9c1b512016-09-06 20:57:50 +0000953 raise Exception(
954 'log enable failed (check LLDB_LINUX_LOG env variable)')
955
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000956 # Ditto for gdb-remote logging if ${GDB_REMOTE_LOG} environment variable is defined.
957 # Use ${GDB_REMOTE_LOG} to specify the log file.
958 if ("GDB_REMOTE_LOG" in os.environ):
959 if ("GDB_REMOTE_LOG_OPTION" in os.environ):
960 gdb_remote_log_option = os.environ["GDB_REMOTE_LOG_OPTION"]
961 else:
962 gdb_remote_log_option = "packets process"
963 ci.HandleCommand(
964 "log enable -n -f " + os.environ["GDB_REMOTE_LOG"] + " gdb-remote "
965 + gdb_remote_log_option,
966 res)
967 if not res.Succeeded():
Kate Stoneb9c1b512016-09-06 20:57:50 +0000968 raise Exception(
969 'log enable failed (check GDB_REMOTE_LOG env variable)')
970
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000971
972def getMyCommandLine():
973 return ' '.join(sys.argv)
974
975# ======================================== #
976# #
977# Execution of the test driver starts here #
978# #
979# ======================================== #
980
Kate Stoneb9c1b512016-09-06 20:57:50 +0000981
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000982def checkDsymForUUIDIsNotOn():
983 cmd = ["defaults", "read", "com.apple.DebugSymbols"]
Kate Stoneb9c1b512016-09-06 20:57:50 +0000984 pipe = subprocess.Popen(
985 cmd,
986 stdout=subprocess.PIPE,
987 stderr=subprocess.STDOUT)
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000988 cmd_output = pipe.stdout.read()
989 if cmd_output and "DBGFileMappedPaths = " in cmd_output:
990 print("%s =>" % ' '.join(cmd))
991 print(cmd_output)
Kate Stoneb9c1b512016-09-06 20:57:50 +0000992 print(
993 "Disable automatic lookup and caching of dSYMs before running the test suite!")
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000994 print("Exiting...")
995 sys.exit(0)
996
Kate Stoneb9c1b512016-09-06 20:57:50 +0000997
998def exitTestSuite(exitCode=None):
Zachary Turnerc432c8f2015-10-28 17:43:26 +0000999 import lldb
1000 lldb.SBDebugger.Terminate()
1001 if exitCode:
1002 sys.exit(exitCode)
1003
1004
1005def isMultiprocessTestRunner():
1006 # We're not multiprocess when we're either explicitly
1007 # the inferior (as specified by the multiprocess test
1008 # runner) OR we've been told to skip using the multiprocess
1009 # test runner
Kate Stoneb9c1b512016-09-06 20:57:50 +00001010 return not (
1011 configuration.is_inferior_test_runner or configuration.no_multiprocess_test_runner)
1012
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001013
Enrico Granata5f92a132015-11-05 00:46:25 +00001014def getVersionForSDK(sdk):
1015 sdk = str.lower(sdk)
1016 full_path = seven.get_command_output('xcrun -sdk %s --show-sdk-path' % sdk)
1017 basename = os.path.basename(full_path)
1018 basename = os.path.splitext(basename)[0]
1019 basename = str.lower(basename)
1020 ver = basename.replace(sdk, '')
1021 return ver
1022
Kate Stoneb9c1b512016-09-06 20:57:50 +00001023
Enrico Granata5f92a132015-11-05 00:46:25 +00001024def getPathForSDK(sdk):
1025 sdk = str.lower(sdk)
1026 full_path = seven.get_command_output('xcrun -sdk %s --show-sdk-path' % sdk)
Kate Stoneb9c1b512016-09-06 20:57:50 +00001027 if os.path.exists(full_path):
1028 return full_path
Enrico Granata5f92a132015-11-05 00:46:25 +00001029 return None
1030
Kate Stoneb9c1b512016-09-06 20:57:50 +00001031
Enrico Granata5f92a132015-11-05 00:46:25 +00001032def setDefaultTripleForPlatform():
Zachary Turner606e3a52015-12-08 01:15:30 +00001033 if configuration.lldb_platform_name == 'ios-simulator':
Kate Stoneb9c1b512016-09-06 20:57:50 +00001034 triple_str = 'x86_64-apple-ios%s' % (
1035 getVersionForSDK('iphonesimulator'))
Enrico Granata5f92a132015-11-05 00:46:25 +00001036 os.environ['TRIPLE'] = triple_str
Kate Stoneb9c1b512016-09-06 20:57:50 +00001037 return {'TRIPLE': triple_str}
Enrico Granata5f92a132015-11-05 00:46:25 +00001038 return {}
1039
Kate Stoneb9c1b512016-09-06 20:57:50 +00001040
Pavel Labath6de25ec2017-03-15 08:51:59 +00001041def checkCompiler():
1042 # Add some intervention here to sanity check that the compiler requested is sane.
1043 # If found not to be an executable program, we abort.
1044 c = configuration.compiler
1045 if which(c):
1046 return
1047
1048 if not sys.platform.startswith("darwin"):
1049 raise Exception(c + " is not a valid compiler")
1050
1051 pipe = subprocess.Popen(
1052 ['xcrun', '-find', c], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
1053 cmd_output = pipe.stdout.read()
1054 if not cmd_output or "not found" in cmd_output:
1055 raise Exception(c + " is not a valid compiler")
1056
1057 configuration.compiler = cmd_output.split('\n')[0]
1058 print("'xcrun -find %s' returning %s" % (c, configuration.compiler))
1059
1060
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001061def run_suite():
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001062 # On MacOS X, check to make sure that domain for com.apple.DebugSymbols defaults
1063 # does not exist before proceeding to running the test suite.
1064 if sys.platform.startswith("darwin"):
1065 checkDsymForUUIDIsNotOn()
1066
1067 #
1068 # Start the actions by first parsing the options while setting up the test
1069 # directories, followed by setting up the search paths for lldb utilities;
1070 # then, we walk the directory trees and collect the tests into our test suite.
1071 #
1072 parseOptionsAndInitTestdirs()
1073
1074 # Setup test results (test results formatter and output handling).
1075 setupTestResults()
1076
1077 # If we are running as the multiprocess test runner, kick off the
1078 # multiprocess test runner here.
1079 if isMultiprocessTestRunner():
Zachary Turnerc1b7cd72015-11-05 19:22:28 +00001080 from . import dosep
Kate Stoneb9c1b512016-09-06 20:57:50 +00001081 dosep.main(
1082 configuration.num_threads,
1083 configuration.multiprocess_test_subdir,
1084 configuration.test_runner_name,
1085 configuration.results_formatter_object)
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001086 raise Exception("should never get here")
Zachary Turner606e3a52015-12-08 01:15:30 +00001087 elif configuration.is_inferior_test_runner:
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001088 # Shut off Ctrl-C processing in inferiors. The parallel
1089 # test runner handles this more holistically.
1090 signal.signal(signal.SIGINT, signal.SIG_IGN)
1091
1092 setupSysPath()
Pavel Labath9cbf7dd2015-12-08 13:32:07 +00001093 configuration.setupCrashInfoHook()
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001094
1095 #
1096 # If '-l' is specified, do not skip the long running tests.
Zachary Turner606e3a52015-12-08 01:15:30 +00001097 if not configuration.skip_long_running_test:
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001098 os.environ["LLDB_SKIP_LONG_RUNNING_TEST"] = "NO"
1099
1100 # For the time being, let's bracket the test runner within the
1101 # lldb.SBDebugger.Initialize()/Terminate() pair.
1102 import lldb
1103
1104 # Create a singleton SBDebugger in the lldb namespace.
1105 lldb.DBG = lldb.SBDebugger.Create()
1106
Zachary Turner606e3a52015-12-08 01:15:30 +00001107 if configuration.lldb_platform_name:
Kate Stoneb9c1b512016-09-06 20:57:50 +00001108 print("Setting up remote platform '%s'" %
1109 (configuration.lldb_platform_name))
1110 lldb.remote_platform = lldb.SBPlatform(
1111 configuration.lldb_platform_name)
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001112 if not lldb.remote_platform.IsValid():
Kate Stoneb9c1b512016-09-06 20:57:50 +00001113 print(
1114 "error: unable to create the LLDB platform named '%s'." %
1115 (configuration.lldb_platform_name))
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001116 exitTestSuite(1)
Zachary Turner606e3a52015-12-08 01:15:30 +00001117 if configuration.lldb_platform_url:
Kate Stoneb9c1b512016-09-06 20:57:50 +00001118 # We must connect to a remote platform if a LLDB platform URL was
1119 # specified
1120 print(
1121 "Connecting to remote platform '%s' at '%s'..." %
1122 (configuration.lldb_platform_name, configuration.lldb_platform_url))
1123 platform_connect_options = lldb.SBPlatformConnectOptions(
1124 configuration.lldb_platform_url)
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001125 err = lldb.remote_platform.ConnectRemote(platform_connect_options)
1126 if err.Success():
1127 print("Connected.")
1128 else:
Kate Stoneb9c1b512016-09-06 20:57:50 +00001129 print("error: failed to connect to remote platform using URL '%s': %s" % (
1130 configuration.lldb_platform_url, err))
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001131 exitTestSuite(1)
1132 else:
Zachary Turner606e3a52015-12-08 01:15:30 +00001133 configuration.lldb_platform_url = None
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001134
Enrico Granata5f92a132015-11-05 00:46:25 +00001135 platform_changes = setDefaultTripleForPlatform()
1136 first = True
1137 for key in platform_changes:
1138 if first:
1139 print("Environment variables setup for platform support:")
1140 first = False
Kate Stoneb9c1b512016-09-06 20:57:50 +00001141 print("%s = %s" % (key, platform_changes[key]))
Enrico Granata5f92a132015-11-05 00:46:25 +00001142
Zachary Turner606e3a52015-12-08 01:15:30 +00001143 if configuration.lldb_platform_working_dir:
Kate Stoneb9c1b512016-09-06 20:57:50 +00001144 print("Setting remote platform working directory to '%s'..." %
1145 (configuration.lldb_platform_working_dir))
1146 lldb.remote_platform.SetWorkingDirectory(
1147 configuration.lldb_platform_working_dir)
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001148 lldb.DBG.SetSelectedPlatform(lldb.remote_platform)
1149 else:
1150 lldb.remote_platform = None
Zachary Turner606e3a52015-12-08 01:15:30 +00001151 configuration.lldb_platform_working_dir = None
1152 configuration.lldb_platform_url = None
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001153
1154 target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
1155
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001156 # Don't do debugserver tests on everything except OS X.
Zachary Turner606e3a52015-12-08 01:15:30 +00001157 configuration.dont_do_debugserver_test = "linux" in target_platform or "freebsd" in target_platform or "windows" in target_platform
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001158
1159 # Don't do lldb-server (llgs) tests on anything except Linux.
Zachary Turner606e3a52015-12-08 01:15:30 +00001160 configuration.dont_do_llgs_test = not ("linux" in target_platform)
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001161
1162 #
1163 # Walk through the testdirs while collecting tests.
1164 #
Zachary Turner606e3a52015-12-08 01:15:30 +00001165 for testdir in configuration.testdirs:
Zachary Turnere6ba0532015-11-05 01:33:54 +00001166 for (dirpath, dirnames, filenames) in os.walk(testdir):
1167 visit('Test', dirpath, filenames)
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001168
1169 #
1170 # Now that we have loaded all the test cases, run the whole test suite.
1171 #
1172
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001173 # Turn on lldb loggings if necessary.
1174 lldbLoggings()
1175
1176 # Disable default dynamic types for testing purposes
1177 disabledynamics()
1178
1179 # Install the control-c handler.
1180 unittest2.signals.installHandler()
1181
1182 # If sdir_name is not specified through the '-s sdir_name' option, get a
1183 # timestamp string and export it as LLDB_SESSION_DIR environment var. This will
1184 # be used when/if we want to dump the session info of individual test cases
1185 # later on.
1186 #
1187 # See also TestBase.dumpSessionInfo() in lldbtest.py.
1188 import datetime
1189 # The windows platforms don't like ':' in the pathname.
1190 timestamp_started = datetime.datetime.now().strftime("%Y-%m-%d-%H_%M_%S")
Zachary Turner606e3a52015-12-08 01:15:30 +00001191 if not configuration.sdir_name:
1192 configuration.sdir_name = timestamp_started
Kate Stoneb9c1b512016-09-06 20:57:50 +00001193 os.environ["LLDB_SESSION_DIRNAME"] = os.path.join(
1194 os.getcwd(), configuration.sdir_name)
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001195
Kate Stoneb9c1b512016-09-06 20:57:50 +00001196 sys.stderr.write(
1197 "\nSession logs for test failures/errors/unexpected successes"
1198 " will go into directory '%s'\n" %
1199 configuration.sdir_name)
Zachary Turner35a76102015-12-09 20:48:42 +00001200 sys.stderr.write("Command invoked: %s\n" % getMyCommandLine())
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001201
Zachary Turner606e3a52015-12-08 01:15:30 +00001202 if not os.path.isdir(configuration.sdir_name):
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001203 try:
Zachary Turner606e3a52015-12-08 01:15:30 +00001204 os.mkdir(configuration.sdir_name)
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001205 except OSError as exception:
1206 if exception.errno != errno.EEXIST:
1207 raise
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001208
1209 #
Pavel Labath6de25ec2017-03-15 08:51:59 +00001210 # Invoke the default TextTestRunner to run the test suite
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001211 #
Pavel Labath6de25ec2017-03-15 08:51:59 +00001212 checkCompiler()
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001213
Zachary Turner606e3a52015-12-08 01:15:30 +00001214 if not configuration.parsable:
Pavel Labath6de25ec2017-03-15 08:51:59 +00001215 print("compiler=%s" % configuration.compiler)
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001216
1217 # Iterating over all possible architecture and compiler combinations.
Pavel Labath6de25ec2017-03-15 08:51:59 +00001218 os.environ["ARCH"] = configuration.arch
1219 os.environ["CC"] = configuration.compiler
1220 configString = "arch=%s compiler=%s" % (configuration.arch,
1221 configuration.compiler)
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001222
Pavel Labath6de25ec2017-03-15 08:51:59 +00001223 # Translate ' ' to '-' for pathname component.
1224 if six.PY2:
1225 import string
1226 tbl = string.maketrans(' ', '-')
1227 else:
1228 tbl = str.maketrans(' ', '-')
1229 configPostfix = configString.translate(tbl)
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001230
Pavel Labath6de25ec2017-03-15 08:51:59 +00001231 # Output the configuration.
1232 if not configuration.parsable:
1233 sys.stderr.write("\nConfiguration: " + configString + "\n")
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001234
Pavel Labath6de25ec2017-03-15 08:51:59 +00001235 # First, write out the number of collected test cases.
1236 if not configuration.parsable:
1237 sys.stderr.write(configuration.separator + "\n")
1238 sys.stderr.write(
1239 "Collected %d test%s\n\n" %
1240 (configuration.suite.countTestCases(),
1241 configuration.suite.countTestCases() != 1 and "s" or ""))
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001242
Pavel Labath6de25ec2017-03-15 08:51:59 +00001243 if configuration.parsable:
1244 v = 0
1245 else:
1246 v = configuration.verbose
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001247
Pavel Labath6de25ec2017-03-15 08:51:59 +00001248 # Invoke the test runner.
1249 if configuration.count == 1:
1250 result = unittest2.TextTestRunner(
1251 stream=sys.stderr,
1252 verbosity=v,
1253 resultclass=test_result.LLDBTestResult).run(
1254 configuration.suite)
1255 else:
1256 # We are invoking the same test suite more than once. In this case,
1257 # mark __ignore_singleton__ flag as True so the signleton pattern is
1258 # not enforced.
1259 test_result.LLDBTestResult.__ignore_singleton__ = True
1260 for i in range(configuration.count):
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001261
Pavel Labath6de25ec2017-03-15 08:51:59 +00001262 result = unittest2.TextTestRunner(
1263 stream=sys.stderr,
1264 verbosity=v,
1265 resultclass=test_result.LLDBTestResult).run(
1266 configuration.suite)
Kate Stoneb9c1b512016-09-06 20:57:50 +00001267
Pavel Labath6de25ec2017-03-15 08:51:59 +00001268 configuration.failed = not result.wasSuccessful()
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001269
Zachary Turner606e3a52015-12-08 01:15:30 +00001270 if configuration.sdir_has_content and not configuration.parsable:
Kate Stoneb9c1b512016-09-06 20:57:50 +00001271 sys.stderr.write(
1272 "Session logs for test failures/errors/unexpected successes"
1273 " can be found in directory '%s'\n" %
1274 configuration.sdir_name)
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001275
Kate Stoneb9c1b512016-09-06 20:57:50 +00001276 if configuration.useCategories and len(
1277 configuration.failuresPerCategory) > 0:
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001278 sys.stderr.write("Failures per category:\n")
Zachary Turner606e3a52015-12-08 01:15:30 +00001279 for category in configuration.failuresPerCategory:
Kate Stoneb9c1b512016-09-06 20:57:50 +00001280 sys.stderr.write(
1281 "%s - %d\n" %
1282 (category, configuration.failuresPerCategory[category]))
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001283
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001284 # Terminate the test suite if ${LLDB_TESTSUITE_FORCE_FINISH} is defined.
1285 # This should not be necessary now.
1286 if ("LLDB_TESTSUITE_FORCE_FINISH" in os.environ):
1287 print("Terminating Test suite...")
1288 subprocess.Popen(["/bin/sh", "-c", "kill %s; exit 0" % (os.getpid())])
1289
1290 # Exiting.
Zachary Turner606e3a52015-12-08 01:15:30 +00001291 exitTestSuite(configuration.failed)
Zachary Turnerc432c8f2015-10-28 17:43:26 +00001292
1293if __name__ == "__main__":
Kate Stoneb9c1b512016-09-06 20:57:50 +00001294 print(
1295 __file__ +
1296 " is for use as a module only. It should not be run as a standalone script.")
Zachary Turner7d564542015-11-02 19:19:49 +00001297 sys.exit(-1)