tools/code_coverage/run_fuzz_target.py
def _PrepareCorpus(fuzzer_name, output_dir):
  """Prepares the corpus to run fuzzer target.

  If a corpus for bots is available, use it directly, otherwise, creates a
  dummy corpus.

  Args:
    fuzzer_name (str): Name of the fuzzer to create corpus for.
    output_dir (str): An output directory to store artifacts.

  Returns:
    A path to the directory of the prepared corpus.
  """
  corpus_dir = os.path.join(output_dir, fuzzer_name + '_corpus')
  _RecreateDir(corpus_dir)

  corpus_for_bots = glob.glob(
      os.path.join(os.path.abspath(_CORPUS_FOR_BOTS_DIR), fuzzer_name, '*.zip'))
  if len(corpus_for_bots) >= 2:
    raise RuntimeError(
        'Expected only one, but multiple versions of corpus exit')

  if len(corpus_for_bots) == 1:
    zipfile.ZipFile(corpus_for_bots[0]).extractall(path=corpus_dir)
    return corpus_dir

  logging.info('Corpus for %s does not exist, create a dummy corpus input',
               fuzzer_name)
  dummy_input_path = os.path.join(corpus_dir, _DUMMY_INPUT_FILENAME)
  with open(dummy_input_path, 'wb') as fh:
    fh.write(_DUMMY_INPUT_CONTENTS)

  return corpus_dir
Prepares the corpus to run fuzzer target.

  If a corpus for bots is available, use it directly, otherwise, creates a
  dummy corpus.

  Args:
    fuzzer_name (str): Name of the fuzzer to create corpus for.
    output_dir (str): An output directory to store artifacts.

  Returns:
    A path to the directory of the prepared corpus.
  
Prepares the corpus to run fuzzer target.
If a corpus for bots is available, use it directly, otherwise, creates a
dummy corpus.
Prepares the corpus to run fuzzer target . If a corpus for bots is available use it directly otherwise creates a dummy corpus .
def _PrepareCorpus(fuzzer_name, output_dir):
  corpus_dir = os.path.join(output_dir, fuzzer_name + '_corpus')
  _RecreateDir(corpus_dir)
  corpus_for_bots = glob.glob(
      os.path.join(os.path.abspath(_CORPUS_FOR_BOTS_DIR), fuzzer_name, '*.zip'))
  if len(corpus_for_bots) >= 2:
    raise RuntimeError(
        'Expected only one, but multiple versions of corpus exit')
  if len(corpus_for_bots) == 1:
    zipfile.ZipFile(corpus_for_bots[0]).extractall(path=corpus_dir)
    return corpus_dir
  logging.info('Corpus for %s does not exist, create a dummy corpus input',
               fuzzer_name)
  dummy_input_path = os.path.join(corpus_dir, _DUMMY_INPUT_FILENAME)
  with open(dummy_input_path, 'wb') as fh:
    fh.write(_DUMMY_INPUT_CONTENTS)
  return corpus_dir
def _PrepareCorpus ( fuzzer_name , output_dir ) : corpus_dir = os . path . join ( output_dir , fuzzer_name + '_corpus' ) _RecreateDir ( corpus_dir ) corpus_for_bots = glob . glob ( os . path . join ( os . path . abspath ( _CORPUS_FOR_BOTS_DIR ) , fuzzer_name , '*.zip' ) ) if len ( corpus_for_bots ) >= 2 : raise RuntimeError ( 'Expected only one, but multiple versions of corpus exit' ) if len ( corpus_for_bots ) == 1 : zipfile . ZipFile ( corpus_for_bots [ 0 ] ) . extractall ( path = corpus_dir ) return corpus_dir logging . info ( 'Corpus for %s does not exist, create a dummy corpus input' , fuzzer_name ) dummy_input_path = os . path . join ( corpus_dir , _DUMMY_INPUT_FILENAME ) with open ( dummy_input_path , 'wb' ) as fh : fh . write ( _DUMMY_INPUT_CONTENTS ) return corpus_dir
Prepares the corpus to run fuzzer target.
Prepares the corpus to run fuzzer target .
"""Prepares the corpus to run fuzzer target.

  If a corpus for bots is available, use it directly, otherwise, creates a
  dummy corpus.

  Args:
    fuzzer_name (str): Name of the fuzzer to create corpus for.
    output_dir (str): An output directory to store artifacts.

  Returns:
    A path to the directory of the prepared corpus.
  """
A path to the directory of the prepared corpus.
A path to the directory of the prepared corpus .
fuzzer_name
Name of the fuzzer to create corpus for.
Name of the fuzzer to create corpus for .
output_dir
An output directory to store artifacts.
An output directory to store artifacts .