blob: 0db40c6f6e669f991dcef5595c03dbb0cb6820d0 [file] [log] [blame]
Johnny Chen9707bb62010-06-25 21:14:08 +00001#!/usr/bin/env python
2
3"""
4A simple testing framework for lldb using python's unit testing framework.
5
6Tests for lldb are written as python scripts which take advantage of the script
7bridging provided by LLDB.framework to interact with lldb core.
8
9A specific naming pattern is followed by the .py script to be recognized as
10a module which implements a test scenario, namely, Test*.py.
11
12To specify the directories where "Test*.py" python test scripts are located,
13you need to pass in a list of directory names. By default, the current
14working directory is searched if nothing is specified on the command line.
Johnny Chen872aee12010-09-16 15:44:23 +000015
16Type:
17
18./dotest.py -h
19
20for available options.
Johnny Chen9707bb62010-06-25 21:14:08 +000021"""
22
Johnny Chen91960d32010-09-08 20:56:16 +000023import os, signal, sys, time
Johnny Chen75e28f92010-08-05 23:42:46 +000024import unittest2
Johnny Chen9707bb62010-06-25 21:14:08 +000025
Johnny Chen877c7e42010-08-07 00:16:07 +000026class _WritelnDecorator(object):
27 """Used to decorate file-like objects with a handy 'writeln' method"""
28 def __init__(self,stream):
29 self.stream = stream
30
31 def __getattr__(self, attr):
32 if attr in ('stream', '__getstate__'):
33 raise AttributeError(attr)
34 return getattr(self.stream,attr)
35
36 def writeln(self, arg=None):
37 if arg:
38 self.write(arg)
39 self.write('\n') # text-mode streams translate to \r\n if needed
40
Johnny Chen9707bb62010-06-25 21:14:08 +000041#
42# Global variables:
43#
44
45# The test suite.
Johnny Chen75e28f92010-08-05 23:42:46 +000046suite = unittest2.TestSuite()
Johnny Chen9707bb62010-06-25 21:14:08 +000047
Johnny Chen4f93bf12010-12-10 00:51:23 +000048# By default, both command line and Python API tests are performed.
Johnny Chen3ebdacc2010-12-10 18:52:10 +000049# Use @python_api_test decorator, defined in lldbtest.py, to mark a test as
50# a Python API test.
Johnny Chen4f93bf12010-12-10 00:51:23 +000051dont_do_python_api_test = False
52
53# By default, both command line and Python API tests are performed.
Johnny Chen4f93bf12010-12-10 00:51:23 +000054just_do_python_api_test = False
55
Johnny Chen82e6b1e2010-12-01 22:47:54 +000056# The blacklist is optional (-b blacklistFile) and allows a central place to skip
57# testclass's and/or testclass.testmethod's.
58blacklist = None
59
60# The dictionary as a result of sourcing blacklistFile.
61blacklistConfig = {}
62
Johnny Chen9fdb0a92010-09-18 00:16:47 +000063# The config file is optional.
64configFile = None
65
Johnny Chend2acdb32010-11-16 22:42:58 +000066# Test suite repeat count. Can be overwritten with '-# count'.
67count = 1
68
Johnny Chenb40056b2010-09-21 00:09:27 +000069# The dictionary as a result of sourcing configFile.
70config = {}
71
Johnny Chen91960d32010-09-08 20:56:16 +000072# Delay startup in order for the debugger to attach.
73delay = False
74
Johnny Chen7d6d8442010-12-03 19:59:35 +000075# By default, failfast is False. Use '-F' to overwrite it.
76failfast = False
77
Johnny Chena224cd12010-11-08 01:21:03 +000078# The filter (testclass.testmethod) used to admit tests into our test suite.
Johnny Chenb62436b2010-10-06 20:40:56 +000079filterspec = None
80
Johnny Chena224cd12010-11-08 01:21:03 +000081# If '-g' is specified, the filterspec is not exclusive. If a test module does
82# not contain testclass.testmethod which matches the filterspec, the whole test
83# module is still admitted into our test suite. fs4all flag defaults to True.
84fs4all = True
Johnny Chenb62436b2010-10-06 20:40:56 +000085
Johnny Chenaf149a02010-09-16 17:11:30 +000086# Ignore the build search path relative to this script to locate the lldb.py module.
87ignore = False
88
Johnny Chen548aefd2010-10-11 22:25:46 +000089# By default, we skip long running test case. Use '-l' option to override.
Johnny Chen41998192010-10-01 22:59:49 +000090skipLongRunningTest = True
91
Johnny Chen7c52ff12010-09-27 23:29:54 +000092# The regular expression pattern to match against eligible filenames as our test cases.
93regexp = None
94
Johnny Chen548aefd2010-10-11 22:25:46 +000095# By default, tests are executed in place and cleanups are performed afterwards.
96# Use '-r dir' option to relocate the tests and their intermediate files to a
97# different directory and to forgo any cleanups. The directory specified must
98# not exist yet.
99rdir = None
100
Johnny Chen125fc2b2010-10-21 16:55:35 +0000101# By default, recorded session info for errored/failed test are dumped into its
102# own file under a session directory named after the timestamp of the test suite
103# run. Use '-s session-dir-name' to specify a specific dir name.
104sdir_name = None
105
Johnny Chen63c2cba2010-10-29 22:20:36 +0000106# Set this flag if there is any session info dumped during the test run.
107sdir_has_content = False
108
Johnny Chen9707bb62010-06-25 21:14:08 +0000109# Default verbosity is 0.
110verbose = 0
111
112# By default, search from the current working directory.
113testdirs = [ os.getcwd() ]
114
Johnny Chen877c7e42010-08-07 00:16:07 +0000115# Separator string.
116separator = '-' * 70
117
Johnny Chen9707bb62010-06-25 21:14:08 +0000118
119def usage():
120 print """
121Usage: dotest.py [option] [args]
122where options:
123-h : print this help message and exit (also --help)
Johnny Chen012cba12011-01-26 19:07:42 +0000124-A : specify the architecture to launch for the inferior process
125-C : specify the compiler used to build the inferior executable
Johnny Chen4f93bf12010-12-10 00:51:23 +0000126-a : don't do lldb Python API tests
127 use @python_api_test to decorate a test case as lldb Python API test
Johnny Chen3ebdacc2010-12-10 18:52:10 +0000128+a : just do lldb Python API tests
Johnny Chencc659ad2010-12-10 19:02:23 +0000129 do not specify both '-a' and '+a' at the same time
Johnny Chen82e6b1e2010-12-01 22:47:54 +0000130-b : read a blacklist file specified after this option
Johnny Chen9fdb0a92010-09-18 00:16:47 +0000131-c : read a config file specified after this option
Johnny Chenb40056b2010-09-21 00:09:27 +0000132 (see also lldb-trunk/example/test/usage-config)
Johnny Chen91960d32010-09-08 20:56:16 +0000133-d : delay startup for 10 seconds (in order for the debugger to attach)
Johnny Chen7d6d8442010-12-03 19:59:35 +0000134-F : failfast, stop the test suite on the first error/failure
Johnny Chen46be75d2010-10-11 16:19:48 +0000135-f : specify a filter, which consists of the test class name, a dot, followed by
Johnny Chen1a6e92a2010-11-08 20:17:04 +0000136 the test method, to only admit such test into the test suite
Johnny Chenb62436b2010-10-06 20:40:56 +0000137 e.g., -f 'ClassTypesTestCase.test_with_dwarf_and_python_api'
Johnny Chena224cd12010-11-08 01:21:03 +0000138-g : if specified, the filterspec by -f is not exclusive, i.e., if a test module
139 does not match the filterspec (testclass.testmethod), the whole module is
140 still admitted to the test suite
Johnny Chenaf149a02010-09-16 17:11:30 +0000141-i : ignore (don't bailout) if 'lldb.py' module cannot be located in the build
142 tree relative to this script; use PYTHONPATH to locate the module
Johnny Chen41998192010-10-01 22:59:49 +0000143-l : don't skip long running test
Johnny Chen7c52ff12010-09-27 23:29:54 +0000144-p : specify a regexp filename pattern for inclusion in the test suite
Johnny Chen548aefd2010-10-11 22:25:46 +0000145-r : specify a dir to relocate the tests and their intermediate files to;
146 the directory must not exist before running this test driver;
147 no cleanup of intermediate test files is performed in this case
Johnny Chen125fc2b2010-10-21 16:55:35 +0000148-s : specify the name of the dir created to store the session files of tests
149 with errored or failed status; if not specified, the test driver uses the
150 timestamp as the session dir name
Johnny Chend0c24b22010-08-23 17:10:44 +0000151-t : trace lldb command execution and result
Johnny Chen9707bb62010-06-25 21:14:08 +0000152-v : do verbose mode of unittest framework
Johnny Chene47649c2010-10-07 02:04:14 +0000153-w : insert some wait time (currently 0.5 sec) between consecutive test cases
Johnny Chend2acdb32010-11-16 22:42:58 +0000154-# : Repeat the test suite for a specified number of times
Johnny Chen9707bb62010-06-25 21:14:08 +0000155
156and:
Johnny Chen9656ab22010-10-22 19:00:18 +0000157args : specify a list of directory names to search for test modules named after
158 Test*.py (test discovery)
Johnny Chen9707bb62010-06-25 21:14:08 +0000159 if empty, search from the curret working directory, instead
Johnny Chen58f93922010-06-29 23:10:39 +0000160
Johnny Chen9656ab22010-10-22 19:00:18 +0000161Examples:
162
Johnny Chena224cd12010-11-08 01:21:03 +0000163This is an example of using the -f option to pinpoint to a specfic test class
164and test method to be run:
Johnny Chen6ad7e5e2010-10-21 00:47:52 +0000165
Johnny Chena224cd12010-11-08 01:21:03 +0000166$ ./dotest.py -f ClassTypesTestCase.test_with_dsym_and_run_command
Johnny Chen6ad7e5e2010-10-21 00:47:52 +0000167----------------------------------------------------------------------
168Collected 1 test
169
170test_with_dsym_and_run_command (TestClassTypes.ClassTypesTestCase)
171Test 'frame variable this' when stopped on a class constructor. ... ok
172
173----------------------------------------------------------------------
174Ran 1 test in 1.396s
175
176OK
Johnny Chen9656ab22010-10-22 19:00:18 +0000177
178And this is an example of using the -p option to run a single file (the filename
179matches the pattern 'ObjC' and it happens to be 'TestObjCMethods.py'):
180
181$ ./dotest.py -v -p ObjC
182----------------------------------------------------------------------
183Collected 4 tests
184
185test_break_with_dsym (TestObjCMethods.FoundationTestCase)
186Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'. ... ok
187test_break_with_dwarf (TestObjCMethods.FoundationTestCase)
188Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'. ... ok
189test_data_type_and_expr_with_dsym (TestObjCMethods.FoundationTestCase)
190Lookup objective-c data types and evaluate expressions. ... ok
191test_data_type_and_expr_with_dwarf (TestObjCMethods.FoundationTestCase)
192Lookup objective-c data types and evaluate expressions. ... ok
193
194----------------------------------------------------------------------
195Ran 4 tests in 16.661s
196
197OK
Johnny Chen6ad7e5e2010-10-21 00:47:52 +0000198
Johnny Chen58f93922010-06-29 23:10:39 +0000199Running of this script also sets up the LLDB_TEST environment variable so that
Johnny Chenaf149a02010-09-16 17:11:30 +0000200individual test cases can locate their supporting files correctly. The script
201tries to set up Python's search paths for modules by looking at the build tree
Johnny Chena85859f2010-11-11 22:14:56 +0000202relative to this script. See also the '-i' option in the following example.
203
204Finally, this is an example of using the lldb.py module distributed/installed by
205Xcode4 to run against the tests under the 'forward' directory, and with the '-w'
206option to add some delay between two tests. It uses ARCH=x86_64 to specify that
207as the architecture and CC=clang to specify the compiler used for the test run:
208
209$ PYTHONPATH=/Xcode4/Library/PrivateFrameworks/LLDB.framework/Versions/A/Resources/Python ARCH=x86_64 CC=clang ./dotest.py -v -w -i forward
210
211Session logs for test failures/errors will go into directory '2010-11-11-13_56_16'
212----------------------------------------------------------------------
213Collected 2 tests
214
215test_with_dsym_and_run_command (TestForwardDeclaration.ForwardDeclarationTestCase)
216Display *bar_ptr when stopped on a function with forward declaration of struct bar. ... ok
217test_with_dwarf_and_run_command (TestForwardDeclaration.ForwardDeclarationTestCase)
218Display *bar_ptr when stopped on a function with forward declaration of struct bar. ... ok
219
220----------------------------------------------------------------------
221Ran 2 tests in 5.659s
222
223OK
224
225The 'Session ...' verbiage is recently introduced (see also the '-s' option) to
226notify the directory containing the session logs for test failures or errors.
227In case there is any test failure/error, a similar message is appended at the
228end of the stderr output for your convenience.
Johnny Chenfde69bc2010-09-14 22:01:40 +0000229
230Environment variables related to loggings:
231
232o LLDB_LOG: if defined, specifies the log file pathname for the 'lldb' subsystem
233 with a default option of 'event process' if LLDB_LOG_OPTION is not defined.
234
235o GDB_REMOTE_LOG: if defined, specifies the log file pathname for the
236 'process.gdb-remote' subsystem with a default option of 'packets' if
237 GDB_REMOTE_LOG_OPTION is not defined.
Johnny Chen9707bb62010-06-25 21:14:08 +0000238"""
Johnny Chen9fdb0a92010-09-18 00:16:47 +0000239 sys.exit(0)
Johnny Chen9707bb62010-06-25 21:14:08 +0000240
241
Johnny Chenaf149a02010-09-16 17:11:30 +0000242def parseOptionsAndInitTestdirs():
243 """Initialize the list of directories containing our unittest scripts.
244
245 '-h/--help as the first option prints out usage info and exit the program.
246 """
247
Johnny Chen4f93bf12010-12-10 00:51:23 +0000248 global dont_do_python_api_test
249 global just_do_python_api_test
Johnny Chen82e6b1e2010-12-01 22:47:54 +0000250 global blacklist
251 global blacklistConfig
Johnny Chen9fdb0a92010-09-18 00:16:47 +0000252 global configFile
Johnny Chend2acdb32010-11-16 22:42:58 +0000253 global count
Johnny Chenaf149a02010-09-16 17:11:30 +0000254 global delay
Johnny Chen7d6d8442010-12-03 19:59:35 +0000255 global failfast
Johnny Chenb62436b2010-10-06 20:40:56 +0000256 global filterspec
257 global fs4all
Johnny Chen7c52ff12010-09-27 23:29:54 +0000258 global ignore
Johnny Chen41998192010-10-01 22:59:49 +0000259 global skipLongRunningTest
Johnny Chen7c52ff12010-09-27 23:29:54 +0000260 global regexp
Johnny Chen548aefd2010-10-11 22:25:46 +0000261 global rdir
Johnny Chen125fc2b2010-10-21 16:55:35 +0000262 global sdir_name
Johnny Chenaf149a02010-09-16 17:11:30 +0000263 global verbose
264 global testdirs
265
266 if len(sys.argv) == 1:
267 return
268
269 # Process possible trace and/or verbose flag, among other things.
270 index = 1
Johnny Chence2212c2010-10-07 15:41:55 +0000271 while index < len(sys.argv):
Johnny Chen4f93bf12010-12-10 00:51:23 +0000272 if sys.argv[index].startswith('-') or sys.argv[index].startswith('+'):
273 # We should continue processing...
274 pass
275 else:
Johnny Chenaf149a02010-09-16 17:11:30 +0000276 # End of option processing.
277 break
278
279 if sys.argv[index].find('-h') != -1:
280 usage()
Johnny Chen012cba12011-01-26 19:07:42 +0000281 elif sys.argv[index].startswith('-A'):
282 # Increment by 1 to fetch the ARCH spec.
283 index += 1
284 if index >= len(sys.argv) or sys.argv[index].startswith('-'):
285 usage()
286 os.environ["ARCH"] = sys.argv[index]
287 index += 1
288 elif sys.argv[index].startswith('-C'):
289 # Increment by 1 to fetch the CC spec.
290 index += 1
291 if index >= len(sys.argv) or sys.argv[index].startswith('-'):
292 usage()
293 os.environ["CC"] = sys.argv[index]
294 index += 1
Johnny Chen4f93bf12010-12-10 00:51:23 +0000295 elif sys.argv[index].startswith('-a'):
296 dont_do_python_api_test = True
297 index += 1
298 elif sys.argv[index].startswith('+a'):
299 just_do_python_api_test = True
300 index += 1
Johnny Chen82e6b1e2010-12-01 22:47:54 +0000301 elif sys.argv[index].startswith('-b'):
302 # Increment by 1 to fetch the blacklist file name option argument.
303 index += 1
304 if index >= len(sys.argv) or sys.argv[index].startswith('-'):
305 usage()
306 blacklistFile = sys.argv[index]
307 if not os.path.isfile(blacklistFile):
308 print "Blacklist file:", blacklistFile, "does not exist!"
309 usage()
310 index += 1
311 # Now read the blacklist contents and assign it to blacklist.
312 execfile(blacklistFile, globals(), blacklistConfig)
313 blacklist = blacklistConfig.get('blacklist')
Johnny Chen9fdb0a92010-09-18 00:16:47 +0000314 elif sys.argv[index].startswith('-c'):
315 # Increment by 1 to fetch the config file name option argument.
316 index += 1
317 if index >= len(sys.argv) or sys.argv[index].startswith('-'):
318 usage()
319 configFile = sys.argv[index]
320 if not os.path.isfile(configFile):
321 print "Config file:", configFile, "does not exist!"
322 usage()
323 index += 1
Johnny Chenaf149a02010-09-16 17:11:30 +0000324 elif sys.argv[index].startswith('-d'):
325 delay = True
326 index += 1
Johnny Chen7d6d8442010-12-03 19:59:35 +0000327 elif sys.argv[index].startswith('-F'):
328 failfast = True
329 index += 1
Johnny Chenb62436b2010-10-06 20:40:56 +0000330 elif sys.argv[index].startswith('-f'):
331 # Increment by 1 to fetch the filter spec.
332 index += 1
333 if index >= len(sys.argv) or sys.argv[index].startswith('-'):
334 usage()
335 filterspec = sys.argv[index]
336 index += 1
337 elif sys.argv[index].startswith('-g'):
Johnny Chena224cd12010-11-08 01:21:03 +0000338 fs4all = False
Johnny Chenb62436b2010-10-06 20:40:56 +0000339 index += 1
Johnny Chenaf149a02010-09-16 17:11:30 +0000340 elif sys.argv[index].startswith('-i'):
341 ignore = True
342 index += 1
Johnny Chen41998192010-10-01 22:59:49 +0000343 elif sys.argv[index].startswith('-l'):
344 skipLongRunningTest = False
345 index += 1
Johnny Chen7c52ff12010-09-27 23:29:54 +0000346 elif sys.argv[index].startswith('-p'):
347 # Increment by 1 to fetch the reg exp pattern argument.
348 index += 1
349 if index >= len(sys.argv) or sys.argv[index].startswith('-'):
350 usage()
351 regexp = sys.argv[index]
352 index += 1
Johnny Chen548aefd2010-10-11 22:25:46 +0000353 elif sys.argv[index].startswith('-r'):
354 # Increment by 1 to fetch the relocated directory argument.
355 index += 1
356 if index >= len(sys.argv) or sys.argv[index].startswith('-'):
357 usage()
358 rdir = os.path.abspath(sys.argv[index])
359 if os.path.exists(rdir):
360 print "Relocated directory:", rdir, "must not exist!"
361 usage()
362 index += 1
Johnny Chen125fc2b2010-10-21 16:55:35 +0000363 elif sys.argv[index].startswith('-s'):
364 # Increment by 1 to fetch the session dir name.
365 index += 1
366 if index >= len(sys.argv) or sys.argv[index].startswith('-'):
367 usage()
368 sdir_name = sys.argv[index]
369 index += 1
Johnny Chenaf149a02010-09-16 17:11:30 +0000370 elif sys.argv[index].startswith('-t'):
371 os.environ["LLDB_COMMAND_TRACE"] = "YES"
372 index += 1
373 elif sys.argv[index].startswith('-v'):
374 verbose = 2
375 index += 1
Johnny Chene47649c2010-10-07 02:04:14 +0000376 elif sys.argv[index].startswith('-w'):
377 os.environ["LLDB_WAIT_BETWEEN_TEST_CASES"] = 'YES'
378 index += 1
Johnny Chend2acdb32010-11-16 22:42:58 +0000379 elif sys.argv[index].startswith('-#'):
380 # Increment by 1 to fetch the repeat count argument.
381 index += 1
382 if index >= len(sys.argv) or sys.argv[index].startswith('-'):
383 usage()
384 count = int(sys.argv[index])
385 index += 1
Johnny Chenaf149a02010-09-16 17:11:30 +0000386 else:
387 print "Unknown option: ", sys.argv[index]
388 usage()
Johnny Chenaf149a02010-09-16 17:11:30 +0000389
Johnny Chencc659ad2010-12-10 19:02:23 +0000390 # Do not specify both '-a' and '+a' at the same time.
391 if dont_do_python_api_test and just_do_python_api_test:
392 usage()
393
Johnny Chenaf149a02010-09-16 17:11:30 +0000394 # Gather all the dirs passed on the command line.
395 if len(sys.argv) > index:
396 testdirs = map(os.path.abspath, sys.argv[index:])
397
Johnny Chen548aefd2010-10-11 22:25:46 +0000398 # If '-r dir' is specified, the tests should be run under the relocated
399 # directory. Let's copy the testdirs over.
400 if rdir:
401 from shutil import copytree, ignore_patterns
402
403 tmpdirs = []
404 for srcdir in testdirs:
405 dstdir = os.path.join(rdir, os.path.basename(srcdir))
406 # Don't copy the *.pyc and .svn stuffs.
407 copytree(srcdir, dstdir, ignore=ignore_patterns('*.pyc', '.svn'))
408 tmpdirs.append(dstdir)
409
410 # This will be our modified testdirs.
411 testdirs = tmpdirs
412
413 # With '-r dir' specified, there's no cleanup of intermediate test files.
414 os.environ["LLDB_DO_CLEANUP"] = 'NO'
415
416 # If testdirs is ['test'], the make directory has already been copied
417 # recursively and is contained within the rdir/test dir. For anything
418 # else, we would need to copy over the make directory and its contents,
419 # so that, os.listdir(rdir) looks like, for example:
420 #
421 # array_types conditional_break make
422 #
423 # where the make directory contains the Makefile.rules file.
424 if len(testdirs) != 1 or os.path.basename(testdirs[0]) != 'test':
425 # Don't copy the .svn stuffs.
426 copytree('make', os.path.join(rdir, 'make'),
427 ignore=ignore_patterns('.svn'))
428
429 #print "testdirs:", testdirs
430
Johnny Chenb40056b2010-09-21 00:09:27 +0000431 # Source the configFile if specified.
432 # The side effect, if any, will be felt from this point on. An example
433 # config file may be these simple two lines:
434 #
435 # sys.stderr = open("/tmp/lldbtest-stderr", "w")
436 # sys.stdout = open("/tmp/lldbtest-stdout", "w")
437 #
438 # which will reassign the two file objects to sys.stderr and sys.stdout,
439 # respectively.
440 #
441 # See also lldb-trunk/example/test/usage-config.
442 global config
443 if configFile:
444 # Pass config (a dictionary) as the locals namespace for side-effect.
445 execfile(configFile, globals(), config)
446 #print "config:", config
447 #print "sys.stderr:", sys.stderr
448 #print "sys.stdout:", sys.stdout
449
Johnny Chenaf149a02010-09-16 17:11:30 +0000450
Johnny Chen9707bb62010-06-25 21:14:08 +0000451def setupSysPath():
452 """Add LLDB.framework/Resources/Python to the search paths for modules."""
453
Johnny Chen548aefd2010-10-11 22:25:46 +0000454 global rdir
455 global testdirs
456
Johnny Chen9707bb62010-06-25 21:14:08 +0000457 # Get the directory containing the current script.
Johnny Chen0de6ab52011-01-19 02:10:40 +0000458 if "DOTEST_PROFILE" in os.environ and "DOTEST_SCRIPT_DIR" in os.environ:
459 scriptPath = os.environ["DOTEST_SCRIPT_DIR"]
460 else:
461 scriptPath = sys.path[0]
Johnny Chena1affab2010-07-03 03:41:59 +0000462 if not scriptPath.endswith('test'):
Johnny Chen9707bb62010-06-25 21:14:08 +0000463 print "This script expects to reside in lldb's test directory."
464 sys.exit(-1)
465
Johnny Chen548aefd2010-10-11 22:25:46 +0000466 if rdir:
467 # Set up the LLDB_TEST environment variable appropriately, so that the
468 # individual tests can be located relatively.
469 #
470 # See also lldbtest.TestBase.setUpClass(cls).
471 if len(testdirs) == 1 and os.path.basename(testdirs[0]) == 'test':
472 os.environ["LLDB_TEST"] = os.path.join(rdir, 'test')
473 else:
474 os.environ["LLDB_TEST"] = rdir
475 else:
476 os.environ["LLDB_TEST"] = scriptPath
Johnny Chen9de4ede2010-08-31 17:42:54 +0000477 pluginPath = os.path.join(scriptPath, 'plugins')
Johnny Chen58f93922010-06-29 23:10:39 +0000478
Johnny Chenaf149a02010-09-16 17:11:30 +0000479 # Append script dir and plugin dir to the sys.path.
480 sys.path.append(scriptPath)
481 sys.path.append(pluginPath)
482
483 global ignore
484
485 # The '-i' option is used to skip looking for lldb.py in the build tree.
486 if ignore:
487 return
488
Johnny Chena1affab2010-07-03 03:41:59 +0000489 base = os.path.abspath(os.path.join(scriptPath, os.pardir))
Johnny Chen9707bb62010-06-25 21:14:08 +0000490 dbgPath = os.path.join(base, 'build', 'Debug', 'LLDB.framework',
491 'Resources', 'Python')
492 relPath = os.path.join(base, 'build', 'Release', 'LLDB.framework',
493 'Resources', 'Python')
Johnny Chenc202c462010-09-15 18:11:19 +0000494 baiPath = os.path.join(base, 'build', 'BuildAndIntegration',
495 'LLDB.framework', 'Resources', 'Python')
Johnny Chen9707bb62010-06-25 21:14:08 +0000496
497 lldbPath = None
498 if os.path.isfile(os.path.join(dbgPath, 'lldb.py')):
499 lldbPath = dbgPath
500 elif os.path.isfile(os.path.join(relPath, 'lldb.py')):
501 lldbPath = relPath
Johnny Chenc202c462010-09-15 18:11:19 +0000502 elif os.path.isfile(os.path.join(baiPath, 'lldb.py')):
503 lldbPath = baiPath
Johnny Chen9707bb62010-06-25 21:14:08 +0000504
505 if not lldbPath:
Johnny Chenc202c462010-09-15 18:11:19 +0000506 print 'This script requires lldb.py to be in either ' + dbgPath + ',',
507 print relPath + ', or ' + baiPath
Johnny Chen9707bb62010-06-25 21:14:08 +0000508 sys.exit(-1)
509
Johnny Chenaf149a02010-09-16 17:11:30 +0000510 # This is to locate the lldb.py module. Insert it right after sys.path[0].
511 sys.path[1:1] = [lldbPath]
Johnny Chen9707bb62010-06-25 21:14:08 +0000512
Johnny Chen9707bb62010-06-25 21:14:08 +0000513
Johnny Chencd0279d2010-09-20 18:07:50 +0000514def doDelay(delta):
515 """Delaying startup for delta-seconds to facilitate debugger attachment."""
516 def alarm_handler(*args):
517 raise Exception("timeout")
518
519 signal.signal(signal.SIGALRM, alarm_handler)
520 signal.alarm(delta)
521 sys.stdout.write("pid=%d\n" % os.getpid())
522 sys.stdout.write("Enter RET to proceed (or timeout after %d seconds):" %
523 delta)
524 sys.stdout.flush()
525 try:
526 text = sys.stdin.readline()
527 except:
528 text = ""
529 signal.alarm(0)
530 sys.stdout.write("proceeding...\n")
531 pass
532
533
Johnny Chen9707bb62010-06-25 21:14:08 +0000534def visit(prefix, dir, names):
535 """Visitor function for os.path.walk(path, visit, arg)."""
536
537 global suite
Johnny Chen7c52ff12010-09-27 23:29:54 +0000538 global regexp
Johnny Chenb62436b2010-10-06 20:40:56 +0000539 global filterspec
540 global fs4all
Johnny Chen9707bb62010-06-25 21:14:08 +0000541
542 for name in names:
543 if os.path.isdir(os.path.join(dir, name)):
544 continue
545
546 if '.py' == os.path.splitext(name)[1] and name.startswith(prefix):
Johnny Chen7c52ff12010-09-27 23:29:54 +0000547 # Try to match the regexp pattern, if specified.
548 if regexp:
549 import re
550 if re.search(regexp, name):
551 #print "Filename: '%s' matches pattern: '%s'" % (name, regexp)
552 pass
553 else:
554 #print "Filename: '%s' does not match pattern: '%s'" % (name, regexp)
555 continue
556
Johnny Chen953864a2010-10-12 21:35:54 +0000557 # We found a match for our test. Add it to the suite.
Johnny Chen79723352010-10-12 15:53:22 +0000558
559 # Update the sys.path first.
Johnny Chena85d7ee2010-06-26 00:19:32 +0000560 if not sys.path.count(dir):
Johnny Chen548aefd2010-10-11 22:25:46 +0000561 sys.path.insert(0, dir)
Johnny Chen9707bb62010-06-25 21:14:08 +0000562 base = os.path.splitext(name)[0]
Johnny Chenb62436b2010-10-06 20:40:56 +0000563
564 # Thoroughly check the filterspec against the base module and admit
565 # the (base, filterspec) combination only when it makes sense.
566 if filterspec:
567 # Optimistically set the flag to True.
568 filtered = True
569 module = __import__(base)
570 parts = filterspec.split('.')
571 obj = module
572 for part in parts:
573 try:
574 parent, obj = obj, getattr(obj, part)
575 except AttributeError:
576 # The filterspec has failed.
577 filtered = False
578 break
579 # Forgo this module if the (base, filterspec) combo is invalid
Johnny Chena224cd12010-11-08 01:21:03 +0000580 # and no '-g' option is specified
Johnny Chenb62436b2010-10-06 20:40:56 +0000581 if fs4all and not filtered:
582 continue
583
Johnny Chen953864a2010-10-12 21:35:54 +0000584 # Add either the filtered test case or the entire test class.
Johnny Chenb62436b2010-10-06 20:40:56 +0000585 if filterspec and filtered:
586 suite.addTests(
587 unittest2.defaultTestLoader.loadTestsFromName(filterspec, module))
588 else:
589 # A simple case of just the module name. Also the failover case
590 # from the filterspec branch when the (base, filterspec) combo
591 # doesn't make sense.
592 suite.addTests(unittest2.defaultTestLoader.loadTestsFromName(base))
Johnny Chen9707bb62010-06-25 21:14:08 +0000593
594
Johnny Chencd0279d2010-09-20 18:07:50 +0000595def lldbLoggings():
596 """Check and do lldb loggings if necessary."""
597
598 # Turn on logging for debugging purposes if ${LLDB_LOG} environment variable is
599 # defined. Use ${LLDB_LOG} to specify the log file.
600 ci = lldb.DBG.GetCommandInterpreter()
601 res = lldb.SBCommandReturnObject()
602 if ("LLDB_LOG" in os.environ):
603 if ("LLDB_LOG_OPTION" in os.environ):
604 lldb_log_option = os.environ["LLDB_LOG_OPTION"]
605 else:
Johnny Chen8fd886c2010-12-08 01:25:21 +0000606 lldb_log_option = "event process expr state api"
Johnny Chencd0279d2010-09-20 18:07:50 +0000607 ci.HandleCommand(
Johnny Chen58bf3442010-12-02 23:31:02 +0000608 "log enable -T -n -f " + os.environ["LLDB_LOG"] + " lldb " + lldb_log_option,
Johnny Chencd0279d2010-09-20 18:07:50 +0000609 res)
610 if not res.Succeeded():
611 raise Exception('log enable failed (check LLDB_LOG env variable.')
612 # Ditto for gdb-remote logging if ${GDB_REMOTE_LOG} environment variable is defined.
613 # Use ${GDB_REMOTE_LOG} to specify the log file.
614 if ("GDB_REMOTE_LOG" in os.environ):
615 if ("GDB_REMOTE_LOG_OPTION" in os.environ):
616 gdb_remote_log_option = os.environ["GDB_REMOTE_LOG_OPTION"]
617 else:
Johnny Chen7ab8c852010-12-02 18:35:13 +0000618 gdb_remote_log_option = "packets process"
Johnny Chencd0279d2010-09-20 18:07:50 +0000619 ci.HandleCommand(
Johnny Chen58bf3442010-12-02 23:31:02 +0000620 "log enable -T -n -f " + os.environ["GDB_REMOTE_LOG"] + " process.gdb-remote "
Johnny Chencd0279d2010-09-20 18:07:50 +0000621 + gdb_remote_log_option,
622 res)
623 if not res.Succeeded():
624 raise Exception('log enable failed (check GDB_REMOTE_LOG env variable.')
625
Johnny Chen067022b2011-01-19 19:31:46 +0000626def getMyCommandLine():
627 import subprocess
628 ps = subprocess.Popen(['ps', '-o', "command=CMD", str(os.getpid())], stdout=subprocess.PIPE).communicate()[0]
629 lines = ps.split('\n')
630 cmd_line = lines[1]
631 return cmd_line
Johnny Chencd0279d2010-09-20 18:07:50 +0000632
Johnny Chend96b5682010-11-05 17:30:53 +0000633# ======================================== #
Johnny Chencd0279d2010-09-20 18:07:50 +0000634# #
635# Execution of the test driver starts here #
636# #
Johnny Chend96b5682010-11-05 17:30:53 +0000637# ======================================== #
Johnny Chencd0279d2010-09-20 18:07:50 +0000638
Johnny Chen9707bb62010-06-25 21:14:08 +0000639#
Johnny Chenaf149a02010-09-16 17:11:30 +0000640# Start the actions by first parsing the options while setting up the test
641# directories, followed by setting up the search paths for lldb utilities;
642# then, we walk the directory trees and collect the tests into our test suite.
Johnny Chen9707bb62010-06-25 21:14:08 +0000643#
Johnny Chenaf149a02010-09-16 17:11:30 +0000644parseOptionsAndInitTestdirs()
Johnny Chen9707bb62010-06-25 21:14:08 +0000645setupSysPath()
Johnny Chen91960d32010-09-08 20:56:16 +0000646
647#
648# If '-d' is specified, do a delay of 10 seconds for the debugger to attach.
649#
650if delay:
Johnny Chencd0279d2010-09-20 18:07:50 +0000651 doDelay(10)
Johnny Chen91960d32010-09-08 20:56:16 +0000652
Johnny Chen49f2f7a2010-09-20 17:25:45 +0000653#
Johnny Chen41998192010-10-01 22:59:49 +0000654# If '-l' is specified, do not skip the long running tests.
655if not skipLongRunningTest:
656 os.environ["LLDB_SKIP_LONG_RUNNING_TEST"] = "NO"
657
658#
Johnny Chen79723352010-10-12 15:53:22 +0000659# Walk through the testdirs while collecting tests.
Johnny Chen49f2f7a2010-09-20 17:25:45 +0000660#
Johnny Chen9707bb62010-06-25 21:14:08 +0000661for testdir in testdirs:
662 os.path.walk(testdir, visit, 'Test')
663
Johnny Chenb40056b2010-09-21 00:09:27 +0000664#
Johnny Chen9707bb62010-06-25 21:14:08 +0000665# Now that we have loaded all the test cases, run the whole test suite.
Johnny Chenb40056b2010-09-21 00:09:27 +0000666#
Johnny Chencd0279d2010-09-20 18:07:50 +0000667
Johnny Chen1bfbd412010-06-29 19:44:16 +0000668# For the time being, let's bracket the test runner within the
669# lldb.SBDebugger.Initialize()/Terminate() pair.
Johnny Chen01f2a6a2010-08-10 20:23:55 +0000670import lldb, atexit
Johnny Chen6b6f5ba2010-10-14 16:36:49 +0000671# Update: the act of importing lldb now executes lldb.SBDebugger.Initialize(),
672# there's no need to call it a second time.
673#lldb.SBDebugger.Initialize()
Johnny Chen01f2a6a2010-08-10 20:23:55 +0000674atexit.register(lambda: lldb.SBDebugger.Terminate())
Johnny Chen1bfbd412010-06-29 19:44:16 +0000675
Johnny Chen909e5a62010-07-01 22:52:57 +0000676# Create a singleton SBDebugger in the lldb namespace.
677lldb.DBG = lldb.SBDebugger.Create()
678
Johnny Chen4f93bf12010-12-10 00:51:23 +0000679# Put the blacklist in the lldb namespace, to be used by lldb.TestBase.
Johnny Chen82e6b1e2010-12-01 22:47:54 +0000680lldb.blacklist = blacklist
681
Johnny Chen4f93bf12010-12-10 00:51:23 +0000682# Put dont/just_do_python_api_test in the lldb namespace, too.
683lldb.dont_do_python_api_test = dont_do_python_api_test
684lldb.just_do_python_api_test = just_do_python_api_test
685
Johnny Chencd0279d2010-09-20 18:07:50 +0000686# Turn on lldb loggings if necessary.
687lldbLoggings()
Johnny Chen909e5a62010-07-01 22:52:57 +0000688
Johnny Chen7987ac92010-08-09 20:40:52 +0000689# Install the control-c handler.
690unittest2.signals.installHandler()
691
Johnny Chen125fc2b2010-10-21 16:55:35 +0000692# If sdir_name is not specified through the '-s sdir_name' option, get a
693# timestamp string and export it as LLDB_SESSION_DIR environment var. This will
694# be used when/if we want to dump the session info of individual test cases
695# later on.
Johnny Chence681462010-10-19 00:25:01 +0000696#
697# See also TestBase.dumpSessionInfo() in lldbtest.py.
Johnny Chen125fc2b2010-10-21 16:55:35 +0000698if not sdir_name:
699 import datetime
Johnny Chen41fae812010-10-29 22:26:38 +0000700 # The windows platforms don't like ':' in the pathname.
Johnny Chen76bd0102010-10-28 16:32:13 +0000701 timestamp = datetime.datetime.now().strftime("%Y-%m-%d-%H_%M_%S")
Johnny Chen125fc2b2010-10-21 16:55:35 +0000702 sdir_name = timestamp
703os.environ["LLDB_SESSION_DIRNAME"] = sdir_name
Johnny Chen067022b2011-01-19 19:31:46 +0000704
Johnny Chen47c47c42010-11-09 23:42:00 +0000705sys.stderr.write("\nSession logs for test failures/errors will go into directory '%s'\n" % sdir_name)
Johnny Chen067022b2011-01-19 19:31:46 +0000706sys.stderr.write("Command invoked: %s\n" % getMyCommandLine())
Johnny Chence681462010-10-19 00:25:01 +0000707
Johnny Chenb40056b2010-09-21 00:09:27 +0000708#
709# Invoke the default TextTestRunner to run the test suite, possibly iterating
710# over different configurations.
711#
712
Johnny Chenb40056b2010-09-21 00:09:27 +0000713iterArchs = False
Johnny Chenf032d902010-09-21 00:16:09 +0000714iterCompilers = False
Johnny Chenb40056b2010-09-21 00:09:27 +0000715
716from types import *
717if "archs" in config:
718 archs = config["archs"]
719 if type(archs) is ListType and len(archs) >= 1:
720 iterArchs = True
721if "compilers" in config:
722 compilers = config["compilers"]
723 if type(compilers) is ListType and len(compilers) >= 1:
724 iterCompilers = True
725
Johnny Chen953864a2010-10-12 21:35:54 +0000726# Make a shallow copy of sys.path, we need to manipulate the search paths later.
727# This is only necessary if we are relocated and with different configurations.
728if rdir and (iterArchs or iterCompilers):
729 old_sys_path = sys.path[:]
730 old_stderr = sys.stderr
731 old_stdout = sys.stdout
732 new_stderr = None
733 new_stdout = None
734
Johnny Chend96b5682010-11-05 17:30:53 +0000735# Iterating over all possible architecture and compiler combinations.
Johnny Chenb40056b2010-09-21 00:09:27 +0000736for ia in range(len(archs) if iterArchs else 1):
737 archConfig = ""
738 if iterArchs:
Johnny Chen18a921f2010-09-30 17:11:58 +0000739 os.environ["ARCH"] = archs[ia]
Johnny Chenb40056b2010-09-21 00:09:27 +0000740 archConfig = "arch=%s" % archs[ia]
741 for ic in range(len(compilers) if iterCompilers else 1):
742 if iterCompilers:
Johnny Chen18a921f2010-09-30 17:11:58 +0000743 os.environ["CC"] = compilers[ic]
Johnny Chenb40056b2010-09-21 00:09:27 +0000744 configString = "%s compiler=%s" % (archConfig, compilers[ic])
745 else:
746 configString = archConfig
747
Johnny Chenb40056b2010-09-21 00:09:27 +0000748 if iterArchs or iterCompilers:
Johnny Chen953864a2010-10-12 21:35:54 +0000749 # If we specified a relocated directory to run the test suite, do
750 # the extra housekeeping to copy the testdirs to a configStringified
751 # directory and to update sys.path before invoking the test runner.
752 # The purpose is to separate the configuration-specific directories
753 # from each other.
754 if rdir:
755 from string import maketrans
756 from shutil import copytree, ignore_patterns
757
758 # Translate ' ' to '-' for dir name.
759 tbl = maketrans(' ', '-')
760 configPostfix = configString.translate(tbl)
761 newrdir = "%s.%s" % (rdir, configPostfix)
762
763 # Copy the tree to a new directory with postfix name configPostfix.
764 copytree(rdir, newrdir, ignore=ignore_patterns('*.pyc', '*.o', '*.d'))
765
766 # Check whether we need to split stderr/stdout into configuration
767 # specific files.
768 if old_stderr.name != '<stderr>' and config.get('split_stderr'):
769 if new_stderr:
770 new_stderr.close()
771 new_stderr = open("%s.%s" % (old_stderr.name, configPostfix), "w")
772 sys.stderr = new_stderr
Johnny Chen4b6630e2010-10-12 21:50:36 +0000773 if old_stdout.name != '<stdout>' and config.get('split_stdout'):
Johnny Chen953864a2010-10-12 21:35:54 +0000774 if new_stdout:
775 new_stdout.close()
776 new_stdout = open("%s.%s" % (old_stdout.name, configPostfix), "w")
777 sys.stdout = new_stdout
778
779 # Update the LLDB_TEST environment variable to reflect new top
780 # level test directory.
781 #
782 # See also lldbtest.TestBase.setUpClass(cls).
783 if len(testdirs) == 1 and os.path.basename(testdirs[0]) == 'test':
784 os.environ["LLDB_TEST"] = os.path.join(newrdir, 'test')
785 else:
786 os.environ["LLDB_TEST"] = newrdir
787
788 # And update the Python search paths for modules.
789 sys.path = [x.replace(rdir, newrdir, 1) for x in old_sys_path]
790
791 # Output the configuration.
Johnny Chenb40056b2010-09-21 00:09:27 +0000792 sys.stderr.write("\nConfiguration: " + configString + "\n")
Johnny Chen953864a2010-10-12 21:35:54 +0000793
794 #print "sys.stderr name is", sys.stderr.name
795 #print "sys.stdout name is", sys.stdout.name
796
797 # First, write out the number of collected test cases.
798 sys.stderr.write(separator + "\n")
799 sys.stderr.write("Collected %d test%s\n\n"
800 % (suite.countTestCases(),
801 suite.countTestCases() != 1 and "s" or ""))
802
Johnny Chen84a6d6f2010-10-15 01:18:29 +0000803 class LLDBTestResult(unittest2.TextTestResult):
804 """
Johnny Chen26be4532010-11-09 23:56:14 +0000805 Enforce a singleton pattern to allow introspection of test progress.
806
807 Overwrite addError(), addFailure(), and addExpectedFailure() methods
808 to enable each test instance to track its failure/error status. It
809 is used in the LLDB test framework to emit detailed trace messages
810 to a log file for easier human inspection of test failres/errors.
Johnny Chen84a6d6f2010-10-15 01:18:29 +0000811 """
812 __singleton__ = None
Johnny Chen360dd372010-11-29 17:50:10 +0000813 __ignore_singleton__ = False
Johnny Chen84a6d6f2010-10-15 01:18:29 +0000814
815 def __init__(self, *args):
Johnny Chen360dd372010-11-29 17:50:10 +0000816 if not LLDBTestResult.__ignore_singleton__ and LLDBTestResult.__singleton__:
Johnny Chend2acdb32010-11-16 22:42:58 +0000817 raise Exception("LLDBTestResult instantiated more than once")
Johnny Chen84a6d6f2010-10-15 01:18:29 +0000818 super(LLDBTestResult, self).__init__(*args)
819 LLDBTestResult.__singleton__ = self
820 # Now put this singleton into the lldb module namespace.
821 lldb.test_result = self
Johnny Chen810042e2011-01-05 20:24:11 +0000822 # Computes the format string for displaying the counter.
823 global suite
824 counterWidth = len(str(suite.countTestCases()))
825 self.fmt = "%" + str(counterWidth) + "d: "
Johnny Chenc87fd492011-01-05 22:50:11 +0000826 self.indentation = ' ' * (counterWidth + 2)
Johnny Chen810042e2011-01-05 20:24:11 +0000827 # This counts from 1 .. suite.countTestCases().
828 self.counter = 0
829
Johnny Chenc87fd492011-01-05 22:50:11 +0000830 def getDescription(self, test):
831 doc_first_line = test.shortDescription()
832 if self.descriptions and doc_first_line:
833 return '\n'.join((str(test), self.indentation + doc_first_line))
834 else:
835 return str(test)
836
Johnny Chen810042e2011-01-05 20:24:11 +0000837 def startTest(self, test):
838 self.counter += 1
839 if self.showAll:
840 self.stream.write(self.fmt % self.counter)
841 super(LLDBTestResult, self).startTest(test)
Johnny Chen84a6d6f2010-10-15 01:18:29 +0000842
Johnny Chence681462010-10-19 00:25:01 +0000843 def addError(self, test, err):
Johnny Chen63c2cba2010-10-29 22:20:36 +0000844 global sdir_has_content
845 sdir_has_content = True
Johnny Chence681462010-10-19 00:25:01 +0000846 super(LLDBTestResult, self).addError(test, err)
847 method = getattr(test, "markError", None)
848 if method:
849 method()
850
Johnny Chen84a6d6f2010-10-15 01:18:29 +0000851 def addFailure(self, test, err):
Johnny Chen63c2cba2010-10-29 22:20:36 +0000852 global sdir_has_content
853 sdir_has_content = True
Johnny Chen84a6d6f2010-10-15 01:18:29 +0000854 super(LLDBTestResult, self).addFailure(test, err)
855 method = getattr(test, "markFailure", None)
856 if method:
857 method()
Johnny Chen84a6d6f2010-10-15 01:18:29 +0000858
Johnny Chendd2bb2c2010-11-03 18:17:03 +0000859 def addExpectedFailure(self, test, err):
860 global sdir_has_content
861 sdir_has_content = True
862 super(LLDBTestResult, self).addExpectedFailure(test, err)
863 method = getattr(test, "markExpectedFailure", None)
864 if method:
865 method()
866
Johnny Chen26be4532010-11-09 23:56:14 +0000867 # Invoke the test runner.
Johnny Chend2acdb32010-11-16 22:42:58 +0000868 if count == 1:
Johnny Chen7d6d8442010-12-03 19:59:35 +0000869 result = unittest2.TextTestRunner(stream=sys.stderr,
870 verbosity=verbose,
871 failfast=failfast,
Johnny Chend2acdb32010-11-16 22:42:58 +0000872 resultclass=LLDBTestResult).run(suite)
873 else:
Johnny Chend6e7ca22010-11-29 17:52:43 +0000874 # We are invoking the same test suite more than once. In this case,
875 # mark __ignore_singleton__ flag as True so the signleton pattern is
876 # not enforced.
Johnny Chen360dd372010-11-29 17:50:10 +0000877 LLDBTestResult.__ignore_singleton__ = True
Johnny Chend2acdb32010-11-16 22:42:58 +0000878 for i in range(count):
Johnny Chen7d6d8442010-12-03 19:59:35 +0000879 result = unittest2.TextTestRunner(stream=sys.stderr,
880 verbosity=verbose,
881 failfast=failfast,
Johnny Chen360dd372010-11-29 17:50:10 +0000882 resultclass=LLDBTestResult).run(suite)
Johnny Chenb40056b2010-09-21 00:09:27 +0000883
Johnny Chen1bfbd412010-06-29 19:44:16 +0000884
Johnny Chen63c2cba2010-10-29 22:20:36 +0000885if sdir_has_content:
Johnny Chen47c47c42010-11-09 23:42:00 +0000886 sys.stderr.write("Session logs for test failures/errors can be found in directory '%s'\n" % sdir_name)
Johnny Chen63c2cba2010-10-29 22:20:36 +0000887
Johnny Chencd0279d2010-09-20 18:07:50 +0000888# Terminate the test suite if ${LLDB_TESTSUITE_FORCE_FINISH} is defined.
889# This should not be necessary now.
Johnny Chen83f6e512010-08-13 22:58:44 +0000890if ("LLDB_TESTSUITE_FORCE_FINISH" in os.environ):
891 import subprocess
892 print "Terminating Test suite..."
893 subprocess.Popen(["/bin/sh", "-c", "kill %s; exit 0" % (os.getpid())])
894
Johnny Chen01f2a6a2010-08-10 20:23:55 +0000895# Exiting.
896sys.exit(not result.wasSuccessful)