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

Side by Side Diff: tools/ipc_fuzzer/play_testcase.py

Issue 1025483002: Restructure the ipc_fuzzer directory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move more files around Created 5 years, 9 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
« no previous file with comments | « tools/ipc_fuzzer/mutate/utils.py ('k') | tools/ipc_fuzzer/remove_close_messages.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Wrapper around chrome.
7
8 Replaces all the child processes (renderer, GPU, plugins and utility) with the
9 IPC fuzzer. The fuzzer will then play back a specified testcase.
10
11 Depends on ipc_fuzzer being available on the same directory as chrome.
12 """
13
14 import argparse
15 import os
16 import platform
17 import subprocess
18 import sys
19
20 CHROME_BINARY_FOR_PLATFORM_DICT = {
21 'LINUX': 'chrome',
22 'MAC': 'Chromium.app/Contents/MacOS/Chromium',
23 'WINDOWS': 'chrome.exe',
24 }
25
26 def GetPlatform():
27 platform = None
28 if sys.platform.startswith('win'):
29 platform = 'WINDOWS'
30 elif sys.platform.startswith('linux'):
31 platform = 'LINUX'
32 elif sys.platform == 'darwin':
33 platform = 'MAC'
34
35 assert platform is not None
36 return platform
37
38 def main():
39 desc = 'Wrapper to run chrome with child processes replaced by IPC fuzzers'
40 parser = argparse.ArgumentParser(description=desc)
41 parser.add_argument('--out-dir', dest='out_dir', default='out',
42 help='output directory under src/ directory')
43 parser.add_argument('--build-type', dest='build_type', default='Release',
44 help='Debug vs. Release build')
45 parser.add_argument('--gdb-browser', dest='gdb_browser', default=False,
46 action='store_true',
47 help='run browser process inside gdb')
48 parser.add_argument('testcase',
49 help='IPC file to be replayed')
50 parser.add_argument('chrome_args',
51 nargs=argparse.REMAINDER,
52 help='any additional arguments are passed to chrome')
53 args = parser.parse_args()
54
55 platform = GetPlatform()
56 chrome_binary = CHROME_BINARY_FOR_PLATFORM_DICT[platform]
57 fuzzer_binary = 'ipc_fuzzer_replay'
58 if platform == 'WINDOWS':
59 fuzzer_binary += '.exe'
60
61 script_path = os.path.realpath(__file__)
62 ipc_fuzzer_dir = os.path.dirname(script_path)
63 src_dir = os.path.abspath(os.path.join(ipc_fuzzer_dir, os.pardir, os.pardir))
64 out_dir = os.path.join(src_dir, args.out_dir)
65 build_dir = os.path.join(out_dir, args.build_type)
66
67 chrome_path = os.path.join(build_dir, chrome_binary)
68 if not os.path.exists(chrome_path):
69 print 'chrome executable not found at ', chrome_path
70 return 1
71
72 fuzzer_path = os.path.join(build_dir, fuzzer_binary)
73 if not os.path.exists(fuzzer_path):
74 print 'fuzzer executable not found at ', fuzzer_path
75 print ('ensure GYP_DEFINES="enable_ipc_fuzzer=1" and build target ' +
76 fuzzer_binary + '.')
77 return 1
78
79 prefixes = {
80 '--renderer-cmd-prefix',
81 '--gpu-launcher',
82 '--plugin-launcher',
83 '--ppapi-plugin-launcher',
84 '--utility-cmd-prefix',
85 }
86
87 chrome_command = [
88 chrome_path,
89 '--ipc-fuzzer-testcase=' + args.testcase,
90 '--no-sandbox',
91 '--disable-kill-after-bad-ipc',
92 '--disable-mojo-channel',
93 ]
94
95 if args.gdb_browser:
96 chrome_command = ['gdb', '--args'] + chrome_command
97
98 launchers = {}
99 for prefix in prefixes:
100 launchers[prefix] = fuzzer_path
101
102 for arg in args.chrome_args:
103 if arg.find('=') != -1:
104 switch, value = arg.split('=', 1)
105 if switch in prefixes:
106 launchers[switch] = value + ' ' + launchers[switch]
107 continue
108 chrome_command.append(arg)
109
110 for switch, value in launchers.items():
111 chrome_command.append(switch + '=' + value)
112
113 command_line = ' '.join(['\'' + arg + '\'' for arg in chrome_command])
114 print 'Executing: ' + command_line
115
116 return subprocess.call(chrome_command)
117
118
119 if __name__ == "__main__":
120 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/ipc_fuzzer/mutate/utils.py ('k') | tools/ipc_fuzzer/remove_close_messages.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698