 Chromium Code Reviews
 Chromium Code Reviews Issue 16627004:
  [Android] Add --skip-deps-push to test scripts.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 16627004:
  [Android] Add --skip-deps-push to test scripts.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| 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 16 matching lines...) Expand all Loading... | |
| 27 NET_TEST_SERVER_PORT_INFO_FILE = 'net-test-server-ports' | 27 NET_TEST_SERVER_PORT_INFO_FILE = 'net-test-server-ports' | 
| 28 | 28 | 
| 29 | 29 | 
| 30 class BaseTestRunner(object): | 30 class BaseTestRunner(object): | 
| 31 """Base class for running tests on a single device. | 31 """Base class for running tests on a single device. | 
| 32 | 32 | 
| 33 A subclass should implement RunTests() with no parameter, so that calling | 33 A subclass should implement RunTests() with no parameter, so that calling | 
| 34 the Run() method will set up tests, run them and tear them down. | 34 the Run() method will set up tests, run them and tear them down. | 
| 35 """ | 35 """ | 
| 36 | 36 | 
| 37 def __init__(self, device, tool, build_type): | 37 def __init__(self, device, tool, build_type, push_deps): | 
| 38 """ | 38 """ | 
| 39 Args: | 39 Args: | 
| 40 device: Tests will run on the device of this ID. | 40 device: Tests will run on the device of this ID. | 
| 41 shard_index: Index number of the shard on which the test suite will run. | 41 shard_index: Index number of the shard on which the test suite will run. | 
| 42 build_type: 'Release' or 'Debug'. | 42 build_type: 'Release' or 'Debug'. | 
| 43 push_deps: If True, push all dependencies to the device. | |
| 43 """ | 44 """ | 
| 44 self.device = device | 45 self.device = device | 
| 45 self.adb = android_commands.AndroidCommands(device=device) | 46 self.adb = android_commands.AndroidCommands(device=device) | 
| 46 self.tool = CreateTool(tool, self.adb) | 47 self.tool = CreateTool(tool, self.adb) | 
| 47 self._http_server = None | 48 self._http_server = None | 
| 48 self._forwarder = None | 49 self._forwarder = None | 
| 49 self._forwarder_device_port = 8000 | 50 self._forwarder_device_port = 8000 | 
| 50 self.forwarder_base_url = ('http://localhost:%d' % | 51 self.forwarder_base_url = ('http://localhost:%d' % | 
| 51 self._forwarder_device_port) | 52 self._forwarder_device_port) | 
| 52 self.flags = FlagChanger(self.adb) | 53 self.flags = FlagChanger(self.adb) | 
| 53 self.flags.AddFlags(['--disable-fre']) | 54 self.flags.AddFlags(['--disable-fre']) | 
| 54 self._spawning_server = None | 55 self._spawning_server = None | 
| 55 self._spawner_forwarder = None | 56 self._spawner_forwarder = None | 
| 56 # We will allocate port for test server spawner when calling method | 57 # We will allocate port for test server spawner when calling method | 
| 57 # LaunchChromeTestServerSpawner and allocate port for test server when | 58 # LaunchChromeTestServerSpawner and allocate port for test server when | 
| 58 # starting it in TestServerThread. | 59 # starting it in TestServerThread. | 
| 59 self.test_server_spawner_port = 0 | 60 self.test_server_spawner_port = 0 | 
| 60 self.test_server_port = 0 | 61 self.test_server_port = 0 | 
| 61 self.build_type = build_type | 62 self.build_type = build_type | 
| 63 self._push_deps = push_deps | |
| 62 | 64 | 
| 63 def _PushTestServerPortInfoToDevice(self): | 65 def _PushTestServerPortInfoToDevice(self): | 
| 64 """Pushes the latest port information to device.""" | 66 """Pushes the latest port information to device.""" | 
| 65 self.adb.SetFileContents(self.adb.GetExternalStorage() + '/' + | 67 self.adb.SetFileContents(self.adb.GetExternalStorage() + '/' + | 
| 66 NET_TEST_SERVER_PORT_INFO_FILE, | 68 NET_TEST_SERVER_PORT_INFO_FILE, | 
| 67 '%d:%d' % (self.test_server_spawner_port, | 69 '%d:%d' % (self.test_server_spawner_port, | 
| 68 self.test_server_port)) | 70 self.test_server_port)) | 
| 69 | 71 | 
| 70 def RunTest(self, test): | 72 def RunTest(self, test): | 
| 71 """Runs a test. Needs to be overridden. | 73 """Runs a test. Needs to be overridden. | 
| 72 | 74 | 
| 73 Args: | 75 Args: | 
| 74 test: A test to run. | 76 test: A test to run. | 
| 75 | 77 | 
| 76 Returns: | 78 Returns: | 
| 77 Tuple containing: | 79 Tuple containing: | 
| 78 (base_test_result.TestRunResults, tests to rerun or None) | 80 (base_test_result.TestRunResults, tests to rerun or None) | 
| 79 """ | 81 """ | 
| 80 raise NotImplementedError | 82 raise NotImplementedError | 
| 81 | 83 | 
| 82 def PushDependencies(self): | 84 def PushDependencies(self): | 
| 83 """Push all dependencies to device once before all tests are run.""" | 85 """Push all dependencies to device once before all tests are run.""" | 
| 84 pass | 86 pass | 
| 85 | 87 | 
| 86 def SetUp(self): | 88 def SetUp(self): | 
| 87 """Run once before all tests are run.""" | 89 """Run once before all tests are run.""" | 
| 88 Forwarder.KillDevice(self.adb, self.tool) | 90 Forwarder.KillDevice(self.adb, self.tool) | 
| 89 self.PushDependencies() | 91 if self._push_deps: | 
| 92 logging.info('Pushing deps to device.') | |
| 93 self.PushDependencies() | |
| 
nilesh
2013/06/12 17:25:12
This causes the apk install to be skipped as well.
 | |
| 94 else: | |
| 95 logging.warning('Skipping pushing deps to device.') | |
| 90 | 96 | 
| 91 def TearDown(self): | 97 def TearDown(self): | 
| 92 """Run once after all tests are run.""" | 98 """Run once after all tests are run.""" | 
| 93 self.ShutdownHelperToolsForTestSuite() | 99 self.ShutdownHelperToolsForTestSuite() | 
| 94 | 100 | 
| 95 def CopyTestData(self, test_data_paths, dest_dir): | 101 def CopyTestData(self, test_data_paths, dest_dir): | 
| 96 """Copies |test_data_paths| list of files/directories to |dest_dir|. | 102 """Copies |test_data_paths| list of files/directories to |dest_dir|. | 
| 97 | 103 | 
| 98 Args: | 104 Args: | 
| 99 test_data_paths: A list of files or directories relative to |dest_dir| | 105 test_data_paths: A list of files or directories relative to |dest_dir| | 
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 break | 210 break | 
| 205 else: | 211 else: | 
| 206 error_msgs.append(error_msg) | 212 error_msgs.append(error_msg) | 
| 207 self._spawning_server.Stop() | 213 self._spawning_server.Stop() | 
| 208 # Wait for 2 seconds then restart. | 214 # Wait for 2 seconds then restart. | 
| 209 time.sleep(2) | 215 time.sleep(2) | 
| 210 if not server_ready: | 216 if not server_ready: | 
| 211 logging.error(';'.join(error_msgs)) | 217 logging.error(';'.join(error_msgs)) | 
| 212 raise Exception('Can not start the test spawner server.') | 218 raise Exception('Can not start the test spawner server.') | 
| 213 self._PushTestServerPortInfoToDevice() | 219 self._PushTestServerPortInfoToDevice() | 
| OLD | NEW |