예제 #1
0
def main():
    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter)

    parser.add_argument("cfg",
                        metavar="<cfg-hjson-file>",
                        help="""Configuration hjson file.""")

    parser.add_argument("-i",
                        "--items",
                        nargs="*",
                        default=["sanity"],
                        metavar="regr1, regr2, regr3|test1, test2, test3, ...",
                        help="""Indicate which regressions or tests to run.""")

    parser.add_argument(
        "-l",
        "--list",
        nargs="+",
        default=[],
        metavar="build_modes|run_modes|tests|regressions",
        help=
        """List the available build_modes / run_modes / tests / regressions for use."""
    )

    parser.add_argument("-t",
                        "--tool",
                        default="",
                        metavar="vcs|xcelium|ascentlint|...",
                        help="Override the tool that is set in hjson file")

    parser.add_argument(
        "-sr",
        "--scratch-root",
        metavar="path",
        help="""root scratch directory path where all build / run drectories go;
                      by default, the tool will create the {scratch_path} = {scratch_root}/{dut}
                      directory if it doesn't already exist; under {scratch_path}, there will be
                      {compile_set} set of directories where all the build outputs go and
                      {test_name} set of directories where the test outputs go"""
    )

    parser.add_argument(
        "-br",
        "--branch",
        default="",
        metavar="<branch-name>",
        help=
        """This variable is used to construct the scratch path directory name. If not
                specified, it defaults to the GitHub branch name. The idea is to uniquefy the
                scratch paths between different branches.""")

    parser.add_argument(
        "-bo",
        "--build-opts",
        nargs="+",
        default=[],
        metavar="",
        help="""pass additional build options over the command line;
                              note that if there are multiple compile sets identified to be built,
                              these options will be passed on to all of them"""
    )

    parser.add_argument(
        "-bm",
        "--build-modes",
        nargs="+",
        default=[],
        metavar="",
        help="""Set build modes on the command line for all tests run as a part
                              of the regression.""")

    parser.add_argument(
        "-ro",
        "--run-opts",
        nargs="+",
        default=[],
        metavar="",
        help="""pass additional run time options over the command line;
                              these options will be passed on to all tests scheduled to be run"""
    )

    parser.add_argument(
        "-rm",
        "--run-modes",
        nargs="+",
        default=[],
        metavar="",
        help="""Set run modes on the command line for all tests run as a part
                              of the regression.""")

    parser.add_argument(
        "-bu",
        "--build-unique",
        default=False,
        action='store_true',
        help=
        """By default, under the {scratch} directory, there is a {compile_set}
                              directory created where the build output goes; this can be
                              uniquified by appending the current timestamp. This is suitable
                              for the case when a test / regression already running and you want
                              to run something else from a different terminal without affecting
                              the previous one""")

    parser.add_argument(
        "--build-only",
        default=False,
        action='store_true',
        help="Only build the simulation executables for the givem items.")

    parser.add_argument(
        "--run-only",
        default=False,
        action='store_true',
        help="Assume sim exec is available and proceed to run step")

    parser.add_argument(
        "-s",
        "--seeds",
        nargs="+",
        default=[],
        metavar="seed0 seed1 ...",
        help=
        """Run tests with a specific seeds. Note that these specific seeds are applied to
           items being run in the order they are passed.""")

    parser.add_argument(
        "-r",
        "--reseed",
        type=int,
        default=-1,
        metavar="N",
        help="""Repeat tests with N iterations with different seeds""")

    parser.add_argument("-rx",
                        "--reseed-multiplier",
                        type=int,
                        default=1,
                        metavar="N",
                        help="""Multiplier for existing reseed values.""")

    parser.add_argument("-w",
                        "--waves",
                        default=False,
                        action='store_true',
                        help="Enable dumping of waves")

    parser.add_argument("-d",
                        "--dump",
                        default="fsdb",
                        metavar="fsdb|shm",
                        help="Dump waves in fsdb or shm.")

    parser.add_argument("-mw",
                        "--max-waves",
                        type=int,
                        default=5,
                        metavar="N",
                        help="""enable dumpling of waves for at most N tests;
                              this includes tests scheduled for run AND automatic rerun"""
                        )

    parser.add_argument("-c",
                        "--cov",
                        default=False,
                        action='store_true',
                        help="turn on coverage collection")

    parser.add_argument(
        "--cov-merge-previous",
        default=False,
        action='store_true',
        help="""Applicable when --cov switch is enabled. If a previous cov
                        database directory exists, this switch will cause it to be merged with
                        the current cov database.""")

    parser.add_argument(
        "--cov-analyze",
        default=False,
        action='store_true',
        help="Analyze the coverage from the last regression result.")

    parser.add_argument("-p",
                        "--profile",
                        default="none",
                        metavar="time|mem",
                        help="Turn on simulation profiling")

    parser.add_argument("--xprop-off",
                        default=False,
                        action='store_true',
                        help="Turn off Xpropagation")

    parser.add_argument("--job-prefix",
                        default="",
                        metavar="job-prefix",
                        help="Job prefix before deploying the tool commands.")

    parser.add_argument("--purge",
                        default=False,
                        action='store_true',
                        help="Clean the scratch directory before running.")

    parser.add_argument(
        "-mo",
        "--max-odirs",
        type=int,
        default=5,
        metavar="N",
        help="""When tests are run, the older runs are backed up. This switch
                              limits the number of backup directories being maintained."""
    )

    parser.add_argument(
        "--no-rerun",
        default=False,
        action='store_true',
        help=
        """by default, failing tests will be automatically be rerun with waves;
                              this option will prevent the rerun from being triggered"""
    )

    parser.add_argument("--skip-ral",
                        default=False,
                        action='store_true',
                        help="""Skip the ral generation step.""")

    parser.add_argument("-v",
                        "--verbosity",
                        default="l",
                        metavar="n|l|m|h|d",
                        help="""set verbosity to none/low/medium/high/debug;
                              This will override any setting added to any of the hjson files
                              used for config""")

    parser.add_argument("--email",
                        nargs="+",
                        default=[],
                        metavar="",
                        help="""email the report to specified addresses""")

    parser.add_argument(
        "--verbose",
        nargs="?",
        default=None,
        const="default",
        metavar="debug",
        help="""Print verbose dvsim tool messages. If 'debug' is passed, then the
                              volume of messages is ven higher.""")

    parser.add_argument("--version",
                        default=False,
                        action='store_true',
                        help="Print version and exit")

    parser.add_argument(
        "-n",
        "--dry-run",
        default=False,
        action='store_true',
        help=
        "Print dvsim tool messages only, without actually running any command")

    parser.add_argument(
        "--map-full-testplan",
        default=False,
        action='store_true',
        help="Force complete testplan annotated results to be shown at the end."
    )

    parser.add_argument(
        "--publish",
        default=False,
        action='store_true',
        help="Publish results to the reports.opentitan.org web server.")

    parser.add_argument(
        "-pi",
        "--print-interval",
        type=int,
        default=10,
        metavar="N",
        help="""Interval in seconds. Print status every N seconds.""")

    parser.add_argument(
        "-mp",
        "--max-parallel",
        type=int,
        default=16,
        metavar="N",
        help="""Run only upto a fixed number of builds/tests at a time.""")

    parser.add_argument(
        "--local",
        default=False,
        action='store_true',
        help=
        """Deploy builds and runs on the local workstation instead of the compute farm.
        Support for this has not been added yet.""")

    args = parser.parse_args()

    if args.version:
        print(version)
        sys.exit()

    # Add log level 'VERBOSE' between INFO and DEBUG
    log.addLevelName(utils.VERBOSE, 'VERBOSE')

    log_format = '%(levelname)s: [%(module)s] %(message)s'
    log_level = log.INFO
    if args.verbose == "default": log_level = utils.VERBOSE
    elif args.verbose == "debug": log_level = log.DEBUG
    log.basicConfig(format=log_format, level=log_level)

    if not os.path.exists(args.cfg):
        log.fatal("Path to config file %s appears to be invalid.", args.cfg)
        sys.exit(1)

    # If publishing results, then force full testplan mapping of results.
    if args.publish: args.map_full_testplan = True

    args.scratch_root = resolve_scratch_root(args.scratch_root)
    args.branch = resolve_branch(args.branch)
    args.cfg = os.path.abspath(args.cfg)

    # Add timestamp to args that all downstream objects can use.
    # Static variables - indicate timestamp.
    ts_format_long = "%A %B %d %Y %I:%M:%S%p %Z"
    ts_format = "%a.%m.%d.%y__%I.%M.%S%p"
    curr_ts = datetime.datetime.now()
    timestamp_long = curr_ts.strftime(ts_format_long)
    timestamp = curr_ts.strftime(ts_format)
    setattr(args, "ts_format_long", ts_format_long)
    setattr(args, "ts_format", ts_format)
    setattr(args, "timestamp_long", timestamp_long)
    setattr(args, "timestamp", timestamp)

    # Register the seeds from command line with RunTest class.
    Deploy.RunTest.seeds = args.seeds

    # Register the common deploy settings.
    Deploy.Deploy.print_interval = args.print_interval
    Deploy.Deploy.max_parallel = args.max_parallel
    Deploy.Deploy.max_odirs = args.max_odirs

    # Build infrastructure from hjson file and create the list of items to
    # be deployed.
    # TODO: SimCfg item below implies DV - need to solve this once we add FPV
    # and other ASIC flow targets.
    if args.tool == 'ascentlint':
        cfg = LintCfg.LintCfg(args.cfg, get_proj_root(), args)
    else:
        cfg = SimCfg.SimCfg(args.cfg, get_proj_root(), args)

    # List items available for run if --list switch is passed, and exit.
    if args.list != []:
        cfg.print_list()
        sys.exit(0)

    # In simulation mode: if --cov-analyze switch is passed, then run the GUI
    # tool.
    if args.cov_analyze:
        cfg.cov_analyze()
        sys.exit(0)

    # Purge the scratch path if --purge option is set.
    if args.purge:
        cfg.purge()

    # Deploy the builds and runs
    if args.items != []:
        # Create deploy objects.
        cfg.create_deploy_objects()
        cfg.deploy_objects()

        # Generate results.
        cfg.gen_results()

        # Publish results
        if args.publish: cfg.publish_results()

    else:
        log.info("No items specified to be run.")

    # Exit with non-zero status if there were errors or failures.
    if cfg.has_errors():
        log.error("Errors were encountered in this run.")
        sys.exit(1)
예제 #2
0
def main():
    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.RawDescriptionHelpFormatter)

    parser.add_argument(
        "-f",
        "--flow",
        default="sim",
        metavar="lint|elab|synth|formal|sim",
        help="which simulation flow' currently only dv flow supported")

    parser.add_argument(
        "--cfg",
        default="cfg.hjson",
        metavar="<file>",
        help="""simulation configuration file; if this is not supplied, it will
                              attempt to look for \"<flow>_cfg.hjson\" file in PWD"""
    )

    parser.add_argument(
        "items",
        nargs="*",
        default=["sanity"],
        metavar="""regr1, regr2, regr3|test1, test2, test3, ...""",
        help="""Indicate which regression or tests to run""")

    parser.add_argument(
        "--list",
        nargs="+",
        default=[],
        metavar="build_modes|run_modes|tests|regressions",
        help=
        """Provides a list of modes / tests / regressions available for use."""
    )

    parser.add_argument("-s",
                        "--simulator",
                        default="vcs",
                        metavar="vcs|xcelium",
                        help="simulator to use; the default is vcs")

    parser.add_argument(
        "-sr",
        "--scratch-root",
        default="scratch",
        metavar="path",
        help="""root scratch directory path where all build / run drectories go;
                      by default, the tool will create the {scratch_path} = {scratch_root}/{dut}
                      directory if it doesn't already exist; under {scratch_path}, there will be
                      {compile_set} set of directories where all the build outputs go and
                      {test_name} set of directories where the test outputs go"""
    )

    parser.add_argument(
        "-br",
        "--branch",
        metavar="<github-branch>",
        help="""GitHub branch name. This is used to construct the build and run
                              directories""")

    parser.add_argument(
        "-bo",
        "--build-opts",
        nargs="+",
        default=[],
        metavar="",
        help="""pass additional build options over the command line;
                              note that if there are multiple compile sets identified to be built,
                              these options will be passed on to all of them"""
    )

    parser.add_argument(
        "-bm",
        "--build-modes",
        nargs="+",
        default=[],
        metavar="",
        help="""Set build modes on the command line for all tests run as a part
                              of the regression.""")

    parser.add_argument(
        "-ro",
        "--run-opts",
        nargs="+",
        default=[],
        metavar="",
        help="""pass additional run time options over the command line;
                              these options will be passed on to all tests schedueld to be run"""
    )

    parser.add_argument(
        "-rm",
        "--run-modes",
        nargs="+",
        default=[],
        metavar="",
        help="""Set run modes on the command line for all tests run as a part
                              of the regression.""")

    parser.add_argument(
        "-bu",
        "--build-unique",
        default=False,
        action='store_true',
        help=
        """By default, under the {scratch} directory, there is a {compile_set}
                              directory created where the build output goes; this can be
                              uniquified by appending the current timestamp. This is suitable
                              for the case when a test / regression already running and you want
                              to run something else from a different terminal without affecting
                              the previous one""")

    parser.add_argument(
        "--build-only",
        default=False,
        action='store_true',
        help="Only build the simulation executables for the givem items.")

    parser.add_argument(
        "--run-only",
        default=False,
        action='store_true',
        help="Assume sim exec is available and proceed to run step")

    parser.add_argument(
        "--seeds",
        nargs="+",
        default=[],
        metavar="seed0 seed1 ...",
        help=
        """Run tests with a specific seeds; if not specified, tool will use a
                              randomly generated seed""")

    parser.add_argument(
        "--reseed",
        type=int,
        default=-1,
        metavar="N",
        help="""repeat tests with N iterations with different seeds""")

    parser.add_argument("-rx",
                        "--reseed-multiplier",
                        type=int,
                        default=1,
                        metavar="N",
                        help="""Multiplier for existing reseed values.""")

    parser.add_argument("-w",
                        "--waves",
                        default=False,
                        action='store_true',
                        help="Enable dumping of waves")

    parser.add_argument("-d",
                        "--dump",
                        default="fsdb",
                        metavar="fsdb|shm",
                        help="Dump waves in fsdb or shm.")

    parser.add_argument("-mw",
                        "--max-waves",
                        type=int,
                        default=5,
                        metavar="N",
                        help="""enable dumpling of waves for at most N tests;
                              this includes tests scheduled for run AND automatic rerun"""
                        )

    parser.add_argument("-c",
                        "--cov",
                        default=False,
                        action='store_true',
                        help="turn on coverage collection")

    parser.add_argument("-p",
                        "--profile",
                        default="none",
                        metavar="time|mem",
                        help="turn on simulation profiling")

    parser.add_argument(
        "--job-prefix",
        default="",
        metavar="job-prefix",
        help="Job prefix before deploying the simulator commands.")

    parser.add_argument("--purge",
                        default=False,
                        action='store_true',
                        help="Clean the scratch directory.")

    parser.add_argument(
        "-mo",
        "--max-odirs",
        type=int,
        default=5,
        metavar="N",
        help="""When tests are run, the older runs are backed up. This switch
                              limits the number of backup directories being maintained."""
    )

    parser.add_argument(
        "--no-rerun",
        default=False,
        action='store_true',
        help=
        """by default, failing tests will be automatically be rerun with waves;
                              this option will prevent the rerun from being triggered"""
    )

    parser.add_argument("--skip-ral",
                        default=False,
                        action='store_true',
                        help="""Skip the ral generation step.""")

    parser.add_argument("-v",
                        "--verbosity",
                        default="l",
                        metavar="n|l|m|h|d",
                        help="""set verbosity to none/low/medium/high/debug;
                              This will override any setting added to any of the hjson files
                              used for config""")

    parser.add_argument("--email",
                        nargs="+",
                        default=[],
                        metavar="",
                        help="""email the report to specified addresses""")

    parser.add_argument(
        "--verbose",
        nargs="?",
        default=None,
        const="default",
        metavar="debug",
        help="""Print verbose dvsim tool messages. If 'debug' is passed, then the
                              volume of messages is ven higher.""")

    parser.add_argument("--version",
                        default=False,
                        action='store_true',
                        help="Print version and exit")

    parser.add_argument(
        "-n",
        "--dry-run",
        default=False,
        action='store_true',
        help=
        "Print dvsim tool messages only, without actually running any command")

    parser.add_argument(
        "-pi",
        "--print-interval",
        type=int,
        default=10,
        metavar="N",
        help="""Interval in seconds. Print status every N seconds.""")

    parser.add_argument(
        "-mp",
        "--max-parallel",
        type=int,
        default=32,
        metavar="N",
        help="""Run only upto a fixed number of builds/tests at a time.""")

    args = parser.parse_args()

    if args.version:
        print(version)
        sys.exit()

    # Add log level 'VERBOSE' between INFO and DEBUG
    log.addLevelName(utils.VERBOSE, 'VERBOSE')

    log_format = '%(levelname)s: [%(module)s] %(message)s'
    log_level = log.INFO
    if args.verbose == "default": log_level = utils.VERBOSE
    elif args.verbose == "debug": log_level = log.DEBUG
    log.basicConfig(format=log_format, level=log_level)

    if args.cfg == "cfg.hjson": args.cfg = args.flow + "_" + args.cfg
    if not os.path.exists(args.cfg):
        log.fatal("Simulation config file %s appears to be invalid.", args.cfg)
        sys.exit(1)

    args.scratch_root = resolve_scratch_root(args.scratch_root)
    args.branch = resolve_branch(args.branch)
    args.cfg = os.path.abspath(args.cfg)

    cfg = SimCfg.SimCfg(proj_root=get_proj_root(), args=args)