コード例 #1
0
ファイル: reproduce.py プロジェクト: harmzway/clusterfuzz
def _prepare_initial_environment(build_directory):
    """Prepare common environment variables that don't depend on the job."""
    # Create a temporary directory to use as ROOT_DIR with a copy of the default
    # bot and configuration directories nested under it.
    root_dir = environment.get_value('ROOT_DIR')
    temp_root_dir = tempfile.mkdtemp()
    environment.set_value('ROOT_DIR', temp_root_dir)

    common.update_dir(os.path.join(root_dir, 'bot'),
                      os.path.join(temp_root_dir, 'bot'))
    common.update_dir(os.path.join(root_dir, 'configs'),
                      os.path.join(temp_root_dir, 'configs'))
    common.update_dir(os.path.join(root_dir, 'resources'),
                      os.path.join(temp_root_dir, 'resources'))
    common.update_dir(os.path.join(root_dir, 'src'),
                      os.path.join(temp_root_dir, 'src'))

    environment.set_value('CONFIG_DIR_OVERRIDE',
                          os.path.join(temp_root_dir, 'configs', 'test'))
    environment.set_value(
        'PYTHONPATH',
        os.pathsep.join(
            [os.path.join(temp_root_dir, 'src'),
             appengine.find_sdk_path()]))

    environment.set_bot_environment()

    # Overrides that should not be set to the default values.
    environment.set_value('APP_DIR', build_directory)
    environment.set_value('BUILD_DIR', build_directory)
    environment.set_value('BUILDS_DIR', build_directory)
コード例 #2
0
def _setup_bot_directory(args):
    """Set up the bot directory."""
    appengine.symlink_config_dir()

    src_root_dir = os.path.abspath('.')
    if os.path.exists(args.directory):
        print('Bot directory already exists. Re-using...')
    else:
        print('Creating new CF bot directory...')
        os.makedirs(args.directory)

    clusterfuzz_dir = os.path.join(args.directory, 'clusterfuzz')
    bot_src_dir = os.path.join(clusterfuzz_dir, 'src')
    if not os.path.exists(clusterfuzz_dir):
        os.makedirs(clusterfuzz_dir)
        os.mkdir(bot_src_dir)

    common.update_dir(os.path.join(src_root_dir, 'src', 'appengine'),
                      os.path.join(bot_src_dir, 'appengine'))
    common.update_dir(os.path.join(src_root_dir, 'src', 'protos'),
                      os.path.join(bot_src_dir, 'protos'))
    common.update_dir(os.path.join(src_root_dir, 'src', 'python'),
                      os.path.join(bot_src_dir, 'python'))
    common.update_dir(os.path.join(src_root_dir, 'src', 'third_party'),
                      os.path.join(bot_src_dir, 'third_party'))

    common.update_dir(os.path.join(src_root_dir, 'resources'),
                      os.path.join(clusterfuzz_dir, 'resources'))
    common.update_dir(os.path.join(src_root_dir, 'bot'),
                      os.path.join(clusterfuzz_dir, 'bot'))