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

Unified 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, 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 side-by-side diff with in-line comments
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 »
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
new file mode 100755
index 0000000000000000000000000000000000000000..5628a30f7b5d4ce2b977c81a05f209018ed9c97e
--- /dev/null
+++ b/testing/libfuzzer/gen_fuzzer_config.py
@@ -0,0 +1,47 @@
+#!/usr/bin/python2
+#
+# Copyright (c) 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Generate or update an existing config (.options file) for libfuzzer test.
+
+Invoked by GN from fuzzer_test.gni.
+"""
+
+import argparse
+import os
+import sys
+
+
+OPTIONS_FILE_TEMPLATE = '''# This is automatically generated fuzzer config.
+[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)
+ 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})
+ return
+
+ # Append 'dict' option to an existing .options file.
+ initial_config = open(args.libfuzzer_options).read()
+ with open(config_path, 'w') as options_file:
+ options_file.write(initial_config)
+ options_file.write('\ndict = %s\n' % dict_name)
+
+
+if __name__ == '__main__':
+ main()
« 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