Johnny Chen | f35a112 | 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. |
| 5 | """ |
| 6 | |
Daniel Malea | 4e7965a | 2013-04-19 18:32:53 +0000 | [diff] [blame^] | 7 | import os, sys, platform |
Johnny Chen | f35a112 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 8 | from optparse import OptionParser |
| 9 | |
| 10 | # Command template of the invocation of the test driver. |
| 11 | template = '%s/dotest.py %s -p %s %s' |
| 12 | |
| 13 | def walk_and_invoke(test_root, dotest_options): |
| 14 | """Look for matched file and invoke test driver on it.""" |
Daniel Malea | 361eb43 | 2013-02-15 21:31:37 +0000 | [diff] [blame] | 15 | failed = [] |
| 16 | passed = [] |
Johnny Chen | f35a112 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 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) |
Daniel Malea | f2025c2 | 2013-02-20 21:31:47 +0000 | [diff] [blame] | 30 | print "Running %s" % (command) |
Daniel Malea | 361eb43 | 2013-02-15 21:31:37 +0000 | [diff] [blame] | 31 | if 0 != os.system(command): |
| 32 | failed.append(name) |
| 33 | else: |
| 34 | passed.append(name) |
| 35 | return (failed, passed) |
Johnny Chen | f35a112 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 36 | |
| 37 | def main(): |
Johnny Chen | f35a112 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 38 | test_root = sys.path[0] |
| 39 | |
| 40 | parser = OptionParser(usage="""\ |
| 41 | Run 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 Malea | 4e7965a | 2013-04-19 18:32:53 +0000 | [diff] [blame^] | 51 | system_info = " ".join(platform.uname()) |
Daniel Malea | 361eb43 | 2013-02-15 21:31:37 +0000 | [diff] [blame] | 52 | (failed, passed) = walk_and_invoke(test_root, dotest_options) |
| 53 | num_tests = len(failed) + len(passed) |
Daniel Malea | 4e7965a | 2013-04-19 18:32:53 +0000 | [diff] [blame^] | 54 | |
Daniel Malea | 361eb43 | 2013-02-15 21:31:37 +0000 | [diff] [blame] | 55 | print "Ran %d tests." % num_tests |
| 56 | if len(failed) > 0: |
| 57 | print "Failing Tests (%d)" % len(failed) |
| 58 | for f in failed: |
Daniel Malea | 4e7965a | 2013-04-19 18:32:53 +0000 | [diff] [blame^] | 59 | print "FAIL: LLDB (suite) :: %s (%s)" % (f, system_info) |
Daniel Malea | 361eb43 | 2013-02-15 21:31:37 +0000 | [diff] [blame] | 60 | sys.exit(1) |
| 61 | sys.exit(0) |
Johnny Chen | f35a112 | 2011-10-31 19:04:07 +0000 | [diff] [blame] | 62 | |
| 63 | if __name__ == '__main__': |
| 64 | main() |