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

Unified Diff: testing/libfuzzer/archive_corpus.py

Issue 1768743002: [libfuzzer] in-vcs corpus support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: making sure 2nd build doesn't build anything. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | testing/libfuzzer/fuzzer_test.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: testing/libfuzzer/archive_corpus.py
diff --git a/testing/libfuzzer/archive_corpus.py b/testing/libfuzzer/archive_corpus.py
new file mode 100755
index 0000000000000000000000000000000000000000..fa90a5a10bbcce07793e8a1dcebedfadc8838c91
--- /dev/null
+++ b/testing/libfuzzer/archive_corpus.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python2
+#
+# Copyright 2016 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.
+
+"""Archive corpus file into zip and generate .d depfile.
+
+Invoked by GN from fuzzer_test.gni.
+"""
+
+from __future__ import print_function
+import argparse
+import os
+import sys
+import zipfile
+
+
+def main():
+ parser = argparse.ArgumentParser(description="Generate fuzzer config.")
+ parser.add_argument('--depfile', required=True)
+ parser.add_argument('--corpus', required=True)
+ parser.add_argument('--output', required=True)
+ parser.add_argument('--fuzzer', required=True)
+ args = parser.parse_args()
+
+ corpus_files = []
+ # Generate .d file with dependency from corpus archive to individual files.
+ with open(args.depfile, 'w') as depfile:
+ print(os.path.basename(args.output), ":", end="", file=depfile)
+ for (dirpath, _, filenames) in os.walk(args.corpus):
+ for filename in filenames:
+ full_filename = os.path.join(dirpath, filename)
+ print(" ", full_filename, end="", file=depfile)
+ corpus_files.append(full_filename)
+ # chrome bots complain about this one:
+ # print(" ", args.fuzzer, end="", file=depfile)
+
+ with zipfile.ZipFile(args.output, 'w') as z:
+ for corpus_file in corpus_files:
+ z.write(corpus_file, os.path.basename(corpus_file))
+
+
+if __name__ == '__main__':
+ main()
+
« no previous file with comments | « no previous file | testing/libfuzzer/fuzzer_test.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698