| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 def TestSetup(self, test): | 178 def TestSetup(self, test): |
| 179 """Sets up the test harness for running a particular test. | 179 """Sets up the test harness for running a particular test. |
| 180 | 180 |
| 181 Args: | 181 Args: |
| 182 test: The name of the test that will be run. | 182 test: The name of the test that will be run. |
| 183 """ | 183 """ |
| 184 self.SetupPerfMonitoringIfNeeded(test) | 184 self.SetupPerfMonitoringIfNeeded(test) |
| 185 self._SetupIndividualTestTimeoutScale(test) | 185 self._SetupIndividualTestTimeoutScale(test) |
| 186 self.tool.SetupEnvironment() | 186 self.tool.SetupEnvironment() |
| 187 | 187 |
| 188 if self.flags and self._IsFreTest(test): |
| 189 self.flags.RemoveFlags(['--disable-fre']) |
| 190 |
| 188 # Make sure the forwarder is still running. | 191 # Make sure the forwarder is still running. |
| 189 self._RestartHttpServerForwarderIfNecessary() | 192 self._RestartHttpServerForwarderIfNecessary() |
| 190 | 193 |
| 191 if self.coverage_dir: | 194 if self.coverage_dir: |
| 192 coverage_basename = '%s.ec' % test | 195 coverage_basename = '%s.ec' % test |
| 193 self.coverage_device_file = '%s/%s/%s' % ( | 196 self.coverage_device_file = '%s/%s/%s' % ( |
| 194 self.device.GetExternalStoragePath(), | 197 self.device.GetExternalStoragePath(), |
| 195 TestRunner._DEVICE_COVERAGE_DIR, coverage_basename) | 198 TestRunner._DEVICE_COVERAGE_DIR, coverage_basename) |
| 196 self.coverage_host_file = os.path.join( | 199 self.coverage_host_file = os.path.join( |
| 197 self.coverage_dir, coverage_basename) | 200 self.coverage_dir, coverage_basename) |
| 198 | 201 |
| 202 def _IsFreTest(self, test): |
| 203 """Determines whether a test is a first run experience test. |
| 204 |
| 205 Args: |
| 206 test: The name of the test to be checked. |
| 207 |
| 208 Returns: |
| 209 Whether the feature being tested is FirstRunExperience. |
| 210 """ |
| 211 freFeature = 'Feature:FirstRunExperience' |
| 212 return freFeature in self.test_pkg.GetTestAnnotations(test) |
| 213 |
| 199 def _IsPerfTest(self, test): | 214 def _IsPerfTest(self, test): |
| 200 """Determines whether a test is a performance test. | 215 """Determines whether a test is a performance test. |
| 201 | 216 |
| 202 Args: | 217 Args: |
| 203 test: The name of the test to be checked. | 218 test: The name of the test to be checked. |
| 204 | 219 |
| 205 Returns: | 220 Returns: |
| 206 Whether the test is annotated as a performance test. | 221 Whether the test is annotated as a performance test. |
| 207 """ | 222 """ |
| 208 return _PERF_TEST_ANNOTATION in self.test_pkg.GetTestAnnotations(test) | 223 return _PERF_TEST_ANNOTATION in self.test_pkg.GetTestAnnotations(test) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 231 """ | 246 """ |
| 232 | 247 |
| 233 self.tool.CleanUpEnvironment() | 248 self.tool.CleanUpEnvironment() |
| 234 | 249 |
| 235 # The logic below relies on the test passing. | 250 # The logic below relies on the test passing. |
| 236 if not result or not result.DidRunPass(): | 251 if not result or not result.DidRunPass(): |
| 237 return | 252 return |
| 238 | 253 |
| 239 self.TearDownPerfMonitoring(test) | 254 self.TearDownPerfMonitoring(test) |
| 240 | 255 |
| 256 if self.flags and self._IsFreTest(test): |
| 257 self.flags.AddFlags(['--disable-fre']) |
| 258 |
| 241 if self.coverage_dir: | 259 if self.coverage_dir: |
| 242 self.device.PullFile( | 260 self.device.PullFile( |
| 243 self.coverage_device_file, self.coverage_host_file) | 261 self.coverage_device_file, self.coverage_host_file) |
| 244 self.device.RunShellCommand( | 262 self.device.RunShellCommand( |
| 245 'rm -f %s' % self.coverage_device_file) | 263 'rm -f %s' % self.coverage_device_file) |
| 246 | 264 |
| 247 def TearDownPerfMonitoring(self, test): | 265 def TearDownPerfMonitoring(self, test): |
| 248 """Cleans up performance monitoring if the specified test required it. | 266 """Cleans up performance monitoring if the specified test required it. |
| 249 | 267 |
| 250 Args: | 268 Args: |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 except device_errors.CommandTimeoutError as e: | 525 except device_errors.CommandTimeoutError as e: |
| 508 results.AddResult(test_result.InstrumentationTestResult( | 526 results.AddResult(test_result.InstrumentationTestResult( |
| 509 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, | 527 test, base_test_result.ResultType.TIMEOUT, start_ms, duration_ms, |
| 510 log=str(e) or 'No information')) | 528 log=str(e) or 'No information')) |
| 511 except device_errors.DeviceUnreachableError as e: | 529 except device_errors.DeviceUnreachableError as e: |
| 512 results.AddResult(test_result.InstrumentationTestResult( | 530 results.AddResult(test_result.InstrumentationTestResult( |
| 513 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, | 531 test, base_test_result.ResultType.CRASH, start_ms, duration_ms, |
| 514 log=str(e) or 'No information')) | 532 log=str(e) or 'No information')) |
| 515 self.TestTeardown(test, results) | 533 self.TestTeardown(test, results) |
| 516 return (results, None if results.DidRunPass() else test) | 534 return (results, None if results.DidRunPass() else test) |
| OLD | NEW |