blob: e09af34c2f5b9e25767118db4d0ad892b0e1ecfd [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 Malea361eb432013-02-15 21:31:37 +000030 if 0 != os.system(command):
31 failed.append(name)
32 else:
33 passed.append(name)
34 return (failed, passed)
Johnny Chenf35a1122011-10-31 19:04:07 +000035
36def main():
Johnny Chenf35a1122011-10-31 19:04:07 +000037 test_root = sys.path[0]
38
39 parser = OptionParser(usage="""\
40Run lldb test suite using a separate process for each test file.
41""")
42 parser.add_option('-o', '--options',
43 type='string', action='store',
44 dest='dotest_options',
45 help="""The options passed to 'dotest.py' if specified.""")
46
47 opts, args = parser.parse_args()
48 dotest_options = opts.dotest_options
49
Daniel Malea4e7965a2013-04-19 18:32:53 +000050 system_info = " ".join(platform.uname())
Daniel Malea361eb432013-02-15 21:31:37 +000051 (failed, passed) = walk_and_invoke(test_root, dotest_options)
52 num_tests = len(failed) + len(passed)
Daniel Malea4e7965a2013-04-19 18:32:53 +000053
Daniel Malea361eb432013-02-15 21:31:37 +000054 print "Ran %d tests." % num_tests
55 if len(failed) > 0:
56 print "Failing Tests (%d)" % len(failed)
57 for f in failed:
Daniel Malea4e7965a2013-04-19 18:32:53 +000058 print "FAIL: LLDB (suite) :: %s (%s)" % (f, system_info)
Daniel Malea361eb432013-02-15 21:31:37 +000059 sys.exit(1)
60 sys.exit(0)
Johnny Chenf35a1122011-10-31 19:04:07 +000061
62if __name__ == '__main__':
63 main()