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