components/zucchini/fuzzers/generate_fuzzer_data.py
def gen(old_file, new_file, patch_file, output_file, is_raw, is_win):
  """Generates a new patch and binary encodes a protobuf pair."""
  # Create output directory if missing.
  output_dir = os.path.dirname(output_file)
  if not os.path.exists(output_dir):
    os.makedirs(output_dir)

  # Handle Windows executable names.
  zucchini = 'zucchini'
  protoc = 'protoc'
  if is_win:
    zucchini += '.exe'
    protoc += '.exe'

  zuc_cmd = [os.path.abspath(zucchini), '-gen']
  if is_raw:
    zuc_cmd.append('-raw')
  # Generate a new patch.
  ret = subprocess.call(zuc_cmd + [old_file, new_file, patch_file],
                        stdout=subprocess.PIPE,
                        stderr=subprocess.PIPE)
  if ret:
    logging.error('Patch generation failed for ({}, {})'.format(old_file,
                                                                new_file))
    return ret
  # Binary encode the protobuf pair.
  ret = subprocess.call([sys.executable,
                         os.path.join(ABS_PATH, 'create_seed_file_pair.py'),
                         os.path.abspath(protoc), old_file, patch_file,
                         output_file])
  os.remove(patch_file)
  return ret
Generates a new patch and binary encodes a protobuf pair.
Generates a new patch and binary encodes a protobuf pair.
Generates a new patch and binary encodes a protobuf pair .
def gen(old_file, new_file, patch_file, output_file, is_raw, is_win):
  output_dir = os.path.dirname(output_file)
  if not os.path.exists(output_dir):
    os.makedirs(output_dir)
  zucchini = 'zucchini'
  protoc = 'protoc'
  if is_win:
    zucchini += '.exe'
    protoc += '.exe'
  zuc_cmd = [os.path.abspath(zucchini), '-gen']
  if is_raw:
    zuc_cmd.append('-raw')
  ret = subprocess.call(zuc_cmd + [old_file, new_file, patch_file],
                        stdout=subprocess.PIPE,
                        stderr=subprocess.PIPE)
  if ret:
    logging.error('Patch generation failed for ({}, {})'.format(old_file,
                                                                new_file))
    return ret
  ret = subprocess.call([sys.executable,
                         os.path.join(ABS_PATH, 'create_seed_file_pair.py'),
                         os.path.abspath(protoc), old_file, patch_file,
                         output_file])
  os.remove(patch_file)
  return ret
def gen ( old_file , new_file , patch_file , output_file , is_raw , is_win ) : output_dir = os . path . dirname ( output_file ) if not os . path . exists ( output_dir ) : os . makedirs ( output_dir ) zucchini = 'zucchini' protoc = 'protoc' if is_win : zucchini += '.exe' protoc += '.exe' zuc_cmd = [ os . path . abspath ( zucchini ) , '-gen' ] if is_raw : zuc_cmd . append ( '-raw' ) ret = subprocess . call ( zuc_cmd + [ old_file , new_file , patch_file ] , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) if ret : logging . error ( 'Patch generation failed for ({}, {})' . format ( old_file , new_file ) ) return ret ret = subprocess . call ( [ sys . executable , os . path . join ( ABS_PATH , 'create_seed_file_pair.py' ) , os . path . abspath ( protoc ) , old_file , patch_file , output_file ] ) os . remove ( patch_file ) return ret
Generates a new patch and binary encodes a protobuf pair.
Generates a new patch and binary encodes a protobuf pair .
"""Generates a new patch and binary encodes a protobuf pair.""" # Create output directory if missing. # Handle Windows executable names. # Generate a new patch. # Binary encode the protobuf pair.
old_file
new_file
patch_file
output_file
is_raw
is_win