Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # Copyright lowRISC contributors. |
| 3 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 5 | """dvsim is a command line tool to deploy ASIC tool flows such as regressions |
| 6 | for design verification (DV), formal property verification (FPV), linting and |
| 7 | synthesis. |
| 8 | |
| 9 | It uses hjson as the format for specifying what to build and run. It is an |
| 10 | end-to-end regression manager that can deploy multiple builds (where some tests |
| 11 | might need different set of compile time options requiring a uniquely build sim |
| 12 | executable) in parallel followed by tests in parallel using the load balancer |
| 13 | of your choice. |
| 14 | |
| 15 | dvsim is built to be tool-agnostic so that you can easily switch between the |
| 16 | tools at your disposal. dvsim uses fusesoc as the starting step to resolve all |
| 17 | inter-package dependencies and provide us with a filelist that will be consumed |
| 18 | by the sim tool. |
| 19 | |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 20 | """ |
| 21 | |
| 22 | import argparse |
Srikrishna Iyer | 544da8d | 2020-01-14 23:51:41 -0800 | [diff] [blame] | 23 | import datetime |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 24 | import logging as log |
| 25 | import os |
Cindy Chen | ec6449e | 2020-12-17 11:55:38 -0800 | [diff] [blame] | 26 | import shutil |
Eunchan Kim | 87e8f85 | 2021-01-05 09:03:01 -0800 | [diff] [blame^] | 27 | import shlex |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 28 | import subprocess |
| 29 | import sys |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 30 | import textwrap |
Weicai Yang | fc2ff3b | 2020-03-19 18:05:14 -0700 | [diff] [blame] | 31 | from signal import SIGINT, signal |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 32 | |
Udi Jonnalagadda | df49fb8 | 2020-03-17 11:05:17 -0700 | [diff] [blame] | 33 | import Deploy |
Udi Jonnalagadda | df49fb8 | 2020-03-17 11:05:17 -0700 | [diff] [blame] | 34 | import utils |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 35 | from CfgFactory import make_cfg |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 36 | |
| 37 | # TODO: add dvsim_cfg.hjson to retrieve this info |
| 38 | version = 0.1 |
| 39 | |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 40 | # By default, all build and run artifacts go here. |
| 41 | DEFAULT_SCRATCH_ROOT = os.getcwd() + "/scratch" |
| 42 | |
Rupert Swarbrick | e83b55e | 2020-05-12 11:44:04 +0100 | [diff] [blame] | 43 | # The different categories that can be passed to the --list argument. |
| 44 | _LIST_CATEGORIES = ["build_modes", "run_modes", "tests", "regressions"] |
| 45 | |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 46 | |
| 47 | # Function to resolve the scratch root directory among the available options: |
| 48 | # If set on the command line, then use that as a preference. |
| 49 | # Else, check if $SCRATCH_ROOT env variable exists and is a directory. |
| 50 | # Else use the default (<cwd>/scratch) |
| 51 | # Try to create the directory if it does not already exist. |
| 52 | def resolve_scratch_root(arg_scratch_root): |
| 53 | scratch_root = os.environ.get('SCRATCH_ROOT') |
Rupert Swarbrick | 0638368 | 2020-03-24 15:56:41 +0000 | [diff] [blame] | 54 | if not arg_scratch_root: |
| 55 | if scratch_root is None: |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 56 | arg_scratch_root = DEFAULT_SCRATCH_ROOT |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 57 | else: |
| 58 | # Scratch space could be mounted in a filesystem (such as NFS) on a network drive. |
| 59 | # If the network is down, it could cause the access access check to hang. So run a |
| 60 | # simple ls command with a timeout to prevent the hang. |
| 61 | (out, |
| 62 | status) = utils.run_cmd_with_timeout(cmd="ls -d " + scratch_root, |
Srikrishna Iyer | 544da8d | 2020-01-14 23:51:41 -0800 | [diff] [blame] | 63 | timeout=1, |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 64 | exit_on_failure=0) |
| 65 | if status == 0 and out != "": |
| 66 | arg_scratch_root = scratch_root |
| 67 | else: |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 68 | arg_scratch_root = DEFAULT_SCRATCH_ROOT |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 69 | log.warning( |
Rupert Swarbrick | 0638368 | 2020-03-24 15:56:41 +0000 | [diff] [blame] | 70 | "Env variable $SCRATCH_ROOT=\"{}\" is not accessible.\n" |
| 71 | "Using \"{}\" instead.".format(scratch_root, |
| 72 | arg_scratch_root)) |
Srikrishna Iyer | 544da8d | 2020-01-14 23:51:41 -0800 | [diff] [blame] | 73 | else: |
| 74 | arg_scratch_root = os.path.realpath(arg_scratch_root) |
| 75 | |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 76 | try: |
| 77 | os.system("mkdir -p " + arg_scratch_root) |
Rupert Swarbrick | 0638368 | 2020-03-24 15:56:41 +0000 | [diff] [blame] | 78 | except OSError: |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 79 | log.fatal( |
| 80 | "Invalid --scratch-root=\"%s\" switch - failed to create directory!", |
| 81 | arg_scratch_root) |
| 82 | sys.exit(1) |
| 83 | return (arg_scratch_root) |
| 84 | |
| 85 | |
Rupert Swarbrick | 536ab20 | 2020-06-09 16:37:12 +0100 | [diff] [blame] | 86 | def read_max_parallel(arg): |
| 87 | '''Take value for --max-parallel as an integer''' |
| 88 | try: |
| 89 | int_val = int(arg) |
| 90 | if int_val <= 0: |
| 91 | raise ValueError('bad value') |
| 92 | return int_val |
| 93 | |
| 94 | except ValueError: |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 95 | raise argparse.ArgumentTypeError( |
| 96 | 'Bad argument for --max-parallel ' |
| 97 | '({!r}): must be a positive integer.'.format(arg)) |
Rupert Swarbrick | 536ab20 | 2020-06-09 16:37:12 +0100 | [diff] [blame] | 98 | |
| 99 | |
| 100 | def resolve_max_parallel(arg): |
| 101 | '''Pick a value of max_parallel, defaulting to 16 or $DVSIM_MAX_PARALLEL''' |
| 102 | if arg is not None: |
| 103 | assert arg > 0 |
| 104 | return arg |
| 105 | |
| 106 | from_env = os.environ.get('DVSIM_MAX_PARALLEL') |
| 107 | if from_env is not None: |
| 108 | try: |
| 109 | return read_max_parallel(from_env) |
| 110 | except argparse.ArgumentTypeError: |
| 111 | log.warning('DVSIM_MAX_PARALLEL environment variable has value ' |
| 112 | '{!r}, which is not a positive integer. Using default ' |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 113 | 'value (16).'.format(from_env)) |
Rupert Swarbrick | 536ab20 | 2020-06-09 16:37:12 +0100 | [diff] [blame] | 114 | |
| 115 | return 16 |
| 116 | |
| 117 | |
Rupert Swarbrick | e83b55e | 2020-05-12 11:44:04 +0100 | [diff] [blame] | 118 | def resolve_branch(branch): |
| 119 | '''Choose a branch name for output files |
| 120 | |
| 121 | If the --branch argument was passed on the command line, the branch |
| 122 | argument is the branch name to use. Otherwise it is None and we use git to |
| 123 | find the name of the current branch in the working directory. |
| 124 | |
| 125 | ''' |
| 126 | |
| 127 | if branch is not None: |
| 128 | return branch |
| 129 | |
| 130 | result = subprocess.run(["git", "rev-parse", "--abbrev-ref", "HEAD"], |
| 131 | stdout=subprocess.PIPE) |
| 132 | branch = result.stdout.decode("utf-8").strip() |
| 133 | if not branch: |
| 134 | log.warning("Failed to find current git branch. " |
| 135 | "Setting it to \"default\"") |
| 136 | branch = "default" |
| 137 | |
| 138 | return branch |
| 139 | |
| 140 | |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 141 | # Get the project root directory path - this is used to construct the full paths |
| 142 | def get_proj_root(): |
Rupert Swarbrick | 0638368 | 2020-03-24 15:56:41 +0000 | [diff] [blame] | 143 | cmd = ["git", "rev-parse", "--show-toplevel"] |
| 144 | result = subprocess.run(cmd, |
Rupert Swarbrick | 1dd327bd | 2020-03-24 15:14:00 +0000 | [diff] [blame] | 145 | stdout=subprocess.PIPE, |
| 146 | stderr=subprocess.PIPE) |
Udi Jonnalagadda | a122dda | 2020-03-13 16:56:45 -0700 | [diff] [blame] | 147 | proj_root = result.stdout.decode("utf-8").strip() |
Rupert Swarbrick | 0638368 | 2020-03-24 15:56:41 +0000 | [diff] [blame] | 148 | if not proj_root: |
Udi Jonnalagadda | a122dda | 2020-03-13 16:56:45 -0700 | [diff] [blame] | 149 | log.error( |
Rupert Swarbrick | 0638368 | 2020-03-24 15:56:41 +0000 | [diff] [blame] | 150 | "Attempted to find the root of this GitHub repository by running:\n" |
| 151 | "{}\n" |
| 152 | "But this command has failed:\n" |
| 153 | "{}".format(' '.join(cmd), result.stderr.decode("utf-8"))) |
Udi Jonnalagadda | a122dda | 2020-03-13 16:56:45 -0700 | [diff] [blame] | 154 | sys.exit(1) |
| 155 | return (proj_root) |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 156 | |
| 157 | |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 158 | def resolve_proj_root(args): |
| 159 | '''Update proj_root based on how DVSim is invoked. |
| 160 | |
| 161 | If --remote env var is set, a location in the scratch area is chosen as the |
| 162 | new proj_root. The entire repo is copied over to this location. Else, the |
| 163 | proj_root is discovered using get_proj_root() method, unless the user |
| 164 | overrides it on the command line. |
| 165 | |
Cindy Chen | 13a5dde | 2020-12-21 09:31:56 -0800 | [diff] [blame] | 166 | This function returns the updated proj_root src and destination path. If |
| 167 | --remote env var is not set, the destination path is identical to the src path. |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 168 | ''' |
Cindy Chen | 13a5dde | 2020-12-21 09:31:56 -0800 | [diff] [blame] | 169 | proj_root_src = args.proj_root or get_proj_root() |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 170 | |
| 171 | # Check if jobs are dispatched to external compute machines. If yes, |
| 172 | # then the repo needs to be copied over to the scratch area |
| 173 | # accessible to those machines. |
Cindy Chen | ec6449e | 2020-12-17 11:55:38 -0800 | [diff] [blame] | 174 | # If --purge arg is set, then purge the repo_top that was copied before. |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 175 | if args.remote: |
Cindy Chen | 13a5dde | 2020-12-21 09:31:56 -0800 | [diff] [blame] | 176 | proj_root_dest = os.path.join(args.scratch_root, args.branch, |
| 177 | "repo_top") |
Srikrishna Iyer | ab4327e | 2020-12-29 12:49:07 -0800 | [diff] [blame] | 178 | if args.purge: |
| 179 | shutil.rmtree(proj_root_dest, ignore_errors=True) |
Cindy Chen | 13a5dde | 2020-12-21 09:31:56 -0800 | [diff] [blame] | 180 | copy_repo(proj_root_src, proj_root_dest, args.dry_run) |
| 181 | else: |
| 182 | proj_root_dest = proj_root_src |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 183 | |
Cindy Chen | 13a5dde | 2020-12-21 09:31:56 -0800 | [diff] [blame] | 184 | return proj_root_src, proj_root_dest |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 185 | |
| 186 | |
Weicai Yang | fc2ff3b | 2020-03-19 18:05:14 -0700 | [diff] [blame] | 187 | def sigint_handler(signal_received, frame): |
| 188 | # Kill processes and background jobs. |
| 189 | log.debug('SIGINT or CTRL-C detected. Exiting gracefully') |
| 190 | cfg.kill() |
| 191 | log.info('Exit due to SIGINT or CTRL-C ') |
| 192 | exit(1) |
| 193 | |
| 194 | |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 195 | def copy_repo(src, dest, dry_run): |
| 196 | '''Copy over the repo to a new location. |
| 197 | |
| 198 | The repo is copied over from src to dest area. It tentatively uses the |
| 199 | rsync utility which provides the ability to specify a file containing some |
| 200 | exclude patterns to skip certain things from being copied over. With GitHub |
| 201 | repos, an existing `.gitignore` serves this purpose pretty well. |
| 202 | ''' |
Srikrishna Iyer | ab4327e | 2020-12-29 12:49:07 -0800 | [diff] [blame] | 203 | rsync_cmd = "rsync --recursive --links --checksum --update --inplace " |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 204 | |
| 205 | # Supply `.gitignore` from the src area to skip temp files. |
| 206 | ignore_patterns_file = os.path.join(src, ".gitignore") |
| 207 | if os.path.exists(ignore_patterns_file): |
| 208 | # TODO: hack - include hw/foundry since it is excluded in .gitignore. |
| 209 | rsync_cmd += "--include=hw/foundry " |
| 210 | rsync_cmd += "--exclude-from={} ".format(ignore_patterns_file) |
Eunchan Kim | 87e8f85 | 2021-01-05 09:03:01 -0800 | [diff] [blame^] | 211 | rsync_cmd += "--exclude={} ".format(shlex.quote('.*')) |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 212 | |
| 213 | rsync_cmd += src + "/. " + dest |
| 214 | |
| 215 | cmd = ["flock", "--timeout", "600", dest, "--command", rsync_cmd] |
| 216 | |
| 217 | log.info("[copy_repo] [dest]: %s", dest) |
| 218 | log.log(utils.VERBOSE, "[copy_repo] [cmd]: \n%s", ' '.join(cmd)) |
| 219 | if not dry_run: |
| 220 | # Make sure the dest exists first. |
| 221 | os.makedirs(dest, exist_ok=True) |
| 222 | try: |
Eunchan Kim | 87e8f85 | 2021-01-05 09:03:01 -0800 | [diff] [blame^] | 223 | subprocess.run(cmd, |
| 224 | check=True, |
| 225 | stdout=subprocess.PIPE, |
| 226 | stderr=subprocess.PIPE) |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 227 | except subprocess.CalledProcessError as e: |
| 228 | log.error("Failed to copy over %s to %s: %s", src, dest, |
| 229 | e.stderr.decode("utf-8").strip()) |
| 230 | log.info("Done.") |
| 231 | |
| 232 | |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 233 | def wrapped_docstring(): |
| 234 | '''Return a text-wrapped version of the module docstring''' |
| 235 | paras = [] |
| 236 | para = [] |
| 237 | for line in __doc__.strip().split('\n'): |
| 238 | line = line.strip() |
| 239 | if not line: |
| 240 | if para: |
| 241 | paras.append('\n'.join(para)) |
| 242 | para = [] |
| 243 | else: |
| 244 | para.append(line) |
| 245 | if para: |
| 246 | paras.append('\n'.join(para)) |
| 247 | |
| 248 | return '\n\n'.join(textwrap.fill(p) for p in paras) |
| 249 | |
| 250 | |
| 251 | def parse_args(): |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 252 | parser = argparse.ArgumentParser( |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 253 | description=wrapped_docstring(), |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 254 | formatter_class=argparse.RawDescriptionHelpFormatter) |
| 255 | |
Srikrishna Iyer | 7cf7cad | 2020-01-08 11:32:53 -0800 | [diff] [blame] | 256 | parser.add_argument("cfg", |
| 257 | metavar="<cfg-hjson-file>", |
| 258 | help="""Configuration hjson file.""") |
| 259 | |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 260 | parser.add_argument("--version", |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 261 | action='store_true', |
| 262 | help="Print version and exit") |
| 263 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 264 | parser.add_argument( |
| 265 | "--tool", |
| 266 | "-t", |
| 267 | help=("Explicitly set the tool to use. This is " |
| 268 | "optional for running simulations (where it can " |
| 269 | "be set in an .hjson file), but is required for " |
| 270 | "other flows. Possible tools include: vcs, " |
| 271 | "xcelium, ascentlint, veriblelint, verilator, dc.")) |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 272 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 273 | parser.add_argument("--list", |
| 274 | "-l", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 275 | nargs="*", |
| 276 | metavar='CAT', |
| 277 | choices=_LIST_CATEGORIES, |
| 278 | help=('Parse the the given .hjson config file, list ' |
| 279 | 'the things that can be run, then exit. The ' |
| 280 | 'list can be filtered with a space-separated ' |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 281 | 'of categories from: {}.'.format( |
| 282 | ', '.join(_LIST_CATEGORIES)))) |
Srikrishna Iyer | 6400905 | 2020-01-13 11:27:39 -0800 | [diff] [blame] | 283 | |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 284 | whatg = parser.add_argument_group('Choosing what to run') |
Srikrishna Iyer | 4f0b090 | 2020-01-25 02:28:47 -0800 | [diff] [blame] | 285 | |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 286 | whatg.add_argument("-i", |
| 287 | "--items", |
| 288 | nargs="*", |
Cindy Chen | e513e36 | 2020-11-11 10:28:54 -0800 | [diff] [blame] | 289 | default=["smoke"], |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 290 | help=('Specify the regressions or tests to run. ' |
Cindy Chen | e513e36 | 2020-11-11 10:28:54 -0800 | [diff] [blame] | 291 | 'Defaults to "smoke", but can be a ' |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 292 | 'space separated list of test or regression ' |
| 293 | 'names.')) |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 294 | |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 295 | whatg.add_argument("--select-cfgs", |
| 296 | nargs="*", |
| 297 | metavar="CFG", |
Scott Johnson | fe79c4b | 2020-07-08 10:31:08 -0700 | [diff] [blame] | 298 | help=('The .hjson file is a primary config. Only run ' |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 299 | 'the given configs from it. If this argument is ' |
| 300 | 'not used, dvsim will process all configs listed ' |
Scott Johnson | fe79c4b | 2020-07-08 10:31:08 -0700 | [diff] [blame] | 301 | 'in a primary config.')) |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 302 | |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 303 | disg = parser.add_argument_group('Dispatch options') |
| 304 | |
| 305 | disg.add_argument("--job-prefix", |
| 306 | default="", |
| 307 | metavar="PFX", |
| 308 | help=('Prepend this string when running each tool ' |
| 309 | 'command.')) |
| 310 | |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 311 | disg.add_argument("--remote", |
| 312 | action='store_true', |
| 313 | help=('Trigger copying of the repo to scratch area.')) |
| 314 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 315 | disg.add_argument("--max-parallel", |
| 316 | "-mp", |
Rupert Swarbrick | 536ab20 | 2020-06-09 16:37:12 +0100 | [diff] [blame] | 317 | type=read_max_parallel, |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 318 | metavar="N", |
| 319 | help=('Run only up to N builds/tests at a time. ' |
Rupert Swarbrick | 536ab20 | 2020-06-09 16:37:12 +0100 | [diff] [blame] | 320 | 'Default value 16, unless the DVSIM_MAX_PARALLEL ' |
| 321 | 'environment variable is set, in which case that ' |
| 322 | 'is used.')) |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 323 | |
| 324 | pathg = parser.add_argument_group('File management') |
| 325 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 326 | pathg.add_argument("--scratch-root", |
| 327 | "-sr", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 328 | metavar="PATH", |
| 329 | help=('Destination for build / run directories. If not ' |
| 330 | 'specified, uses the path in the SCRATCH_ROOT ' |
| 331 | 'environment variable, if set, or ./scratch ' |
| 332 | 'otherwise.')) |
| 333 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 334 | pathg.add_argument("--proj-root", |
| 335 | "-pr", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 336 | metavar="PATH", |
| 337 | help=('The root directory of the project. If not ' |
| 338 | 'specified, dvsim will search for a git ' |
| 339 | 'repository containing the current directory.')) |
| 340 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 341 | pathg.add_argument("--branch", |
| 342 | "-br", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 343 | metavar='B', |
| 344 | help=('By default, dvsim creates files below ' |
| 345 | '{scratch-root}/{dut}.{flow}.{tool}/{branch}. ' |
| 346 | 'If --branch is not specified, dvsim assumes the ' |
| 347 | 'current directory is a git repository and uses ' |
| 348 | 'the name of the current branch.')) |
| 349 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 350 | pathg.add_argument("--max-odirs", |
| 351 | "-mo", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 352 | type=int, |
| 353 | default=5, |
| 354 | metavar="N", |
| 355 | help=('When tests are run, older runs are backed ' |
| 356 | 'up. Discard all but the N most recent (defaults ' |
| 357 | 'to 5).')) |
| 358 | |
| 359 | pathg.add_argument("--purge", |
| 360 | action='store_true', |
| 361 | help="Clean the scratch directory before running.") |
| 362 | |
| 363 | buildg = parser.add_argument_group('Options for building') |
| 364 | |
| 365 | buildg.add_argument("--build-only", |
Weicai Yang | 528b3c0 | 2020-12-04 16:13:16 -0800 | [diff] [blame] | 366 | "-bu", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 367 | action='store_true', |
| 368 | help=('Stop after building executables for the given ' |
| 369 | 'items.')) |
| 370 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 371 | buildg.add_argument("--build-unique", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 372 | action='store_true', |
| 373 | help=('Append a timestamp to the directory in which ' |
| 374 | 'files are built. This is suitable for the case ' |
| 375 | 'when another test is already running and you ' |
| 376 | 'want to run something else from a different ' |
| 377 | 'terminal without affecting it.')) |
| 378 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 379 | buildg.add_argument("--build-opts", |
| 380 | "-bo", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 381 | nargs="+", |
| 382 | default=[], |
| 383 | metavar="OPT", |
| 384 | help=('Additional options passed on the command line ' |
| 385 | 'each time a build tool is run.')) |
| 386 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 387 | buildg.add_argument("--build-modes", |
| 388 | "-bm", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 389 | nargs="+", |
| 390 | default=[], |
| 391 | metavar="MODE", |
| 392 | help=('The options for each build_mode in this list ' |
| 393 | 'are applied to all build and run targets.')) |
| 394 | |
| 395 | rung = parser.add_argument_group('Options for running') |
| 396 | |
| 397 | rung.add_argument("--run-only", |
Weicai Yang | 528b3c0 | 2020-12-04 16:13:16 -0800 | [diff] [blame] | 398 | "-ru", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 399 | action='store_true', |
| 400 | help=('Skip the build step (assume that simulation ' |
| 401 | 'executables have already been built).')) |
| 402 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 403 | rung.add_argument("--run-opts", |
| 404 | "-ro", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 405 | nargs="+", |
| 406 | default=[], |
| 407 | metavar="OPT", |
| 408 | help=('Additional options passed on the command line ' |
| 409 | 'each time a test is run.')) |
| 410 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 411 | rung.add_argument("--run-modes", |
| 412 | "-rm", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 413 | nargs="+", |
| 414 | default=[], |
| 415 | metavar="MODE", |
| 416 | help=('The options for each run_mode in this list are ' |
| 417 | 'applied to each simulation run.')) |
| 418 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 419 | rung.add_argument("--profile", |
| 420 | "-p", |
Srikrishna Iyer | f807f9d | 2020-11-17 01:37:52 -0800 | [diff] [blame] | 421 | nargs="?", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 422 | choices=['time', 'mem'], |
Srikrishna Iyer | f807f9d | 2020-11-17 01:37:52 -0800 | [diff] [blame] | 423 | const="time", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 424 | metavar="P", |
| 425 | help=('Turn on simulation profiling (where P is time ' |
| 426 | 'or mem).')) |
| 427 | |
| 428 | rung.add_argument("--xprop-off", |
| 429 | action='store_true', |
| 430 | help="Turn off X-propagation in simulation.") |
| 431 | |
| 432 | rung.add_argument("--no-rerun", |
| 433 | action='store_true', |
| 434 | help=("Disable the default behaviour, where failing " |
| 435 | "tests are automatically rerun with waves " |
| 436 | "enabled.")) |
| 437 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 438 | rung.add_argument("--verbosity", |
| 439 | "-v", |
Srikrishna Iyer | a4f0664 | 2020-12-04 17:46:01 -0800 | [diff] [blame] | 440 | choices=['n', 'l', 'm', 'h', 'f', 'd'], |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 441 | metavar='V', |
Rupert Swarbrick | dcec994 | 2020-09-04 08:15:07 +0100 | [diff] [blame] | 442 | help=('Set tool/simulation verbosity to none (n), low ' |
Srikrishna Iyer | a4f0664 | 2020-12-04 17:46:01 -0800 | [diff] [blame] | 443 | '(l), medium (m), high (h), full (f) or debug (d).' |
| 444 | ' The default value is set in config files.')) |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 445 | |
| 446 | seedg = parser.add_argument_group('Test seeds') |
| 447 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 448 | seedg.add_argument("--seeds", |
| 449 | "-s", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 450 | nargs="+", |
| 451 | default=[], |
| 452 | metavar="S", |
| 453 | help=('A list of seeds for tests. Note that these ' |
| 454 | 'specific seeds are applied to items being run ' |
| 455 | 'in the order they are passed.')) |
| 456 | |
| 457 | seedg.add_argument("--fixed-seed", |
| 458 | type=int, |
| 459 | metavar='S', |
| 460 | help=('Run all items with the seed S. This implies ' |
| 461 | '--reseed 1.')) |
| 462 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 463 | seedg.add_argument("--reseed", |
| 464 | "-r", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 465 | type=int, |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 466 | metavar="N", |
| 467 | help=('Override any reseed value in the test ' |
| 468 | 'configuration and run each test N times, with ' |
| 469 | 'a new seed each time.')) |
| 470 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 471 | seedg.add_argument("--reseed-multiplier", |
| 472 | "-rx", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 473 | type=int, |
| 474 | default=1, |
| 475 | metavar="N", |
| 476 | help=('Scale each reseed value in the test ' |
| 477 | 'configuration by N. This allows e.g. running ' |
| 478 | 'the tests 10 times as much as normal while ' |
| 479 | 'maintaining the ratio of numbers of runs ' |
| 480 | 'between different tests.')) |
| 481 | |
| 482 | waveg = parser.add_argument_group('Dumping waves') |
| 483 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 484 | waveg.add_argument( |
| 485 | "--waves", |
| 486 | "-w", |
| 487 | nargs="?", |
| 488 | choices=["default", "fsdb", "shm", "vpd", "vcd", "evcd", "fst"], |
| 489 | const="default", |
| 490 | help=("Enable dumping of waves. It takes an optional " |
| 491 | "argument to pick the desired wave format. If " |
| 492 | "the optional argument is not supplied, it picks " |
| 493 | "whatever is the default for the chosen tool. " |
| 494 | "By default, dumping waves is not enabled.")) |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 495 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 496 | waveg.add_argument("--max-waves", |
| 497 | "-mw", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 498 | type=int, |
| 499 | default=5, |
| 500 | metavar="N", |
| 501 | help=('Only dump waves for the first N tests run. This ' |
| 502 | 'includes both tests scheduled for run and those ' |
| 503 | 'that are automatically rerun.')) |
| 504 | |
| 505 | covg = parser.add_argument_group('Generating simulation coverage') |
| 506 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 507 | covg.add_argument("--cov", |
| 508 | "-c", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 509 | action='store_true', |
| 510 | help="Enable collection of coverage data.") |
| 511 | |
| 512 | covg.add_argument("--cov-merge-previous", |
| 513 | action='store_true', |
| 514 | help=('Only applicable with --cov. Merge any previous ' |
| 515 | 'coverage database directory with the new ' |
| 516 | 'coverage database.')) |
| 517 | |
Weicai Yang | 080632d | 2020-10-16 17:52:14 -0700 | [diff] [blame] | 518 | covg.add_argument("--cov-unr", |
| 519 | action='store_true', |
| 520 | help=('Run coverage UNR analysis and generate report. ' |
| 521 | 'This only supports VCS now.')) |
| 522 | |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 523 | covg.add_argument("--cov-analyze", |
| 524 | action='store_true', |
| 525 | help=('Rather than building or running any tests, ' |
| 526 | 'analyze the coverage from the last run.')) |
| 527 | |
| 528 | pubg = parser.add_argument_group('Generating and publishing results') |
| 529 | |
| 530 | pubg.add_argument("--map-full-testplan", |
| 531 | action='store_true', |
| 532 | help=("Show complete testplan annotated results " |
| 533 | "at the end.")) |
| 534 | |
| 535 | pubg.add_argument("--publish", |
| 536 | action='store_true', |
| 537 | help="Publish results to reports.opentitan.org.") |
| 538 | |
| 539 | dvg = parser.add_argument_group('Controlling DVSim itself') |
| 540 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 541 | dvg.add_argument("--print-interval", |
| 542 | "-pi", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 543 | type=int, |
| 544 | default=10, |
| 545 | metavar="N", |
| 546 | help="Print status every N seconds.") |
| 547 | |
| 548 | dvg.add_argument("--verbose", |
| 549 | nargs="?", |
| 550 | choices=['default', 'debug'], |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 551 | const="default", |
| 552 | metavar="D", |
| 553 | help=('With no argument, print verbose dvsim tool ' |
| 554 | 'messages. With --verbose=debug, the volume of ' |
| 555 | 'messages is even higher.')) |
| 556 | |
Weicai Yang | 813d689 | 2020-10-19 16:20:31 -0700 | [diff] [blame] | 557 | dvg.add_argument("--dry-run", |
| 558 | "-n", |
Rupert Swarbrick | b7aacc1 | 2020-06-02 11:04:55 +0100 | [diff] [blame] | 559 | action='store_true', |
| 560 | help=("Print dvsim tool messages but don't actually " |
| 561 | "run any command")) |
| 562 | |
Rupert Swarbrick | 536ab20 | 2020-06-09 16:37:12 +0100 | [diff] [blame] | 563 | args = parser.parse_args() |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 564 | |
| 565 | if args.version: |
| 566 | print(version) |
| 567 | sys.exit() |
| 568 | |
Rupert Swarbrick | e83b55e | 2020-05-12 11:44:04 +0100 | [diff] [blame] | 569 | # We want the --list argument to default to "all categories", but allow |
| 570 | # filtering. If args.list is None, then --list wasn't supplied. If it is |
| 571 | # [], then --list was supplied with no further arguments and we want to |
| 572 | # list all categories. |
| 573 | if args.list == []: |
| 574 | args.list = _LIST_CATEGORIES |
| 575 | |
Rupert Swarbrick | 536ab20 | 2020-06-09 16:37:12 +0100 | [diff] [blame] | 576 | # Get max_parallel from environment if it wasn't specified on the command |
| 577 | # line. |
| 578 | args.max_parallel = resolve_max_parallel(args.max_parallel) |
| 579 | assert args.max_parallel > 0 |
| 580 | |
| 581 | return args |
| 582 | |
| 583 | |
| 584 | def main(): |
| 585 | args = parse_args() |
| 586 | |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 587 | # Add log level 'VERBOSE' between INFO and DEBUG |
| 588 | log.addLevelName(utils.VERBOSE, 'VERBOSE') |
| 589 | |
| 590 | log_format = '%(levelname)s: [%(module)s] %(message)s' |
| 591 | log_level = log.INFO |
Rupert Swarbrick | 0638368 | 2020-03-24 15:56:41 +0000 | [diff] [blame] | 592 | if args.verbose == "default": |
| 593 | log_level = utils.VERBOSE |
| 594 | elif args.verbose == "debug": |
| 595 | log_level = log.DEBUG |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 596 | log.basicConfig(format=log_format, level=log_level) |
| 597 | |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 598 | if not os.path.exists(args.cfg): |
Michael Schaffner | 8ac6c4c | 2020-03-03 15:00:20 -0800 | [diff] [blame] | 599 | log.fatal("Path to config file %s appears to be invalid.", args.cfg) |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 600 | sys.exit(1) |
| 601 | |
Srikrishna Iyer | 4f0b090 | 2020-01-25 02:28:47 -0800 | [diff] [blame] | 602 | # If publishing results, then force full testplan mapping of results. |
Rupert Swarbrick | 0638368 | 2020-03-24 15:56:41 +0000 | [diff] [blame] | 603 | if args.publish: |
| 604 | args.map_full_testplan = True |
Srikrishna Iyer | 4f0b090 | 2020-01-25 02:28:47 -0800 | [diff] [blame] | 605 | |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 606 | args.scratch_root = resolve_scratch_root(args.scratch_root) |
| 607 | args.branch = resolve_branch(args.branch) |
Cindy Chen | 13a5dde | 2020-12-21 09:31:56 -0800 | [diff] [blame] | 608 | proj_root_src, proj_root = resolve_proj_root(args) |
Srikrishna Iyer | 981c36b | 2020-12-12 12:20:35 -0800 | [diff] [blame] | 609 | log.info("[proj_root]: %s", proj_root) |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 610 | |
Cindy Chen | 13a5dde | 2020-12-21 09:31:56 -0800 | [diff] [blame] | 611 | args.cfg = os.path.abspath(args.cfg) |
| 612 | if args.remote: |
| 613 | cfg_path = args.cfg.replace(proj_root_src + "/", "") |
| 614 | args.cfg = os.path.join(proj_root, cfg_path) |
| 615 | |
Srikrishna Iyer | 544da8d | 2020-01-14 23:51:41 -0800 | [diff] [blame] | 616 | # Add timestamp to args that all downstream objects can use. |
| 617 | # Static variables - indicate timestamp. |
Eunchan Kim | 46125cd | 2020-04-09 09:26:52 -0700 | [diff] [blame] | 618 | ts_format_long = "%A %B %d %Y %I:%M:%S%p UTC" |
Srikrishna Iyer | 544da8d | 2020-01-14 23:51:41 -0800 | [diff] [blame] | 619 | ts_format = "%a.%m.%d.%y__%I.%M.%S%p" |
Eunchan Kim | 46125cd | 2020-04-09 09:26:52 -0700 | [diff] [blame] | 620 | curr_ts = datetime.datetime.utcnow() |
Srikrishna Iyer | 544da8d | 2020-01-14 23:51:41 -0800 | [diff] [blame] | 621 | timestamp_long = curr_ts.strftime(ts_format_long) |
| 622 | timestamp = curr_ts.strftime(ts_format) |
| 623 | setattr(args, "ts_format_long", ts_format_long) |
| 624 | setattr(args, "ts_format", ts_format) |
| 625 | setattr(args, "timestamp_long", timestamp_long) |
| 626 | setattr(args, "timestamp", timestamp) |
| 627 | |
| 628 | # Register the seeds from command line with RunTest class. |
| 629 | Deploy.RunTest.seeds = args.seeds |
Srikrishna Iyer | 96e5410 | 2020-03-12 22:46:50 -0700 | [diff] [blame] | 630 | # If we are fixing a seed value, no point in tests having multiple reseeds. |
Rupert Swarbrick | 0638368 | 2020-03-24 15:56:41 +0000 | [diff] [blame] | 631 | if args.fixed_seed: |
| 632 | args.reseed = 1 |
Srikrishna Iyer | 96e5410 | 2020-03-12 22:46:50 -0700 | [diff] [blame] | 633 | Deploy.RunTest.fixed_seed = args.fixed_seed |
Srikrishna Iyer | 544da8d | 2020-01-14 23:51:41 -0800 | [diff] [blame] | 634 | |
| 635 | # Register the common deploy settings. |
| 636 | Deploy.Deploy.print_interval = args.print_interval |
| 637 | Deploy.Deploy.max_parallel = args.max_parallel |
| 638 | Deploy.Deploy.max_odirs = args.max_odirs |
| 639 | |
Srikrishna Iyer | 7cf7cad | 2020-01-08 11:32:53 -0800 | [diff] [blame] | 640 | # Build infrastructure from hjson file and create the list of items to |
| 641 | # be deployed. |
Weicai Yang | fc2ff3b | 2020-03-19 18:05:14 -0700 | [diff] [blame] | 642 | global cfg |
Rupert Swarbrick | a23dfec | 2020-09-07 10:01:28 +0100 | [diff] [blame] | 643 | cfg = make_cfg(args.cfg, args, proj_root) |
Rupert Swarbrick | e83b55e | 2020-05-12 11:44:04 +0100 | [diff] [blame] | 644 | |
Weicai Yang | fc2ff3b | 2020-03-19 18:05:14 -0700 | [diff] [blame] | 645 | # Handle Ctrl-C exit. |
| 646 | signal(SIGINT, sigint_handler) |
Udi Jonnalagadda | a122dda | 2020-03-13 16:56:45 -0700 | [diff] [blame] | 647 | |
Srikrishna Iyer | 6400905 | 2020-01-13 11:27:39 -0800 | [diff] [blame] | 648 | # List items available for run if --list switch is passed, and exit. |
Rupert Swarbrick | e83b55e | 2020-05-12 11:44:04 +0100 | [diff] [blame] | 649 | if args.list is not None: |
Srikrishna Iyer | 6400905 | 2020-01-13 11:27:39 -0800 | [diff] [blame] | 650 | cfg.print_list() |
| 651 | sys.exit(0) |
| 652 | |
Weicai Yang | 080632d | 2020-10-16 17:52:14 -0700 | [diff] [blame] | 653 | # Purge the scratch path if --purge option is set. |
| 654 | if args.purge: |
| 655 | cfg.purge() |
| 656 | |
| 657 | # If --cov-unr is passed, run UNR to generate report for unreachable |
| 658 | # exclusion file. |
| 659 | if args.cov_unr: |
| 660 | cfg.cov_unr() |
| 661 | cfg.deploy_objects() |
| 662 | sys.exit(0) |
| 663 | |
Srikrishna Iyer | 2a710a4 | 2020-02-10 10:39:15 -0800 | [diff] [blame] | 664 | # In simulation mode: if --cov-analyze switch is passed, then run the GUI |
| 665 | # tool. |
| 666 | if args.cov_analyze: |
| 667 | cfg.cov_analyze() |
Srikrishna Iyer | 39ffebd | 2020-03-30 11:53:12 -0700 | [diff] [blame] | 668 | cfg.deploy_objects() |
Srikrishna Iyer | 2a710a4 | 2020-02-10 10:39:15 -0800 | [diff] [blame] | 669 | sys.exit(0) |
| 670 | |
Srikrishna Iyer | 7cf7cad | 2020-01-08 11:32:53 -0800 | [diff] [blame] | 671 | # Deploy the builds and runs |
Srikrishna Iyer | 2a710a4 | 2020-02-10 10:39:15 -0800 | [diff] [blame] | 672 | if args.items != []: |
| 673 | # Create deploy objects. |
| 674 | cfg.create_deploy_objects() |
| 675 | cfg.deploy_objects() |
Srikrishna Iyer | 7cf7cad | 2020-01-08 11:32:53 -0800 | [diff] [blame] | 676 | |
Srikrishna Iyer | 2a710a4 | 2020-02-10 10:39:15 -0800 | [diff] [blame] | 677 | # Generate results. |
Weicai Yang | fd2c22e | 2020-02-11 18:37:14 -0800 | [diff] [blame] | 678 | cfg.gen_results() |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 679 | |
Srikrishna Iyer | 2a710a4 | 2020-02-10 10:39:15 -0800 | [diff] [blame] | 680 | # Publish results |
Rupert Swarbrick | 0638368 | 2020-03-24 15:56:41 +0000 | [diff] [blame] | 681 | if args.publish: |
| 682 | cfg.publish_results() |
Weicai Yang | fd2c22e | 2020-02-11 18:37:14 -0800 | [diff] [blame] | 683 | |
Srikrishna Iyer | 2a710a4 | 2020-02-10 10:39:15 -0800 | [diff] [blame] | 684 | else: |
| 685 | log.info("No items specified to be run.") |
Srikrishna Iyer | 4f0b090 | 2020-01-25 02:28:47 -0800 | [diff] [blame] | 686 | |
Srikrishna Iyer | 442d8db | 2020-03-05 15:17:17 -0800 | [diff] [blame] | 687 | # Exit with non-zero status if there were errors or failures. |
| 688 | if cfg.has_errors(): |
| 689 | log.error("Errors were encountered in this run.") |
| 690 | sys.exit(1) |
| 691 | |
Srikrishna Iyer | 09a81e9 | 2019-12-30 10:47:57 -0800 | [diff] [blame] | 692 | |
| 693 | if __name__ == '__main__': |
| 694 | main() |