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

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

Issue 2695963003: Use logdog butler subcommand to run tests. (Closed)
Patch Set: minor fixes again 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
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
dnj 2017/02/28 18:28:38 Don't know what this is. Why not just use the logd
BigBossZhiling 2017/02/28 22:35:47 This is a really simple wrapper written by Michael
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('--unified-logcats-file',
121 dest='unified_logcats_file',
122 help='The logcat file to upload 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.unified_logcats_file:
783 with open(args.unified_logcats_file) as src:
784 with logdog_helper.open_text('unified_logcats') as dst:
785 shutil.copyfileobj(src, dst)
777 786
778 if args.command == 'perf' and (args.steps or args.single_step): 787 if args.command == 'perf' and (args.steps or args.single_step):
779 return 0 788 return 0
780 789
781 return (0 if all(r.DidRunPass() for r in all_iteration_results) 790 return (0 if all(r.DidRunPass() for r in all_iteration_results)
782 else constants.ERROR_EXIT_CODE) 791 else constants.ERROR_EXIT_CODE)
783 792
784 793
785 CommandConfigTuple = collections.namedtuple( 794 CommandConfigTuple = collections.namedtuple(
786 'CommandConfigTuple', 795 'CommandConfigTuple',
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 if e.is_infra_error: 846 if e.is_infra_error:
838 return constants.INFRA_EXIT_CODE 847 return constants.INFRA_EXIT_CODE
839 return constants.ERROR_EXIT_CODE 848 return constants.ERROR_EXIT_CODE
840 except: # pylint: disable=W0702 849 except: # pylint: disable=W0702
841 logging.exception('Unrecognized error occurred.') 850 logging.exception('Unrecognized error occurred.')
842 return constants.ERROR_EXIT_CODE 851 return constants.ERROR_EXIT_CODE
843 852
844 853
845 if __name__ == '__main__': 854 if __name__ == '__main__':
846 sys.exit(main()) 855 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | build/android/test_wrapper/logdog_wrapper.py » ('j') | build/android/test_wrapper/logdog_wrapper.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698