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

Side by Side Diff: testing/libfuzzer/gen_fuzzer_runner.py

Issue 1703523002: [libfuzzer] support of custom libfuzzer options via .options file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use forward_variables_from in .gni, refactor launcher generator Created 4 years, 10 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 | « testing/libfuzzer/fuzzer_test.gni ('k') | testing/libfuzzer/tests/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2015 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2015 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Generate .sh runner for libfuzzer test. 7 """Generate .sh runner for libfuzzer test.
8 8
9 Invoked by GN from fuzzer_test.gni. 9 Invoked by GN from fuzzer_test.gni.
10 """ 10 """
11 11
12 import argparse 12 import argparse
13 import os 13 import os
14 import sys 14 import sys
15 15
16 16
17 parser = argparse.ArgumentParser(description="Generate fuzzer launcher.") 17 LAUNCHER_TEMPLATE = """#!/bin/bash
18 parser.add_argument('--fuzzer', required=True)
19 parser.add_argument('--launcher', required=True)
20 parser.add_argument('--dict', required=True)
21 args = parser.parse_args()
22
23 out = open(args.launcher, 'w')
24 out.write("""#!/bin/bash
25 set -ue 18 set -ue
26 DIR=$(dirname $0) 19 DIR=$(dirname $0)
27 $DIR/%(fuzzer)s -dict=$DIR/%(dict)s $* 20 $DIR/%(fuzzer)s %(arguments)s
28 """ % { "fuzzer": args.fuzzer, "dict": args.dict }) 21 """
29 out.close()
30 22
31 os.chmod(args.launcher, os.stat(args.launcher).st_mode | 0o111) # chmod a+x 23
24 def buildFuzzerArguments(args):
Oliver Chang 2016/02/18 22:31:42 nit: follow chromium python style guide (https://w
25 fuzzer_arguments = ""
26 if args.dict:
27 fuzzer_arguments += "-dict=$DIR/%(dict)s " % { "dict": args.dict }
28
29 fuzzer_arguments += "$*"
30
31 # Put custom parameters after $* to overwrite default values from ClusterFuzz.
Oliver Chang 2016/02/18 22:31:42 Why do we want to override values from ClusterFuzz
32 if args.params:
33 fuzzer_arguments += " %(params)s" % { "params": args.params[1 : -1]}
Oliver Chang 2016/02/18 22:31:42 why is the quoting in fuzzer_test.gni necessary if
34
35 return fuzzer_arguments
36
37
38 def main():
39 parser = argparse.ArgumentParser(description="Generate fuzzer launcher.")
40 parser.add_argument('--fuzzer', required=True)
41 parser.add_argument('--launcher', required=True)
42 parser.add_argument('--dict', required=False)
43 parser.add_argument('--params', required=False)
44 args = parser.parse_args()
45
46 fuzzer_arguments = buildFuzzerArguments(args)
47
48 launcher_source_code = LAUNCHER_TEMPLATE % {"fuzzer": args.fuzzer,
49 "arguments": fuzzer_arguments}
50
51 out = open(args.launcher, 'w')
52 out.write(launcher_source_code)
53 out.close()
54
55 os.chmod(args.launcher, os.stat(args.launcher).st_mode | 0o111) # chmod a+x
56
57
58 if __name__ == '__main__':
59 main()
OLDNEW
« no previous file with comments | « testing/libfuzzer/fuzzer_test.gni ('k') | testing/libfuzzer/tests/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698