Johnny Chen | e8d9dc6 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | """ |
| 4 | Run the test suite using a separate process for each test file. |
Vince Harron | ede5965 | 2015-01-08 02:11:26 +0000 | [diff] [blame] | 5 | |
Siva Chandra | 2d7832e | 2015-05-08 23:08:53 +0000 | [diff] [blame] | 6 | Each test will run with a time limit of 10 minutes by default. |
Vince Harron | ede5965 | 2015-01-08 02:11:26 +0000 | [diff] [blame] | 7 | |
Siva Chandra | 2d7832e | 2015-05-08 23:08:53 +0000 | [diff] [blame] | 8 | Override the default time limit of 10 minutes by setting |
Vince Harron | ede5965 | 2015-01-08 02:11:26 +0000 | [diff] [blame] | 9 | the environment variable LLDB_TEST_TIMEOUT. |
| 10 | |
| 11 | E.g., export LLDB_TEST_TIMEOUT=10m |
| 12 | |
| 13 | Override the time limit for individual tests by setting |
| 14 | the environment variable LLDB_[TEST NAME]_TIMEOUT. |
| 15 | |
| 16 | E.g., export LLDB_TESTCONCURRENTEVENTS_TIMEOUT=2m |
| 17 | |
| 18 | Set to "0" to run without time limit. |
| 19 | |
| 20 | E.g., export LLDB_TEST_TIMEOUT=0 |
| 21 | or export LLDB_TESTCONCURRENTEVENTS_TIMEOUT=0 |
Vince Harron | dcc2b9f | 2015-05-27 04:40:36 +0000 | [diff] [blame] | 22 | |
| 23 | To collect core files for timed out tests, do the following before running dosep.py |
| 24 | |
| 25 | OSX |
| 26 | ulimit -c unlimited |
| 27 | sudo sysctl -w kern.corefile=core.%P |
| 28 | |
| 29 | Linux: |
| 30 | ulimit -c unlimited |
| 31 | echo core.%p | sudo tee /proc/sys/kernel/core_pattern |
Johnny Chen | e8d9dc6 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 32 | """ |
| 33 | |
Greg Clayton | 2256d0d | 2014-03-24 23:01:57 +0000 | [diff] [blame] | 34 | import multiprocessing |
Todd Fiala | 3f0a360 | 2014-07-08 06:42:37 +0000 | [diff] [blame] | 35 | import os |
Vince Harron | dcc2b9f | 2015-05-27 04:40:36 +0000 | [diff] [blame] | 36 | import fnmatch |
Todd Fiala | 3f0a360 | 2014-07-08 06:42:37 +0000 | [diff] [blame] | 37 | import platform |
Vince Harron | 0638173 | 2015-05-12 23:10:36 +0000 | [diff] [blame] | 38 | import re |
Vince Harron | f8b9a1d | 2015-05-18 19:40:54 +0000 | [diff] [blame] | 39 | import dotest_args |
Vince Harron | 17f429f | 2014-12-13 00:08:19 +0000 | [diff] [blame] | 40 | import shlex |
| 41 | import subprocess |
Todd Fiala | 3f0a360 | 2014-07-08 06:42:37 +0000 | [diff] [blame] | 42 | import sys |
Steve Pucci | befe2b1 | 2014-03-07 00:01:11 +0000 | [diff] [blame] | 43 | |
Johnny Chen | e8d9dc6 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 44 | from optparse import OptionParser |
| 45 | |
Vince Harron | 17f429f | 2014-12-13 00:08:19 +0000 | [diff] [blame] | 46 | def get_timeout_command(): |
Vince Harron | ede5965 | 2015-01-08 02:11:26 +0000 | [diff] [blame] | 47 | """Search for a suitable timeout command.""" |
Vince Harron | 17f429f | 2014-12-13 00:08:19 +0000 | [diff] [blame] | 48 | if sys.platform.startswith("win32"): |
| 49 | return None |
| 50 | try: |
| 51 | subprocess.call("timeout") |
| 52 | return "timeout" |
| 53 | except OSError: |
| 54 | pass |
| 55 | try: |
| 56 | subprocess.call("gtimeout") |
| 57 | return "gtimeout" |
| 58 | except OSError: |
| 59 | pass |
| 60 | return None |
| 61 | |
| 62 | timeout_command = get_timeout_command() |
| 63 | |
Siva Chandra | 2d7832e | 2015-05-08 23:08:53 +0000 | [diff] [blame] | 64 | default_timeout = os.getenv("LLDB_TEST_TIMEOUT") or "10m" |
Vince Harron | 17f429f | 2014-12-13 00:08:19 +0000 | [diff] [blame] | 65 | |
| 66 | # Status codes for running command with timeout. |
| 67 | eTimedOut, ePassed, eFailed = 124, 0, 1 |
| 68 | |
Zachary Turner | c7a7c8a | 2015-05-28 19:56:26 +0000 | [diff] [blame^] | 69 | def parse_test_results(output): |
| 70 | passes = 0 |
| 71 | failures = 0 |
| 72 | for result in output: |
| 73 | pass_count = re.search("^RESULT:.*([0-9]+) passes", result, re.MULTILINE) |
| 74 | fail_count = re.search("^RESULT:.*([0-9]+) failures", result, re.MULTILINE) |
| 75 | error_count = re.search("^RESULT:.*([0-9]+) errors", result, re.MULTILINE) |
| 76 | this_fail_count = 0 |
| 77 | this_error_count = 0 |
| 78 | if pass_count != None: |
| 79 | passes = passes + int(pass_count.group(1)) |
| 80 | if fail_count != None: |
| 81 | failures = failures + int(fail_count.group(1)) |
| 82 | if error_count != None: |
| 83 | failures = failures + int(error_count.group(1)) |
| 84 | pass |
| 85 | return passes, failures |
| 86 | |
Vince Harron | 17f429f | 2014-12-13 00:08:19 +0000 | [diff] [blame] | 87 | def call_with_timeout(command, timeout): |
Vince Harron | ede5965 | 2015-01-08 02:11:26 +0000 | [diff] [blame] | 88 | """Run command with a timeout if possible.""" |
Vince Harron | dcc2b9f | 2015-05-27 04:40:36 +0000 | [diff] [blame] | 89 | """-s QUIT will create a coredump if they are enabled on your system""" |
Zachary Turner | c7a7c8a | 2015-05-28 19:56:26 +0000 | [diff] [blame^] | 90 | process = None |
| 91 | if timeout_command and timeout != "0": |
| 92 | command = [timeout_command, '-s', 'QUIT', timeout] + command |
| 93 | # Specifying a value for close_fds is unsupported on Windows when using subprocess.PIPE |
Zachary Turner | dc494d5 | 2015-02-07 00:14:55 +0000 | [diff] [blame] | 94 | if os.name != "nt": |
Zachary Turner | c7a7c8a | 2015-05-28 19:56:26 +0000 | [diff] [blame^] | 95 | process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) |
Zachary Turner | dc494d5 | 2015-02-07 00:14:55 +0000 | [diff] [blame] | 96 | else: |
Zachary Turner | c7a7c8a | 2015-05-28 19:56:26 +0000 | [diff] [blame^] | 97 | process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 98 | output = process.communicate() |
| 99 | exit_status = process.returncode |
| 100 | passes, failures = parse_test_results(output) |
| 101 | return exit_status, passes, failures |
Johnny Chen | e8d9dc6 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 102 | |
Vince Harron | 41657cc | 2015-05-21 18:15:09 +0000 | [diff] [blame] | 103 | def process_dir(root, files, test_root, dotest_argv): |
Steve Pucci | befe2b1 | 2014-03-07 00:01:11 +0000 | [diff] [blame] | 104 | """Examine a directory for tests, and invoke any found within it.""" |
Vince Harron | 17f429f | 2014-12-13 00:08:19 +0000 | [diff] [blame] | 105 | timed_out = [] |
Daniel Malea | cbaef26 | 2013-02-15 21:31:37 +0000 | [diff] [blame] | 106 | failed = [] |
| 107 | passed = [] |
Zachary Turner | c7a7c8a | 2015-05-28 19:56:26 +0000 | [diff] [blame^] | 108 | pass_sub_count = 0 |
| 109 | fail_sub_count = 0 |
Steve Pucci | befe2b1 | 2014-03-07 00:01:11 +0000 | [diff] [blame] | 110 | for name in files: |
| 111 | path = os.path.join(root, name) |
| 112 | |
| 113 | # We're only interested in the test file with the "Test*.py" naming pattern. |
| 114 | if not name.startswith("Test") or not name.endswith(".py"): |
| 115 | continue |
| 116 | |
| 117 | # Neither a symbolically linked file. |
| 118 | if os.path.islink(path): |
| 119 | continue |
| 120 | |
Zachary Turner | f6896b0 | 2015-01-05 19:37:03 +0000 | [diff] [blame] | 121 | script_file = os.path.join(test_root, "dotest.py") |
Zachary Turner | f6896b0 | 2015-01-05 19:37:03 +0000 | [diff] [blame] | 122 | command = ([sys.executable, script_file] + |
Vince Harron | 41657cc | 2015-05-21 18:15:09 +0000 | [diff] [blame] | 123 | dotest_argv + |
Vince Harron | 17f429f | 2014-12-13 00:08:19 +0000 | [diff] [blame] | 124 | ["-p", name, root]) |
| 125 | |
| 126 | timeout_name = os.path.basename(os.path.splitext(name)[0]).upper() |
| 127 | |
| 128 | timeout = os.getenv("LLDB_%s_TIMEOUT" % timeout_name) or default_timeout |
| 129 | |
Zachary Turner | c7a7c8a | 2015-05-28 19:56:26 +0000 | [diff] [blame^] | 130 | exit_status, pass_count, fail_count = call_with_timeout(command, timeout) |
Vince Harron | 17f429f | 2014-12-13 00:08:19 +0000 | [diff] [blame] | 131 | |
Zachary Turner | c7a7c8a | 2015-05-28 19:56:26 +0000 | [diff] [blame^] | 132 | pass_sub_count = pass_sub_count + pass_count |
| 133 | fail_sub_count = fail_sub_count + fail_count |
| 134 | |
| 135 | if exit_status == ePassed: |
Steve Pucci | befe2b1 | 2014-03-07 00:01:11 +0000 | [diff] [blame] | 136 | passed.append(name) |
Vince Harron | 17f429f | 2014-12-13 00:08:19 +0000 | [diff] [blame] | 137 | else: |
| 138 | if eTimedOut == exit_status: |
| 139 | timed_out.append(name) |
| 140 | failed.append(name) |
Zachary Turner | c7a7c8a | 2015-05-28 19:56:26 +0000 | [diff] [blame^] | 141 | return (timed_out, failed, passed, fail_sub_count, pass_sub_count) |
Steve Pucci | befe2b1 | 2014-03-07 00:01:11 +0000 | [diff] [blame] | 142 | |
| 143 | in_q = None |
| 144 | out_q = None |
| 145 | |
Todd Fiala | 3f0a360 | 2014-07-08 06:42:37 +0000 | [diff] [blame] | 146 | def process_dir_worker(arg_tuple): |
Steve Pucci | befe2b1 | 2014-03-07 00:01:11 +0000 | [diff] [blame] | 147 | """Worker thread main loop when in multithreaded mode. |
| 148 | Takes one directory specification at a time and works on it.""" |
Vince Harron | 41657cc | 2015-05-21 18:15:09 +0000 | [diff] [blame] | 149 | (root, files, test_root, dotest_argv) = arg_tuple |
| 150 | return process_dir(root, files, test_root, dotest_argv) |
Steve Pucci | befe2b1 | 2014-03-07 00:01:11 +0000 | [diff] [blame] | 151 | |
Vince Harron | 41657cc | 2015-05-21 18:15:09 +0000 | [diff] [blame] | 152 | def walk_and_invoke(test_directory, test_subdir, dotest_argv, num_threads): |
Steve Pucci | befe2b1 | 2014-03-07 00:01:11 +0000 | [diff] [blame] | 153 | """Look for matched files and invoke test driver on each one. |
| 154 | In single-threaded mode, each test driver is invoked directly. |
| 155 | In multi-threaded mode, submit each test driver to a worker |
Vince Harron | e06a7a8 | 2015-05-12 23:12:19 +0000 | [diff] [blame] | 156 | queue, and then wait for all to complete. |
| 157 | |
| 158 | test_directory - lldb/test/ directory |
| 159 | test_subdir - lldb/test/ or a subfolder with the tests we're interested in running |
| 160 | """ |
Todd Fiala | 3f0a360 | 2014-07-08 06:42:37 +0000 | [diff] [blame] | 161 | |
| 162 | # Collect the test files that we'll run. |
| 163 | test_work_items = [] |
Vince Harron | e06a7a8 | 2015-05-12 23:12:19 +0000 | [diff] [blame] | 164 | for root, dirs, files in os.walk(test_subdir, topdown=False): |
Vince Harron | 41657cc | 2015-05-21 18:15:09 +0000 | [diff] [blame] | 165 | test_work_items.append((root, files, test_directory, dotest_argv)) |
Todd Fiala | 3f0a360 | 2014-07-08 06:42:37 +0000 | [diff] [blame] | 166 | |
| 167 | # Run the items, either in a pool (for multicore speedup) or |
| 168 | # calling each individually. |
| 169 | if num_threads > 1: |
| 170 | pool = multiprocessing.Pool(num_threads) |
| 171 | test_results = pool.map(process_dir_worker, test_work_items) |
| 172 | else: |
| 173 | test_results = [] |
| 174 | for work_item in test_work_items: |
| 175 | test_results.append(process_dir_worker(work_item)) |
| 176 | |
Vince Harron | 17f429f | 2014-12-13 00:08:19 +0000 | [diff] [blame] | 177 | timed_out = [] |
Steve Pucci | befe2b1 | 2014-03-07 00:01:11 +0000 | [diff] [blame] | 178 | failed = [] |
| 179 | passed = [] |
Zachary Turner | c7a7c8a | 2015-05-28 19:56:26 +0000 | [diff] [blame^] | 180 | fail_sub_count = 0 |
| 181 | pass_sub_count = 0 |
Todd Fiala | 3f0a360 | 2014-07-08 06:42:37 +0000 | [diff] [blame] | 182 | |
| 183 | for test_result in test_results: |
Zachary Turner | c7a7c8a | 2015-05-28 19:56:26 +0000 | [diff] [blame^] | 184 | (dir_timed_out, dir_failed, dir_passed, dir_fail_sub_count, dir_pass_sub_count) = test_result |
Vince Harron | 17f429f | 2014-12-13 00:08:19 +0000 | [diff] [blame] | 185 | timed_out += dir_timed_out |
Todd Fiala | 3f0a360 | 2014-07-08 06:42:37 +0000 | [diff] [blame] | 186 | failed += dir_failed |
| 187 | passed += dir_passed |
Zachary Turner | c7a7c8a | 2015-05-28 19:56:26 +0000 | [diff] [blame^] | 188 | fail_sub_count = fail_sub_count + dir_fail_sub_count |
| 189 | pass_sub_count = pass_sub_count + dir_pass_sub_count |
Todd Fiala | 3f0a360 | 2014-07-08 06:42:37 +0000 | [diff] [blame] | 190 | |
Zachary Turner | c7a7c8a | 2015-05-28 19:56:26 +0000 | [diff] [blame^] | 191 | return (timed_out, failed, passed, fail_sub_count, pass_sub_count) |
Johnny Chen | e8d9dc6 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 192 | |
Vince Harron | f8b9a1d | 2015-05-18 19:40:54 +0000 | [diff] [blame] | 193 | def getExpectedTimeouts(platform_name): |
Vince Harron | 0638173 | 2015-05-12 23:10:36 +0000 | [diff] [blame] | 194 | # returns a set of test filenames that might timeout |
| 195 | # are we running against a remote target? |
Vince Harron | f8b9a1d | 2015-05-18 19:40:54 +0000 | [diff] [blame] | 196 | if platform_name is None: |
Vince Harron | 0638173 | 2015-05-12 23:10:36 +0000 | [diff] [blame] | 197 | target = sys.platform |
| 198 | remote = False |
Vince Harron | f8b9a1d | 2015-05-18 19:40:54 +0000 | [diff] [blame] | 199 | else: |
| 200 | m = re.search('remote-(\w+)', platform_name) |
| 201 | target = m.group(1) |
| 202 | remote = True |
Vince Harron | 0638173 | 2015-05-12 23:10:36 +0000 | [diff] [blame] | 203 | |
| 204 | expected_timeout = set() |
| 205 | |
| 206 | if target.startswith("linux"): |
| 207 | expected_timeout |= { |
Vince Harron | de92b52 | 2015-05-13 23:59:03 +0000 | [diff] [blame] | 208 | "TestAttachDenied.py", |
Vince Harron | 0638173 | 2015-05-12 23:10:36 +0000 | [diff] [blame] | 209 | "TestAttachResume.py", |
| 210 | "TestConnectRemote.py", |
| 211 | "TestCreateAfterAttach.py", |
Tamas Berghammer | 0d0ec9f | 2015-05-19 10:49:40 +0000 | [diff] [blame] | 212 | "TestEvents.py", |
Vince Harron | 0638173 | 2015-05-12 23:10:36 +0000 | [diff] [blame] | 213 | "TestExitDuringStep.py", |
| 214 | "TestThreadStepOut.py", |
| 215 | } |
| 216 | elif target.startswith("android"): |
| 217 | expected_timeout |= { |
| 218 | "TestExitDuringStep.py", |
| 219 | "TestHelloWorld.py", |
| 220 | } |
Ed Maste | 4dd8fba | 2015-05-14 16:25:52 +0000 | [diff] [blame] | 221 | elif target.startswith("freebsd"): |
| 222 | expected_timeout |= { |
| 223 | "TestBreakpointConditions.py", |
Ed Maste | 0894813 | 2015-05-28 18:45:30 +0000 | [diff] [blame] | 224 | "TestChangeProcessGroup.py", |
Ed Maste | bfd0563 | 2015-05-27 19:11:29 +0000 | [diff] [blame] | 225 | "TestValueObjectRecursion.py", |
Ed Maste | 4dd8fba | 2015-05-14 16:25:52 +0000 | [diff] [blame] | 226 | "TestWatchpointConditionAPI.py", |
| 227 | } |
Vince Harron | 0f173ac | 2015-05-18 19:36:33 +0000 | [diff] [blame] | 228 | elif target.startswith("darwin"): |
| 229 | expected_timeout |= { |
| 230 | "TestThreadSpecificBreakpoint.py", # times out on MBP Retina, Mid 2012 |
| 231 | } |
Vince Harron | 0638173 | 2015-05-12 23:10:36 +0000 | [diff] [blame] | 232 | return expected_timeout |
| 233 | |
Vince Harron | 0b9dbb5 | 2015-05-21 18:18:52 +0000 | [diff] [blame] | 234 | def touch(fname, times=None): |
| 235 | with open(fname, 'a'): |
| 236 | os.utime(fname, times) |
| 237 | |
Vince Harron | dcc2b9f | 2015-05-27 04:40:36 +0000 | [diff] [blame] | 238 | def find(pattern, path): |
| 239 | result = [] |
| 240 | for root, dirs, files in os.walk(path): |
| 241 | for name in files: |
| 242 | if fnmatch.fnmatch(name, pattern): |
| 243 | result.append(os.path.join(root, name)) |
| 244 | return result |
| 245 | |
Johnny Chen | e8d9dc6 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 246 | def main(): |
Vince Harron | d5fa102 | 2015-05-10 15:24:12 +0000 | [diff] [blame] | 247 | # We can't use sys.path[0] to determine the script directory |
| 248 | # because it doesn't work under a debugger |
Vince Harron | e06a7a8 | 2015-05-12 23:12:19 +0000 | [diff] [blame] | 249 | test_directory = os.path.dirname(os.path.realpath(__file__)) |
Johnny Chen | e8d9dc6 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 250 | parser = OptionParser(usage="""\ |
| 251 | Run lldb test suite using a separate process for each test file. |
Vince Harron | ede5965 | 2015-01-08 02:11:26 +0000 | [diff] [blame] | 252 | |
Siva Chandra | 2d7832e | 2015-05-08 23:08:53 +0000 | [diff] [blame] | 253 | Each test will run with a time limit of 10 minutes by default. |
Vince Harron | ede5965 | 2015-01-08 02:11:26 +0000 | [diff] [blame] | 254 | |
Siva Chandra | 2d7832e | 2015-05-08 23:08:53 +0000 | [diff] [blame] | 255 | Override the default time limit of 10 minutes by setting |
Vince Harron | ede5965 | 2015-01-08 02:11:26 +0000 | [diff] [blame] | 256 | the environment variable LLDB_TEST_TIMEOUT. |
| 257 | |
| 258 | E.g., export LLDB_TEST_TIMEOUT=10m |
| 259 | |
| 260 | Override the time limit for individual tests by setting |
| 261 | the environment variable LLDB_[TEST NAME]_TIMEOUT. |
| 262 | |
| 263 | E.g., export LLDB_TESTCONCURRENTEVENTS_TIMEOUT=2m |
| 264 | |
| 265 | Set to "0" to run without time limit. |
| 266 | |
| 267 | E.g., export LLDB_TEST_TIMEOUT=0 |
| 268 | or export LLDB_TESTCONCURRENTEVENTS_TIMEOUT=0 |
Johnny Chen | e8d9dc6 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 269 | """) |
| 270 | parser.add_option('-o', '--options', |
| 271 | type='string', action='store', |
| 272 | dest='dotest_options', |
| 273 | help="""The options passed to 'dotest.py' if specified.""") |
| 274 | |
Greg Clayton | 2256d0d | 2014-03-24 23:01:57 +0000 | [diff] [blame] | 275 | parser.add_option('-t', '--threads', |
| 276 | type='int', |
| 277 | dest='num_threads', |
Ed Maste | cec2a5b | 2014-11-21 02:41:25 +0000 | [diff] [blame] | 278 | help="""The number of threads to use when running tests separately.""") |
Greg Clayton | 2256d0d | 2014-03-24 23:01:57 +0000 | [diff] [blame] | 279 | |
Johnny Chen | e8d9dc6 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 280 | opts, args = parser.parse_args() |
Vince Harron | f8b9a1d | 2015-05-18 19:40:54 +0000 | [diff] [blame] | 281 | dotest_option_string = opts.dotest_options |
| 282 | |
Vince Harron | 41657cc | 2015-05-21 18:15:09 +0000 | [diff] [blame] | 283 | is_posix = (os.name == "posix") |
| 284 | dotest_argv = shlex.split(dotest_option_string, posix=is_posix) if dotest_option_string else [] |
Vince Harron | 8994fed | 2015-05-22 19:49:23 +0000 | [diff] [blame] | 285 | |
| 286 | parser = dotest_args.create_parser() |
| 287 | dotest_options = dotest_args.parse_args(parser, dotest_argv) |
| 288 | |
Vince Harron | 41657cc | 2015-05-21 18:15:09 +0000 | [diff] [blame] | 289 | if not dotest_options.s: |
| 290 | # no session log directory, we need to add this to prevent |
| 291 | # every dotest invocation from creating its own directory |
| 292 | import datetime |
| 293 | # The windows platforms don't like ':' in the pathname. |
| 294 | timestamp_started = datetime.datetime.now().strftime("%Y-%m-%d-%H_%M_%S") |
| 295 | dotest_argv.append('-s') |
| 296 | dotest_argv.append(timestamp_started) |
Vince Harron | 0b9dbb5 | 2015-05-21 18:18:52 +0000 | [diff] [blame] | 297 | dotest_options.s = timestamp_started |
| 298 | |
| 299 | session_dir = os.path.join(os.getcwd(), dotest_options.s) |
Ed Maste | cec2a5b | 2014-11-21 02:41:25 +0000 | [diff] [blame] | 300 | |
Vince Harron | e06a7a8 | 2015-05-12 23:12:19 +0000 | [diff] [blame] | 301 | # The root directory was specified on the command line |
| 302 | if len(args) == 0: |
| 303 | test_subdir = test_directory |
| 304 | else: |
| 305 | test_subdir = os.path.join(test_directory, args[0]) |
| 306 | |
Vince Harron | dcc2b9f | 2015-05-27 04:40:36 +0000 | [diff] [blame] | 307 | # clean core files in test tree from previous runs (Linux) |
| 308 | cores = find('core.*', test_subdir) |
| 309 | for core in cores: |
| 310 | os.unlink(core) |
| 311 | |
Ed Maste | cec2a5b | 2014-11-21 02:41:25 +0000 | [diff] [blame] | 312 | if opts.num_threads: |
| 313 | num_threads = opts.num_threads |
| 314 | else: |
Greg Clayton | 2256d0d | 2014-03-24 23:01:57 +0000 | [diff] [blame] | 315 | num_threads_str = os.environ.get("LLDB_TEST_THREADS") |
| 316 | if num_threads_str: |
| 317 | num_threads = int(num_threads_str) |
Greg Clayton | 2256d0d | 2014-03-24 23:01:57 +0000 | [diff] [blame] | 318 | else: |
Ed Maste | cec2a5b | 2014-11-21 02:41:25 +0000 | [diff] [blame] | 319 | num_threads = multiprocessing.cpu_count() |
| 320 | if num_threads < 1: |
| 321 | num_threads = 1 |
Johnny Chen | e8d9dc6 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 322 | |
Daniel Malea | b42556f | 2013-04-19 18:32:53 +0000 | [diff] [blame] | 323 | system_info = " ".join(platform.uname()) |
Zachary Turner | c7a7c8a | 2015-05-28 19:56:26 +0000 | [diff] [blame^] | 324 | (timed_out, failed, passed, all_fails, all_passes) = walk_and_invoke(test_directory, test_subdir, dotest_argv, num_threads) |
| 325 | |
Vince Harron | 17f429f | 2014-12-13 00:08:19 +0000 | [diff] [blame] | 326 | timed_out = set(timed_out) |
Zachary Turner | c7a7c8a | 2015-05-28 19:56:26 +0000 | [diff] [blame^] | 327 | num_test_files = len(failed) + len(passed) |
| 328 | num_tests = all_fails + all_passes |
Daniel Malea | b42556f | 2013-04-19 18:32:53 +0000 | [diff] [blame] | 329 | |
Vince Harron | dcc2b9f | 2015-05-27 04:40:36 +0000 | [diff] [blame] | 330 | # move core files into session dir |
| 331 | cores = find('core.*', test_subdir) |
| 332 | for core in cores: |
| 333 | dst = core.replace(test_directory, "")[1:] |
| 334 | dst = dst.replace(os.path.sep, "-") |
| 335 | os.rename(core, os.path.join(session_dir, dst)) |
| 336 | |
Vince Harron | 0638173 | 2015-05-12 23:10:36 +0000 | [diff] [blame] | 337 | # remove expected timeouts from failures |
Vince Harron | f8b9a1d | 2015-05-18 19:40:54 +0000 | [diff] [blame] | 338 | expected_timeout = getExpectedTimeouts(dotest_options.lldb_platform_name) |
Vince Harron | 0638173 | 2015-05-12 23:10:36 +0000 | [diff] [blame] | 339 | for xtime in expected_timeout: |
| 340 | if xtime in timed_out: |
| 341 | timed_out.remove(xtime) |
| 342 | failed.remove(xtime) |
Vince Harron | 0b9dbb5 | 2015-05-21 18:18:52 +0000 | [diff] [blame] | 343 | result = "ExpectedTimeout" |
| 344 | elif xtime in passed: |
| 345 | result = "UnexpectedCompletion" |
| 346 | else: |
| 347 | result = None # failed |
| 348 | |
| 349 | if result: |
| 350 | test_name = os.path.splitext(xtime)[0] |
| 351 | touch(os.path.join(session_dir, "{}-{}".format(result, test_name))) |
Vince Harron | 0638173 | 2015-05-12 23:10:36 +0000 | [diff] [blame] | 352 | |
Zachary Turner | c7a7c8a | 2015-05-28 19:56:26 +0000 | [diff] [blame^] | 353 | print "Ran %d test suites (%d failed) (%f%%)" % (num_test_files, len(failed), 100.0*len(failed)/num_test_files) |
| 354 | print "Ran %d test cases (%d failed) (%f%%)" % (num_tests, all_fails, 100.0*all_fails/num_tests) |
Daniel Malea | cbaef26 | 2013-02-15 21:31:37 +0000 | [diff] [blame] | 355 | if len(failed) > 0: |
Shawn Best | 13491c4 | 2014-10-22 19:29:00 +0000 | [diff] [blame] | 356 | failed.sort() |
Daniel Malea | cbaef26 | 2013-02-15 21:31:37 +0000 | [diff] [blame] | 357 | for f in failed: |
Vince Harron | 17f429f | 2014-12-13 00:08:19 +0000 | [diff] [blame] | 358 | print "%s: LLDB (suite) :: %s (%s)" % ( |
| 359 | "TIMEOUT" if f in timed_out else "FAIL", f, system_info |
| 360 | ) |
Daniel Malea | cbaef26 | 2013-02-15 21:31:37 +0000 | [diff] [blame] | 361 | sys.exit(1) |
| 362 | sys.exit(0) |
Johnny Chen | e8d9dc6 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 363 | |
| 364 | if __name__ == '__main__': |
| 365 | main() |