blob: 0543e07ee1ed72fcb58e0f6b835d8219b305a2ec [file] [log] [blame]
Johnny Chene8d9dc62011-10-31 19:04:07 +00001#!/usr/bin/env python
2
3"""
4Run the test suite using a separate process for each test file.
Vince Harronede59652015-01-08 02:11:26 +00005
Siva Chandra2d7832e2015-05-08 23:08:53 +00006Each test will run with a time limit of 10 minutes by default.
Vince Harronede59652015-01-08 02:11:26 +00007
Siva Chandra2d7832e2015-05-08 23:08:53 +00008Override the default time limit of 10 minutes by setting
Vince Harronede59652015-01-08 02:11:26 +00009the environment variable LLDB_TEST_TIMEOUT.
10
11E.g., export LLDB_TEST_TIMEOUT=10m
12
13Override the time limit for individual tests by setting
14the environment variable LLDB_[TEST NAME]_TIMEOUT.
15
16E.g., export LLDB_TESTCONCURRENTEVENTS_TIMEOUT=2m
17
18Set to "0" to run without time limit.
19
20E.g., export LLDB_TEST_TIMEOUT=0
21or export LLDB_TESTCONCURRENTEVENTS_TIMEOUT=0
Vince Harrondcc2b9f2015-05-27 04:40:36 +000022
23To collect core files for timed out tests, do the following before running dosep.py
24
25OSX
26ulimit -c unlimited
27sudo sysctl -w kern.corefile=core.%P
28
29Linux:
30ulimit -c unlimited
31echo core.%p | sudo tee /proc/sys/kernel/core_pattern
Johnny Chene8d9dc62011-10-31 19:04:07 +000032"""
33
Greg Clayton2256d0d2014-03-24 23:01:57 +000034import multiprocessing
Todd Fiala3f0a3602014-07-08 06:42:37 +000035import os
Vince Harrondcc2b9f2015-05-27 04:40:36 +000036import fnmatch
Todd Fiala3f0a3602014-07-08 06:42:37 +000037import platform
Vince Harron06381732015-05-12 23:10:36 +000038import re
Vince Harronf8b9a1d2015-05-18 19:40:54 +000039import dotest_args
Vince Harron17f429f2014-12-13 00:08:19 +000040import shlex
41import subprocess
Todd Fiala3f0a3602014-07-08 06:42:37 +000042import sys
Steve Puccibefe2b12014-03-07 00:01:11 +000043
Johnny Chene8d9dc62011-10-31 19:04:07 +000044from optparse import OptionParser
45
Vince Harron17f429f2014-12-13 00:08:19 +000046def get_timeout_command():
Vince Harronede59652015-01-08 02:11:26 +000047 """Search for a suitable timeout command."""
Ying Chen93190c42015-07-20 20:04:22 +000048 if not sys.platform.startswith("win32"):
49 try:
50 subprocess.call("timeout", stderr=subprocess.PIPE)
51 return "timeout"
52 except OSError:
53 pass
Vince Harron17f429f2014-12-13 00:08:19 +000054 try:
Chaoren Lin45c17ff2015-05-28 23:00:10 +000055 subprocess.call("gtimeout", stderr=subprocess.PIPE)
Vince Harron17f429f2014-12-13 00:08:19 +000056 return "gtimeout"
57 except OSError:
58 pass
59 return None
60
61timeout_command = get_timeout_command()
62
Vince Harron17f429f2014-12-13 00:08:19 +000063# Status codes for running command with timeout.
64eTimedOut, ePassed, eFailed = 124, 0, 1
65
Chaoren Lin5e3ab2b2015-06-01 17:49:25 +000066output_lock = None
67test_counter = None
68total_tests = None
Pavel Labath05ab2372015-07-06 15:57:52 +000069dotest_options = None
Zachary Turner38e64172015-08-10 17:46:11 +000070output_on_success = False
Chaoren Lin5e3ab2b2015-06-01 17:49:25 +000071
Pavel Labath05ab2372015-07-06 15:57:52 +000072def setup_global_variables(lock, counter, total, options):
73 global output_lock, test_counter, total_tests, dotest_options
Chaoren Lin5e3ab2b2015-06-01 17:49:25 +000074 output_lock = lock
75 test_counter = counter
76 total_tests = total
Pavel Labath05ab2372015-07-06 15:57:52 +000077 dotest_options = options
Chaoren Lin5e3ab2b2015-06-01 17:49:25 +000078
Zachary Turner38e64172015-08-10 17:46:11 +000079def report_test_failure(name, command, output):
80 global output_lock
81 with output_lock:
82 print >> sys.stderr, "\n"
83 print >> sys.stderr, output
84 print >> sys.stderr, "Command invoked: %s" % ' '.join(command)
85 update_progress(name, "FAILED")
86
87def report_test_pass(name, output):
88 global output_lock, output_on_success
89 with output_lock:
90 if output_on_success:
91 print >> sys.stderr, "\n"
92 print >> sys.stderr, output
93 update_progress(name, "PASSED")
94
95def update_progress(test_name, result):
Chaoren Lin5e3ab2b2015-06-01 17:49:25 +000096 global output_lock, test_counter, total_tests
97 with output_lock:
Zachary Turner38e64172015-08-10 17:46:11 +000098 if test_name != None:
99 sys.stderr.write("\n[%s %s] - %d out of %d test suites processed" %
100 (result, test_name, test_counter.value, total_tests))
101 else:
102 sys.stderr.write("\n%d out of %d test suites processed" %
103 (test_counter.value, total_tests))
Chaoren Lin5e3ab2b2015-06-01 17:49:25 +0000104 test_counter.value += 1
Zachary Turner38e64172015-08-10 17:46:11 +0000105 sys.stdout.flush()
106 sys.stderr.flush()
Chaoren Lin5e3ab2b2015-06-01 17:49:25 +0000107
Zachary Turnerc7a7c8a2015-05-28 19:56:26 +0000108def parse_test_results(output):
109 passes = 0
110 failures = 0
111 for result in output:
112 pass_count = re.search("^RESULT:.*([0-9]+) passes", result, re.MULTILINE)
113 fail_count = re.search("^RESULT:.*([0-9]+) failures", result, re.MULTILINE)
114 error_count = re.search("^RESULT:.*([0-9]+) errors", result, re.MULTILINE)
115 this_fail_count = 0
116 this_error_count = 0
117 if pass_count != None:
118 passes = passes + int(pass_count.group(1))
119 if fail_count != None:
120 failures = failures + int(fail_count.group(1))
121 if error_count != None:
122 failures = failures + int(error_count.group(1))
123 pass
124 return passes, failures
125
Chaoren Lin5e3ab2b2015-06-01 17:49:25 +0000126def call_with_timeout(command, timeout, name):
Vince Harronede59652015-01-08 02:11:26 +0000127 """Run command with a timeout if possible."""
Vince Harrondcc2b9f2015-05-27 04:40:36 +0000128 """-s QUIT will create a coredump if they are enabled on your system"""
Zachary Turnerc7a7c8a2015-05-28 19:56:26 +0000129 process = None
130 if timeout_command and timeout != "0":
131 command = [timeout_command, '-s', 'QUIT', timeout] + command
132 # Specifying a value for close_fds is unsupported on Windows when using subprocess.PIPE
Zachary Turnerdc494d52015-02-07 00:14:55 +0000133 if os.name != "nt":
Chaoren Lin9d2b7f92015-05-29 18:43:46 +0000134 process = subprocess.Popen(command, stdin=subprocess.PIPE,
135 stdout=subprocess.PIPE,
136 stderr=subprocess.PIPE,
137 close_fds=True)
Zachary Turnerdc494d52015-02-07 00:14:55 +0000138 else:
Chaoren Lin9d2b7f92015-05-29 18:43:46 +0000139 process = subprocess.Popen(command, stdin=subprocess.PIPE,
140 stdout=subprocess.PIPE,
141 stderr=subprocess.PIPE)
Zachary Turnerc7a7c8a2015-05-28 19:56:26 +0000142 output = process.communicate()
143 exit_status = process.returncode
144 passes, failures = parse_test_results(output)
Zachary Turner38e64172015-08-10 17:46:11 +0000145 if exit_status == 0:
146 # stdout does not have any useful information from 'dotest.py', only stderr does.
147 report_test_pass(name, output[1])
148 else:
149 report_test_failure(name, command, output[1])
Zachary Turnerc7a7c8a2015-05-28 19:56:26 +0000150 return exit_status, passes, failures
Johnny Chene8d9dc62011-10-31 19:04:07 +0000151
Vince Harron41657cc2015-05-21 18:15:09 +0000152def process_dir(root, files, test_root, dotest_argv):
Steve Puccibefe2b12014-03-07 00:01:11 +0000153 """Examine a directory for tests, and invoke any found within it."""
Vince Harron17f429f2014-12-13 00:08:19 +0000154 timed_out = []
Daniel Maleacbaef262013-02-15 21:31:37 +0000155 failed = []
156 passed = []
Zachary Turnerc7a7c8a2015-05-28 19:56:26 +0000157 pass_sub_count = 0
158 fail_sub_count = 0
Steve Puccibefe2b12014-03-07 00:01:11 +0000159 for name in files:
160 path = os.path.join(root, name)
161
162 # We're only interested in the test file with the "Test*.py" naming pattern.
163 if not name.startswith("Test") or not name.endswith(".py"):
164 continue
165
166 # Neither a symbolically linked file.
167 if os.path.islink(path):
168 continue
169
Zachary Turnerf6896b02015-01-05 19:37:03 +0000170 script_file = os.path.join(test_root, "dotest.py")
Zachary Turnerf6896b02015-01-05 19:37:03 +0000171 command = ([sys.executable, script_file] +
Vince Harron41657cc2015-05-21 18:15:09 +0000172 dotest_argv +
Vince Harron17f429f2014-12-13 00:08:19 +0000173 ["-p", name, root])
174
175 timeout_name = os.path.basename(os.path.splitext(name)[0]).upper()
176
Pavel Labath05ab2372015-07-06 15:57:52 +0000177 timeout = os.getenv("LLDB_%s_TIMEOUT" % timeout_name) or getDefaultTimeout(dotest_options.lldb_platform_name)
Vince Harron17f429f2014-12-13 00:08:19 +0000178
Chaoren Lin5e3ab2b2015-06-01 17:49:25 +0000179 exit_status, pass_count, fail_count = call_with_timeout(command, timeout, name)
Vince Harron17f429f2014-12-13 00:08:19 +0000180
Zachary Turnerc7a7c8a2015-05-28 19:56:26 +0000181 pass_sub_count = pass_sub_count + pass_count
182 fail_sub_count = fail_sub_count + fail_count
183
184 if exit_status == ePassed:
Steve Puccibefe2b12014-03-07 00:01:11 +0000185 passed.append(name)
Vince Harron17f429f2014-12-13 00:08:19 +0000186 else:
187 if eTimedOut == exit_status:
188 timed_out.append(name)
189 failed.append(name)
Zachary Turnerc7a7c8a2015-05-28 19:56:26 +0000190 return (timed_out, failed, passed, fail_sub_count, pass_sub_count)
Steve Puccibefe2b12014-03-07 00:01:11 +0000191
192in_q = None
193out_q = None
194
Todd Fiala3f0a3602014-07-08 06:42:37 +0000195def process_dir_worker(arg_tuple):
Steve Puccibefe2b12014-03-07 00:01:11 +0000196 """Worker thread main loop when in multithreaded mode.
197 Takes one directory specification at a time and works on it."""
Vince Harron41657cc2015-05-21 18:15:09 +0000198 (root, files, test_root, dotest_argv) = arg_tuple
199 return process_dir(root, files, test_root, dotest_argv)
Steve Puccibefe2b12014-03-07 00:01:11 +0000200
Vince Harron41657cc2015-05-21 18:15:09 +0000201def walk_and_invoke(test_directory, test_subdir, dotest_argv, num_threads):
Steve Puccibefe2b12014-03-07 00:01:11 +0000202 """Look for matched files and invoke test driver on each one.
203 In single-threaded mode, each test driver is invoked directly.
204 In multi-threaded mode, submit each test driver to a worker
Vince Harrone06a7a82015-05-12 23:12:19 +0000205 queue, and then wait for all to complete.
206
207 test_directory - lldb/test/ directory
208 test_subdir - lldb/test/ or a subfolder with the tests we're interested in running
209 """
Todd Fiala3f0a3602014-07-08 06:42:37 +0000210
211 # Collect the test files that we'll run.
212 test_work_items = []
Vince Harrone06a7a82015-05-12 23:12:19 +0000213 for root, dirs, files in os.walk(test_subdir, topdown=False):
Vince Harron41657cc2015-05-21 18:15:09 +0000214 test_work_items.append((root, files, test_directory, dotest_argv))
Todd Fiala3f0a3602014-07-08 06:42:37 +0000215
Chaoren Lin5e3ab2b2015-06-01 17:49:25 +0000216 global output_lock, test_counter, total_tests
Zachary Turner38e64172015-08-10 17:46:11 +0000217 output_lock = multiprocessing.RLock()
Chaoren Lin5e3ab2b2015-06-01 17:49:25 +0000218 total_tests = len(test_work_items)
219 test_counter = multiprocessing.Value('i', 0)
220 print >> sys.stderr, "Testing: %d tests, %d threads" % (total_tests, num_threads)
Zachary Turner38e64172015-08-10 17:46:11 +0000221 update_progress(None, None)
Chaoren Lin5e3ab2b2015-06-01 17:49:25 +0000222
Todd Fiala3f0a3602014-07-08 06:42:37 +0000223 # Run the items, either in a pool (for multicore speedup) or
224 # calling each individually.
225 if num_threads > 1:
Chaoren Lin5e3ab2b2015-06-01 17:49:25 +0000226 pool = multiprocessing.Pool(num_threads,
Pavel Labath05ab2372015-07-06 15:57:52 +0000227 initializer = setup_global_variables,
228 initargs = (output_lock, test_counter, total_tests, dotest_options))
Todd Fiala3f0a3602014-07-08 06:42:37 +0000229 test_results = pool.map(process_dir_worker, test_work_items)
230 else:
231 test_results = []
232 for work_item in test_work_items:
233 test_results.append(process_dir_worker(work_item))
234
Vince Harron17f429f2014-12-13 00:08:19 +0000235 timed_out = []
Steve Puccibefe2b12014-03-07 00:01:11 +0000236 failed = []
237 passed = []
Zachary Turnerc7a7c8a2015-05-28 19:56:26 +0000238 fail_sub_count = 0
239 pass_sub_count = 0
Todd Fiala3f0a3602014-07-08 06:42:37 +0000240
241 for test_result in test_results:
Zachary Turnerc7a7c8a2015-05-28 19:56:26 +0000242 (dir_timed_out, dir_failed, dir_passed, dir_fail_sub_count, dir_pass_sub_count) = test_result
Vince Harron17f429f2014-12-13 00:08:19 +0000243 timed_out += dir_timed_out
Todd Fiala3f0a3602014-07-08 06:42:37 +0000244 failed += dir_failed
245 passed += dir_passed
Zachary Turnerc7a7c8a2015-05-28 19:56:26 +0000246 fail_sub_count = fail_sub_count + dir_fail_sub_count
247 pass_sub_count = pass_sub_count + dir_pass_sub_count
Todd Fiala3f0a3602014-07-08 06:42:37 +0000248
Zachary Turnerc7a7c8a2015-05-28 19:56:26 +0000249 return (timed_out, failed, passed, fail_sub_count, pass_sub_count)
Johnny Chene8d9dc62011-10-31 19:04:07 +0000250
Vince Harronf8b9a1d2015-05-18 19:40:54 +0000251def getExpectedTimeouts(platform_name):
Vince Harron06381732015-05-12 23:10:36 +0000252 # returns a set of test filenames that might timeout
253 # are we running against a remote target?
Vince Harronf8b9a1d2015-05-18 19:40:54 +0000254 if platform_name is None:
Vince Harron06381732015-05-12 23:10:36 +0000255 target = sys.platform
256 remote = False
Vince Harronf8b9a1d2015-05-18 19:40:54 +0000257 else:
258 m = re.search('remote-(\w+)', platform_name)
259 target = m.group(1)
260 remote = True
Vince Harron06381732015-05-12 23:10:36 +0000261
262 expected_timeout = set()
263
264 if target.startswith("linux"):
265 expected_timeout |= {
Vince Harronde92b522015-05-13 23:59:03 +0000266 "TestAttachDenied.py",
Vince Harron06381732015-05-12 23:10:36 +0000267 "TestAttachResume.py",
Chaoren Lin0b8bb3d2015-07-22 20:52:17 +0000268 "TestProcessAttach.py",
Vince Harron06381732015-05-12 23:10:36 +0000269 "TestConnectRemote.py",
270 "TestCreateAfterAttach.py",
Tamas Berghammer0d0ec9f2015-05-19 10:49:40 +0000271 "TestEvents.py",
Vince Harron06381732015-05-12 23:10:36 +0000272 "TestExitDuringStep.py",
Tamas Berghammer0b11db52015-06-02 14:45:25 +0000273 "TestHelloWorld.py", # Times out in ~10% of the times on the build bot
Oleksiy Vyalov18f4c9f2015-06-10 01:34:25 +0000274 "TestMultithreaded.py",
Vince Harrone8843892015-06-22 20:54:14 +0000275 "TestRegisters.py", # ~12/600 dosep runs (build 3120-3122)
Vince Harron06381732015-05-12 23:10:36 +0000276 "TestThreadStepOut.py",
277 }
278 elif target.startswith("android"):
279 expected_timeout |= {
280 "TestExitDuringStep.py",
281 "TestHelloWorld.py",
282 }
Ed Maste4dd8fba2015-05-14 16:25:52 +0000283 elif target.startswith("freebsd"):
284 expected_timeout |= {
285 "TestBreakpointConditions.py",
Ed Maste08948132015-05-28 18:45:30 +0000286 "TestChangeProcessGroup.py",
Ed Mastebfd05632015-05-27 19:11:29 +0000287 "TestValueObjectRecursion.py",
Ed Maste4dd8fba2015-05-14 16:25:52 +0000288 "TestWatchpointConditionAPI.py",
289 }
Vince Harron0f173ac2015-05-18 19:36:33 +0000290 elif target.startswith("darwin"):
291 expected_timeout |= {
292 "TestThreadSpecificBreakpoint.py", # times out on MBP Retina, Mid 2012
293 }
Vince Harron06381732015-05-12 23:10:36 +0000294 return expected_timeout
295
Pavel Labathfad30cf2015-06-29 14:16:51 +0000296def getDefaultTimeout(platform_name):
297 if os.getenv("LLDB_TEST_TIMEOUT"):
298 return os.getenv("LLDB_TEST_TIMEOUT")
299
300 if platform_name is None:
301 platform_name = sys.platform
302
303 if platform_name.startswith("remote-"):
304 return "10m"
305 else:
306 return "4m"
307
Vince Harron0b9dbb52015-05-21 18:18:52 +0000308def touch(fname, times=None):
Greg Clayton8c3f9c92015-08-11 21:01:32 +0000309 if os.path.exists(fname):
Vince Harron0b9dbb52015-05-21 18:18:52 +0000310 os.utime(fname, times)
311
Vince Harrondcc2b9f2015-05-27 04:40:36 +0000312def find(pattern, path):
313 result = []
314 for root, dirs, files in os.walk(path):
315 for name in files:
316 if fnmatch.fnmatch(name, pattern):
317 result.append(os.path.join(root, name))
318 return result
319
Johnny Chene8d9dc62011-10-31 19:04:07 +0000320def main():
Vince Harrond5fa1022015-05-10 15:24:12 +0000321 # We can't use sys.path[0] to determine the script directory
322 # because it doesn't work under a debugger
Vince Harrone06a7a82015-05-12 23:12:19 +0000323 test_directory = os.path.dirname(os.path.realpath(__file__))
Johnny Chene8d9dc62011-10-31 19:04:07 +0000324 parser = OptionParser(usage="""\
325Run lldb test suite using a separate process for each test file.
Vince Harronede59652015-01-08 02:11:26 +0000326
Siva Chandra2d7832e2015-05-08 23:08:53 +0000327 Each test will run with a time limit of 10 minutes by default.
Vince Harronede59652015-01-08 02:11:26 +0000328
Siva Chandra2d7832e2015-05-08 23:08:53 +0000329 Override the default time limit of 10 minutes by setting
Vince Harronede59652015-01-08 02:11:26 +0000330 the environment variable LLDB_TEST_TIMEOUT.
331
332 E.g., export LLDB_TEST_TIMEOUT=10m
333
334 Override the time limit for individual tests by setting
335 the environment variable LLDB_[TEST NAME]_TIMEOUT.
336
337 E.g., export LLDB_TESTCONCURRENTEVENTS_TIMEOUT=2m
338
339 Set to "0" to run without time limit.
340
341 E.g., export LLDB_TEST_TIMEOUT=0
342 or export LLDB_TESTCONCURRENTEVENTS_TIMEOUT=0
Johnny Chene8d9dc62011-10-31 19:04:07 +0000343""")
344 parser.add_option('-o', '--options',
345 type='string', action='store',
346 dest='dotest_options',
347 help="""The options passed to 'dotest.py' if specified.""")
348
Zachary Turner38e64172015-08-10 17:46:11 +0000349 parser.add_option('-s', '--output-on-success',
350 action='store_true',
351 dest='output_on_success',
352 default=False,
353 help="""Print full output of 'dotest.py' even when it succeeds.""")
354
Greg Clayton2256d0d2014-03-24 23:01:57 +0000355 parser.add_option('-t', '--threads',
356 type='int',
357 dest='num_threads',
Ed Mastecec2a5b2014-11-21 02:41:25 +0000358 help="""The number of threads to use when running tests separately.""")
Greg Clayton2256d0d2014-03-24 23:01:57 +0000359
Johnny Chene8d9dc62011-10-31 19:04:07 +0000360 opts, args = parser.parse_args()
Vince Harronf8b9a1d2015-05-18 19:40:54 +0000361 dotest_option_string = opts.dotest_options
362
Vince Harron41657cc2015-05-21 18:15:09 +0000363 is_posix = (os.name == "posix")
364 dotest_argv = shlex.split(dotest_option_string, posix=is_posix) if dotest_option_string else []
Vince Harron8994fed2015-05-22 19:49:23 +0000365
366 parser = dotest_args.create_parser()
Pavel Labath05ab2372015-07-06 15:57:52 +0000367 global dotest_options
Zachary Turner38e64172015-08-10 17:46:11 +0000368 global output_on_success
369 output_on_success = opts.output_on_success
Vince Harron8994fed2015-05-22 19:49:23 +0000370 dotest_options = dotest_args.parse_args(parser, dotest_argv)
371
Vince Harron41657cc2015-05-21 18:15:09 +0000372 if not dotest_options.s:
373 # no session log directory, we need to add this to prevent
374 # every dotest invocation from creating its own directory
375 import datetime
376 # The windows platforms don't like ':' in the pathname.
377 timestamp_started = datetime.datetime.now().strftime("%Y-%m-%d-%H_%M_%S")
378 dotest_argv.append('-s')
379 dotest_argv.append(timestamp_started)
Vince Harron0b9dbb52015-05-21 18:18:52 +0000380 dotest_options.s = timestamp_started
381
382 session_dir = os.path.join(os.getcwd(), dotest_options.s)
Ed Mastecec2a5b2014-11-21 02:41:25 +0000383
Vince Harrone06a7a82015-05-12 23:12:19 +0000384 # The root directory was specified on the command line
385 if len(args) == 0:
386 test_subdir = test_directory
387 else:
388 test_subdir = os.path.join(test_directory, args[0])
389
Vince Harrondcc2b9f2015-05-27 04:40:36 +0000390 # clean core files in test tree from previous runs (Linux)
391 cores = find('core.*', test_subdir)
392 for core in cores:
393 os.unlink(core)
394
Ed Mastecec2a5b2014-11-21 02:41:25 +0000395 if opts.num_threads:
396 num_threads = opts.num_threads
397 else:
Greg Clayton2256d0d2014-03-24 23:01:57 +0000398 num_threads_str = os.environ.get("LLDB_TEST_THREADS")
399 if num_threads_str:
400 num_threads = int(num_threads_str)
Greg Clayton2256d0d2014-03-24 23:01:57 +0000401 else:
Ed Mastecec2a5b2014-11-21 02:41:25 +0000402 num_threads = multiprocessing.cpu_count()
403 if num_threads < 1:
404 num_threads = 1
Johnny Chene8d9dc62011-10-31 19:04:07 +0000405
Daniel Maleab42556f2013-04-19 18:32:53 +0000406 system_info = " ".join(platform.uname())
Zachary Turnerc7a7c8a2015-05-28 19:56:26 +0000407 (timed_out, failed, passed, all_fails, all_passes) = walk_and_invoke(test_directory, test_subdir, dotest_argv, num_threads)
408
Vince Harron17f429f2014-12-13 00:08:19 +0000409 timed_out = set(timed_out)
Zachary Turnerc7a7c8a2015-05-28 19:56:26 +0000410 num_test_files = len(failed) + len(passed)
411 num_tests = all_fails + all_passes
Daniel Maleab42556f2013-04-19 18:32:53 +0000412
Vince Harrondcc2b9f2015-05-27 04:40:36 +0000413 # move core files into session dir
414 cores = find('core.*', test_subdir)
415 for core in cores:
416 dst = core.replace(test_directory, "")[1:]
417 dst = dst.replace(os.path.sep, "-")
418 os.rename(core, os.path.join(session_dir, dst))
419
Vince Harron06381732015-05-12 23:10:36 +0000420 # remove expected timeouts from failures
Vince Harronf8b9a1d2015-05-18 19:40:54 +0000421 expected_timeout = getExpectedTimeouts(dotest_options.lldb_platform_name)
Vince Harron06381732015-05-12 23:10:36 +0000422 for xtime in expected_timeout:
423 if xtime in timed_out:
424 timed_out.remove(xtime)
425 failed.remove(xtime)
Vince Harron0b9dbb52015-05-21 18:18:52 +0000426 result = "ExpectedTimeout"
427 elif xtime in passed:
428 result = "UnexpectedCompletion"
429 else:
430 result = None # failed
431
432 if result:
433 test_name = os.path.splitext(xtime)[0]
434 touch(os.path.join(session_dir, "{}-{}".format(result, test_name)))
Vince Harron06381732015-05-12 23:10:36 +0000435
Chaoren Lin5e3ab2b2015-06-01 17:49:25 +0000436 print
Chaoren Lin273aea82015-06-01 19:06:01 +0000437 print "Ran %d test suites (%d failed) (%f%%)" % (num_test_files, len(failed),
438 (100.0 * len(failed) / num_test_files) if num_test_files > 0 else float('NaN'))
439 print "Ran %d test cases (%d failed) (%f%%)" % (num_tests, all_fails,
440 (100.0 * all_fails / num_tests) if num_tests > 0 else float('NaN'))
Daniel Maleacbaef262013-02-15 21:31:37 +0000441 if len(failed) > 0:
Shawn Best13491c42014-10-22 19:29:00 +0000442 failed.sort()
Ying Chen10ed1a92015-05-28 23:51:49 +0000443 print "Failing Tests (%d)" % len(failed)
Daniel Maleacbaef262013-02-15 21:31:37 +0000444 for f in failed:
Vince Harron17f429f2014-12-13 00:08:19 +0000445 print "%s: LLDB (suite) :: %s (%s)" % (
446 "TIMEOUT" if f in timed_out else "FAIL", f, system_info
447 )
Daniel Maleacbaef262013-02-15 21:31:37 +0000448 sys.exit(1)
449 sys.exit(0)
Johnny Chene8d9dc62011-10-31 19:04:07 +0000450
451if __name__ == '__main__':
452 main()