Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 """Runs content browser tests.""" | |
| 8 | |
| 9 import logging | |
| 10 import optparse | |
| 11 import os | |
| 12 import sys | |
| 13 | |
| 14 from pylib import android_commands | |
| 15 from pylib import cmd_helper | |
| 16 from pylib import ports | |
| 17 from pylib.browsertests import test_sharder | |
| 18 from pylib.utils import run_tests_helper | |
| 19 from pylib.utils import test_options_parser | |
| 20 | |
| 21 CONTENT_BROWSERTEST_SUITENAME = 'content_browsertests' | |
| 22 | |
| 23 | |
| 24 def _RunContentBrowserTestSuite(options): | |
|
frankf
2013/02/15 02:10:02
Let's move this to browsertests.dispatch similar t
| |
| 25 attached_devices = [] | |
| 26 if options.test_device: | |
| 27 attached_devices = [options.test_device] | |
| 28 else: | |
| 29 attached_devices = android_commands.GetAttachedDevices() | |
| 30 | |
| 31 if not attached_devices: | |
| 32 logging.critical('A device must be attached and online.') | |
| 33 return 1 | |
| 34 | |
| 35 if options.gtest_filter: | |
| 36 logging.warning('Sharding is not possible with these configurations.') | |
| 37 attached_devices = [attached_devices[0]] | |
| 38 | |
| 39 # Reset the test port allocation. It's important to do it before starting | |
| 40 # to dispatch any tests. | |
| 41 if not ports.ResetTestServerPortAllocation(): | |
| 42 raise Exception('Failed to reset test server port.') | |
| 43 | |
| 44 test_suite_dir = os.path.join(cmd_helper.OutDirectory.get(), | |
| 45 options.build_type) | |
| 46 options.test_suite = os.path.join(test_suite_dir, | |
| 47 'apks', | |
| 48 CONTENT_BROWSERTEST_SUITENAME + '.apk') | |
| 49 sharder = test_sharder.TestSharder( | |
| 50 attached_devices, | |
| 51 options.test_suite, | |
| 52 options.gtest_filter, | |
| 53 options.test_arguments, | |
| 54 options.timeout, | |
| 55 options.cleanup_test_files, | |
| 56 options.tool, | |
| 57 options.build_type) | |
| 58 | |
| 59 test_results = sharder.RunShardedTests() | |
| 60 test_results.LogFull( | |
| 61 test_type='Unit test', | |
| 62 test_package=CONTENT_BROWSERTEST_SUITENAME, | |
| 63 build_type=options.build_type, | |
| 64 flakiness_server=options.flakiness_dashboard_server) | |
| 65 test_results.PrintAnnotation() | |
| 66 | |
| 67 def main(argv): | |
| 68 option_parser = optparse.OptionParser() | |
| 69 test_options_parser.AddGTestOptions(option_parser) | |
| 70 options, args = option_parser.parse_args(argv) | |
| 71 | |
| 72 if len(args) > 1: | |
| 73 option_parser.error('Unknown argument: %s' % args[1:]) | |
| 74 | |
| 75 run_tests_helper.SetLogLevel(options.verbose_count) | |
| 76 return _RunContentBrowserTestSuite(options) | |
| 77 | |
| 78 | |
| 79 if __name__ == '__main__': | |
| 80 sys.exit(main(sys.argv)) | |
| OLD | NEW |