| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Runs all types of tests from one unified interface.""" | 7 """Runs all types of tests from one unified interface.""" |
| 8 | 8 |
| 9 import collections | 9 import collections |
| 10 import logging | 10 import logging |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 from pylib.instrumentation import test_options as instrumentation_test_options | 31 from pylib.instrumentation import test_options as instrumentation_test_options |
| 32 from pylib.monkey import setup as monkey_setup | 32 from pylib.monkey import setup as monkey_setup |
| 33 from pylib.monkey import test_options as monkey_test_options | 33 from pylib.monkey import test_options as monkey_test_options |
| 34 from pylib.perf import setup as perf_setup | 34 from pylib.perf import setup as perf_setup |
| 35 from pylib.perf import test_options as perf_test_options | 35 from pylib.perf import test_options as perf_test_options |
| 36 from pylib.perf import test_runner as perf_test_runner | 36 from pylib.perf import test_runner as perf_test_runner |
| 37 from pylib.uiautomator import setup as uiautomator_setup | 37 from pylib.uiautomator import setup as uiautomator_setup |
| 38 from pylib.uiautomator import test_options as uiautomator_test_options | 38 from pylib.uiautomator import test_options as uiautomator_test_options |
| 39 from pylib.utils import command_option_parser | 39 from pylib.utils import command_option_parser |
| 40 from pylib.utils import report_results | 40 from pylib.utils import report_results |
| 41 from pylib.utils import reraiser_thread |
| 41 from pylib.utils import run_tests_helper | 42 from pylib.utils import run_tests_helper |
| 42 | 43 |
| 43 | 44 |
| 44 def AddCommonOptions(option_parser): | 45 def AddCommonOptions(option_parser): |
| 45 """Adds all common options to |option_parser|.""" | 46 """Adds all common options to |option_parser|.""" |
| 46 | 47 |
| 47 group = optparse.OptionGroup(option_parser, 'Common Options') | 48 group = optparse.OptionGroup(option_parser, 'Common Options') |
| 48 default_build_type = os.environ.get('BUILDTYPE', 'Debug') | 49 default_build_type = os.environ.get('BUILDTYPE', 'Debug') |
| 49 group.add_option('--debug', action='store_const', const='Debug', | 50 group.add_option('--debug', action='store_const', const='Debug', |
| 50 dest='build_type', default=default_build_type, | 51 dest='build_type', default=default_build_type, |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 AddMonkeyTestOptions, RunTestsCommand), | 791 AddMonkeyTestOptions, RunTestsCommand), |
| 791 'perf': CommandFunctionTuple( | 792 'perf': CommandFunctionTuple( |
| 792 AddPerfTestOptions, RunTestsCommand), | 793 AddPerfTestOptions, RunTestsCommand), |
| 793 'linker': CommandFunctionTuple( | 794 'linker': CommandFunctionTuple( |
| 794 AddLinkerTestOptions, RunTestsCommand), | 795 AddLinkerTestOptions, RunTestsCommand), |
| 795 'help': CommandFunctionTuple(lambda option_parser: None, HelpCommand) | 796 'help': CommandFunctionTuple(lambda option_parser: None, HelpCommand) |
| 796 } | 797 } |
| 797 | 798 |
| 798 | 799 |
| 799 def DumpThreadStacks(signal, frame): | 800 def DumpThreadStacks(signal, frame): |
| 800 thread_names_map = dict( | 801 for thread in threading.enumerate(): |
| 801 [(thread.ident, thread.name) for thread in threading.enumerate()]) | 802 reraiser_thread.LogThreadStack(thread) |
| 802 lines = [] | |
| 803 for thread_id, stack in sys._current_frames().items(): | |
| 804 lines.append( | |
| 805 '\n# Thread: %s (%d)' % ( | |
| 806 thread_names_map.get(thread_id, ''), thread_id)) | |
| 807 for filename, lineno, name, line in traceback.extract_stack(stack): | |
| 808 lines.append('File: "%s", line %d, in %s' % (filename, lineno, name)) | |
| 809 if line: | |
| 810 lines.append(' %s' % (line.strip())) | |
| 811 print '\n'.join(lines) | |
| 812 | 803 |
| 813 | 804 |
| 814 def main(argv): | 805 def main(argv): |
| 815 signal.signal(signal.SIGUSR1, DumpThreadStacks) | 806 signal.signal(signal.SIGUSR1, DumpThreadStacks) |
| 816 option_parser = command_option_parser.CommandOptionParser( | 807 option_parser = command_option_parser.CommandOptionParser( |
| 817 commands_dict=VALID_COMMANDS) | 808 commands_dict=VALID_COMMANDS) |
| 818 return command_option_parser.ParseAndExecute(option_parser) | 809 return command_option_parser.ParseAndExecute(option_parser) |
| 819 | 810 |
| 820 | 811 |
| 821 if __name__ == '__main__': | 812 if __name__ == '__main__': |
| 822 sys.exit(main(sys.argv)) | 813 sys.exit(main(sys.argv)) |
| OLD | NEW |