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 sys | 10 import sys |
(...skipping 30 matching lines...) Expand all Loading... |
41 additional_flags=None): | 41 additional_flags=None): |
42 """Create a new TestRunner. | 42 """Create a new TestRunner. |
43 | 43 |
44 Args: | 44 Args: |
45 test_options: An InstrumentationOptions object. | 45 test_options: An InstrumentationOptions object. |
46 device: Attached android device. | 46 device: Attached android device. |
47 shard_index: Shard index. | 47 shard_index: Shard index. |
48 test_pkg: A TestPackage object. | 48 test_pkg: A TestPackage object. |
49 additional_flags: A list of additional flags to add to the command line. | 49 additional_flags: A list of additional flags to add to the command line. |
50 """ | 50 """ |
51 super(TestRunner, self).__init__(device, test_options.tool, | 51 super(TestRunner, self).__init__(device, test_options.tool) |
52 test_options.cleanup_test_files) | |
53 self._lighttp_port = constants.LIGHTTPD_RANDOM_PORT_FIRST + shard_index | 52 self._lighttp_port = constants.LIGHTTPD_RANDOM_PORT_FIRST + shard_index |
54 self._logcat_monitor = None | 53 self._logcat_monitor = None |
55 | 54 |
56 self.coverage_device_file = None | 55 self.coverage_device_file = None |
57 self.coverage_dir = test_options.coverage_dir | 56 self.coverage_dir = test_options.coverage_dir |
58 self.coverage_host_file = None | 57 self.coverage_host_file = None |
59 self.options = test_options | 58 self.options = test_options |
60 self.test_pkg = test_pkg | 59 self.test_pkg = test_pkg |
61 # Use the correct command line file for the package under test. | 60 # Use the correct command line file for the package under test. |
62 cmdline_file = [a.cmdline_file for a in constants.PACKAGE_INFO.itervalues() | 61 cmdline_file = [a.cmdline_file for a in constants.PACKAGE_INFO.itervalues() |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 221 |
223 # Wait and grab annotation data so we can figure out which traces to parse | 222 # Wait and grab annotation data so we can figure out which traces to parse |
224 regex = self._logcat_monitor.WaitFor( | 223 regex = self._logcat_monitor.WaitFor( |
225 re.compile(r'\*\*PERFANNOTATION\(' + raw_test_name + r'\)\:(.*)')) | 224 re.compile(r'\*\*PERFANNOTATION\(' + raw_test_name + r'\)\:(.*)')) |
226 | 225 |
227 # If the test is set to run on a specific device type only (IE: only | 226 # If the test is set to run on a specific device type only (IE: only |
228 # tablet or phone) and it is being run on the wrong device, the test | 227 # tablet or phone) and it is being run on the wrong device, the test |
229 # just quits and does not do anything. The java test harness will still | 228 # just quits and does not do anything. The java test harness will still |
230 # print the appropriate annotation for us, but will add --NORUN-- for | 229 # print the appropriate annotation for us, but will add --NORUN-- for |
231 # us so we know to ignore the results. | 230 # us so we know to ignore the results. |
232 # The --NORUN-- tag is managed by MainActivityTestBase.java | 231 # The --NORUN-- tag is managed by ChromeTabbedActivityTestBase.java |
233 if regex.group(1) != '--NORUN--': | 232 if regex.group(1) != '--NORUN--': |
234 | 233 |
235 # Obtain the relevant perf data. The data is dumped to a | 234 # Obtain the relevant perf data. The data is dumped to a |
236 # JSON formatted file. | 235 # JSON formatted file. |
237 json_string = self.device.ReadFile( | 236 json_string = self.device.ReadFile( |
238 '/data/data/com.google.android.apps.chrome/files/PerfTestData.txt', | 237 '/data/data/com.google.android.apps.chrome/files/PerfTestData.txt', |
239 as_root=True) | 238 as_root=True) |
240 | 239 |
241 if not json_string: | 240 if not json_string: |
242 raise Exception('Perf file is empty') | 241 raise Exception('Perf file is empty') |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 except device_errors.CommandTimeoutError as e: | 362 except device_errors.CommandTimeoutError as e: |
364 results.AddResult(test_result.InstrumentationTestResult( | 363 results.AddResult(test_result.InstrumentationTestResult( |
365 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, | 364 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, |
366 log=str(e) or 'No information')) | 365 log=str(e) or 'No information')) |
367 except device_errors.DeviceUnreachableError as e: | 366 except device_errors.DeviceUnreachableError as e: |
368 results.AddResult(test_result.InstrumentationTestResult( | 367 results.AddResult(test_result.InstrumentationTestResult( |
369 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, | 368 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, |
370 log=str(e) or 'No information')) | 369 log=str(e) or 'No information')) |
371 self.TestTeardown(test, results) | 370 self.TestTeardown(test, results) |
372 return (results, None if results.DidRunPass() else test) | 371 return (results, None if results.DidRunPass() else test) |
OLD | NEW |