Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """A Windows-only end-to-end integration test for Kasko, Chrome and Crashpad. | 6 """A Windows-only end-to-end integration test for the Chrome hang watcher. |
| 7 | 7 |
| 8 This test ensures that the interface between Kasko and Chrome and Crashpad works | 8 This test ensures that the hang watcher is able to detect when Chrome hangs and |
| 9 as expected. The test causes Kasko to set certain crash keys and invoke a crash | 9 to generate a Kasko report. The report is then delivered to a locally hosted |
| 10 report, which is in turn delivered to a locally hosted test crash server. If the | 10 test crash server. If a crash report is received then all is well. |
| 11 crash report is received intact with the expected crash keys then all is well. | |
| 12 | 11 |
| 13 Note that this test only works against non-component Release and Official builds | 12 Note that this test only works against non-component Release and Official builds |
| 14 of Chrome with Chrome branding, and attempting to use it with anything else will | 13 of Chrome with Chrome branding, and attempting to use it with anything else will |
| 15 most likely lead to constant failures. | 14 most likely lead to constant failures. |
| 16 | 15 |
| 17 Typical usage (assuming in root 'src' directory): | 16 Typical usage (assuming in root 'src' directory): |
| 18 | 17 |
| 19 - generate project files with the following GYP variables: | 18 - generate project files with the following GYP variables: |
| 20 syzyasan=1 win_z7=0 chromium_win_pch=0 | 19 branding=Chrome kasko=1 kasko_hang_reports=1 |
| 21 - build the release Chrome binaries: | 20 - build the release Chrome binaries: |
| 22 ninja -C out\Release chrome.exe | 21 ninja -C out\Release chrome.exe |
| 22 ninja -C out\Release chromedriver.exe | |
|
chrisha
2016/01/20 22:20:31
This may as well be ninja -C out\Release chrome.ex
Patrick Monette
2016/01/21 00:05:10
Done.
| |
| 23 - run the test: | 23 - run the test: |
| 24 python chrome/test/kasko/kasko_integration_test.py | 24 python chrome/test/kasko/hang_watcher_integration_test.py |
| 25 """ | 25 """ |
| 26 | 26 |
| 27 import logging | 27 import logging |
| 28 import os | 28 import os |
| 29 import sys | 29 import sys |
| 30 | 30 |
| 31 # Bring in the Kasko module. | 31 # Bring in the Kasko module. |
| 32 KASKO_DIR = os.path.join(os.path.dirname(__file__), 'py') | 32 KASKO_DIR = os.path.join(os.path.dirname(__file__), 'py') |
| 33 sys.path.append(KASKO_DIR) | 33 sys.path.append(KASKO_DIR) |
| 34 import kasko | 34 import kasko |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 60 # Launch the test server. | 60 # Launch the test server. |
| 61 server = kasko.crash_server.CrashServer() | 61 server = kasko.crash_server.CrashServer() |
| 62 with kasko.util.ScopedStartStop(server): | 62 with kasko.util.ScopedStartStop(server): |
| 63 _LOGGER.info('Started server on port %d', server.port) | 63 _LOGGER.info('Started server on port %d', server.port) |
| 64 | 64 |
| 65 # Configure the environment so Chrome can find the test crash server. | 65 # Configure the environment so Chrome can find the test crash server. |
| 66 os.environ['KASKO_CRASH_SERVER_URL'] = ( | 66 os.environ['KASKO_CRASH_SERVER_URL'] = ( |
| 67 'http://127.0.0.1:%d/crash' % server.port) | 67 'http://127.0.0.1:%d/crash' % server.port) |
| 68 | 68 |
| 69 # Launch Chrome and navigate it to the test URL. | 69 # Launch Chrome and navigate it to the test URL. |
| 70 chrome = kasko.process.ChromeInstance(options.chromedriver, | 70 chrome = kasko.process.ChromeInstance(options.chromedriver, |
|
chrisha
2016/01/20 22:20:31
The whole body of this test is still the same as t
Patrick Monette
2016/01/21 00:05:10
Done.
| |
| 71 options.chrome, user_data_dir) | 71 options.chrome, user_data_dir) |
| 72 with kasko.util.ScopedStartStop(chrome): | 72 with kasko.util.ScopedStartStop(chrome): |
| 73 _LOGGER.info('Navigating to Kasko debug URL') | 73 _LOGGER.info('Navigating to Kasko debug URL') |
| 74 chrome.navigate_to('chrome://kasko/send-report') | 74 chrome.navigate_to('chrome://delayeduithreadhang') |
| 75 | 75 |
| 76 _LOGGER.info('Waiting for Kasko report') | 76 _LOGGER.info('Waiting for Kasko report') |
| 77 if not server.wait_for_report(10): | 77 if not server.wait_for_report(120): |
| 78 raise Exception('No Kasko report received.') | 78 raise Exception('No Kasko report received.') |
| 79 | 79 |
| 80 # Verify a few crash keys. | |
| 80 report = server.crash(0) | 81 report = server.crash(0) |
| 81 kasko.report.LogCrashKeys(report) | 82 kasko.report.LogCrashKeys(report) |
| 82 kasko.report.ValidateCrashReport(report, | 83 expected_keys = [ |
| 83 {'kasko-set-crash-key-value-impl': 'SetCrashKeyValueImpl'}) | 84 'guid', |
| 85 'kasko-generated-by-version', | |
| 86 'kasko-uploaded-by-version', | |
| 87 'pid', | |
| 88 'plat', | |
| 89 'prod', | |
| 90 'report-id', | |
| 91 'ver', | |
|
chrisha
2016/01/20 22:20:31
You should be able to use ValidateCrashReport as i
Patrick Monette
2016/01/21 00:05:10
Done.
| |
| 92 ] | |
| 93 kasko.report.ValidateNonEmptyCrashKeys(report, expected_keys) | |
| 94 | |
| 95 _LOGGER.info('Test passed successfully!') | |
|
chrisha
2016/01/20 22:20:31
Ditto to adding this to the other couple tests...
Patrick Monette
2016/01/21 00:05:10
Done.
| |
| 84 | 96 |
| 85 return 0 | 97 return 0 |
| 86 | 98 |
| 87 | 99 |
| 88 if __name__ == '__main__': | 100 if __name__ == '__main__': |
| 89 sys.exit(Main()) | 101 sys.exit(Main()) |
| OLD | NEW |