blob: 759b44592c1b3809e3cd89ecff9acdef488fd5e1 [file] [log] [blame]
Johnny Chenf35a1122011-10-31 19:04:07 +00001#!/usr/bin/env python
2
3"""
4Run the test suite using a separate process for each test file.
5"""
6
Daniel Malea4e7965a2013-04-19 18:32:53 +00007import os, sys, platform
Johnny Chenf35a1122011-10-31 19:04:07 +00008from optparse import OptionParser
9
10# Command template of the invocation of the test driver.
11template = '%s/dotest.py %s -p %s %s'
12
13def walk_and_invoke(test_root, dotest_options):
14 """Look for matched file and invoke test driver on it."""
Daniel Malea361eb432013-02-15 21:31:37 +000015 failed = []
16 passed = []
Johnny Chenf35a1122011-10-31 19:04:07 +000017 for root, dirs, files in os.walk(test_root, topdown=False):
18 for name in files:
19 path = os.path.join(root, name)
20
21 # We're only interested in the test file with the "Test*.py" naming pattern.
22 if not name.startswith("Test") or not name.endswith(".py"):
23 continue
24
25 # Neither a symbolically linked file.
26 if os.path.islink(path):
27 continue
28
29 command = template % (test_root, dotest_options if dotest_options else "", name, root)
Daniel Maleaf2025c22013-02-20 21:31:47 +000030 print "Running %s" % (command)
Daniel Malea361eb432013-02-15 21:31:37 +000031 if 0 != os.system(command):
32 failed.append(name)
33 else:
34 passed.append(name)
35 return (failed, passed)
Johnny Chenf35a1122011-10-31 19:04:07 +000036
37def main():
Johnny Chenf35a1122011-10-31 19:04:07 +000038 test_root = sys.path[0]
39
40 parser = OptionParser(usage="""\
41Run lldb test suite using a separate process for each test file.
42""")
43 parser.add_option('-o', '--options',
44 type='string', action='store',
45 dest='dotest_options',
46 help="""The options passed to 'dotest.py' if specified.""")
47
48 opts, args = parser.parse_args()
49 dotest_options = opts.dotest_options
50
Daniel Malea4e7965a2013-04-19 18:32:53 +000051 system_info = " ".join(platform.uname())
Daniel Malea361eb432013-02-15 21:31:37 +000052 (failed, passed) = walk_and_invoke(test_root, dotest_options)
53 num_tests = len(failed) + len(passed)
Daniel Malea4e7965a2013-04-19 18:32:53 +000054
Daniel Malea361eb432013-02-15 21:31:37 +000055 print "Ran %d tests." % num_tests
56 if len(failed) > 0:
57 print "Failing Tests (%d)" % len(failed)
58 for f in failed:
Daniel Malea4e7965a2013-04-19 18:32:53 +000059 print "FAIL: LLDB (suite) :: %s (%s)" % (f, system_info)
Daniel Malea361eb432013-02-15 21:31:37 +000060 sys.exit(1)
61 sys.exit(0)
Johnny Chenf35a1122011-10-31 19:04:07 +000062
63if __name__ == '__main__':
64 main()