| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 import logging | 5 import logging |
| 6 | 6 |
| 7 from telemetry.testing import serially_executed_browser_test_case | 7 from telemetry.testing import serially_executed_browser_test_case |
| 8 from telemetry.util import screenshot | 8 from telemetry.util import screenshot |
| 9 | 9 |
| 10 from gpu_tests import exception_formatter | 10 from gpu_tests import exception_formatter |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 # Perhaps only if multiple arguments are yielded in the test | 74 # Perhaps only if multiple arguments are yielded in the test |
| 75 # generator? | 75 # generator? |
| 76 if len(args) == 1 and isinstance(args[0], tuple): | 76 if len(args) == 1 and isinstance(args[0], tuple): |
| 77 args = args[0] | 77 args = args[0] |
| 78 self.RunActualGpuTest(url, *args) | 78 self.RunActualGpuTest(url, *args) |
| 79 except Exception: | 79 except Exception: |
| 80 if expectation == 'pass': | 80 if expectation == 'pass': |
| 81 # This is not an expected exception or test failure, so print | 81 # This is not an expected exception or test failure, so print |
| 82 # the detail to the console. | 82 # the detail to the console. |
| 83 exception_formatter.PrintFormattedException() | 83 exception_formatter.PrintFormattedException() |
| 84 # Symbolize any crash dump (like from the GPU process) that |
| 85 # might have happened but wasn't detected above. Note we don't |
| 86 # do this for either 'fail' or 'flaky' expectations because |
| 87 # there are still quite a few flaky failures in the WebGL test |
| 88 # expectations, and since minidump symbolization is slow |
| 89 # (upwards of one minute on a fast laptop), symbolizing all the |
| 90 # stacks could slow down the tests' running time unacceptably. |
| 91 self._SymbolizeUnsymbolizedMinidumps() |
| 84 # This failure might have been caused by a browser or renderer | 92 # This failure might have been caused by a browser or renderer |
| 85 # crash, so restart the browser to make sure any state doesn't | 93 # crash, so restart the browser to make sure any state doesn't |
| 86 # propagate to the next test iteration. | 94 # propagate to the next test iteration. |
| 87 self._RestartBrowser('unexpected test failure') | 95 self._RestartBrowser('unexpected test failure') |
| 88 raise | 96 raise |
| 89 elif expectation == 'fail': | 97 elif expectation == 'fail': |
| 90 msg = 'Expected exception while running %s' % test_name | 98 msg = 'Expected exception while running %s' % test_name |
| 91 exception_formatter.PrintFormattedException(msg=msg) | 99 exception_formatter.PrintFormattedException(msg=msg) |
| 92 # Even though this is a known failure, the browser might still | 100 # Even though this is a known failure, the browser might still |
| 93 # be in a bad state; for example, certain kinds of timeouts | 101 # be in a bad state; for example, certain kinds of timeouts |
| (...skipping 27 matching lines...) Expand all Loading... |
| 121 if ii == num_retries - 1: | 129 if ii == num_retries - 1: |
| 122 # Restart the browser after the last failure to make sure | 130 # Restart the browser after the last failure to make sure |
| 123 # any state doesn't propagate to the next iteration. | 131 # any state doesn't propagate to the next iteration. |
| 124 self._RestartBrowser('excessive flaky test failures') | 132 self._RestartBrowser('excessive flaky test failures') |
| 125 raise | 133 raise |
| 126 else: | 134 else: |
| 127 if expectation == 'fail': | 135 if expectation == 'fail': |
| 128 logging.warning( | 136 logging.warning( |
| 129 '%s was expected to fail, but passed.\n', test_name) | 137 '%s was expected to fail, but passed.\n', test_name) |
| 130 | 138 |
| 139 def _SymbolizeUnsymbolizedMinidumps(self): |
| 140 # The fakes used for unit tests don't mock this entry point yet. |
| 141 if not hasattr(self.browser, 'GetAllUnsymbolizedMinidumpPaths'): |
| 142 return |
| 143 i = 10 |
| 144 if self.browser.GetAllUnsymbolizedMinidumpPaths(): |
| 145 logging.error('Symbolizing minidump paths: ' + str( |
| 146 self.browser.GetAllUnsymbolizedMinidumpPaths())) |
| 147 else: |
| 148 logging.error('No minidump paths to symbolize') |
| 149 while i > 0 and self.browser.GetAllUnsymbolizedMinidumpPaths(): |
| 150 i = i - 1 |
| 151 sym = self.browser.SymbolizeMinidump( |
| 152 self.browser.GetAllUnsymbolizedMinidumpPaths()[0]) |
| 153 if sym[0]: |
| 154 logging.error('Symbolized minidump:\n' + sym[1]) |
| 155 else: |
| 156 logging.error('Minidump symbolization failed:\n' + sym[1]) |
| 157 |
| 131 @classmethod | 158 @classmethod |
| 132 def GenerateGpuTests(cls, options): | 159 def GenerateGpuTests(cls, options): |
| 133 """Subclasses must implement this to yield (test_name, url, args) | 160 """Subclasses must implement this to yield (test_name, url, args) |
| 134 tuples of tests to run.""" | 161 tuples of tests to run.""" |
| 135 raise NotImplementedError | 162 raise NotImplementedError |
| 136 | 163 |
| 137 def RunActualGpuTest(self, file_path, *args): | 164 def RunActualGpuTest(self, file_path, *args): |
| 138 """Subclasses must override this to run the actual test at the given | 165 """Subclasses must override this to run the actual test at the given |
| 139 URL. file_path is a path on the local file system that may need to | 166 URL. file_path is a path on the local file system that may need to |
| 140 be resolved via UrlOfStaticFilePath. | 167 be resolved via UrlOfStaticFilePath. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 165 cls.tab = cls.browser.tabs[0] | 192 cls.tab = cls.browser.tabs[0] |
| 166 except Exception: | 193 except Exception: |
| 167 # restart the browser to make sure a failure in a test doesn't | 194 # restart the browser to make sure a failure in a test doesn't |
| 168 # propagate to the next test iteration. | 195 # propagate to the next test iteration. |
| 169 logging.exception("Failure during browser startup") | 196 logging.exception("Failure during browser startup") |
| 170 cls._RestartBrowser('failure in setup') | 197 cls._RestartBrowser('failure in setup') |
| 171 raise | 198 raise |
| 172 | 199 |
| 173 def setUp(self): | 200 def setUp(self): |
| 174 self._EnsureTabIsAvailable() | 201 self._EnsureTabIsAvailable() |
| OLD | NEW |