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