Commit a82ea31a authored by Sergiy Byelozyorov's avatar Sergiy Byelozyorov Committed by Commit Bot

[tools] Detect location of android build tools automatically

R=machenbach@chromium.org

No-Try: true
Bug: chromium:838864
Change-Id: Ifbdd9fe986e84197fd1ff6441c1565fed44c2c6f
Reviewed-on: https://chromium-review.googlesource.com/1149869
Commit-Queue: Sergiy Byelozyorov <sergiyb@chromium.org>
Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54689}
parent 6f790cbe
......@@ -1099,6 +1099,7 @@ action("v8_dump_build_config") {
rebase_path("$root_out_dir/v8_build_config.json", root_build_dir),
"current_cpu=\"$current_cpu\"",
"dcheck_always_on=$dcheck_always_on",
"is_android=$is_android",
"is_asan=$is_asan",
"is_cfi=$is_cfi",
"is_component_build=$is_component_build",
......
......@@ -56,7 +56,7 @@ A suite without "tests" is considered a performance test itself.
Full example (suite with one runner):
{
"path": ["."],
"owner": ["username@chromium.org"],
"owners": ["username@chromium.org"],
"flags": ["--expose-gc"],
"test_flags": ["5"],
"archs": ["ia32", "x64"],
......@@ -76,7 +76,7 @@ Full example (suite with one runner):
Full example (suite with several runners):
{
"path": ["."],
"owner": ["username@chromium.org", "otherowner@google.com"],
"owners": ["username@chromium.org", "otherowner@google.com"],
"flags": ["--expose-gc"],
"archs": ["ia32", "x64"],
"run_count": 5,
......@@ -124,6 +124,8 @@ GENERIC_RESULTS_RE = re.compile(r"^RESULT ([^:]+): ([^=]+)= ([^ ]+) ([^ ]*)$")
RESULT_STDDEV_RE = re.compile(r"^\{([^\}]+)\}$")
RESULT_LIST_RE = re.compile(r"^\[([^\]]+)\]$")
TOOLS_BASE = os.path.abspath(os.path.dirname(__file__))
ANDROID_BUILD_TOOLS = os.path.join(
os.path.dirname(TOOLS_BASE), 'build', 'android')
def LoadAndroidBuildTools(path): # pragma: no cover
......@@ -631,9 +633,17 @@ class Platform(object):
self.shell_dir_secondary = options.shell_dir_secondary
self.extra_flags = options.extra_flags.split()
@staticmethod
def ReadBuildConfig(options):
config_path = os.path.join(options.shell_dir, 'v8_build_config.json')
if not os.path.isfile(config_path):
return {}
with open(config_path) as f:
return json.load(f)
@staticmethod
def GetPlatform(options):
if options.android_build_tools:
if Platform.ReadBuildConfig(options).get('is_android', False):
return AndroidPlatform(options)
else:
return DesktopPlatform(options)
......@@ -727,7 +737,7 @@ class AndroidPlatform(Platform): # pragma: no cover
def __init__(self, options):
super(AndroidPlatform, self).__init__(options)
LoadAndroidBuildTools(options.android_build_tools)
LoadAndroidBuildTools(ANDROID_BUILD_TOOLS)
if not options.device:
# Detect attached device if not specified.
......@@ -975,9 +985,7 @@ class CustomMachineConfiguration:
def Main(args):
logging.getLogger().setLevel(logging.INFO)
parser = optparse.OptionParser()
parser.add_option("--android-build-tools",
help="Path to chromium's build/android. Specifying this "
"option will run tests using android platform.")
parser.add_option("--android-build-tools", help="Deprecated.")
parser.add_option("--arch",
help=("The architecture to run tests for, "
"'auto' or 'native' for auto-detect"),
......@@ -1048,10 +1056,6 @@ def Main(args):
print "Unknown architecture %s" % options.arch
return 1
if options.device and not options.android_build_tools: # pragma: no cover
print "Specifying a device requires Android build tools."
return 1
if (options.json_test_results_secondary and
not options.outdir_secondary): # pragma: no cover
print("For writing secondary json test results, a secondary outdir patch "
......
......@@ -6,8 +6,7 @@
from collections import namedtuple
import coverage
import json
from mock import DEFAULT
from mock import MagicMock
from mock import MagicMock, patch
import os
from os import path, sys
import platform
......@@ -27,6 +26,7 @@ TEST_WORKSPACE = path.join(tempfile.gettempdir(), "test-v8-run-perf")
V8_JSON = {
"path": ["."],
"owners": ["username@chromium.org"],
"binary": "d7",
"flags": ["--flag"],
"main": "run.js",
......@@ -40,6 +40,7 @@ V8_JSON = {
V8_NESTED_SUITES_JSON = {
"path": ["."],
"owners": ["username@chromium.org"],
"flags": ["--flag"],
"run_count": 1,
"units": "score",
......@@ -76,6 +77,7 @@ V8_NESTED_SUITES_JSON = {
V8_GENERIC_JSON = {
"path": ["."],
"owners": ["username@chromium.org"],
"binary": "cc",
"flags": ["--flag"],
"generic": True,
......@@ -429,9 +431,9 @@ class PerfTest(unittest.TestCase):
platform.Run = MagicMock(
return_value=("Richards: 1.234\nDeltaBlue: 10657567\n", None))
run_perf.AndroidPlatform = MagicMock(return_value=platform)
self.assertEquals(
0, self._CallMain("--android-build-tools", "/some/dir",
"--arch", "arm"))
with patch.object(run_perf.Platform, 'ReadBuildConfig',
MagicMock(return_value={'is_android': True})):
self.assertEquals(0, self._CallMain("--arch", "arm"))
self._VerifyResults("test", "score", [
{"name": "Richards", "results": ["1.234"], "stddev": ""},
{"name": "DeltaBlue", "results": ["10657567.0"], "stddev": ""},
......
{
"path": ["."],
"owners": ["username@chromium.org"],
"flags": [],
"main": "run.js",
"run_count": 2,
......
{
"path": ["."],
"owners": ["username@chromium.org"],
"flags": [],
"main": "run.js",
"run_count": 2,
......
{
"path": ["."],
"owners": ["username@chromium.org"],
"flags": [],
"run_count": 1,
"results_processor": "results_processor.py",
......
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