Add a yapf style to //build/chromeos/ and auto-format all python files.
Format all the things! Change-Id: I33f02e6e21c4388f381b35e06394fb916bfddddd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1891735 Commit-Queue: Ben Pastene <bpastene@chromium.org> Reviewed-by: John Budorick <jbudorick@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#711845} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: df195fd51b35cccbfcc22d810747e3ac11af3d1a
This commit is contained in:
Родитель
b7b7c189e3
Коммит
337f0f19d5
|
@ -0,0 +1,2 @@
|
|||
[style]
|
||||
based_on_style = chromium
|
|
@ -1,7 +1,6 @@
|
|||
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
"""Presubmit script for build/chromeos/.
|
||||
|
||||
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
|
||||
|
@ -11,9 +10,7 @@ details on the presubmit API built into depot_tools.
|
|||
|
||||
def CommonChecks(input_api, output_api):
|
||||
return input_api.canned_checks.RunPylint(
|
||||
input_api,
|
||||
output_api,
|
||||
pylintrc='pylintrc')
|
||||
input_api, output_api, pylintrc='pylintrc')
|
||||
|
||||
|
||||
def CheckChangeOnUpload(input_api, output_api):
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
# Copyright 2018 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
"""Creates a script that runs a CrOS VM test by delegating to
|
||||
build/chromeos/test_runner.py.
|
||||
"""
|
||||
|
@ -12,7 +11,6 @@ import argparse
|
|||
import os
|
||||
import sys
|
||||
|
||||
|
||||
SCRIPT_TEMPLATE = """\
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
|
@ -90,7 +88,8 @@ def main(args):
|
|||
vm_test_args.append('--deploy-chrome')
|
||||
|
||||
vm_test_args += [
|
||||
'--board', args.board,
|
||||
'--board',
|
||||
args.board,
|
||||
'-v',
|
||||
]
|
||||
if args.use_vm:
|
||||
|
@ -100,17 +99,18 @@ def main(args):
|
|||
('--cros-cache', RelativizePathToScript(args.cros_cache)),
|
||||
]
|
||||
if args.runtime_deps_path:
|
||||
vm_test_path_args.append(
|
||||
('--runtime-deps-path', RelativizePathToScript(args.runtime_deps_path)))
|
||||
vm_test_path_args.append(('--runtime-deps-path',
|
||||
RelativizePathToScript(args.runtime_deps_path)))
|
||||
if args.output_directory:
|
||||
vm_test_path_args.append(
|
||||
('--path-to-outdir', RelativizePathToScript(args.output_directory)))
|
||||
vm_test_path_args.append(('--path-to-outdir',
|
||||
RelativizePathToScript(args.output_directory)))
|
||||
|
||||
with open(args.script_output_path, 'w') as script:
|
||||
script.write(SCRIPT_TEMPLATE.format(
|
||||
vm_test_script=run_test_path,
|
||||
vm_test_args=str(vm_test_args),
|
||||
vm_test_path_args=str(vm_test_path_args)))
|
||||
script.write(
|
||||
SCRIPT_TEMPLATE.format(
|
||||
vm_test_script=run_test_path,
|
||||
vm_test_args=str(vm_test_args),
|
||||
vm_test_path_args=str(vm_test_path_args)))
|
||||
|
||||
os.chmod(args.script_output_path, 0750)
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ import dateutil.parser # pylint: disable=import-error
|
|||
import jsonlines # pylint: disable=import-error
|
||||
import psutil # pylint: disable=import-error
|
||||
|
||||
CHROMIUM_SRC_PATH = os.path.abspath(os.path.join(
|
||||
os.path.dirname(__file__), '..', '..'))
|
||||
CHROMIUM_SRC_PATH = os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), '..', '..'))
|
||||
|
||||
# Use the android test-runner's gtest results support library for generating
|
||||
# output json ourselves.
|
||||
|
@ -36,12 +36,12 @@ sys.path.insert(
|
|||
0, os.path.join(CHROMIUM_SRC_PATH, 'tools', 'swarming_client', 'utils'))
|
||||
import subprocess42 # pylint: disable=import-error
|
||||
|
||||
DEFAULT_CROS_CACHE = os.path.abspath(os.path.join(
|
||||
CHROMIUM_SRC_PATH, 'build', 'cros_cache'))
|
||||
CHROMITE_PATH = os.path.abspath(os.path.join(
|
||||
CHROMIUM_SRC_PATH, 'third_party', 'chromite'))
|
||||
CROS_RUN_TEST_PATH = os.path.abspath(os.path.join(
|
||||
CHROMITE_PATH, 'bin', 'cros_run_test'))
|
||||
DEFAULT_CROS_CACHE = os.path.abspath(
|
||||
os.path.join(CHROMIUM_SRC_PATH, 'build', 'cros_cache'))
|
||||
CHROMITE_PATH = os.path.abspath(
|
||||
os.path.join(CHROMIUM_SRC_PATH, 'third_party', 'chromite'))
|
||||
CROS_RUN_TEST_PATH = os.path.abspath(
|
||||
os.path.join(CHROMITE_PATH, 'bin', 'cros_run_test'))
|
||||
|
||||
# GN target that corresponds to the cros browser sanity test.
|
||||
SANITY_TEST_TARGET = 'cros_browser_sanity_test'
|
||||
|
@ -68,15 +68,15 @@ class RemoteTest(object):
|
|||
# This is a basic shell script that can be appended to in order to invoke the
|
||||
# test on the device.
|
||||
BASIC_SHELL_SCRIPT = [
|
||||
'#!/bin/sh',
|
||||
'#!/bin/sh',
|
||||
|
||||
# /home and /tmp are mounted with "noexec" in the device, but some of our
|
||||
# tools and tests use those dirs as a workspace (eg: vpython downloads
|
||||
# python binaries to ~/.vpython-root and /tmp/vpython_bootstrap).
|
||||
# /usr/local/tmp doesn't have this restriction, so change the location of
|
||||
# the home and temp dirs for the duration of the test.
|
||||
'export HOME=/usr/local/tmp',
|
||||
'export TMPDIR=/usr/local/tmp',
|
||||
# /home and /tmp are mounted with "noexec" in the device, but some of our
|
||||
# tools and tests use those dirs as a workspace (eg: vpython downloads
|
||||
# python binaries to ~/.vpython-root and /tmp/vpython_bootstrap).
|
||||
# /usr/local/tmp doesn't have this restriction, so change the location of
|
||||
# the home and temp dirs for the duration of the test.
|
||||
'export HOME=/usr/local/tmp',
|
||||
'export TMPDIR=/usr/local/tmp',
|
||||
]
|
||||
|
||||
def __init__(self, args, unknown_args):
|
||||
|
@ -96,15 +96,18 @@ class RemoteTest(object):
|
|||
|
||||
self._test_cmd = [
|
||||
CROS_RUN_TEST_PATH,
|
||||
'--board', args.board,
|
||||
'--cache-dir', args.cros_cache,
|
||||
'--board',
|
||||
args.board,
|
||||
'--cache-dir',
|
||||
args.cros_cache,
|
||||
]
|
||||
if args.use_vm:
|
||||
self._test_cmd += [
|
||||
'--start',
|
||||
# Don't persist any filesystem changes after the VM shutsdown.
|
||||
'--copy-on-write',
|
||||
'--device', 'localhost'
|
||||
'--device',
|
||||
'localhost'
|
||||
]
|
||||
else:
|
||||
self._test_cmd += [
|
||||
|
@ -127,9 +130,7 @@ class RemoteTest(object):
|
|||
self._llvm_profile_var = '/tmp/profraw/%s' % llvm_profile_file
|
||||
|
||||
# This should make the vm test runner exfil the profiling data.
|
||||
self._test_cmd += [
|
||||
'--results-src', '/tmp/profraw'
|
||||
]
|
||||
self._test_cmd += ['--results-src', '/tmp/profraw']
|
||||
|
||||
self._test_env = setup_env()
|
||||
|
||||
|
@ -146,7 +147,8 @@ class RemoteTest(object):
|
|||
# set cwd.
|
||||
self._test_cmd += [
|
||||
'--remote-cmd',
|
||||
'--cwd', os.path.relpath(self._path_to_outdir, CHROMIUM_SRC_PATH),
|
||||
'--cwd',
|
||||
os.path.relpath(self._path_to_outdir, CHROMIUM_SRC_PATH),
|
||||
]
|
||||
logging.info('Running the following command on the device:')
|
||||
logging.info('\n' + '\n'.join(script_contents))
|
||||
|
@ -162,10 +164,10 @@ class RemoteTest(object):
|
|||
# and gets timeout-killed by swarming. See also:
|
||||
# https://chromium.googlesource.com/infra/luci/luci-py/+/master/appengine/swarming/doc/Bot.md#graceful-termination_aka-the-sigterm-and-sigkill-dance
|
||||
test_proc = None
|
||||
|
||||
def _kill_child_procs(trapped_signal, _):
|
||||
logging.warning(
|
||||
'Received signal %d. Killing child processes of test.',
|
||||
trapped_signal)
|
||||
logging.warning('Received signal %d. Killing child processes of test.',
|
||||
trapped_signal)
|
||||
if not test_proc or not test_proc.pid:
|
||||
# This shouldn't happen?
|
||||
logging.error('Test process not running.')
|
||||
|
@ -176,12 +178,14 @@ class RemoteTest(object):
|
|||
|
||||
signal.signal(signal.SIGTERM, _kill_child_procs)
|
||||
|
||||
for i in xrange(self._retries+1):
|
||||
for i in xrange(self._retries + 1):
|
||||
logging.info('########################################')
|
||||
logging.info('Test attempt #%d', i)
|
||||
logging.info('########################################')
|
||||
test_proc = subprocess42.Popen(
|
||||
self._test_cmd, stdout=sys.stdout, stderr=sys.stderr,
|
||||
self._test_cmd,
|
||||
stdout=sys.stdout,
|
||||
stderr=sys.stderr,
|
||||
env=self._test_env)
|
||||
try:
|
||||
test_proc.wait(timeout=self._timeout)
|
||||
|
@ -214,8 +218,9 @@ class RemoteTest(object):
|
|||
# only one test (suite_name), and will either be a PASS or FAIL depending on
|
||||
# return_code.
|
||||
if self._test_launcher_summary_output:
|
||||
result = (base_test_result.ResultType.FAIL if return_code else
|
||||
base_test_result.ResultType.PASS)
|
||||
result = (
|
||||
base_test_result.ResultType.FAIL
|
||||
if return_code else base_test_result.ResultType.PASS)
|
||||
suite_result = base_test_result.BaseTestResult(self.suite_name, result)
|
||||
run_results = base_test_result.TestRunResults()
|
||||
run_results.AddResult(suite_result)
|
||||
|
@ -245,17 +250,17 @@ class TastTest(RemoteTest):
|
|||
|
||||
def build_test_command(self):
|
||||
if '--gtest_filter=%s' % self.suite_name in self._additional_args:
|
||||
logging.info(
|
||||
'GTest filtering not supported for tast tests. The '
|
||||
'--gtest_filter arg will be ignored.')
|
||||
logging.info('GTest filtering not supported for tast tests. The '
|
||||
'--gtest_filter arg will be ignored.')
|
||||
self._additional_args.remove('--gtest_filter=%s' % self.suite_name)
|
||||
if any(arg.startswith('--gtest_repeat') for arg in self._additional_args):
|
||||
logging.info(
|
||||
'--gtest_repeat not supported for tast tests. The arg will be '
|
||||
'ignored.')
|
||||
self._additional_args = [
|
||||
arg for arg in self._additional_args if not arg.startswith(
|
||||
'--gtest_repeat')]
|
||||
arg for arg in self._additional_args
|
||||
if not arg.startswith('--gtest_repeat')
|
||||
]
|
||||
|
||||
if self._additional_args:
|
||||
logging.error(
|
||||
|
@ -265,7 +270,8 @@ class TastTest(RemoteTest):
|
|||
self._test_cmd += [
|
||||
'--deploy',
|
||||
'--mount',
|
||||
'--build-dir', os.path.relpath(self._path_to_outdir, CHROMIUM_SRC_PATH),
|
||||
'--build-dir',
|
||||
os.path.relpath(self._path_to_outdir, CHROMIUM_SRC_PATH),
|
||||
]
|
||||
|
||||
# Coverage tests require some special pre-test setup, so use an
|
||||
|
@ -276,8 +282,8 @@ class TastTest(RemoteTest):
|
|||
# test.
|
||||
device_test_script_contents = self.BASIC_SHELL_SCRIPT[:]
|
||||
device_test_script_contents += [
|
||||
'echo "LLVM_PROFILE_FILE=%s" >> /etc/chrome_dev.conf' % (
|
||||
self._llvm_profile_var)
|
||||
'echo "LLVM_PROFILE_FILE=%s" >> /etc/chrome_dev.conf' %
|
||||
(self._llvm_profile_var)
|
||||
]
|
||||
|
||||
local_test_runner_cmd = ['local_test_runner', '-waituntilready']
|
||||
|
@ -295,8 +301,8 @@ class TastTest(RemoteTest):
|
|||
device_test_script_contents)
|
||||
|
||||
self._test_cmd += [
|
||||
'--files', os.path.relpath(self._on_device_script),
|
||||
'--',
|
||||
'--files',
|
||||
os.path.relpath(self._on_device_script), '--',
|
||||
'./' + os.path.relpath(self._on_device_script, self._path_to_outdir)
|
||||
]
|
||||
else:
|
||||
|
@ -306,7 +312,8 @@ class TastTest(RemoteTest):
|
|||
# Capture tast's results in the logs dir as well.
|
||||
if self._logs_dir:
|
||||
self._test_cmd += [
|
||||
'--results-dir', self._logs_dir,
|
||||
'--results-dir',
|
||||
self._logs_dir,
|
||||
]
|
||||
if self._conditional:
|
||||
# Don't use pipes.quote() here. Something funky happens with the arg
|
||||
|
@ -327,8 +334,8 @@ class TastTest(RemoteTest):
|
|||
tast_results_path = os.path.join(self._logs_dir, 'streamed_results.jsonl')
|
||||
if not os.path.exists(tast_results_path):
|
||||
logging.error(
|
||||
'Tast results not found at %s. Falling back to generic result '
|
||||
'reporting.', tast_results_path)
|
||||
'Tast results not found at %s. Falling back to generic result '
|
||||
'reporting.', tast_results_path)
|
||||
return super(TastTest, self).post_run(return_code)
|
||||
|
||||
# See the link below for the format of the results:
|
||||
|
@ -357,8 +364,8 @@ class TastTest(RemoteTest):
|
|||
for err in errors:
|
||||
error_log += err['stack'].encode('utf-8') + '\n'
|
||||
error_log += (
|
||||
"\nIf you're unsure why this test failed, consult the steps "
|
||||
'outlined in\n%s\n' % TAST_DEBUG_DOC)
|
||||
"\nIf you're unsure why this test failed, consult the steps "
|
||||
'outlined in\n%s\n' % TAST_DEBUG_DOC)
|
||||
base_result = base_test_result.BaseTestResult(
|
||||
test['name'], result, duration=duration_ms, log=error_log)
|
||||
suite_results.AddResult(base_result)
|
||||
|
@ -377,7 +384,6 @@ class TastTest(RemoteTest):
|
|||
return 0
|
||||
|
||||
|
||||
|
||||
class GTestTest(RemoteTest):
|
||||
|
||||
# The following list corresponds to paths that should not be copied over to
|
||||
|
@ -431,35 +437,34 @@ class GTestTest(RemoteTest):
|
|||
result_dir = '.'
|
||||
device_result_file = '/tmp/%s' % result_file
|
||||
self._test_cmd += [
|
||||
'--results-src', device_result_file,
|
||||
'--results-dest-dir', result_dir,
|
||||
'--results-src',
|
||||
device_result_file,
|
||||
'--results-dest-dir',
|
||||
result_dir,
|
||||
]
|
||||
|
||||
# Build the shell script that will be used on the device to invoke the test.
|
||||
device_test_script_contents = self.BASIC_SHELL_SCRIPT[:]
|
||||
if self._llvm_profile_var:
|
||||
device_test_script_contents += [
|
||||
'export LLVM_PROFILE_FILE=%s'% self._llvm_profile_var,
|
||||
'export LLVM_PROFILE_FILE=%s' % self._llvm_profile_var,
|
||||
]
|
||||
|
||||
if self._vpython_dir:
|
||||
vpython_spec_path = os.path.relpath(
|
||||
os.path.join(CHROMIUM_SRC_PATH, '.vpython'),
|
||||
self._path_to_outdir)
|
||||
os.path.join(CHROMIUM_SRC_PATH, '.vpython'), self._path_to_outdir)
|
||||
# Initialize the vpython cache. This can take 10-20s, and some tests
|
||||
# can't afford to wait that long on the first invocation.
|
||||
device_test_script_contents.extend([
|
||||
'export PATH=$PATH:$PWD/%s' % (self._vpython_dir),
|
||||
'vpython -vpython-spec %s -vpython-tool install' % (
|
||||
vpython_spec_path),
|
||||
'vpython -vpython-spec %s -vpython-tool install' %
|
||||
(vpython_spec_path),
|
||||
])
|
||||
|
||||
test_invocation = (
|
||||
'LD_LIBRARY_PATH=./ ./%s --test-launcher-shard-index=%d '
|
||||
'--test-launcher-total-shards=%d' % (
|
||||
self._test_exe, self._test_launcher_shard_index,
|
||||
self._test_launcher_total_shards)
|
||||
)
|
||||
test_invocation = ('LD_LIBRARY_PATH=./ ./%s --test-launcher-shard-index=%d '
|
||||
'--test-launcher-total-shards=%d' %
|
||||
(self._test_exe, self._test_launcher_shard_index,
|
||||
self._test_launcher_total_shards))
|
||||
if self._test_launcher_summary_output:
|
||||
test_invocation += ' --test-launcher-summary-output=%s' % (
|
||||
device_result_file)
|
||||
|
@ -496,8 +501,8 @@ class GTestTest(RemoteTest):
|
|||
# relative to src dir, so fix the path up a bit.
|
||||
runtime_files.append(
|
||||
os.path.relpath(
|
||||
os.path.abspath(os.path.join(self._path_to_outdir,
|
||||
self._vpython_dir)),
|
||||
os.path.abspath(
|
||||
os.path.join(self._path_to_outdir, self._vpython_dir)),
|
||||
CHROMIUM_SRC_PATH))
|
||||
# TODO(bpastene): Add the vpython spec to the test's runtime deps instead
|
||||
# of handling it here.
|
||||
|
@ -547,17 +552,17 @@ class BrowserSanityTest(RemoteTest):
|
|||
|
||||
def build_test_command(self):
|
||||
if '--gtest_filter=%s' % SANITY_TEST_TARGET in self._additional_args:
|
||||
logging.info(
|
||||
'GTest filtering not supported for the sanity test. The '
|
||||
'--gtest_filter arg will be ignored.')
|
||||
logging.info('GTest filtering not supported for the sanity test. The '
|
||||
'--gtest_filter arg will be ignored.')
|
||||
self._additional_args.remove('--gtest_filter=%s' % SANITY_TEST_TARGET)
|
||||
if any(arg.startswith('--gtest_repeat') for arg in self._additional_args):
|
||||
logging.info(
|
||||
'--gtest_repeat not supported for sanity test. The arg will be '
|
||||
'ignored.')
|
||||
self._additional_args = [
|
||||
arg for arg in self._additional_args if not arg.startswith(
|
||||
'--gtest_repeat')]
|
||||
arg for arg in self._additional_args
|
||||
if not arg.startswith('--gtest_repeat')
|
||||
]
|
||||
|
||||
if self._additional_args:
|
||||
logging.error(
|
||||
|
@ -572,8 +577,8 @@ class BrowserSanityTest(RemoteTest):
|
|||
device_test_script_contents = self.BASIC_SHELL_SCRIPT[:]
|
||||
if self._llvm_profile_var:
|
||||
device_test_script_contents += [
|
||||
'echo "LLVM_PROFILE_FILE=%s" >> /etc/chrome_dev.conf' % (
|
||||
self._llvm_profile_var)
|
||||
'echo "LLVM_PROFILE_FILE=%s" >> /etc/chrome_dev.conf' %
|
||||
(self._llvm_profile_var)
|
||||
]
|
||||
|
||||
# vm_sanity.py is the sanity test, which is baked into the device image.
|
||||
|
@ -583,12 +588,14 @@ class BrowserSanityTest(RemoteTest):
|
|||
device_test_script_contents)
|
||||
|
||||
self._test_cmd += [
|
||||
'--files', os.path.relpath(self._on_device_script),
|
||||
'--files',
|
||||
os.path.relpath(self._on_device_script),
|
||||
# The sanity test smoke-checks the system browser, so deploy our
|
||||
# locally-built chrome to the device before testing.
|
||||
'--deploy',
|
||||
'--mount',
|
||||
'--build-dir', os.path.relpath(self._path_to_outdir, CHROMIUM_SRC_PATH),
|
||||
'--build-dir',
|
||||
os.path.relpath(self._path_to_outdir, CHROMIUM_SRC_PATH),
|
||||
'--',
|
||||
'./' + os.path.relpath(self._on_device_script, self._path_to_outdir)
|
||||
]
|
||||
|
@ -621,23 +628,26 @@ def host_cmd(args, unknown_args):
|
|||
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)))
|
||||
'Args "%s" unsupported. Is your host command correctly formatted?' %
|
||||
(' '.join(unknown_args)))
|
||||
elif args.deploy_chrome and not args.path_to_outdir:
|
||||
raise TestFormatError(
|
||||
'--path-to-outdir must be specified if --deploy-chrome is passed.')
|
||||
|
||||
cros_run_test_cmd = [
|
||||
CROS_RUN_TEST_PATH,
|
||||
'--board', args.board,
|
||||
'--cache-dir', args.cros_cache,
|
||||
'--board',
|
||||
args.board,
|
||||
'--cache-dir',
|
||||
args.cros_cache,
|
||||
]
|
||||
if args.use_vm:
|
||||
cros_run_test_cmd += [
|
||||
'--start',
|
||||
# Don't persist any filesystem changes after the VM shutsdown.
|
||||
'--copy-on-write',
|
||||
'--device', 'localhost',
|
||||
'--device',
|
||||
'localhost',
|
||||
]
|
||||
else:
|
||||
cros_run_test_cmd += [
|
||||
|
@ -658,7 +668,8 @@ def host_cmd(args, unknown_args):
|
|||
# Mounting the browser gives it enough disk space to not need stripping.
|
||||
'--mount',
|
||||
'--nostrip',
|
||||
'--build-dir', os.path.abspath(args.path_to_outdir),
|
||||
'--build-dir',
|
||||
os.path.abspath(args.path_to_outdir),
|
||||
]
|
||||
|
||||
cros_run_test_cmd += [
|
||||
|
@ -697,36 +708,47 @@ def add_common_args(*parsers):
|
|||
parser.add_argument(
|
||||
'--board', type=str, required=True, help='Type of CrOS device.')
|
||||
parser.add_argument(
|
||||
'--cros-cache', type=str, default=DEFAULT_CROS_CACHE,
|
||||
'--cros-cache',
|
||||
type=str,
|
||||
default=DEFAULT_CROS_CACHE,
|
||||
help='Path to cros cache.')
|
||||
parser.add_argument(
|
||||
'--path-to-outdir', type=str, required=True,
|
||||
'--path-to-outdir',
|
||||
type=str,
|
||||
required=True,
|
||||
help='Path to output directory, all of whose contents will be '
|
||||
'deployed to the device.')
|
||||
'deployed to the device.')
|
||||
parser.add_argument(
|
||||
'--runtime-deps-path', type=str,
|
||||
'--runtime-deps-path',
|
||||
type=str,
|
||||
help='Runtime data dependency file from GN.')
|
||||
parser.add_argument(
|
||||
'--vpython-dir', type=str,
|
||||
'--vpython-dir',
|
||||
type=str,
|
||||
help='Location on host of a directory containing a vpython binary to '
|
||||
'deploy to the device before the test starts. The location of '
|
||||
'this dir will be added onto PATH in the device. WARNING: The '
|
||||
'arch of the device might not match the arch of the host, so '
|
||||
'avoid using "${platform}" when downloading vpython via CIPD.')
|
||||
'deploy to the device before the test starts. The location of '
|
||||
'this dir will be added onto PATH in the device. WARNING: The '
|
||||
'arch of the device might not match the arch of the host, so '
|
||||
'avoid using "${platform}" when downloading vpython via CIPD.')
|
||||
# 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',
|
||||
'--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.')
|
||||
'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',
|
||||
'--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,
|
||||
'--device',
|
||||
type=str,
|
||||
help='Hostname (or IP) of device to run the test on. This arg is not '
|
||||
'required if --use-vm is set.')
|
||||
'required if --use-vm is set.')
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -736,46 +758,52 @@ def main():
|
|||
host_cmd_parser = subparsers.add_parser(
|
||||
'host-cmd',
|
||||
help='Runs a host-side test. Pass the host-side command to run after '
|
||||
'"--". If --use-vm is passed, hostname and port for the device '
|
||||
'will be 127.0.0.1:9222.')
|
||||
'"--". If --use-vm is passed, hostname and port for the device '
|
||||
'will be 127.0.0.1:9222.')
|
||||
host_cmd_parser.set_defaults(func=host_cmd)
|
||||
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 '
|
||||
'running the host-cmd.')
|
||||
'running the host-cmd.')
|
||||
host_cmd_parser.add_argument('cmd', nargs=argparse.REMAINDER)
|
||||
# GTest args.
|
||||
# TODO(bpastene): Rename 'vm-test' arg to 'gtest'.
|
||||
gtest_parser = subparsers.add_parser(
|
||||
'vm-test',
|
||||
help='Runs a device-side gtest.')
|
||||
'vm-test', help='Runs a device-side gtest.')
|
||||
gtest_parser.set_defaults(func=device_test)
|
||||
gtest_parser.add_argument(
|
||||
'--test-exe', type=str, required=True,
|
||||
'--test-exe',
|
||||
type=str,
|
||||
required=True,
|
||||
help='Path to test executable to run inside the device. If the value is '
|
||||
'%s, the sanity test that ships with the device image runs instead. '
|
||||
'This test smokes-check the system browser (eg: loads a simple '
|
||||
'webpage, executes some javascript), so a fully-built Chrome binary '
|
||||
'that can get deployed to the device is expected to be available in '
|
||||
'the out-dir.' % SANITY_TEST_TARGET)
|
||||
'%s, the sanity test that ships with the device image runs instead. '
|
||||
'This test smokes-check the system browser (eg: loads a simple '
|
||||
'webpage, executes some javascript), so a fully-built Chrome binary '
|
||||
'that can get deployed to the device is expected to be available in '
|
||||
'the out-dir.' % SANITY_TEST_TARGET)
|
||||
|
||||
# GTest args. Some are passed down to the test binary in the device. Others
|
||||
# are parsed here since they might need tweaking or special handling.
|
||||
gtest_parser.add_argument(
|
||||
'--test-launcher-summary-output', type=str,
|
||||
'--test-launcher-summary-output',
|
||||
type=str,
|
||||
help='When set, will pass the same option down to the test and retrieve '
|
||||
'its result file at the specified location.')
|
||||
'its result file at the specified location.')
|
||||
# Shard args are parsed here since we might also specify them via env vars.
|
||||
gtest_parser.add_argument(
|
||||
'--test-launcher-shard-index',
|
||||
type=int, default=os.environ.get('GTEST_SHARD_INDEX', 0),
|
||||
type=int,
|
||||
default=os.environ.get('GTEST_SHARD_INDEX', 0),
|
||||
help='Index of the external shard to run.')
|
||||
gtest_parser.add_argument(
|
||||
'--test-launcher-total-shards',
|
||||
type=int, default=os.environ.get('GTEST_TOTAL_SHARDS', 1),
|
||||
type=int,
|
||||
default=os.environ.get('GTEST_TOTAL_SHARDS', 1),
|
||||
help='Total number of external shards.')
|
||||
gtest_parser.add_argument(
|
||||
'--stop-ui', action='store_true',
|
||||
'--stop-ui',
|
||||
action='store_true',
|
||||
help='Will stop the UI service in the device before running the test.')
|
||||
|
||||
# Tast test args.
|
||||
|
@ -783,23 +811,33 @@ def main():
|
|||
tast_test_parser = subparsers.add_parser(
|
||||
'tast',
|
||||
help='Runs a device-side set of Tast tests. For more details, see: '
|
||||
'https://chromium.googlesource.com/chromiumos/platform/tast/+/master/docs/running_tests.md')
|
||||
'https://chromium.googlesource.com/chromiumos/platform/tast/+/master/docs/running_tests.md'
|
||||
)
|
||||
tast_test_parser.set_defaults(func=device_test)
|
||||
tast_test_parser.add_argument(
|
||||
'--suite-name', type=str, required=True,
|
||||
'--suite-name',
|
||||
type=str,
|
||||
required=True,
|
||||
help='Name to apply to the set of Tast tests to run. This has no effect '
|
||||
'on what is executed, but is used mainly for test results reporting '
|
||||
'and tracking (eg: flakiness dashboard).')
|
||||
'on what is executed, but is used mainly for test results reporting '
|
||||
'and tracking (eg: flakiness dashboard).')
|
||||
tast_test_parser.add_argument(
|
||||
'--test-launcher-summary-output', type=str,
|
||||
'--test-launcher-summary-output',
|
||||
type=str,
|
||||
help='Generates a simple GTest-style JSON result file for the test run.')
|
||||
# TODO(bpastene): Change all uses of "--conditional" to use "--attr-expr".
|
||||
tast_test_parser.add_argument(
|
||||
'--conditional', '--attr-expr', type=str, dest='conditional',
|
||||
'--conditional',
|
||||
'--attr-expr',
|
||||
type=str,
|
||||
dest='conditional',
|
||||
help='A boolean expression whose matching tests will run '
|
||||
'(eg: ("dep:chrome")).')
|
||||
'(eg: ("dep:chrome")).')
|
||||
tast_test_parser.add_argument(
|
||||
'--test', '-t', action='append', dest='tests',
|
||||
'--test',
|
||||
'-t',
|
||||
action='append',
|
||||
dest='tests',
|
||||
help='A Tast test to run in the device (eg: "ui.ChromeLogin").')
|
||||
|
||||
add_common_args(gtest_parser, tast_test_parser, host_cmd_parser)
|
||||
|
@ -815,8 +853,8 @@ def main():
|
|||
try:
|
||||
socket.getaddrinfo(LAB_DUT_HOSTNAME, None)
|
||||
except socket.gaierror:
|
||||
logging.error(
|
||||
'The default DUT hostname of %s is unreachable.', LAB_DUT_HOSTNAME)
|
||||
logging.error('The default DUT hostname of %s is unreachable.',
|
||||
LAB_DUT_HOSTNAME)
|
||||
return 1
|
||||
if args.use_vm:
|
||||
if not os.path.exists('/dev/kvm'):
|
||||
|
|
Загрузка…
Ссылка в новой задаче