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 import glob | 5 import glob |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 import sys | 8 import sys |
9 | 9 |
10 import android_commands | 10 import android_commands |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 class SingleTestRunner(BaseTestRunner): | 22 class SingleTestRunner(BaseTestRunner): |
23 """Single test suite attached to a single device. | 23 """Single test suite attached to a single device. |
24 | 24 |
25 Args: | 25 Args: |
26 device: Device to run the tests. | 26 device: Device to run the tests. |
27 test_suite: A specific test suite to run, empty to run all. | 27 test_suite: A specific test suite to run, empty to run all. |
28 gtest_filter: A gtest_filter flag. | 28 gtest_filter: A gtest_filter flag. |
29 test_arguments: Additional arguments to pass to the test binary. | 29 test_arguments: Additional arguments to pass to the test binary. |
30 timeout: Timeout for each test. | 30 timeout: Timeout for each test. |
31 performance_test: Whether or not performance test(s). | |
32 cleanup_test_files: Whether or not to cleanup test files on device. | 31 cleanup_test_files: Whether or not to cleanup test files on device. |
33 tool: Name of the Valgrind tool. | 32 tool: Name of the Valgrind tool. |
34 shard_index: index number of the shard on which the test suite will run. | 33 shard_index: index number of the shard on which the test suite will run. |
35 dump_debug_info: Whether or not to dump debug information. | 34 dump_debug_info: Whether or not to dump debug information. |
36 build_type: 'Release' or 'Debug'. | 35 build_type: 'Release' or 'Debug'. |
37 in_webkit_checkout: Whether the suite is being run from a WebKit checkout. | 36 in_webkit_checkout: Whether the suite is being run from a WebKit checkout. |
38 """ | 37 """ |
39 | 38 |
40 def __init__(self, device, test_suite, gtest_filter, test_arguments, timeout, | 39 def __init__(self, device, test_suite, gtest_filter, test_arguments, timeout, |
41 performance_test, cleanup_test_files, tool_name, | 40 cleanup_test_files, tool_name, shard_index, dump_debug_info, |
42 shard_index, dump_debug_info, fast_and_loose, build_type, | 41 fast_and_loose, build_type, in_webkit_checkout): |
43 in_webkit_checkout): | |
44 BaseTestRunner.__init__(self, device, tool_name, shard_index, build_type) | 42 BaseTestRunner.__init__(self, device, tool_name, shard_index, build_type) |
45 self._running_on_emulator = self.device.startswith('emulator') | 43 self._running_on_emulator = self.device.startswith('emulator') |
46 self._gtest_filter = gtest_filter | 44 self._gtest_filter = gtest_filter |
47 self._test_arguments = test_arguments | 45 self._test_arguments = test_arguments |
48 self.test_results = TestResults() | 46 self.test_results = TestResults() |
49 if dump_debug_info: | 47 if dump_debug_info: |
50 self.dump_debug_info = debug_info.GTestDebugInfo( | 48 self.dump_debug_info = debug_info.GTestDebugInfo( |
51 self.adb, device, | 49 self.adb, device, |
52 os.path.basename(test_suite), gtest_filter) | 50 os.path.basename(test_suite), gtest_filter) |
53 else: | 51 else: |
54 self.dump_debug_info = None | 52 self.dump_debug_info = None |
55 self.fast_and_loose = fast_and_loose | 53 self.fast_and_loose = fast_and_loose |
56 self.in_webkit_checkout = in_webkit_checkout | 54 self.in_webkit_checkout = in_webkit_checkout |
57 | 55 |
58 logging.warning('Test suite: ' + test_suite) | 56 logging.warning('Test suite: ' + test_suite) |
59 if os.path.splitext(test_suite)[1] == '.apk': | 57 if os.path.splitext(test_suite)[1] == '.apk': |
60 self.test_package = TestPackageApk( | 58 self.test_package = TestPackageApk( |
61 self.adb, | 59 self.adb, |
62 device, | 60 device, |
63 test_suite, | 61 test_suite, |
64 timeout, | 62 timeout, |
65 performance_test, | |
66 cleanup_test_files, | 63 cleanup_test_files, |
67 self.tool, | 64 self.tool, |
68 self.dump_debug_info) | 65 self.dump_debug_info) |
69 else: | 66 else: |
70 # Put a copy into the android out/target directory, to allow stack trace | 67 # Put a copy into the android out/target directory, to allow stack trace |
71 # generation. | 68 # generation. |
72 symbols_dir = os.path.join(constants.CHROME_DIR, 'out', build_type, | 69 symbols_dir = os.path.join(constants.CHROME_DIR, 'out', build_type, |
73 'lib.target') | 70 'lib.target') |
74 self.test_package = TestPackageExecutable( | 71 self.test_package = TestPackageExecutable( |
75 self.adb, | 72 self.adb, |
76 device, | 73 device, |
77 test_suite, timeout, | 74 test_suite, timeout, |
78 performance_test, | |
79 cleanup_test_files, | 75 cleanup_test_files, |
80 self.tool, | 76 self.tool, |
81 self.dump_debug_info, | 77 self.dump_debug_info, |
82 symbols_dir) | 78 symbols_dir) |
83 self._performance_test_setup = None | |
84 if performance_test: | |
85 self._performance_test_setup = perf_tests_helper.PerfTestSetup(self.adb) | |
86 | 79 |
87 def _TestSuiteRequiresMockTestServer(self): | 80 def _TestSuiteRequiresMockTestServer(self): |
88 """Returns True if the test suite requires mock test server.""" | 81 """Returns True if the test suite requires mock test server.""" |
89 tests_require_net_test_server = ['unit_tests', 'net_unittests', | 82 tests_require_net_test_server = ['unit_tests', 'net_unittests', |
90 'content_unittests'] | 83 'content_unittests'] |
91 return (self.test_package.test_suite_basename in | 84 return (self.test_package.test_suite_basename in |
92 tests_require_net_test_server) | 85 tests_require_net_test_server) |
93 | 86 |
94 def _GetFilterFileName(self): | 87 def _GetFilterFileName(self): |
95 """Returns the filename of gtest filter.""" | 88 """Returns the filename of gtest filter.""" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 failed_tests += [BaseTestResult(t, '')] | 268 failed_tests += [BaseTestResult(t, '')] |
276 self.test_results = TestResults.FromRun( | 269 self.test_results = TestResults.FromRun( |
277 failed=failed_tests, device_exception=self.device) | 270 failed=failed_tests, device_exception=self.device) |
278 | 271 |
279 return self.test_results | 272 return self.test_results |
280 | 273 |
281 def SetUp(self): | 274 def SetUp(self): |
282 """Sets up necessary test enviroment for the test suite.""" | 275 """Sets up necessary test enviroment for the test suite.""" |
283 super(SingleTestRunner, self).SetUp() | 276 super(SingleTestRunner, self).SetUp() |
284 self.adb.ClearApplicationState(constants.CHROME_PACKAGE) | 277 self.adb.ClearApplicationState(constants.CHROME_PACKAGE) |
285 if self._performance_test_setup: | |
286 self._performance_test_setup.SetUp() | |
287 if self.dump_debug_info: | 278 if self.dump_debug_info: |
288 self.dump_debug_info.StartRecordingLog(True) | 279 self.dump_debug_info.StartRecordingLog(True) |
289 self.StripAndCopyFiles() | 280 self.StripAndCopyFiles() |
290 self.LaunchHelperToolsForTestSuite() | 281 self.LaunchHelperToolsForTestSuite() |
291 self.tool.SetupEnvironment() | 282 self.tool.SetupEnvironment() |
292 | 283 |
293 def TearDown(self): | 284 def TearDown(self): |
294 """Cleans up the test enviroment for the test suite.""" | 285 """Cleans up the test enviroment for the test suite.""" |
295 self.tool.CleanUpEnvironment() | 286 self.tool.CleanUpEnvironment() |
296 if self.test_package.cleanup_test_files: | 287 if self.test_package.cleanup_test_files: |
297 self.adb.RemovePushedFiles() | 288 self.adb.RemovePushedFiles() |
298 if self.dump_debug_info: | 289 if self.dump_debug_info: |
299 self.dump_debug_info.StopRecordingLog() | 290 self.dump_debug_info.StopRecordingLog() |
300 if self._performance_test_setup: | |
301 self._performance_test_setup.TearDown() | |
302 if self.dump_debug_info: | 291 if self.dump_debug_info: |
303 self.dump_debug_info.ArchiveNewCrashFiles() | 292 self.dump_debug_info.ArchiveNewCrashFiles() |
304 super(SingleTestRunner, self).TearDown() | 293 super(SingleTestRunner, self).TearDown() |
OLD | NEW |