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 logging | 7 import logging |
8 import time | 8 import time |
9 | 9 |
10 from pylib import ports | 10 from pylib import ports |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 # LaunchChromeTestServerSpawner and allocate port for test server when | 45 # LaunchChromeTestServerSpawner and allocate port for test server when |
46 # starting it in TestServerThread. | 46 # starting it in TestServerThread. |
47 self.test_server_spawner_port = 0 | 47 self.test_server_spawner_port = 0 |
48 self.test_server_port = 0 | 48 self.test_server_port = 0 |
49 self._push_deps = push_deps | 49 self._push_deps = push_deps |
50 self._cleanup_test_files = cleanup_test_files | 50 self._cleanup_test_files = cleanup_test_files |
51 | 51 |
52 def _PushTestServerPortInfoToDevice(self): | 52 def _PushTestServerPortInfoToDevice(self): |
53 """Pushes the latest port information to device.""" | 53 """Pushes the latest port information to device.""" |
54 self.device.old_interface.SetFileContents( | 54 self.device.old_interface.SetFileContents( |
55 self.device.old_interface.GetExternalStorage() + '/' + | 55 self.device.GetExternalStoragePath() + '/' + |
56 NET_TEST_SERVER_PORT_INFO_FILE, | 56 NET_TEST_SERVER_PORT_INFO_FILE, |
57 '%d:%d' % (self.test_server_spawner_port, self.test_server_port)) | 57 '%d:%d' % (self.test_server_spawner_port, self.test_server_port)) |
58 | 58 |
59 def RunTest(self, test): | 59 def RunTest(self, test): |
60 """Runs a test. Needs to be overridden. | 60 """Runs a test. Needs to be overridden. |
61 | 61 |
62 Args: | 62 Args: |
63 test: A test to run. | 63 test: A test to run. |
64 | 64 |
65 Returns: | 65 Returns: |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 break | 192 break |
193 else: | 193 else: |
194 error_msgs.append(error_msg) | 194 error_msgs.append(error_msg) |
195 self._spawning_server.Stop() | 195 self._spawning_server.Stop() |
196 # Wait for 2 seconds then restart. | 196 # Wait for 2 seconds then restart. |
197 time.sleep(2) | 197 time.sleep(2) |
198 if not server_ready: | 198 if not server_ready: |
199 logging.error(';'.join(error_msgs)) | 199 logging.error(';'.join(error_msgs)) |
200 raise Exception('Can not start the test spawner server.') | 200 raise Exception('Can not start the test spawner server.') |
201 self._PushTestServerPortInfoToDevice() | 201 self._PushTestServerPortInfoToDevice() |
OLD | NEW |