OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright (c) 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 os | |
15 import platform | |
16 import subprocess | |
17 import sys | |
18 | |
19 def main(): | |
20 if len(sys.argv) <= 1: | |
21 print 'Usage: play_testcase.py [chrome_flag...] testcase' | |
22 sys.exit(1) | |
jochen (gone - plz use gerrit)
2013/10/31 10:47:00
return 1
aedla
2013/11/26 17:09:50
Done.
| |
23 | |
24 script_path = os.path.realpath(__file__) | |
25 ipc_fuzzer_dir = os.path.dirname(script_path) | |
26 out_dir = os.path.abspath(os.path.join(ipc_fuzzer_dir, os.pardir, | |
27 os.pardir, 'out')); | |
28 build_dir = '' | |
29 chrome_path = '' | |
30 chrome_binary = 'chrome' | |
31 | |
32 for build in ['Debug', 'Release']: | |
33 try_build = os.path.join(out_dir, build) | |
34 try_chrome = os.path.join(try_build, chrome_binary) | |
35 if os.path.exists(try_chrome): | |
36 build_dir = try_build | |
37 chrome_path = try_chrome | |
38 | |
39 if not chrome_path: | |
40 print 'chrome executable not found.' | |
41 sys.exit(1) | |
42 | |
43 fuzzer_path = os.path.join(build_dir, 'ipc_fuzzer') | |
44 if not os.path.exists(fuzzer_path): | |
45 print fuzzer_path + ' not found.' | |
46 print ('Please use enable_ipc_fuzzer=1 GYP define and ' | |
47 'build ipc_fuzzer target.') | |
48 sys.exit(1) | |
49 | |
50 prefixes = { | |
51 '--renderer-cmd-prefix', | |
52 '--gpu-launcher', | |
53 '--plugin-launcher', | |
54 '--ppapi-plugin-launcher', | |
55 '--utility-cmd-prefix', | |
56 } | |
57 | |
58 args = [ | |
59 chrome_path, | |
60 '--ipc-fuzzer-testcase=' + sys.argv[-1], | |
61 '--no-sandbox', | |
62 ] | |
63 | |
64 launchers = {} | |
65 for prefix in prefixes: | |
66 launchers[prefix] = fuzzer_path | |
67 | |
68 for arg in sys.argv[1:-1]: | |
69 if arg.find('=') != -1: | |
70 switch, value = arg.split('=', 1) | |
71 if switch in prefixes: | |
72 launchers[switch] = value + ' ' + launchers[switch] | |
73 continue | |
74 args.append(arg) | |
75 | |
76 for switch, value in launchers.items(): | |
77 args.append(switch + '=' + value) | |
78 | |
79 print args | |
80 | |
81 return subprocess.call(args) | |
82 | |
83 | |
84 if __name__ == "__main__": | |
85 sys.exit(main()) | |
OLD | NEW |