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

Side by Side Diff: testing/libfuzzer/gen_fuzzer_config.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: fix nits in check_fuzzer_config.py script and fuzzer_launcher_test.cc Created 4 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 | « testing/libfuzzer/fuzzer_test.gni ('k') | testing/libfuzzer/gen_fuzzer_runner.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/python2
2 #
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
5 # found in the LICENSE file.
6
7 """Generate or update an existing config (.options file) for libfuzzer test.
8
9 Invoked by GN from fuzzer_test.gni.
10 """
11
12 import argparse
13 import os
14 import sys
15
16
17 OPTIONS_FILE_TEMPLATE = '''# This is automatically generated fuzzer config.
18 [libfuzzer]
19 dict = %(dict)s
20 '''
21
22 def main():
23 parser = argparse.ArgumentParser(description="Generate fuzzer config.")
24 parser.add_argument('--config', required=True)
25 parser.add_argument('--dict', required=True)
26 parser.add_argument('--libfuzzer_options', required=False)
27 args = parser.parse_args()
28
29 config_path = args.config
30 # Dict will be copied into build directory, use only its basename for config.
31 dict_name = os.path.basename(args.dict)
32
33 if not args.libfuzzer_options:
34 # Generate .options file with initialized 'dict' option.
35 with open(config_path, 'w') as options_file:
36 options_file.write(OPTIONS_FILE_TEMPLATE % {'dict': dict_name})
37 return
38
39 # Append 'dict' option to an existing .options file.
40 initial_config = open(args.libfuzzer_options).read()
41 with open(config_path, 'w') as options_file:
42 options_file.write(initial_config)
43 options_file.write('\ndict = %s\n' % dict_name)
44
45
46 if __name__ == '__main__':
47 main()
OLDNEW
« no previous file with comments | « testing/libfuzzer/fuzzer_test.gni ('k') | testing/libfuzzer/gen_fuzzer_runner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698