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

Side by Side Diff: tools/ipc_fuzzer/mutate/cf_package_builder.py

Issue 1025483002: Restructure the ipc_fuzzer directory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move more files around Created 5 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 unified diff | Download patch
« no previous file with comments | « tools/ipc_fuzzer/mutate/DEPS ('k') | tools/ipc_fuzzer/mutate/fuzzer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Creates IPC fuzzer packages suitable for uploading to ClusterFuzz. Stores
7 the packages into chrome build directory. See fuzzer_list below for the list of
8 fuzzers.
9 """
10
11 import argparse
12 import distutils.archive_util
13 import os
14 import shutil
15 import sys
16 import tempfile
17
18 FUZZER_LIST = [
19 'ipc_fuzzer_mut',
20 'ipc_fuzzer_gen',
21 ]
22
23 class CFPackageBuilder:
24 def __init__(self):
25 self.fuzzer_list = FUZZER_LIST
26
27 def parse_arguments(self):
28 desc = 'Builder of IPC fuzzer packages for ClusterFuzz'
29 parser = argparse.ArgumentParser(description=desc)
30 parser.add_argument('--out-dir', dest='out_dir', default='out',
31 help='output directory under src/ directory')
32 parser.add_argument('--build-type', dest='build_type', default='Release',
33 help='Debug vs. Release build')
34 self.args = parser.parse_args()
35
36 def set_application_paths(self):
37 script_path = os.path.realpath(__file__)
38 self.mutate_dir = os.path.dirname(script_path)
39 src_dir = os.path.join(self.mutate_dir, os.pardir, os.pardir, os.pardir)
40 src_dir = os.path.abspath(src_dir)
41 out_dir = os.path.join(src_dir, self.args.out_dir)
42 self.build_dir = os.path.join(out_dir, self.args.build_type)
43
44 def switch_to_temp_work_directory(self):
45 self.old_cwd = os.getcwd()
46 self.work_dir = tempfile.mkdtemp()
47 os.chdir(self.work_dir)
48
49 def remove_temp_work_directory(self):
50 os.chdir(self.old_cwd)
51 shutil.rmtree(self.work_dir)
52
53 def build_package(self, fuzzer):
54 os.makedirs(fuzzer)
55 fuzzer_src_path = os.path.join(self.mutate_dir, fuzzer + '.py')
56 fuzzer_dst_path = os.path.join(fuzzer, 'run.py')
57 shutil.copyfile(fuzzer_src_path, fuzzer_dst_path)
58 utils_src_path = os.path.join(self.mutate_dir, 'utils.py')
59 utils_dst_path = os.path.join(fuzzer, 'utils.py')
60 shutil.copyfile(utils_src_path, utils_dst_path)
61 distutils.archive_util.make_zipfile(fuzzer, fuzzer)
62 package_name = fuzzer + '.zip'
63 shutil.copy(package_name, self.build_dir)
64 final_package_path = os.path.join(self.build_dir, package_name)
65 print 'Built %s.' % final_package_path
66
67 def main(self):
68 self.parse_arguments()
69 self.set_application_paths()
70 self.switch_to_temp_work_directory()
71 for fuzzer in self.fuzzer_list:
72 self.build_package(fuzzer)
73 self.remove_temp_work_directory()
74
75 return 0
76
77 if __name__ == "__main__":
78 builder = CFPackageBuilder()
79 sys.exit(builder.main())
OLDNEW
« no previous file with comments | « tools/ipc_fuzzer/mutate/DEPS ('k') | tools/ipc_fuzzer/mutate/fuzzer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698