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

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

Issue 1358593002: [Android] Switch gtests to platform mode. (RELAND) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed Created 5 years, 3 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
(...skipping 14 matching lines...) Expand all
25 from devil.utils import run_tests_helper 25 from devil.utils import run_tests_helper
26 26
27 from pylib import constants 27 from pylib import constants
28 from pylib import forwarder 28 from pylib import forwarder
29 from pylib.base import base_test_result 29 from pylib.base import base_test_result
30 from pylib.base import environment_factory 30 from pylib.base import environment_factory
31 from pylib.base import test_dispatcher 31 from pylib.base import test_dispatcher
32 from pylib.base import test_instance_factory 32 from pylib.base import test_instance_factory
33 from pylib.base import test_run_factory 33 from pylib.base import test_run_factory
34 from pylib.gtest import gtest_config 34 from pylib.gtest import gtest_config
35 # TODO(jbudorick): Remove this once we stop selectively enabling platform mode.
36 from pylib.gtest import gtest_test_instance
37 from pylib.gtest import setup as gtest_setup 35 from pylib.gtest import setup as gtest_setup
38 from pylib.gtest import test_options as gtest_test_options 36 from pylib.gtest import test_options as gtest_test_options
39 from pylib.linker import setup as linker_setup 37 from pylib.linker import setup as linker_setup
40 from pylib.host_driven import setup as host_driven_setup 38 from pylib.host_driven import setup as host_driven_setup
41 from pylib.instrumentation import setup as instrumentation_setup 39 from pylib.instrumentation import setup as instrumentation_setup
42 from pylib.instrumentation import test_options as instrumentation_test_options 40 from pylib.instrumentation import test_options as instrumentation_test_options
43 from pylib.junit import setup as junit_setup 41 from pylib.junit import setup as junit_setup
44 from pylib.junit import test_dispatcher as junit_dispatcher 42 from pylib.junit import test_dispatcher as junit_dispatcher
45 from pylib.monkey import setup as monkey_setup 43 from pylib.monkey import setup as monkey_setup
46 from pylib.monkey import test_options as monkey_test_options 44 from pylib.monkey import test_options as monkey_test_options
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 if command in constants.LOCAL_MACHINE_TESTS: 935 if command in constants.LOCAL_MACHINE_TESTS:
938 devices = [] 936 devices = []
939 else: 937 else:
940 devices = _GetAttachedDevices(args.blacklist_file, args.test_device) 938 devices = _GetAttachedDevices(args.blacklist_file, args.test_device)
941 939
942 forwarder.Forwarder.RemoveHostLog() 940 forwarder.Forwarder.RemoveHostLog()
943 if not ports.ResetTestServerPortAllocation(): 941 if not ports.ResetTestServerPortAllocation():
944 raise Exception('Failed to reset test server port.') 942 raise Exception('Failed to reset test server port.')
945 943
946 if command == 'gtest': 944 if command == 'gtest':
947 if args.suite_name[0] in gtest_test_instance.BROWSER_TEST_SUITES: 945 return RunTestsInPlatformMode(args, parser)
948 return RunTestsInPlatformMode(args, parser)
949 return _RunGTests(args, devices)
950 elif command == 'linker': 946 elif command == 'linker':
951 return _RunLinkerTests(args, devices) 947 return _RunLinkerTests(args, devices)
952 elif command == 'instrumentation': 948 elif command == 'instrumentation':
953 return _RunInstrumentationTests(args, devices) 949 return _RunInstrumentationTests(args, devices)
954 elif command == 'uiautomator': 950 elif command == 'uiautomator':
955 return _RunUIAutomatorTests(args, devices) 951 return _RunUIAutomatorTests(args, devices)
956 elif command == 'junit': 952 elif command == 'junit':
957 return _RunJUnitTests(args) 953 return _RunJUnitTests(args)
958 elif command == 'monkey': 954 elif command == 'monkey':
959 return _RunMonkeyTests(args, devices) 955 return _RunMonkeyTests(args, devices)
960 elif command == 'perf': 956 elif command == 'perf':
961 return _RunPerfTests(args, devices) 957 return _RunPerfTests(args, devices)
962 elif command == 'python': 958 elif command == 'python':
963 return _RunPythonTests(args) 959 return _RunPythonTests(args)
964 else: 960 else:
965 raise Exception('Unknown test type.') 961 raise Exception('Unknown test type.')
966 962
967 963
968 _SUPPORTED_IN_PLATFORM_MODE = [ 964 _SUPPORTED_IN_PLATFORM_MODE = [
969 # TODO(jbudorick): Add support for more test types. 965 # TODO(jbudorick): Add support for more test types.
970 'gtest', 966 'gtest',
971 'instrumentation', 967 'instrumentation',
972 'uirobot', 968 'uirobot',
973 ] 969 ]
974 970
975 971
976 def RunTestsInPlatformMode(args, parser): 972 def RunTestsInPlatformMode(args, parser):
977 973
974 def infra_error(message):
975 parser.exit(status=constants.INFRA_EXIT_CODE, message=message)
976
978 if args.command not in _SUPPORTED_IN_PLATFORM_MODE: 977 if args.command not in _SUPPORTED_IN_PLATFORM_MODE:
979 parser.error('%s is not yet supported in platform mode' % args.command) 978 infra_error('%s is not yet supported in platform mode' % args.command)
980 979
981 with environment_factory.CreateEnvironment(args, parser.error) as env: 980 with environment_factory.CreateEnvironment(args, infra_error) as env:
982 with test_instance_factory.CreateTestInstance(args, parser.error) as test: 981 with test_instance_factory.CreateTestInstance(args, infra_error) as test:
983 with test_run_factory.CreateTestRun( 982 with test_run_factory.CreateTestRun(
984 args, env, test, parser.error) as test_run: 983 args, env, test, infra_error) as test_run:
985 results = test_run.RunTests() 984 results = test_run.RunTests()
986 985
987 if args.environment == 'remote_device' and args.trigger: 986 if args.environment == 'remote_device' and args.trigger:
988 return 0 # Not returning results, only triggering. 987 return 0 # Not returning results, only triggering.
989 988
990 report_results.LogFull( 989 report_results.LogFull(
991 results=results, 990 results=results,
992 test_type=test.TestType(), 991 test_type=test.TestType(),
993 test_package=test_run.TestPackage(), 992 test_package=test_run.TestPackage(),
994 annotation=getattr(args, 'annotations', None), 993 annotation=getattr(args, 'annotations', None),
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 if e.is_infra_error: 1061 if e.is_infra_error:
1063 return constants.INFRA_EXIT_CODE 1062 return constants.INFRA_EXIT_CODE
1064 return constants.ERROR_EXIT_CODE 1063 return constants.ERROR_EXIT_CODE
1065 except: # pylint: disable=W0702 1064 except: # pylint: disable=W0702
1066 logging.exception('Unrecognized error occurred.') 1065 logging.exception('Unrecognized error occurred.')
1067 return constants.ERROR_EXIT_CODE 1066 return constants.ERROR_EXIT_CODE
1068 1067
1069 1068
1070 if __name__ == '__main__': 1069 if __name__ == '__main__':
1071 sys.exit(main()) 1070 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/pylib/local/device/local_device_test_run.py ('k') | testing/android/native_test/java/AndroidManifest.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698