blob: b9d45bceb329c61a2d4e5950c00b60f6fa8cc11d [file] [log] [blame]
#!/usr/bin/env python
# Copyright 2018 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import argparse
import json
import sys
from collections import defaultdict
def main():
parser = argparse.ArgumentParser("Creates a component manifest for a fuzzer")
parser.add_argument("--out", help="Path to the output file", required=True)
help="Path to the binary; absolute or relative to package's bin directory",
parser.add_argument("--cmx", help="Optional starting manifest")
args = parser.parse_args()
cmx = defaultdict(dict)
if args.cmx:
with open(args.cmx, "r") as f:
cmx = json.load(f)
if args.bin.startswith("/"):
# Zircon fuzz_targets are absolute paths in bootfs.
cmx["program"]["binary"] = args.bin
# Fuchsia fuzz_targets are part of a package
cmx["program"]["binary"] = "bin/" + args.bin
if "services" not in cmx["sandbox"]:
cmx["sandbox"]["services"] = []
if "features" not in cmx["sandbox"]:
cmx["sandbox"]["features"] = []
if "isolated-persistent-storage" not in cmx["sandbox"]["features"]:
with open(args.out, "w") as f:
f.write(json.dumps(cmx, sort_keys=True, indent=4))
if __name__ == "__main__":