Commit fef7399c authored by Ben Pastene's avatar Ben Pastene Committed by Commit Bot

chromeos: Restructure test runner args a bit.

This makes the "test_type" arg the very first arg. Previously, anything
that came before it couldn't be passed in from the generated test script.

eg: running `./$out/bin/run_gtest --device $DUT_IP` would have no effect
since "--device" came before the "test_type" arg (which itself was
set in the generated script).

Bug: 866062
Change-Id: I7712f11b23f78f28e9831fe506b9467db8c217e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1572959Reviewed-by: default avatarJohn Budorick <jbudorick@chromium.org>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
Cr-Commit-Position: refs/heads/master@{#652208}
parent 4f4c5ff1
...@@ -63,13 +63,7 @@ def main(args): ...@@ -63,13 +63,7 @@ def main(args):
run_test_path = RelativizePathToScript( run_test_path = RelativizePathToScript(
os.path.join(os.path.dirname(__file__), 'test_runner.py')) os.path.join(os.path.dirname(__file__), 'test_runner.py'))
vm_test_args = [ vm_test_args = []
'--board', args.board,
'-v',
]
if args.use_vm:
vm_test_args += ['--use-vm']
if args.test_exe: if args.test_exe:
vm_test_args.extend([ vm_test_args.extend([
'vm-test', 'vm-test',
...@@ -95,6 +89,13 @@ def main(args): ...@@ -95,6 +89,13 @@ def main(args):
if args.deploy_chrome: if args.deploy_chrome:
vm_test_args.append('--deploy-chrome') vm_test_args.append('--deploy-chrome')
vm_test_args += [
'--board', args.board,
'-v',
]
if args.use_vm:
vm_test_args += ['--use-vm']
vm_test_path_args = [ vm_test_path_args = [
('--cros-cache', RelativizePathToScript(args.cros_cache)), ('--cros-cache', RelativizePathToScript(args.cros_cache)),
] ]
......
...@@ -679,45 +679,46 @@ def setup_env(): ...@@ -679,45 +679,46 @@ def setup_env():
return env return env
def add_common_args(parser): def add_common_args(*parsers):
parser.add_argument( for parser in parsers:
'--cros-cache', type=str, default=DEFAULT_CROS_CACHE, parser.add_argument('--verbose', '-v', action='store_true')
help='Path to cros cache.') parser.add_argument(
parser.add_argument( '--board', type=str, required=True, help='Type of CrOS device.')
'--path-to-outdir', type=str, required=True, parser.add_argument(
help='Path to output directory, all of whose contents will be ' '--cros-cache', type=str, default=DEFAULT_CROS_CACHE,
'deployed to the device.') help='Path to cros cache.')
parser.add_argument( parser.add_argument(
'--runtime-deps-path', type=str, '--path-to-outdir', type=str, required=True,
help='Runtime data dependency file from GN.') help='Path to output directory, all of whose contents will be '
parser.add_argument( 'deployed to the device.')
'--vpython-dir', type=str, parser.add_argument(
help='Location on host of a directory containing a vpython binary to ' '--runtime-deps-path', type=str,
'deploy to the device before the test starts. The location of this ' help='Runtime data dependency file from GN.')
'dir will be added onto PATH in the device. WARNING: The arch of ' parser.add_argument(
'the device might not match the arch of the host, so avoid using ' '--vpython-dir', type=str,
'"${platform}" when downloading vpython via CIPD.') help='Location on host of a directory containing a vpython binary to '
# TODO(bpastene): Switch all uses of "--vm-logs-dir" to "--logs-dir". 'deploy to the device before the test starts. The location of '
parser.add_argument( 'this dir will be added onto PATH in the device. WARNING: The '
'--vm-logs-dir', '--logs-dir', type=str, dest='logs_dir', 'arch of the device might not match the arch of the host, so '
help='Will copy everything under /var/log/ from the device after the ' 'avoid using "${platform}" when downloading vpython via CIPD.')
'test into the specified dir.') # TODO(bpastene): Switch all uses of "--vm-logs-dir" to "--logs-dir".
parser.add_argument(
'--vm-logs-dir', '--logs-dir', type=str, dest='logs_dir',
help='Will copy everything under /var/log/ from the device after the '
'test into the specified dir.')
vm_or_device_group = parser.add_mutually_exclusive_group()
vm_or_device_group.add_argument(
'--use-vm', action='store_true',
help='Will run the test in the VM instead of a device.')
vm_or_device_group.add_argument(
'--device', type=str,
help='Hostname (or IP) of device to run the test on. This arg is not '
'required if --use-vm is set.')
def main(): def main():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--verbose', '-v', action='store_true')
# Required args.
parser.add_argument(
'--board', type=str, required=True, help='Type of CrOS device.')
vm_or_device_group = parser.add_mutually_exclusive_group()
vm_or_device_group.add_argument(
'--use-vm', action='store_true',
help='Will run the test in the VM instead of a device.')
vm_or_device_group.add_argument(
'--device', type=str,
help='Hostname (or IP) of device to run the test on. This arg is not '
'required if --use-vm is set.')
subparsers = parser.add_subparsers(dest='test_type') subparsers = parser.add_subparsers(dest='test_type')
# Host-side test args. # Host-side test args.
host_cmd_parser = subparsers.add_parser( host_cmd_parser = subparsers.add_parser(
...@@ -726,13 +727,6 @@ def main(): ...@@ -726,13 +727,6 @@ def main():
'"--". If --use-vm is passed, hostname and port for the device ' '"--". If --use-vm is passed, hostname and port for the device '
'will be 127.0.0.1:9222.') 'will be 127.0.0.1:9222.')
host_cmd_parser.set_defaults(func=host_cmd) host_cmd_parser.set_defaults(func=host_cmd)
host_cmd_parser.add_argument(
'--cros-cache', type=str, default=DEFAULT_CROS_CACHE,
help='Path to cros cache.')
host_cmd_parser.add_argument(
'--path-to-outdir', type=os.path.realpath,
help='Path to output directory, all of whose contents will be deployed '
'to the device.')
host_cmd_parser.add_argument( host_cmd_parser.add_argument(
'--deploy-chrome', action='store_true', '--deploy-chrome', action='store_true',
help='Will deploy a locally built Chrome binary to the device before ' help='Will deploy a locally built Chrome binary to the device before '
...@@ -797,8 +791,7 @@ def main(): ...@@ -797,8 +791,7 @@ def main():
help='Use the host-side Tast bin to run the tests instead of the ' help='Use the host-side Tast bin to run the tests instead of the '
'DUT-side local_test_runner. TODO(bpastene): Make this default.') 'DUT-side local_test_runner. TODO(bpastene): Make this default.')
add_common_args(gtest_parser) add_common_args(gtest_parser, tast_test_parser, host_cmd_parser)
add_common_args(tast_test_parser)
args, unknown_args = parser.parse_known_args() args, unknown_args = parser.parse_known_args()
logging.basicConfig(level=logging.DEBUG if args.verbose else logging.WARN) logging.basicConfig(level=logging.DEBUG if args.verbose else logging.WARN)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment