dosep.ty revision e27cafba1267c53004486c8f4afa966e52ee49c8
1#!/usr/bin/env python
2
3"""
4Run the test suite using a separate process for each test file.
5"""
6
7import os, sys
8from 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."""
15    failed = []
16    passed = []
17    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)
30            print "Running %s" % (command)
31            if 0 != os.system(command):
32                failed.append(name) 
33            else:
34                passed.append(name)
35    return (failed, passed)
36
37def main():
38    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
51    print "dotest.py options:", dotest_options
52
53    (failed, passed) = walk_and_invoke(test_root, dotest_options)
54    num_tests = len(failed) + len(passed)
55    print "Ran %d tests." % num_tests
56    if len(failed) > 0:
57        print "Failing Tests (%d)" % len(failed)
58        for f in failed:
59          print "FAIL: LLDB :: %s" % f
60        sys.exit(1)
61    sys.exit(0)
62
63if __name__ == '__main__':
64    main()
65