Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(416)

Side by Side Diff: chrome/test/kasko/kasko_integration_test.py

Issue 1543803005: Added an integration test for kasko hang reports (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments #1 Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 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 Kasko, Chrome and Crashpad.
7 7
8 This test ensures that the interface between Kasko and Chrome and Crashpad works 8 This test ensures that the interface between Kasko and Chrome and Crashpad works
9 as expected. The test causes Kasko to set certain crash keys and invoke a crash 9 as expected. The test causes Kasko to set certain crash keys and invoke a crash
10 report, which is in turn delivered to a locally hosted test crash server. If the 10 report, which is in turn delivered to a locally hosted test crash server. If the
11 crash report is received intact with the expected crash keys then all is well. 11 crash report is received intact with the expected crash keys then all is well.
12 12
13 Note that this test only works against non-component Release and Official builds 13 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 14 of Chrome with Chrome branding, and attempting to use it with anything else will
15 most likely lead to constant failures. 15 most likely lead to constant failures.
16 16
17 Typical usage (assuming in root 'src' directory): 17 Typical usage (assuming in root 'src' directory):
18 18
19 - generate project files with the following GYP variables: 19 - generate project files with the following GYP variables:
20 syzyasan=1 win_z7=0 chromium_win_pch=0 20 syzyasan=1 win_z7=0 chromium_win_pch=0
21 - build the release Chrome binaries: 21 - build the release Chrome binaries:
22 ninja -C out\Release chrome.exe 22 ninja -C out\Release chrome.exe chromedriver.exe
23 - run the test: 23 - run the test:
24 python chrome/test/kasko/kasko_integration_test.py 24 python chrome/test/kasko/kasko_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
35 35
36 36
37 _LOGGER = logging.getLogger(os.path.basename(__file__)) 37 _LOGGER = logging.getLogger(os.path.basename(__file__))
38 38
39 39
40 def Main(): 40 def Main():
41 options = kasko.config.ParseCommandLine() 41 options = kasko.config.ParseCommandLine()
42 42
43 # Generate a temporary directory for use in the tests. 43 kasko.integration_test.RunTest(
44 with kasko.util.ScopedTempDir() as temp_dir: 44 options,
45 # Prevent the temporary directory from self cleaning if requested. 45 'chrome://kasko/send-report',
46 if options.keep_temp_dirs: 46 10,
47 temp_dir_path = temp_dir.release() 47 {'kasko-set-crash-key-value-impl': 'SetCrashKeyValueImpl'})
chrisha 2016/01/21 18:17:41 Much cleaner, thanks!
48 else:
49 temp_dir_path = temp_dir.path
50 48
51 # Use the specified user data directory if requested. 49 _LOGGER.info('Test passed successfully!')
52 if options.user_data_dir:
53 user_data_dir = options.user_data_dir
54 else:
55 user_data_dir = os.path.join(temp_dir_path, 'user-data-dir')
56
57 kasko_dir = os.path.join(temp_dir_path, 'kasko')
58 os.makedirs(kasko_dir)
59
60 # Launch the test server.
61 server = kasko.crash_server.CrashServer()
62 with kasko.util.ScopedStartStop(server):
63 _LOGGER.info('Started server on port %d', server.port)
64
65 # Configure the environment so Chrome can find the test crash server.
66 os.environ['KASKO_CRASH_SERVER_URL'] = (
67 'http://127.0.0.1:%d/crash' % server.port)
68
69 # Launch Chrome and navigate it to the test URL.
70 chrome = kasko.process.ChromeInstance(options.chromedriver,
71 options.chrome, user_data_dir)
72 with kasko.util.ScopedStartStop(chrome):
73 _LOGGER.info('Navigating to Kasko debug URL')
74 chrome.navigate_to('chrome://kasko/send-report')
75
76 _LOGGER.info('Waiting for Kasko report')
77 if not server.wait_for_report(10):
78 raise Exception('No Kasko report received.')
79
80 report = server.crash(0)
81 kasko.report.LogCrashKeys(report)
82 kasko.report.ValidateCrashReport(report,
83 {'kasko-set-crash-key-value-impl': 'SetCrashKeyValueImpl'})
84
85 return 0
86 50
87 51
88 if __name__ == '__main__': 52 if __name__ == '__main__':
89 sys.exit(Main()) 53 sys.exit(Main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698