Chromium Code Reviews| 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..99bfeb966f8b9702ffb1cb2de4002c7de72b0893 |
| --- /dev/null |
| +++ b/testing/libfuzzer/archive_corpus.py |
| @@ -0,0 +1,43 @@ |
| +#!/usr/bin/python2 |
| +# |
| +# Copyright (c) 2015 The Chromium Authors. All rights reserved. |
|
mmoroz
2016/03/07 14:08:55
There is no "(c)" now, 2015 -> 2016.
Looks like w
aizatsky
2016/03/07 21:42:54
Done.
|
| +# 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) |
| + args = parser.parse_args() |
| + |
| + corpus_files = [] |
| + # Generate .d file with dependency from corpus archive to individual files. |
| + with open(args.depfile, 'w') as depfile: |
|
mmoroz
2016/03/07 14:08:55
Do we need this .d file? On ClusterFuzz side we ca
aizatsky
2016/03/07 21:42:54
This file is needed for gn/ninja. I've also added
|
| + print(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) |
|
mmoroz
2016/03/07 14:08:55
Seems that this call will write strings like "<spa
aizatsky
2016/03/07 21:42:54
Number of spaces is irrelevant. The format is :
<
|
| + corpus_files.append(full_filename) |
| + |
| + 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() |
| + |