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 """Base class for running tests on a single device.""" | 5 """Base class for running tests on a single device.""" |
6 | 6 |
7 import contextlib | 7 import contextlib |
8 import httplib | 8 import httplib |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 logging.warning( | 104 logging.warning( |
105 'Total data transferred: %0.3fMB' % | 105 'Total data transferred: %0.3fMB' % |
106 ((push_size_after[1] - push_size_before[1]) / float(2 ** 20))) | 106 ((push_size_after[1] - push_size_before[1]) / float(2 ** 20))) |
107 else: | 107 else: |
108 logging.warning('Skipping pushing data to device.') | 108 logging.warning('Skipping pushing data to device.') |
109 | 109 |
110 def TearDown(self): | 110 def TearDown(self): |
111 """Run once after all tests are run.""" | 111 """Run once after all tests are run.""" |
112 self.ShutdownHelperToolsForTestSuite() | 112 self.ShutdownHelperToolsForTestSuite() |
113 | 113 |
114 def CopyTestData(self, test_data_paths, dest_dir): | 114 def CopyTestData(self, test_data_paths, dest_root, |
115 """Copies |test_data_paths| list of files/directories to |dest_dir|. | 115 src_root=constants.DIR_SOURCE_ROOT): |
bulach
2013/07/04 11:05:21
suggestion: there's only one caller passing the ex
frankf
2013/07/09 01:09:35
Done. I've inlined CopyTestData and removed it all
| |
116 """Copies a list of paths from |src_root| to |dst_root|. | |
116 | 117 |
117 Args: | 118 Args: |
118 test_data_paths: A list of files or directories relative to |dest_dir| | 119 test_data_paths: A list of paths relative to root directories. |
119 which should be copied to the device. The paths must exist in | 120 dest_root: Absolute root path on device. |
120 |DIR_SOURCE_ROOT|. | 121 src_root: Absolute root path on host. |
121 dest_dir: Absolute path to copy to on the device. | |
122 """ | 122 """ |
123 for p in test_data_paths: | 123 for p in test_data_paths: |
124 self.adb.PushIfNeeded( | 124 self.adb.PushIfNeeded( |
125 os.path.join(constants.DIR_SOURCE_ROOT, p), | 125 os.path.join(src_root, p), |
126 os.path.join(dest_dir, p)) | 126 os.path.join(dest_root, p)) |
127 | 127 |
128 def LaunchTestHttpServer(self, document_root, port=None, | 128 def LaunchTestHttpServer(self, document_root, port=None, |
129 extra_config_contents=None): | 129 extra_config_contents=None): |
130 """Launches an HTTP server to serve HTTP tests. | 130 """Launches an HTTP server to serve HTTP tests. |
131 | 131 |
132 Args: | 132 Args: |
133 document_root: Document root of the HTTP server. | 133 document_root: Document root of the HTTP server. |
134 port: port on which we want to the http server bind. | 134 port: port on which we want to the http server bind. |
135 extra_config_contents: Extra config contents for the HTTP server. | 135 extra_config_contents: Extra config contents for the HTTP server. |
136 """ | 136 """ |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 break | 223 break |
224 else: | 224 else: |
225 error_msgs.append(error_msg) | 225 error_msgs.append(error_msg) |
226 self._spawning_server.Stop() | 226 self._spawning_server.Stop() |
227 # Wait for 2 seconds then restart. | 227 # Wait for 2 seconds then restart. |
228 time.sleep(2) | 228 time.sleep(2) |
229 if not server_ready: | 229 if not server_ready: |
230 logging.error(';'.join(error_msgs)) | 230 logging.error(';'.join(error_msgs)) |
231 raise Exception('Can not start the test spawner server.') | 231 raise Exception('Can not start the test spawner server.') |
232 self._PushTestServerPortInfoToDevice() | 232 self._PushTestServerPortInfoToDevice() |
OLD | NEW |