Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: build/android/test_runner.py

Issue 2695963003: Use logdog butler subcommand to run tests. (Closed)
Patch Set: fixed it to not crash horribly on local Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/android/test_wrapper/logdog_wrapper.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 argparse 9 import argparse
10 import collections 10 import collections
11 import contextlib 11 import contextlib
12 import itertools 12 import itertools
13 import logging 13 import logging
14 import os 14 import os
15 import shutil
15 import signal 16 import signal
16 import sys 17 import sys
17 import threading 18 import threading
18 import traceback 19 import traceback
19 import unittest 20 import unittest
20 21
21 import devil_chromium 22 import devil_chromium
22 from devil import base_error 23 from devil import base_error
23 from devil.android import device_blacklist 24 from devil.android import device_blacklist
24 from devil.android import device_errors 25 from devil.android import device_errors
25 from devil.android import device_utils 26 from devil.android import device_utils
26 from devil.android import forwarder 27 from devil.android import forwarder
27 from devil.android import ports 28 from devil.android import ports
28 from devil.utils import reraiser_thread 29 from devil.utils import reraiser_thread
29 from devil.utils import run_tests_helper 30 from devil.utils import run_tests_helper
30 31
31 from pylib import constants 32 from pylib import constants
32 from pylib.base import base_test_result 33 from pylib.base import base_test_result
33 from pylib.base import environment_factory 34 from pylib.base import environment_factory
34 from pylib.base import test_instance_factory 35 from pylib.base import test_instance_factory
35 from pylib.base import test_run_factory 36 from pylib.base import test_run_factory
36 from pylib.constants import host_paths 37 from pylib.constants import host_paths
37 from pylib.results import json_results 38 from pylib.results import json_results
38 from pylib.results import report_results 39 from pylib.results import report_results
40 from pylib.utils import logdog_helper
39 41
40 from py_utils import contextlib_ext 42 from py_utils import contextlib_ext
41 43
42 44
43 _DEVIL_STATIC_CONFIG_FILE = os.path.abspath(os.path.join( 45 _DEVIL_STATIC_CONFIG_FILE = os.path.abspath(os.path.join(
44 host_paths.DIR_SOURCE_ROOT, 'build', 'android', 'devil_config.json')) 46 host_paths.DIR_SOURCE_ROOT, 'build', 'android', 'devil_config.json'))
45 47
46 48
47 def AddCommonOptions(parser): 49 def AddCommonOptions(parser):
48 """Adds all common options to |parser|.""" 50 """Adds all common options to |parser|."""
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 'should be used.')) 110 'should be used.'))
109 group.add_argument('--json-results-file', '--test-launcher-summary-output', 111 group.add_argument('--json-results-file', '--test-launcher-summary-output',
110 dest='json_results_file', type=os.path.realpath, 112 dest='json_results_file', type=os.path.realpath,
111 help='If set, will dump results in JSON form ' 113 help='If set, will dump results in JSON form '
112 'to specified file.') 114 'to specified file.')
113 group.add_argument('--trace-output', metavar='FILENAME', 115 group.add_argument('--trace-output', metavar='FILENAME',
114 type=os.path.realpath, 116 type=os.path.realpath,
115 help='Path to save test_runner trace data to. This option ' 117 help='Path to save test_runner trace data to. This option '
116 'has been implemented for gtest, instrumentation ' 118 'has been implemented for gtest, instrumentation '
117 'test and perf test.') 119 'test and perf test.')
120 group.add_argument('--upload-logcats-file', action='store_true',
121 dest='upload_logcats_file',
122 help='Whether to upload logcat file to logdog.')
118 123
119 logcat_output_group = group.add_mutually_exclusive_group() 124 logcat_output_group = group.add_mutually_exclusive_group()
120 logcat_output_group.add_argument( 125 logcat_output_group.add_argument(
121 '--logcat-output-dir', type=os.path.realpath, 126 '--logcat-output-dir', type=os.path.realpath,
122 help='If set, will dump logcats recorded during test run to directory. ' 127 help='If set, will dump logcats recorded during test run to directory. '
123 'File names will be the device ids with timestamps.') 128 'File names will be the device ids with timestamps.')
124 logcat_output_group.add_argument( 129 logcat_output_group.add_argument(
125 '--logcat-output-file', type=os.path.realpath, 130 '--logcat-output-file', type=os.path.realpath,
126 help='If set, will merge logcats recorded during test run and dump them ' 131 help='If set, will merge logcats recorded during test run and dump them '
127 'to the specified file.') 132 'to the specified file.')
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 test_name, 772 test_name,
768 ', '.join('%s %s' % (str(result_counts[test_name][i]), i) 773 ', '.join('%s %s' % (str(result_counts[test_name][i]), i)
769 for i in base_test_result.ResultType.GetTypes())) 774 for i in base_test_result.ResultType.GetTypes()))
770 else: 775 else:
771 all_pass += 1 776 all_pass += 1
772 777
773 logging.critical('%s of %s tests passed in all %s runs', 778 logging.critical('%s of %s tests passed in all %s runs',
774 str(all_pass), 779 str(all_pass),
775 str(tot_tests), 780 str(tot_tests),
776 str(iteration_count)) 781 str(iteration_count))
782 if args.upload_logcats_file:
jbudorick 2017/03/04 01:22:33 We should handle this similarly to json_writer s.t
BigBossZhiling 2017/03/04 02:14:59 Done.
783 if not args.logcat_output_file:
784 logging.critical('Cannot upload logcats file. '
785 'File to save logcat is not specified.')
786 else:
787 with open(args.logcat_output_file) as src:
788 dst = logdog_helper.open_text('unified_logcats')
BigBossZhiling 2017/03/04 00:59:14 @mikecase's NotRaiseException doesn't raise any ex
jbudorick 2017/03/04 01:22:33 ack. We should log something if dst is None, thoug
BigBossZhiling 2017/03/04 02:14:58 I think Case's decorator logs it. It doesn't raise
789 if dst:
790 with open(dst) as dst:
791 shutil.copyfileobj(src, dst)
777 792
778 if args.command == 'perf' and (args.steps or args.single_step): 793 if args.command == 'perf' and (args.steps or args.single_step):
779 return 0 794 return 0
780 795
781 return (0 if all(r.DidRunPass() for r in all_iteration_results) 796 return (0 if all(r.DidRunPass() for r in all_iteration_results)
782 else constants.ERROR_EXIT_CODE) 797 else constants.ERROR_EXIT_CODE)
783 798
784 799
785 CommandConfigTuple = collections.namedtuple( 800 CommandConfigTuple = collections.namedtuple(
786 'CommandConfigTuple', 801 'CommandConfigTuple',
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 if e.is_infra_error: 852 if e.is_infra_error:
838 return constants.INFRA_EXIT_CODE 853 return constants.INFRA_EXIT_CODE
839 return constants.ERROR_EXIT_CODE 854 return constants.ERROR_EXIT_CODE
840 except: # pylint: disable=W0702 855 except: # pylint: disable=W0702
841 logging.exception('Unrecognized error occurred.') 856 logging.exception('Unrecognized error occurred.')
842 return constants.ERROR_EXIT_CODE 857 return constants.ERROR_EXIT_CODE
843 858
844 859
845 if __name__ == '__main__': 860 if __name__ == '__main__':
846 sys.exit(main()) 861 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | build/android/test_wrapper/logdog_wrapper.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698