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

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

Issue 19220004: [Android] Move modules_unittest to isolate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed all comments Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « build/android/pylib/gtest/dispatch.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 logging 5 import logging
6 import os 6 import os
7 7
8 from pylib import android_commands 8 from pylib import android_commands
9 from pylib import constants 9 from pylib import constants
10 from pylib.android_commands import errors 10 from pylib.android_commands import errors
11 from pylib.base import base_test_result 11 from pylib.base import base_test_result
12 from pylib.base import base_test_runner 12 from pylib.base import base_test_runner
13 from pylib.utils import run_tests_helper 13 from pylib.utils import run_tests_helper
14 14
15 import test_package_apk 15 import test_package_apk
16 import test_package_executable 16 import test_package_executable
17 17
18 18
19 # We're moving to using isolate files instead of harcoding
20 # dependencies here. Look at the TODO in dispatch.py.
21 def _GetDataFilesForTestSuite(test_suite_basename):
22 """Returns a list of data files/dirs needed by the test suite.
23
24 Args:
25 test_suite_basename: The test suite basename (e.g. base_unittests).
26
27 Returns:
28 A list of test file and directory paths.
29 """
30 # Ideally, we'd just push all test data. However, it has >100MB, and a lot
31 # of the files are not relevant (some are used for browser_tests, others for
32 # features not supported, etc..).
33 if test_suite_basename == 'modules_unittests':
34 return [
35 'resources',
36 'data',
37 ]
38 return []
39
40
41 def _TestSuiteRequiresMockTestServer(test_suite_basename): 19 def _TestSuiteRequiresMockTestServer(test_suite_basename):
42 """Returns True if the test suite requires mock test server.""" 20 """Returns True if the test suite requires mock test server."""
43 tests_require_net_test_server = ['unit_tests', 'net_unittests', 21 tests_require_net_test_server = ['unit_tests', 'net_unittests',
44 'content_unittests', 22 'content_unittests',
45 'content_browsertests'] 23 'content_browsertests']
46 return (test_suite_basename in 24 return (test_suite_basename in
47 tests_require_net_test_server) 25 tests_require_net_test_server)
48 26
49 27
50 class TestRunner(base_test_runner.BaseTestRunner): 28 class TestRunner(base_test_runner.BaseTestRunner):
51 """Single test suite attached to a single device. 29 """Single test suite attached to a single device.
52 30
53 Args: 31 Args:
54 device: Device to run the tests. 32 device: Device to run the tests.
55 test_suite: A specific test suite to run, empty to run all. 33 test_suite: A specific test suite to run, empty to run all.
56 test_arguments: Additional arguments to pass to the test binary. 34 test_arguments: Additional arguments to pass to the test binary.
57 timeout: Timeout for each test. 35 timeout: Timeout for each test.
58 cleanup_test_files: Whether or not to cleanup test files on device. 36 cleanup_test_files: Whether or not to cleanup test files on device.
59 tool_name: Name of the Valgrind tool. 37 tool_name: Name of the Valgrind tool.
60 build_type: 'Release' or 'Debug'. 38 build_type: 'Release' or 'Debug'.
61 in_webkit_checkout: Whether the suite is being run from a WebKit checkout. 39 in_webkit_checkout: Whether the suite is being run from a WebKit checkout.
62 push_deps: If True, push all dependencies to the device. 40 push_deps: If True, push all dependencies to the device.
63 test_apk_package_name: Apk package name for tests running in APKs. 41 test_apk_package_name: Apk package name for tests running in APKs.
64 test_activity_name: Test activity to invoke for APK tests. 42 test_activity_name: Test activity to invoke for APK tests.
65 command_line_file: Filename to use to pass arguments to tests. 43 command_line_file: Filename to use to pass arguments to tests.
66 deps_dir: The path to the dependency dir on the host to push to the device.
67 """ 44 """
68 45
69 def __init__(self, device, test_suite, test_arguments, timeout, 46 def __init__(self, device, test_suite, test_arguments, timeout,
70 cleanup_test_files, tool_name, build_type, 47 cleanup_test_files, tool_name, build_type,
71 in_webkit_checkout, push_deps, test_apk_package_name=None, 48 in_webkit_checkout, push_deps, test_apk_package_name=None,
72 test_activity_name=None, command_line_file=None, deps_dir=None): 49 test_activity_name=None, command_line_file=None):
73 super(TestRunner, self).__init__(device, tool_name, build_type, push_deps) 50 super(TestRunner, self).__init__(device, tool_name, build_type, push_deps)
74 self._running_on_emulator = self.device.startswith('emulator') 51 self._running_on_emulator = self.device.startswith('emulator')
75 self._test_arguments = test_arguments 52 self._test_arguments = test_arguments
76 self.in_webkit_checkout = in_webkit_checkout 53 self.in_webkit_checkout = in_webkit_checkout
77 self._cleanup_test_files = cleanup_test_files 54 self._cleanup_test_files = cleanup_test_files
78 self._deps_dir = deps_dir
79 55
80 logging.warning('Test suite: ' + test_suite) 56 logging.warning('Test suite: ' + test_suite)
81 if os.path.splitext(test_suite)[1] == '.apk': 57 if os.path.splitext(test_suite)[1] == '.apk':
82 self.test_package = test_package_apk.TestPackageApk( 58 self.test_package = test_package_apk.TestPackageApk(
83 self.adb, 59 self.adb,
84 device, 60 device,
85 test_suite, 61 test_suite,
86 timeout, 62 timeout,
87 self._cleanup_test_files, 63 self._cleanup_test_files,
88 self.tool, 64 self.tool,
(...skipping 19 matching lines...) Expand all
108 self.test_package.StripAndCopyExecutable() 84 self.test_package.StripAndCopyExecutable()
109 85
110 #override 86 #override
111 def PushDataDeps(self): 87 def PushDataDeps(self):
112 self.adb.WaitForSdCardReady(20) 88 self.adb.WaitForSdCardReady(20)
113 self.tool.CopyFiles() 89 self.tool.CopyFiles()
114 if self.test_package.test_suite_basename == 'webkit_unit_tests': 90 if self.test_package.test_suite_basename == 'webkit_unit_tests':
115 self.PushWebKitUnitTestsData() 91 self.PushWebKitUnitTestsData()
116 return 92 return
117 93
118 if not self._deps_dir: 94 if os.path.exists(constants.ISOLATE_DEPS_DIR):
119 logging.info('Did not find an isolate file for the test suite.') 95 device_dir = self.adb.GetExternalStorage()
120 for p in _GetDataFilesForTestSuite(self.test_package.test_suite_basename): 96 # TODO(frankf): linux_dumper_unittest_helper needs to be in the same dir
97 # as breakpad_unittests exe. Find a better way to do this.
98 if self.test_package.test_suite_basename == 'breakpad_unittests':
99 device_dir = constants.TEST_EXECUTABLE_DIR
100 for p in os.listdir(constants.ISOLATE_DEPS_DIR):
121 self.adb.PushIfNeeded( 101 self.adb.PushIfNeeded(
122 os.path.join(constants.DIR_SOURCE_ROOT, p), 102 os.path.join(constants.ISOLATE_DEPS_DIR, p),
123 os.path.join(self.adb.GetExternalStorage(), p)) 103 os.path.join(device_dir, p))
124 return
125
126 device_dir = self.adb.GetExternalStorage()
127 # TODO(frankf): linux_dumper_unittest_helper needs to be in the same dir
128 # as breakpad_unittests exe. Find a better way to do this.
129 if self.test_package.test_suite_basename == 'breakpad_unittests':
130 device_dir = constants.TEST_EXECUTABLE_DIR
131 for p in os.listdir(self._deps_dir):
132 self.adb.PushIfNeeded(
133 os.path.join(self._deps_dir, p),
134 os.path.join(device_dir, p))
135 104
136 def PushWebKitUnitTestsData(self): 105 def PushWebKitUnitTestsData(self):
137 """Pushes the webkit_unit_tests data files to the device. 106 """Pushes the webkit_unit_tests data files to the device.
138 107
139 The path of this directory is different when the suite is being run as 108 The path of this directory is different when the suite is being run as
140 part of a WebKit check-out. 109 part of a WebKit check-out.
141 """ 110 """
142 webkit_src = os.path.join(constants.DIR_SOURCE_ROOT, 'third_party', 111 webkit_src = os.path.join(constants.DIR_SOURCE_ROOT, 'third_party',
143 'WebKit') 112 'WebKit')
144 if self.in_webkit_checkout: 113 if self.in_webkit_checkout:
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 self.LaunchChromeTestServerSpawner() 173 self.LaunchChromeTestServerSpawner()
205 self.tool.SetupEnvironment() 174 self.tool.SetupEnvironment()
206 175
207 #override 176 #override
208 def TearDown(self): 177 def TearDown(self):
209 """Cleans up the test enviroment for the test suite.""" 178 """Cleans up the test enviroment for the test suite."""
210 self.tool.CleanUpEnvironment() 179 self.tool.CleanUpEnvironment()
211 if self._cleanup_test_files: 180 if self._cleanup_test_files:
212 self.adb.RemovePushedFiles() 181 self.adb.RemovePushedFiles()
213 super(TestRunner, self).TearDown() 182 super(TestRunner, self).TearDown()
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/dispatch.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698