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

Unified Diff: testing/libfuzzer/gen_fuzzer_config.py

Issue 1867833002: [libfuzzer] store custom options in .GN build target instead of a separate file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update reference.md of libFuzzer & CF documentation. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « testing/libfuzzer/fuzzers/v8_wasm_fuzzer.options ('k') | testing/libfuzzer/reference.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/libfuzzer/gen_fuzzer_config.py
diff --git a/testing/libfuzzer/gen_fuzzer_config.py b/testing/libfuzzer/gen_fuzzer_config.py
index 5628a30f7b5d4ce2b977c81a05f209018ed9c97e..310b7b934429fd4c3b285118bd7316c1c68280cb 100755
--- a/testing/libfuzzer/gen_fuzzer_config.py
+++ b/testing/libfuzzer/gen_fuzzer_config.py
@@ -14,34 +14,33 @@ import os
import sys
-OPTIONS_FILE_TEMPLATE = '''# This is automatically generated fuzzer config.
+CONFIG_HEADER = '''# This is an automatically generated config for libFuzzer.
[libfuzzer]
-dict = %(dict)s
'''
def main():
parser = argparse.ArgumentParser(description="Generate fuzzer config.")
parser.add_argument('--config', required=True)
- parser.add_argument('--dict', required=True)
- parser.add_argument('--libfuzzer_options', required=False)
+ parser.add_argument('--dict')
+ parser.add_argument('--libfuzzer_options', nargs='+', default=[])
args = parser.parse_args()
- config_path = args.config
- # Dict will be copied into build directory, use only its basename for config.
- dict_name = os.path.basename(args.dict)
-
- if not args.libfuzzer_options:
- # Generate .options file with initialized 'dict' option.
- with open(config_path, 'w') as options_file:
- options_file.write(OPTIONS_FILE_TEMPLATE % {'dict': dict_name})
+ # Script shouldn't be invoked without both arguments, but just in case.
+ if not args.dict and not args.libfuzzer_options:
return
- # Append 'dict' option to an existing .options file.
- initial_config = open(args.libfuzzer_options).read()
+ config_path = args.config
+ # Generate .options file.
with open(config_path, 'w') as options_file:
- options_file.write(initial_config)
- options_file.write('\ndict = %s\n' % dict_name)
+ options_file.write(CONFIG_HEADER)
+
+ # Dict will be copied into build directory, need only basename for config.
+ if args.dict:
+ options_file.write('dict = %s\n' % os.path.basename(args.dict))
+ for option in args.libfuzzer_options:
+ options_file.write(option)
+ options_file.write('\n')
if __name__ == '__main__':
main()
« no previous file with comments | « testing/libfuzzer/fuzzers/v8_wasm_fuzzer.options ('k') | testing/libfuzzer/reference.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698