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