1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3# Copyright (c) 2022 Huawei Device Co., Ltd. 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16import sys 17import os 18import argparse 19import shutil 20import subprocess 21import multiprocessing 22sys.path.append( 23 os.path.dirname(os.path.dirname(os.path.dirname( 24 os.path.abspath(__file__))))) 25 26def copytree(source, destination): 27 shutil.copytree(source, destination, dirs_exist_ok=True) 28 29def copy_file(fuzz_config_file_path, fuzz_config_file_output_path): 30 if not os.path.exists(fuzz_config_file_path): 31 raise Exception("fuzz_config_file_path '{}' doesn't exist.".format(fuzz_config_file_path)) 32 target_file_path = os.path.join(fuzz_config_file_output_path, os.path.basename(fuzz_config_file_path)) 33 try: 34 p = multiprocessing.Process(target=copytree, args=(fuzz_config_file_path, target_file_path)) 35 p.start() 36 p.join() 37 except: 38 subprocess.call(["cp", "-rf", fuzz_config_file_path, fuzz_config_file_output_path]) 39 40 41def main(): 42 parser = argparse.ArgumentParser() 43 parser.add_argument('--fuzz-config-file-path', required=True) 44 parser.add_argument('--fuzz-config-file-output-path', required=True) 45 args = parser.parse_args() 46 47 copy_file(args.fuzz_config_file_path, args.fuzz_config_file_output_path) 48 return 0 49 50 51if __name__ == '__main__': 52 sys.exit(main()) 53