OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Class for running instrumentation tests on a single device.""" | 5 """Class for running instrumentation tests on a single device.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import re | 9 import re |
10 import time | 10 import time |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 """Responsible for running a series of tests connected to a single device.""" | 45 """Responsible for running a series of tests connected to a single device.""" |
46 | 46 |
47 _DEVICE_DATA_DIR = 'chrome/test/data' | 47 _DEVICE_DATA_DIR = 'chrome/test/data' |
48 _DEVICE_COVERAGE_DIR = 'chrome/test/coverage' | 48 _DEVICE_COVERAGE_DIR = 'chrome/test/coverage' |
49 _HOSTMACHINE_PERF_OUTPUT_FILE = '/tmp/chrome-profile' | 49 _HOSTMACHINE_PERF_OUTPUT_FILE = '/tmp/chrome-profile' |
50 _DEVICE_PERF_OUTPUT_SEARCH_PREFIX = (constants.DEVICE_PERF_OUTPUT_DIR + | 50 _DEVICE_PERF_OUTPUT_SEARCH_PREFIX = (constants.DEVICE_PERF_OUTPUT_DIR + |
51 '/chrome-profile*') | 51 '/chrome-profile*') |
52 _DEVICE_HAS_TEST_FILES = {} | 52 _DEVICE_HAS_TEST_FILES = {} |
53 | 53 |
54 def __init__(self, test_options, device, shard_index, test_pkg, | 54 def __init__(self, test_options, device, shard_index, test_pkg, |
55 ports_to_forward): | 55 ports_to_forward, additional_flags=None): |
56 """Create a new TestRunner. | 56 """Create a new TestRunner. |
57 | 57 |
58 Args: | 58 Args: |
59 test_options: An InstrumentationOptions object. | 59 test_options: An InstrumentationOptions object. |
60 device: Attached android device. | 60 device: Attached android device. |
61 shard_index: Shard index. | 61 shard_index: Shard index. |
62 test_pkg: A TestPackage object. | 62 test_pkg: A TestPackage object. |
63 ports_to_forward: A list of port numbers for which to set up forwarders. | 63 ports_to_forward: A list of port numbers for which to set up forwarders. |
64 Can be optionally requested by a test case. | 64 Can be optionally requested by a test case. |
| 65 additional_flags: A list of additional flags to add to the command line. |
65 """ | 66 """ |
66 super(TestRunner, self).__init__(device, test_options.tool, | 67 super(TestRunner, self).__init__(device, test_options.tool, |
67 test_options.push_deps, | 68 test_options.push_deps, |
68 test_options.cleanup_test_files) | 69 test_options.cleanup_test_files) |
69 self._lighttp_port = constants.LIGHTTPD_RANDOM_PORT_FIRST + shard_index | 70 self._lighttp_port = constants.LIGHTTPD_RANDOM_PORT_FIRST + shard_index |
70 | 71 |
71 self.options = test_options | 72 self.options = test_options |
72 self.test_pkg = test_pkg | 73 self.test_pkg = test_pkg |
73 self.ports_to_forward = ports_to_forward | 74 self.ports_to_forward = ports_to_forward |
74 self.coverage_dir = test_options.coverage_dir | 75 self.coverage_dir = test_options.coverage_dir |
75 # Use the correct command line file for the package under test. | 76 # Use the correct command line file for the package under test. |
76 cmdline_file = [a.cmdline_file for a in constants.PACKAGE_INFO.itervalues() | 77 cmdline_file = [a.cmdline_file for a in constants.PACKAGE_INFO.itervalues() |
77 if a.test_package == self.test_pkg.GetPackageName()] | 78 if a.test_package == self.test_pkg.GetPackageName()] |
78 assert len(cmdline_file) < 2, 'Multiple packages have the same test package' | 79 assert len(cmdline_file) < 2, 'Multiple packages have the same test package' |
79 if len(cmdline_file) and cmdline_file[0]: | 80 if len(cmdline_file) and cmdline_file[0]: |
80 self.flags = flag_changer.FlagChanger(self.adb, cmdline_file[0]) | 81 self.flags = flag_changer.FlagChanger(self.adb, cmdline_file[0]) |
81 else: | 82 else: |
82 self.flags = flag_changer.FlagChanger(self.adb) | 83 self.flags = flag_changer.FlagChanger(self.adb) |
| 84 if additional_flags: |
| 85 self.flags.AddFlags(additional_flags) |
83 | 86 |
84 #override | 87 #override |
85 def InstallTestPackage(self): | 88 def InstallTestPackage(self): |
86 self.test_pkg.Install(self.adb) | 89 self.test_pkg.Install(self.adb) |
87 | 90 |
88 #override | 91 #override |
89 def PushDataDeps(self): | 92 def PushDataDeps(self): |
90 # TODO(frankf): Implement a general approach for copying/installing | 93 # TODO(frankf): Implement a general approach for copying/installing |
91 # once across test runners. | 94 # once across test runners. |
92 if TestRunner._DEVICE_HAS_TEST_FILES.get(self.device, False): | 95 if TestRunner._DEVICE_HAS_TEST_FILES.get(self.device, False): |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 duration_ms = 0 | 366 duration_ms = 0 |
364 message = str(e) | 367 message = str(e) |
365 if not message: | 368 if not message: |
366 message = 'No information.' | 369 message = 'No information.' |
367 results.AddResult(test_result.InstrumentationTestResult( | 370 results.AddResult(test_result.InstrumentationTestResult( |
368 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, | 371 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, |
369 log=message)) | 372 log=message)) |
370 raw_result = None | 373 raw_result = None |
371 self.TestTeardown(test, raw_result) | 374 self.TestTeardown(test, raw_result) |
372 return (results, None if results.DidRunPass() else test) | 375 return (results, None if results.DidRunPass() else test) |
OLD | NEW |