From 106d24dbf54af53372be8f27769bcde23163c865 Mon Sep 17 00:00:00 2001 From: jbudorick Date: Tue, 13 Oct 2015 22:56:02 -0700 Subject: [PATCH] [Android] Clear application state on instrumentation test failure. Some (still-unidentified) instrumentation tests leave an account on the device, causing subsequent uses of the device to fail the DCHECK here: https://code.google.com/p/chromium/codesearch#chromium/src/chrome/browser/signin/oauth2_token_service_delegate_android.cc&l=552 Clearing the application state on failure should return the device to a viable state. This CL _does not_ resolve the underlying flake, but it does further mitigate its impact while I keep looking for it. BUG=533188 TBR=mikecase@chromium.org Review URL: https://codereview.chromium.org/1407613004 Cr-Original-Commit-Position: refs/heads/master@{#353964} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 150d81724c609b042dffacf1e770945b81673ac7 --- android/pylib/instrumentation/test_runner.py | 23 ++++++++++--------- .../local_device_instrumentation_test_run.py | 2 ++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/android/pylib/instrumentation/test_runner.py b/android/pylib/instrumentation/test_runner.py index 9473566b0..ae6fb8310 100644 --- a/android/pylib/instrumentation/test_runner.py +++ b/android/pylib/instrumentation/test_runner.py @@ -196,20 +196,21 @@ class TestRunner(base_test_runner.BaseTestRunner): self.tool.CleanUpEnvironment() - # The logic below relies on the test passing. - if not result or not result.DidRunPass(): + if not result: return + if result.DidRunPass(): + self.TearDownPerfMonitoring(test) - self.TearDownPerfMonitoring(test) + if self.flags and self._IsFreTest(test): + self.flags.AddFlags(['--disable-fre']) - if self.flags and self._IsFreTest(test): - self.flags.AddFlags(['--disable-fre']) - - if self.coverage_dir: - self.device.PullFile( - self.coverage_device_file, self.coverage_host_file) - self.device.RunShellCommand( - 'rm -f %s' % self.coverage_device_file) + if self.coverage_dir: + self.device.PullFile( + self.coverage_device_file, self.coverage_host_file) + self.device.RunShellCommand( + 'rm -f %s' % self.coverage_device_file) + elif self.package_info: + self.device.ClearApplicationState(self.package_info.package) def TearDownPerfMonitoring(self, test): """Cleans up performance monitoring if the specified test required it. diff --git a/android/pylib/local/device/local_device_instrumentation_test_run.py b/android/pylib/local/device/local_device_instrumentation_test_run.py index daf2a7d79..afae9abcc 100644 --- a/android/pylib/local/device/local_device_instrumentation_test_run.py +++ b/android/pylib/local/device/local_device_instrumentation_test_run.py @@ -167,6 +167,8 @@ class LocalDeviceInstrumentationTestRun( for r in results: if r.GetType() == base_test_result.ResultType.UNKNOWN: r.SetType(base_test_result.ResultType.CRASH) + # TODO(jbudorick): ClearApplicationState on failure before switching + # instrumentation tests to platform mode. return results #override