Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/python2 | |
| 2 # | |
| 3 # 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.
| |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 """Archive corpus file into zip and generate .d depfile. | |
| 8 | |
| 9 Invoked by GN from fuzzer_test.gni. | |
| 10 """ | |
| 11 | |
| 12 from __future__ import print_function | |
| 13 import argparse | |
| 14 import os | |
| 15 import sys | |
| 16 import zipfile | |
| 17 | |
| 18 | |
| 19 def main(): | |
| 20 parser = argparse.ArgumentParser(description="Generate fuzzer config.") | |
| 21 parser.add_argument('--depfile', required=True) | |
| 22 parser.add_argument('--corpus', required=True) | |
| 23 parser.add_argument('--output', required=True) | |
| 24 args = parser.parse_args() | |
| 25 | |
| 26 corpus_files = [] | |
| 27 # Generate .d file with dependency from corpus archive to individual files. | |
| 28 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
| |
| 29 print(args.output, ":", end="", file=depfile) | |
| 30 for (dirpath, _, filenames) in os.walk(args.corpus): | |
| 31 for filename in filenames: | |
| 32 full_filename = os.path.join(dirpath, filename) | |
| 33 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 :
<
| |
| 34 corpus_files.append(full_filename) | |
| 35 | |
| 36 with zipfile.ZipFile(args.output, 'w') as z: | |
| 37 for corpus_file in corpus_files: | |
| 38 z.write(corpus_file, os.path.basename(corpus_file)) | |
| 39 | |
| 40 | |
| 41 if __name__ == '__main__': | |
| 42 main() | |
| 43 | |
| OLD | NEW |