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 |
11 import optparse | 11 import optparse |
12 import os | 12 import os |
13 import shutil | 13 import shutil |
| 14 import signal |
14 import sys | 15 import sys |
| 16 import threading |
| 17 import traceback |
15 | 18 |
16 from pylib import android_commands | 19 from pylib import android_commands |
17 from pylib import constants | 20 from pylib import constants |
18 from pylib import forwarder | 21 from pylib import forwarder |
19 from pylib import ports | 22 from pylib import ports |
20 from pylib.base import base_test_result | 23 from pylib.base import base_test_result |
21 from pylib.base import test_dispatcher | 24 from pylib.base import test_dispatcher |
22 from pylib.gtest import gtest_config | 25 from pylib.gtest import gtest_config |
23 from pylib.gtest import setup as gtest_setup | 26 from pylib.gtest import setup as gtest_setup |
24 from pylib.gtest import test_options as gtest_test_options | 27 from pylib.gtest import test_options as gtest_test_options |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 'monkey': CommandFunctionTuple( | 789 'monkey': CommandFunctionTuple( |
787 AddMonkeyTestOptions, RunTestsCommand), | 790 AddMonkeyTestOptions, RunTestsCommand), |
788 'perf': CommandFunctionTuple( | 791 'perf': CommandFunctionTuple( |
789 AddPerfTestOptions, RunTestsCommand), | 792 AddPerfTestOptions, RunTestsCommand), |
790 'linker': CommandFunctionTuple( | 793 'linker': CommandFunctionTuple( |
791 AddLinkerTestOptions, RunTestsCommand), | 794 AddLinkerTestOptions, RunTestsCommand), |
792 'help': CommandFunctionTuple(lambda option_parser: None, HelpCommand) | 795 'help': CommandFunctionTuple(lambda option_parser: None, HelpCommand) |
793 } | 796 } |
794 | 797 |
795 | 798 |
| 799 def DumpThreadStacks(signal, frame): |
| 800 thread_names_map = dict( |
| 801 [(thread.ident, thread.name) for thread in threading.enumerate()]) |
| 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 |
| 813 |
796 def main(argv): | 814 def main(argv): |
| 815 signal.signal(signal.SIGUSR1, DumpThreadStacks) |
797 option_parser = command_option_parser.CommandOptionParser( | 816 option_parser = command_option_parser.CommandOptionParser( |
798 commands_dict=VALID_COMMANDS) | 817 commands_dict=VALID_COMMANDS) |
799 return command_option_parser.ParseAndExecute(option_parser) | 818 return command_option_parser.ParseAndExecute(option_parser) |
800 | 819 |
801 | 820 |
802 if __name__ == '__main__': | 821 if __name__ == '__main__': |
803 sys.exit(main(sys.argv)) | 822 sys.exit(main(sys.argv)) |
OLD | NEW |