Commit 5b185d12 authored by Ben Pastene's avatar Ben Pastene Committed by Commit Bot

chromeos: Treat all unknown-args as the cmd to run in host-side tests.

When running tests that are launched from the host (eg telemetry tests),
the test_runner will take all args passed to it after the last known
arg and treat that as the host-side test command.

Consequently if a known arg is interleaved into the unknown args, the
test runner will not pick it up. By treating unknown args (rather than
trailing args) as the command, we can embed known args into the list.

This will let something like crrev.com/c/2283576 land as-is where we add
'--flash' as the very last arg. Without this CL, that arg is treated
as an arg to telemetry instead of an arg to the test runner.

Bug: 1057152
Change-Id: Id5326dfa3bceab86ae97dc260c9699cf35f56b08
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2283899Reviewed-by: default avatarBrian Sheedy <bsheedy@chromium.org>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
Cr-Commit-Position: refs/heads/master@{#785787}
parent 01c1683c
...@@ -692,13 +692,9 @@ def device_test(args, unknown_args): ...@@ -692,13 +692,9 @@ def device_test(args, unknown_args):
return test.run_test() return test.run_test()
def host_cmd(args, unknown_args): def host_cmd(args, cmd_args):
if not args.cmd: if not cmd_args:
raise TestFormatError('Must specify command to run on the host.') raise TestFormatError('Must specify command to run on the host.')
elif unknown_args:
raise TestFormatError(
'Args "%s" unsupported. Is your host command correctly formatted?' %
(' '.join(unknown_args)))
elif args.deploy_chrome and not args.path_to_outdir: elif args.deploy_chrome and not args.path_to_outdir:
raise TestFormatError( raise TestFormatError(
'--path-to-outdir must be specified if --deploy-chrome is passed.') '--path-to-outdir must be specified if --deploy-chrome is passed.')
...@@ -745,7 +741,7 @@ def host_cmd(args, unknown_args): ...@@ -745,7 +741,7 @@ def host_cmd(args, unknown_args):
cros_run_test_cmd += [ cros_run_test_cmd += [
'--host-cmd', '--host-cmd',
'--', '--',
] + args.cmd ] + cmd_args
logging.info('Running the following command:') logging.info('Running the following command:')
logging.info(' '.join(cros_run_test_cmd)) logging.info(' '.join(cros_run_test_cmd))
...@@ -841,7 +837,6 @@ def main(): ...@@ -841,7 +837,6 @@ def main():
action='store_true', 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 '
'running the host-cmd.') 'running the host-cmd.')
host_cmd_parser.add_argument('cmd', nargs=argparse.REMAINDER)
# GTest args. # GTest args.
# TODO(bpastene): Rename 'vm-test' arg to 'gtest'. # TODO(bpastene): Rename 'vm-test' arg to 'gtest'.
gtest_parser = subparsers.add_parser( gtest_parser = subparsers.add_parser(
......
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