Chromium Code Reviews| 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 """Class for running instrumentation tests on a single device.""" | 5 """Class for running instrumentation tests on a single device.""" |
| 6 | 6 |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import sys | 10 import sys |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 | 75 |
| 76 self.options = test_options | 76 self.options = test_options |
| 77 self.test_pkg = test_pkg | 77 self.test_pkg = test_pkg |
| 78 self.coverage_dir = test_options.coverage_dir | 78 self.coverage_dir = test_options.coverage_dir |
| 79 # Use the correct command line file for the package under test. | 79 # Use the correct command line file for the package under test. |
| 80 cmdline_file = [a.cmdline_file for a in constants.PACKAGE_INFO.itervalues() | 80 cmdline_file = [a.cmdline_file for a in constants.PACKAGE_INFO.itervalues() |
| 81 if a.test_package == self.test_pkg.GetPackageName()] | 81 if a.test_package == self.test_pkg.GetPackageName()] |
| 82 assert len(cmdline_file) < 2, 'Multiple packages have the same test package' | 82 assert len(cmdline_file) < 2, 'Multiple packages have the same test package' |
| 83 if len(cmdline_file) and cmdline_file[0]: | 83 if len(cmdline_file) and cmdline_file[0]: |
| 84 self.flags = flag_changer.FlagChanger(self.adb, cmdline_file[0]) | 84 self.flags = flag_changer.FlagChanger(self.adb, cmdline_file[0]) |
| 85 if additional_flags: | |
| 86 self.flags.AddFlags(additional_flags) | |
| 85 else: | 87 else: |
| 86 self.flags = flag_changer.FlagChanger(self.adb) | 88 self.flags = None |
|
navabi
2013/12/19 22:51:17
Is it ok that this is now None? Is there anywhere
frankf
2013/12/20 20:22:17
Yea, these are all the instances.
On 2013/12/19 2
| |
| 87 if additional_flags: | |
| 88 self.flags.AddFlags(additional_flags) | |
| 89 | 89 |
| 90 #override | 90 #override |
| 91 def InstallTestPackage(self): | 91 def InstallTestPackage(self): |
| 92 self.test_pkg.Install(self.adb) | 92 self.test_pkg.Install(self.adb) |
| 93 | 93 |
| 94 #override | 94 #override |
| 95 def PushDataDeps(self): | 95 def PushDataDeps(self): |
| 96 # TODO(frankf): Implement a general approach for copying/installing | 96 # TODO(frankf): Implement a general approach for copying/installing |
| 97 # once across test runners. | 97 # once across test runners. |
| 98 if TestRunner._DEVICE_HAS_TEST_FILES.get(self.device, False): | 98 if TestRunner._DEVICE_HAS_TEST_FILES.get(self.device, False): |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 self.device) | 147 self.device) |
| 148 else: | 148 else: |
| 149 if self.adb.SetJavaAssertsEnabled(True): | 149 if self.adb.SetJavaAssertsEnabled(True): |
| 150 self.adb.Reboot(full_reboot=False) | 150 self.adb.Reboot(full_reboot=False) |
| 151 | 151 |
| 152 # We give different default value to launch HTTP server based on shard index | 152 # We give different default value to launch HTTP server based on shard index |
| 153 # because it may have race condition when multiple processes are trying to | 153 # because it may have race condition when multiple processes are trying to |
| 154 # launch lighttpd with same port at same time. | 154 # launch lighttpd with same port at same time. |
| 155 http_server_ports = self.LaunchTestHttpServer( | 155 http_server_ports = self.LaunchTestHttpServer( |
| 156 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port) | 156 os.path.join(constants.DIR_SOURCE_ROOT), self._lighttp_port) |
| 157 self.flags.AddFlags(['--disable-fre', '--enable-test-intents']) | 157 if self.flags: |
| 158 self.flags.AddFlags(['--disable-fre', '--enable-test-intents']) | |
| 158 | 159 |
| 159 def TearDown(self): | 160 def TearDown(self): |
| 160 """Cleans up the test harness and saves outstanding data from test run.""" | 161 """Cleans up the test harness and saves outstanding data from test run.""" |
| 161 self.flags.Restore() | 162 if self.flags: |
| 163 self.flags.Restore() | |
| 162 super(TestRunner, self).TearDown() | 164 super(TestRunner, self).TearDown() |
| 163 | 165 |
| 164 def TestSetup(self, test): | 166 def TestSetup(self, test): |
| 165 """Sets up the test harness for running a particular test. | 167 """Sets up the test harness for running a particular test. |
| 166 | 168 |
| 167 Args: | 169 Args: |
| 168 test: The name of the test that will be run. | 170 test: The name of the test that will be run. |
| 169 """ | 171 """ |
| 170 self.SetupPerfMonitoringIfNeeded(test) | 172 self.SetupPerfMonitoringIfNeeded(test) |
| 171 self._SetupIndividualTestTimeoutScale(test) | 173 self._SetupIndividualTestTimeoutScale(test) |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 368 duration_ms = 0 | 370 duration_ms = 0 |
| 369 message = str(e) | 371 message = str(e) |
| 370 if not message: | 372 if not message: |
| 371 message = 'No information.' | 373 message = 'No information.' |
| 372 results.AddResult(test_result.InstrumentationTestResult( | 374 results.AddResult(test_result.InstrumentationTestResult( |
| 373 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, | 375 test, base_test_result.ResultType.CRASH, start_date_ms, duration_ms, |
| 374 log=message)) | 376 log=message)) |
| 375 raw_result = None | 377 raw_result = None |
| 376 self.TestTeardown(test, raw_result) | 378 self.TestTeardown(test, raw_result) |
| 377 return (results, None if results.DidRunPass() else test) | 379 return (results, None if results.DidRunPass() else test) |
| OLD | NEW |