WiFiServiceImpl (Windows): Fixed wrong authentication type with WEP-PSK.
[chromium-blink-merge.git] / tools / ipc_fuzzer / scripts / cf_package_builder.py
blob1fc98d186934c3c2f52aaa2107c2fb693ed39cde
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.
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 """
11 import argparse
12 import distutils.archive_util
13 import os
14 import shutil
15 import sys
16 import tempfile
18 FUZZER_LIST = [
19 'ipc_fuzzer_mut',
20 'ipc_fuzzer_gen',
23 class CFPackageBuilder:
24 def __init__(self):
25 self.fuzzer_list = FUZZER_LIST
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()
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)
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)
49 def remove_temp_work_directory(self):
50 os.chdir(self.old_cwd)
51 shutil.rmtree(self.work_dir)
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
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()
75 return 0
77 if __name__ == "__main__":
78 builder = CFPackageBuilder()
79 sys.exit(builder.main())