2018-04-23 23:43:30 +03:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
# Originally taken from /talos/mach_commands.py
|
|
|
|
|
|
|
|
# Integrates raptor mozharness with mach
|
|
|
|
|
|
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
|
|
|
|
|
|
|
import json
|
2020-04-21 14:58:04 +03:00
|
|
|
import logging
|
2019-05-31 17:43:39 +03:00
|
|
|
import os
|
2018-08-14 21:06:20 +03:00
|
|
|
import shutil
|
2018-04-23 23:43:30 +03:00
|
|
|
import socket
|
2018-08-07 21:21:08 +03:00
|
|
|
import subprocess
|
2019-05-31 17:43:39 +03:00
|
|
|
import sys
|
2018-04-23 23:43:30 +03:00
|
|
|
|
2018-08-14 21:06:20 +03:00
|
|
|
import mozfile
|
2021-09-27 21:12:51 +03:00
|
|
|
from mach.decorators import Command
|
2018-08-07 21:21:08 +03:00
|
|
|
from mozboot.util import get_state_dir
|
2020-04-21 14:58:04 +03:00
|
|
|
from mozbuild.base import (
|
|
|
|
MozbuildObject,
|
|
|
|
BinaryNotFoundException,
|
|
|
|
)
|
2019-05-31 17:43:39 +03:00
|
|
|
from mozbuild.base import MachCommandConditions as Conditions
|
2018-04-23 23:43:30 +03:00
|
|
|
|
|
|
|
HERE = os.path.dirname(os.path.realpath(__file__))
|
2019-05-31 17:43:39 +03:00
|
|
|
|
2018-08-07 21:21:08 +03:00
|
|
|
BENCHMARK_REPOSITORY = "https://github.com/mozilla/perf-automation"
|
2021-03-25 15:29:08 +03:00
|
|
|
BENCHMARK_REVISION = "54c3c3d9d3f651f0d8ebb809d25232f72b5b06f2"
|
2018-04-23 23:43:30 +03:00
|
|
|
|
2021-03-24 13:44:22 +03:00
|
|
|
ANDROID_BROWSERS = ["geckoview", "refbrow", "fenix", "chrome-m"]
|
2019-05-31 17:43:05 +03:00
|
|
|
|
2018-04-23 23:43:30 +03:00
|
|
|
|
|
|
|
class RaptorRunner(MozbuildObject):
|
2018-11-10 14:10:08 +03:00
|
|
|
def run_test(self, raptor_args, kwargs):
|
2019-05-31 17:43:39 +03:00
|
|
|
"""Setup and run mozharness.
|
|
|
|
|
2019-05-11 11:13:29 +03:00
|
|
|
We want to do a few things before running Raptor:
|
2019-05-31 17:43:39 +03:00
|
|
|
|
2018-04-23 23:43:30 +03:00
|
|
|
1. Clone mozharness
|
2019-05-11 11:13:29 +03:00
|
|
|
2. Make the config for Raptor mozharness
|
2018-04-23 23:43:30 +03:00
|
|
|
3. Run mozharness
|
|
|
|
"""
|
2018-11-10 14:10:08 +03:00
|
|
|
self.init_variables(raptor_args, kwargs)
|
2018-08-07 21:21:08 +03:00
|
|
|
self.setup_benchmarks()
|
2018-04-23 23:43:30 +03:00
|
|
|
self.make_config()
|
|
|
|
self.write_config()
|
|
|
|
self.make_args()
|
|
|
|
return self.run_mozharness()
|
|
|
|
|
2018-11-10 14:10:08 +03:00
|
|
|
def init_variables(self, raptor_args, kwargs):
|
2019-05-31 17:43:39 +03:00
|
|
|
self.raptor_args = raptor_args
|
|
|
|
|
|
|
|
if kwargs.get("host") == "HOST_IP":
|
|
|
|
kwargs["host"] = os.environ["HOST_IP"]
|
|
|
|
self.host = kwargs["host"]
|
|
|
|
self.is_release_build = kwargs["is_release_build"]
|
|
|
|
self.memory_test = kwargs["memory_test"]
|
|
|
|
self.power_test = kwargs["power_test"]
|
2019-06-06 19:57:34 +03:00
|
|
|
self.cpu_test = kwargs["cpu_test"]
|
2020-04-23 13:02:06 +03:00
|
|
|
self.live_sites = kwargs["live_sites"]
|
2020-04-03 22:24:58 +03:00
|
|
|
self.disable_perf_tuning = kwargs["disable_perf_tuning"]
|
2021-04-03 14:08:14 +03:00
|
|
|
self.conditioned_profile = kwargs["conditioned_profile"]
|
2019-12-19 01:20:18 +03:00
|
|
|
self.device_name = kwargs["device_name"]
|
2021-01-15 14:17:29 +03:00
|
|
|
self.enable_marionette_trace = kwargs["enable_marionette_trace"]
|
2021-04-01 18:46:53 +03:00
|
|
|
self.browsertime_visualmetrics = kwargs["browsertime_visualmetrics"]
|
2019-05-31 17:43:05 +03:00
|
|
|
|
2020-03-27 17:31:28 +03:00
|
|
|
if Conditions.is_android(self) or kwargs["app"] in ANDROID_BROWSERS:
|
2019-05-31 17:43:05 +03:00
|
|
|
self.binary_path = None
|
|
|
|
else:
|
2019-05-31 03:04:35 +03:00
|
|
|
self.binary_path = kwargs.get("binary") or self.get_binary_path()
|
2019-05-31 17:43:05 +03:00
|
|
|
|
2019-05-31 17:43:39 +03:00
|
|
|
self.python = sys.executable
|
|
|
|
|
|
|
|
self.raptor_dir = os.path.join(self.topsrcdir, "testing", "raptor")
|
|
|
|
self.mozharness_dir = os.path.join(self.topsrcdir, "testing", "mozharness")
|
|
|
|
self.config_file_path = os.path.join(
|
|
|
|
self._topobjdir, "testing", "raptor-in_tree_conf.json"
|
|
|
|
)
|
|
|
|
|
|
|
|
self.virtualenv_script = os.path.join(
|
|
|
|
self.topsrcdir, "third_party", "python", "virtualenv", "virtualenv.py"
|
|
|
|
)
|
|
|
|
self.virtualenv_path = os.path.join(self._topobjdir, "testing", "raptor-venv")
|
2018-04-23 23:43:30 +03:00
|
|
|
|
2018-08-07 21:21:08 +03:00
|
|
|
def setup_benchmarks(self):
|
|
|
|
"""Make sure benchmarks are linked to the proper location in the objdir.
|
|
|
|
|
|
|
|
Benchmarks can either live in-tree or in an external repository. In the latter
|
|
|
|
case also clone/update the repository if necessary.
|
|
|
|
"""
|
2019-02-04 23:52:31 +03:00
|
|
|
external_repo_path = os.path.join(get_state_dir(), "performance-tests")
|
2018-08-07 21:21:08 +03:00
|
|
|
|
2019-05-15 17:27:57 +03:00
|
|
|
print("Updating external benchmarks from {}".format(BENCHMARK_REPOSITORY))
|
|
|
|
|
2018-10-29 19:43:22 +03:00
|
|
|
try:
|
|
|
|
subprocess.check_output(["git", "--version"])
|
|
|
|
except Exception as ex:
|
|
|
|
print(
|
|
|
|
"Git is not available! Please install git and "
|
|
|
|
"ensure it is included in the terminal path"
|
|
|
|
)
|
|
|
|
raise ex
|
|
|
|
|
2018-08-07 21:21:08 +03:00
|
|
|
if not os.path.isdir(external_repo_path):
|
2021-03-25 15:29:08 +03:00
|
|
|
print("Cloning the benchmarks to {}".format(external_repo_path))
|
2018-08-07 21:21:08 +03:00
|
|
|
subprocess.check_call(
|
|
|
|
["git", "clone", BENCHMARK_REPOSITORY, external_repo_path]
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
subprocess.check_call(["git", "checkout", "master"], cwd=external_repo_path)
|
|
|
|
subprocess.check_call(["git", "pull"], cwd=external_repo_path)
|
|
|
|
|
|
|
|
subprocess.check_call(
|
|
|
|
["git", "checkout", BENCHMARK_REVISION], cwd=external_repo_path
|
|
|
|
)
|
|
|
|
|
2018-08-14 21:06:20 +03:00
|
|
|
# Link or copy benchmarks to the objdir
|
2018-08-07 21:21:08 +03:00
|
|
|
benchmark_paths = (
|
|
|
|
os.path.join(external_repo_path, "benchmarks"),
|
|
|
|
os.path.join(self.topsrcdir, "third_party", "webkit", "PerformanceTests"),
|
|
|
|
)
|
2018-08-14 21:06:20 +03:00
|
|
|
|
|
|
|
benchmark_dest = os.path.join(self.topobjdir, "testing", "raptor", "benchmarks")
|
|
|
|
if not os.path.isdir(benchmark_dest):
|
|
|
|
os.makedirs(benchmark_dest)
|
2018-08-07 21:21:08 +03:00
|
|
|
|
|
|
|
for benchmark_path in benchmark_paths:
|
2018-08-14 21:06:20 +03:00
|
|
|
for name in os.listdir(benchmark_path):
|
|
|
|
path = os.path.join(benchmark_path, name)
|
|
|
|
dest = os.path.join(benchmark_dest, name)
|
|
|
|
if not os.path.isdir(path) or name.startswith("."):
|
2018-08-07 21:21:08 +03:00
|
|
|
continue
|
|
|
|
|
2021-09-09 15:13:01 +03:00
|
|
|
if hasattr(os, "symlink") and os.name != "nt":
|
2018-08-14 21:06:20 +03:00
|
|
|
if not os.path.exists(dest):
|
|
|
|
os.symlink(path, dest)
|
|
|
|
else:
|
|
|
|
# Clobber the benchmark in case a recent update removed any files.
|
|
|
|
mozfile.remove(dest)
|
|
|
|
shutil.copytree(path, dest)
|
2018-08-07 21:21:08 +03:00
|
|
|
|
2018-04-23 23:43:30 +03:00
|
|
|
def make_config(self):
|
2019-04-12 13:33:24 +03:00
|
|
|
default_actions = [
|
|
|
|
"populate-webroot",
|
|
|
|
"create-virtualenv",
|
2020-07-31 17:32:03 +03:00
|
|
|
"install-chromium-distribution",
|
2019-04-12 13:33:24 +03:00
|
|
|
"run-tests",
|
|
|
|
]
|
2018-04-23 23:43:30 +03:00
|
|
|
self.config = {
|
|
|
|
"run_local": True,
|
|
|
|
"binary_path": self.binary_path,
|
|
|
|
"repo_path": self.topsrcdir,
|
|
|
|
"raptor_path": self.raptor_dir,
|
|
|
|
"obj_path": self.topobjdir,
|
|
|
|
"log_name": "raptor",
|
|
|
|
"virtualenv_path": self.virtualenv_path,
|
2019-05-08 20:50:21 +03:00
|
|
|
"pypi_url": "http://pypi.org/simple",
|
2018-04-23 23:43:30 +03:00
|
|
|
"base_work_dir": self.mozharness_dir,
|
|
|
|
"exes": {
|
2019-05-31 17:43:39 +03:00
|
|
|
"python": self.python,
|
2020-10-10 02:39:01 +03:00
|
|
|
"virtualenv": [self.python, self.virtualenv_script],
|
2018-04-23 23:43:30 +03:00
|
|
|
},
|
|
|
|
"title": socket.gethostname(),
|
|
|
|
"default_actions": default_actions,
|
2018-06-04 22:42:44 +03:00
|
|
|
"raptor_cmd_line_args": self.raptor_args,
|
2018-11-10 14:10:08 +03:00
|
|
|
"host": self.host,
|
2018-12-19 23:52:28 +03:00
|
|
|
"power_test": self.power_test,
|
2019-04-16 21:55:34 +03:00
|
|
|
"memory_test": self.memory_test,
|
2019-06-06 19:57:34 +03:00
|
|
|
"cpu_test": self.cpu_test,
|
2020-04-23 13:02:06 +03:00
|
|
|
"live_sites": self.live_sites,
|
2020-04-03 22:24:58 +03:00
|
|
|
"disable_perf_tuning": self.disable_perf_tuning,
|
2021-04-03 14:08:14 +03:00
|
|
|
"conditioned_profile": self.conditioned_profile,
|
2018-11-10 14:10:08 +03:00
|
|
|
"is_release_build": self.is_release_build,
|
2019-12-19 01:20:18 +03:00
|
|
|
"device_name": self.device_name,
|
2021-01-15 14:17:29 +03:00
|
|
|
"enable_marionette_trace": self.enable_marionette_trace,
|
2021-04-01 18:46:53 +03:00
|
|
|
"browsertime_visualmetrics": self.browsertime_visualmetrics,
|
2018-04-23 23:43:30 +03:00
|
|
|
}
|
|
|
|
|
2019-07-27 00:30:03 +03:00
|
|
|
sys.path.insert(0, os.path.join(self.topsrcdir, "tools", "browsertime"))
|
|
|
|
try:
|
|
|
|
import mach_commands as browsertime
|
2020-10-26 21:34:53 +03:00
|
|
|
|
2019-07-27 00:30:03 +03:00
|
|
|
# We don't set `browsertime_{chromedriver,geckodriver} -- those will be found by
|
|
|
|
# browsertime in its `node_modules` directory, which is appropriate for local builds.
|
Bug 1566174 - Part 2: Add browsertime dependencies to Raptor tasks when --browsertime flag is present. r=rwood,tomprince
This commit prepares the decks for turning specific Raptor tasks into
Raptor + browsertime tasks. The `--browsertime` flag to `mach try
...` flips the switch; eventually, the Raptor harness will recognize
the `--browsertime` flag and use browsertime to perform the pageload
measurements.
To run browsertime, we need:
1) Node.js
2) the browsertime `node_modules` (provided by the
`toolchain-browsertime` task)
3) ffmpeg (for producing videos from captured frames)
4) chromedriver (in the future, when targeting Chrome/Chromium)
5) geckodriver (provided by the `toolchain-*-geckodriver` tasks)
6) `PATH` configured
This commit arranges those things.
Since the configuration varies by test platform, and eventually we
expect the changes implemented by the flag to be moved into YAML task
definitions, we elect to use `by-test-platform` conditionals as much
as possible. The end expression is pleasant, thanks to
`evaluate_keyed_by`.
Handling PATH, however, is a rabbit hole. At this time, it's not
possible to use `fetch` task repackaging, because `releng-hardware`
doesn't support `zstandard` (Bug 1576244) and there's no appetite to
avoid `zstandard` entirely (Bug 1576698). Generally PATH is
configured using `mozharness` configuration files, which can execute
arbitrary Python and configure the PATH only for browsertime jobs.
However, the Raptor mozharness script itself runs the Raptor harness
in a stripped down environment, throwing away modifications to PATH.
It's not clear what impacts changing that has, so we leave it alone,
and add a `--browsertime-ffmpeg` flag and custom handling in the
Raptor harness. This can transition smoothly into a browsertime flag
(so that the PATH doesn't need to be set at all) and into a unified
interface for Raptor and `mach browsertime` to configure the
browsertime execution environment.
Differential Revision: https://phabricator.services.mozilla.com/D38781
--HG--
extra : moz-landing-system : lando
2019-09-06 21:53:49 +03:00
|
|
|
# We don't set `browsertime_ffmpeg` yet: it will need to be on the path. There is code
|
|
|
|
# to configure the environment including the path in
|
|
|
|
# `tools/browsertime/mach_commands.py` but integrating it here will take more effort.
|
2019-07-27 00:30:03 +03:00
|
|
|
self.config.update(
|
|
|
|
{
|
|
|
|
"browsertime_node": browsertime.node_path(),
|
|
|
|
"browsertime_browsertimejs": browsertime.browsertime_path(),
|
2020-09-30 18:13:06 +03:00
|
|
|
"browsertime_vismet_script": browsertime.visualmetrics_path(),
|
2019-07-27 00:30:03 +03:00
|
|
|
}
|
|
|
|
)
|
2020-09-30 18:13:06 +03:00
|
|
|
|
2021-05-28 14:09:16 +03:00
|
|
|
def _get_browsertime_package():
|
|
|
|
with open(
|
|
|
|
os.path.join(
|
|
|
|
self.topsrcdir,
|
|
|
|
"tools",
|
|
|
|
"browsertime",
|
|
|
|
"node_modules",
|
|
|
|
"browsertime",
|
|
|
|
"package.json",
|
|
|
|
)
|
|
|
|
) as package:
|
|
|
|
return json.load(package)
|
|
|
|
|
|
|
|
def _get_browsertime_resolved():
|
|
|
|
try:
|
|
|
|
with open(
|
|
|
|
os.path.join(
|
|
|
|
self.topsrcdir,
|
|
|
|
"tools",
|
|
|
|
"browsertime",
|
|
|
|
"node_modules",
|
|
|
|
".package-lock.json",
|
|
|
|
)
|
|
|
|
) as package_lock:
|
|
|
|
return json.load(package_lock)["packages"][
|
|
|
|
"node_modules/browsertime"
|
|
|
|
]["resolved"]
|
|
|
|
except FileNotFoundError:
|
|
|
|
# Older versions of node/npm add this metadata to package.json
|
|
|
|
return _get_browsertime_package()["_from"]
|
|
|
|
|
2021-01-11 21:37:36 +03:00
|
|
|
def _should_install():
|
|
|
|
# If browsertime doesn't exist, install it
|
|
|
|
if not os.path.exists(
|
2020-09-30 18:13:06 +03:00
|
|
|
self.config["browsertime_browsertimejs"]
|
2021-01-11 21:37:36 +03:00
|
|
|
) or not os.path.exists(self.config["browsertime_vismet_script"]):
|
|
|
|
return True
|
|
|
|
|
|
|
|
# Browsertime exists, check if it's outdated
|
|
|
|
with open(
|
|
|
|
os.path.join(self.topsrcdir, "tools", "browsertime", "package.json")
|
2021-05-28 14:09:16 +03:00
|
|
|
) as new:
|
2021-01-11 21:37:36 +03:00
|
|
|
new_pkg = json.load(new)
|
|
|
|
|
2021-05-28 14:09:16 +03:00
|
|
|
return not _get_browsertime_resolved().endswith(
|
2021-01-11 21:37:36 +03:00
|
|
|
new_pkg["devDependencies"]["browsertime"]
|
|
|
|
)
|
|
|
|
|
|
|
|
def _get_browsertime_version():
|
2021-05-28 14:09:16 +03:00
|
|
|
# Returns the (version number, current commit) used
|
|
|
|
return (
|
|
|
|
_get_browsertime_package()["version"],
|
|
|
|
_get_browsertime_resolved(),
|
|
|
|
)
|
2020-10-26 21:34:53 +03:00
|
|
|
|
2020-09-30 18:13:06 +03:00
|
|
|
# Check if browsertime scripts exist and try to install them if
|
|
|
|
# they aren't
|
2021-01-11 21:37:36 +03:00
|
|
|
if _should_install():
|
2020-09-30 18:13:06 +03:00
|
|
|
# TODO: Make this "integration" nicer in the near future
|
|
|
|
print("Missing browsertime files...attempting to install")
|
|
|
|
subprocess.check_call(
|
|
|
|
[
|
|
|
|
os.path.join(self.topsrcdir, "mach"),
|
|
|
|
"browsertime",
|
|
|
|
"--setup",
|
|
|
|
"--clobber",
|
|
|
|
]
|
|
|
|
)
|
2021-01-11 21:37:36 +03:00
|
|
|
if _should_install():
|
2020-09-30 18:13:06 +03:00
|
|
|
raise Exception(
|
|
|
|
"Failed installation attempt. Cannot find browsertime scripts. "
|
|
|
|
"Run `./mach browsertime --setup --clobber` to set it up."
|
|
|
|
)
|
2021-01-11 21:37:36 +03:00
|
|
|
|
|
|
|
print("Using browsertime version %s from %s" % _get_browsertime_version())
|
|
|
|
|
2019-07-27 00:30:03 +03:00
|
|
|
finally:
|
|
|
|
sys.path = sys.path[1:]
|
|
|
|
|
2018-04-23 23:43:30 +03:00
|
|
|
def make_args(self):
|
|
|
|
self.args = {
|
|
|
|
"config": {},
|
|
|
|
"initial_config_file": self.config_file_path,
|
|
|
|
}
|
|
|
|
|
|
|
|
def write_config(self):
|
|
|
|
try:
|
2020-06-24 17:33:12 +03:00
|
|
|
config_file = open(self.config_file_path, "w")
|
2018-04-23 23:43:30 +03:00
|
|
|
config_file.write(json.dumps(self.config))
|
|
|
|
config_file.close()
|
|
|
|
except IOError as e:
|
|
|
|
err_str = "Error writing to Raptor Mozharness config file {0}:{1}"
|
|
|
|
print(err_str.format(self.config_file_path, str(e)))
|
|
|
|
raise e
|
|
|
|
|
|
|
|
def run_mozharness(self):
|
|
|
|
sys.path.insert(0, self.mozharness_dir)
|
|
|
|
from mozharness.mozilla.testing.raptor import Raptor
|
2020-10-26 21:34:53 +03:00
|
|
|
|
2018-04-23 23:43:30 +03:00
|
|
|
raptor_mh = Raptor(
|
|
|
|
config=self.args["config"],
|
|
|
|
initial_config_file=self.args["initial_config_file"],
|
|
|
|
)
|
|
|
|
return raptor_mh.run()
|
|
|
|
|
|
|
|
|
|
|
|
def create_parser():
|
|
|
|
sys.path.insert(0, HERE) # allow to import the raptor package
|
|
|
|
from raptor.cmdline import create_parser
|
2020-10-26 21:34:53 +03:00
|
|
|
|
2018-04-23 23:43:30 +03:00
|
|
|
return create_parser(mach_interface=True)
|
|
|
|
|
|
|
|
|
2021-09-27 21:12:51 +03:00
|
|
|
@Command(
|
|
|
|
"raptor",
|
|
|
|
category="testing",
|
|
|
|
description="Run Raptor performance tests.",
|
|
|
|
parser=create_parser,
|
|
|
|
)
|
|
|
|
def run_raptor(command_context, **kwargs):
|
|
|
|
# Defers this import so that a transitive dependency doesn't
|
|
|
|
# stop |mach bootstrap| from running
|
|
|
|
from raptor.power import enable_charging, disable_charging
|
2021-09-20 23:21:07 +03:00
|
|
|
|
2021-09-27 21:12:51 +03:00
|
|
|
build_obj = command_context
|
2021-09-21 05:16:50 +03:00
|
|
|
|
2021-09-27 21:12:51 +03:00
|
|
|
is_android = Conditions.is_android(build_obj) or kwargs["app"] in ANDROID_BROWSERS
|
2021-09-21 23:38:16 +03:00
|
|
|
|
2021-09-27 21:12:51 +03:00
|
|
|
if is_android:
|
|
|
|
from mozrunner.devices.android_device import (
|
|
|
|
verify_android_device,
|
|
|
|
InstallIntent,
|
|
|
|
)
|
|
|
|
from mozdevice import ADBDeviceFactory
|
2021-09-23 13:06:40 +03:00
|
|
|
|
2021-09-27 21:12:51 +03:00
|
|
|
install = (
|
|
|
|
InstallIntent.NO if kwargs.pop("noinstall", False) else InstallIntent.YES
|
|
|
|
)
|
|
|
|
verbose = False
|
|
|
|
if (
|
|
|
|
kwargs.get("log_mach_verbose")
|
|
|
|
or kwargs.get("log_tbpl_level") == "debug"
|
|
|
|
or kwargs.get("log_mach_level") == "debug"
|
|
|
|
or kwargs.get("log_raw_level") == "debug"
|
|
|
|
):
|
|
|
|
verbose = True
|
|
|
|
if not verify_android_device(
|
|
|
|
build_obj,
|
|
|
|
install=install,
|
|
|
|
app=kwargs["binary"],
|
|
|
|
verbose=verbose,
|
|
|
|
xre=True,
|
|
|
|
): # Equivalent to 'run_local' = True.
|
2021-09-21 23:38:16 +03:00
|
|
|
return 1
|
2021-09-27 21:12:51 +03:00
|
|
|
|
|
|
|
# Remove mach global arguments from sys.argv to prevent them
|
|
|
|
# from being consumed by raptor. Treat any item in sys.argv
|
|
|
|
# occuring before "raptor" as a mach global argument.
|
|
|
|
argv = []
|
|
|
|
in_mach = True
|
|
|
|
for arg in sys.argv:
|
|
|
|
if not in_mach:
|
|
|
|
argv.append(arg)
|
|
|
|
if arg.startswith("raptor"):
|
|
|
|
in_mach = False
|
|
|
|
|
|
|
|
raptor = command_context._spawn(RaptorRunner)
|
|
|
|
device = None
|
|
|
|
|
|
|
|
try:
|
|
|
|
if kwargs["power_test"] and is_android:
|
|
|
|
device = ADBDeviceFactory(verbose=True)
|
|
|
|
disable_charging(device)
|
|
|
|
return raptor.run_test(argv, kwargs)
|
|
|
|
except BinaryNotFoundException as e:
|
|
|
|
command_context.log(
|
|
|
|
logging.ERROR, "raptor", {"error": str(e)}, "ERROR: {error}"
|
|
|
|
)
|
|
|
|
command_context.log(logging.INFO, "raptor", {"help": e.help()}, "{help}")
|
|
|
|
return 1
|
|
|
|
except Exception as e:
|
|
|
|
print(repr(e))
|
|
|
|
return 1
|
|
|
|
finally:
|
|
|
|
if kwargs["power_test"] and device:
|
|
|
|
enable_charging(device)
|
|
|
|
|
|
|
|
|
|
|
|
@Command(
|
|
|
|
"raptor-test",
|
|
|
|
category="testing",
|
|
|
|
description="Run Raptor performance tests.",
|
|
|
|
parser=create_parser,
|
|
|
|
)
|
|
|
|
def run_raptor_test(command_context, **kwargs):
|
|
|
|
return run_raptor(command_context, **kwargs)
|