Commit 8db64ed2 authored by jbudorick's avatar jbudorick Committed by Commit bot

[Android] Push gtest deps in gtest/setup.py.

This patch is an alternative approach to only attempting to push gtest
deps once. (The first attempt to do this, landed in
https://codereview.chromium.org/560133002, caused issues and had to be
reverted.)

BUG=400440

Review URL: https://codereview.chromium.org/651923002

Cr-Commit-Position: refs/heads/master@{#299314}
parent 88a5d47e
...@@ -14,9 +14,11 @@ import sys ...@@ -14,9 +14,11 @@ import sys
from pylib import cmd_helper from pylib import cmd_helper
from pylib import constants from pylib import constants
from pylib import valgrind_tools
from pylib.base import base_test_result from pylib.base import base_test_result
from pylib.base import test_dispatcher from pylib.base import test_dispatcher
from pylib.device import device_utils
from pylib.gtest import test_package_apk from pylib.gtest import test_package_apk
from pylib.gtest import test_package_exe from pylib.gtest import test_package_exe
from pylib.gtest import test_runner from pylib.gtest import test_runner
...@@ -287,6 +289,19 @@ def _FilterDisabledTests(tests, suite_name, has_gtest_filter): ...@@ -287,6 +289,19 @@ def _FilterDisabledTests(tests, suite_name, has_gtest_filter):
return tests return tests
def PushDataDeps(device, test_options, test_package):
valgrind_tools.PushFilesForTool(test_options.tool, device)
if os.path.exists(constants.ISOLATE_DEPS_DIR):
device_dir = (
constants.TEST_EXECUTABLE_DIR
if test_package.suite_name == 'breakpad_unittests'
else device.GetExternalStoragePath())
device.PushChangedFiles([
(os.path.join(constants.ISOLATE_DEPS_DIR, p),
'%s/%s' % (device_dir, p))
for p in os.listdir(constants.ISOLATE_DEPS_DIR)])
def Setup(test_options, devices): def Setup(test_options, devices):
"""Create the test runner factory and tests. """Create the test runner factory and tests.
...@@ -314,6 +329,9 @@ def Setup(test_options, devices): ...@@ -314,6 +329,9 @@ def Setup(test_options, devices):
_GenerateDepsDirUsingIsolate(test_options.suite_name, _GenerateDepsDirUsingIsolate(test_options.suite_name,
test_options.isolate_file_path) test_options.isolate_file_path)
device_utils.DeviceUtils.parallel(devices).pMap(
PushDataDeps, test_options, test_package)
tests = _GetTests(test_options, test_package, devices) tests = _GetTests(test_options, test_package, devices)
# Constructs a new TestRunner with the current options. # Constructs a new TestRunner with the current options.
......
...@@ -131,5 +131,5 @@ class TestPackageApk(TestPackage): ...@@ -131,5 +131,5 @@ class TestPackageApk(TestPackage):
#override #override
def Install(self, device): def Install(self, device):
self.tool.CopyFiles() self.tool.CopyFiles(device)
device.Install(self.suite_path) device.Install(self.suite_path)
...@@ -6,7 +6,6 @@ import logging ...@@ -6,7 +6,6 @@ import logging
import os import os
import re import re
from pylib import constants
from pylib import pexpect from pylib import pexpect
from pylib.base import base_test_result from pylib.base import base_test_result
from pylib.base import base_test_runner from pylib.base import base_test_runner
...@@ -59,22 +58,6 @@ class TestRunner(base_test_runner.BaseTestRunner): ...@@ -59,22 +58,6 @@ class TestRunner(base_test_runner.BaseTestRunner):
def InstallTestPackage(self): def InstallTestPackage(self):
self.test_package.Install(self.device) self.test_package.Install(self.device)
#override
def PushDataDeps(self):
self.device.WaitUntilFullyBooted(timeout=20)
self.tool.CopyFiles()
if os.path.exists(constants.ISOLATE_DEPS_DIR):
# TODO(frankf): linux_dumper_unittest_helper needs to be in the same dir
# as breakpad_unittests exe. Find a better way to do this.
if self.test_package.suite_name == 'breakpad_unittests':
device_dir = constants.TEST_EXECUTABLE_DIR
else:
device_dir = self.device.GetExternalStoragePath()
self.device.PushChangedFiles(
[(os.path.join(constants.ISOLATE_DEPS_DIR, p),
os.path.join(device_dir, p))
for p in os.listdir(constants.ISOLATE_DEPS_DIR)])
def _ParseTestOutput(self, p): def _ParseTestOutput(self, p):
"""Process the test output. """Process the test output.
......
...@@ -126,7 +126,7 @@ class TestRunner(base_test_runner.BaseTestRunner): ...@@ -126,7 +126,7 @@ class TestRunner(base_test_runner.BaseTestRunner):
dst_layer))] dst_layer))]
if host_device_file_tuples: if host_device_file_tuples:
self.device.PushChangedFiles(host_device_file_tuples) self.device.PushChangedFiles(host_device_file_tuples)
self.tool.CopyFiles() self.tool.CopyFiles(self.device)
TestRunner._DEVICE_HAS_TEST_FILES[str(self.device)] = True TestRunner._DEVICE_HAS_TEST_FILES[str(self.device)] = True
def _GetInstrumentationArgs(self): def _GetInstrumentationArgs(self):
......
...@@ -10,12 +10,12 @@ The interface is intended to be used as follows. ...@@ -10,12 +10,12 @@ The interface is intended to be used as follows.
1. For tests that simply run a native process (i.e. no activity is spawned): 1. For tests that simply run a native process (i.e. no activity is spawned):
Call tool.CopyFiles(). Call tool.CopyFiles(device).
Prepend test command line with tool.GetTestWrapper(). Prepend test command line with tool.GetTestWrapper().
2. For tests that spawn an activity: 2. For tests that spawn an activity:
Call tool.CopyFiles(). Call tool.CopyFiles(device).
Call tool.SetupEnvironment(). Call tool.SetupEnvironment().
Run the test as usual. Run the test as usual.
Call tool.CleanUpEnvironment(). Call tool.CleanUpEnvironment().
...@@ -62,7 +62,8 @@ class BaseTool(object): ...@@ -62,7 +62,8 @@ class BaseTool(object):
""" """
return '' return ''
def CopyFiles(self): @classmethod
def CopyFiles(cls, device):
"""Copies tool-specific files to the device, create directories, etc.""" """Copies tool-specific files to the device, create directories, etc."""
pass pass
...@@ -106,21 +107,21 @@ class AddressSanitizerTool(BaseTool): ...@@ -106,21 +107,21 @@ class AddressSanitizerTool(BaseTool):
# This is required because ASan is a compiler-based tool, and md5sum # This is required because ASan is a compiler-based tool, and md5sum
# includes instrumented code from base. # includes instrumented code from base.
device.old_interface.SetUtilWrapper(self.GetUtilWrapper()) device.old_interface.SetUtilWrapper(self.GetUtilWrapper())
@classmethod
def CopyFiles(cls, device):
"""Copies ASan tools to the device."""
libs = glob.glob(os.path.join(DIR_SOURCE_ROOT, libs = glob.glob(os.path.join(DIR_SOURCE_ROOT,
'third_party/llvm-build/Release+Asserts/', 'third_party/llvm-build/Release+Asserts/',
'lib/clang/*/lib/linux/', 'lib/clang/*/lib/linux/',
'libclang_rt.asan-arm-android.so')) 'libclang_rt.asan-arm-android.so'))
assert len(libs) == 1 assert len(libs) == 1
self._lib = libs[0]
def CopyFiles(self):
"""Copies ASan tools to the device."""
subprocess.call([os.path.join(DIR_SOURCE_ROOT, subprocess.call([os.path.join(DIR_SOURCE_ROOT,
'tools/android/asan/asan_device_setup.sh'), 'tools/android/asan/asan_device_setup.sh'),
'--device', str(self._device), '--device', str(device),
'--lib', self._lib, '--lib', libs[0],
'--extra-options', AddressSanitizerTool.EXTRA_OPTIONS]) '--extra-options', AddressSanitizerTool.EXTRA_OPTIONS])
self._device.WaitUntilFullyBooted() device.WaitUntilFullyBooted()
def GetTestWrapper(self): def GetTestWrapper(self):
return AddressSanitizerTool.WRAPPER_NAME return AddressSanitizerTool.WRAPPER_NAME
...@@ -164,15 +165,16 @@ class ValgrindTool(BaseTool): ...@@ -164,15 +165,16 @@ class ValgrindTool(BaseTool):
self._wrap_properties = ['wrap.com.google.android.apps.ch', self._wrap_properties = ['wrap.com.google.android.apps.ch',
'wrap.org.chromium.native_test'] 'wrap.org.chromium.native_test']
def CopyFiles(self): @classmethod
def CopyFiles(cls, device):
"""Copies Valgrind tools to the device.""" """Copies Valgrind tools to the device."""
self._device.RunShellCommand( device.RunShellCommand(
'rm -r %s; mkdir %s' % (ValgrindTool.VG_DIR, ValgrindTool.VG_DIR)) 'rm -r %s; mkdir %s' % (ValgrindTool.VG_DIR, ValgrindTool.VG_DIR))
self._device.RunShellCommand( device.RunShellCommand(
'rm -r %s; mkdir %s' % (ValgrindTool.VGLOGS_DIR, 'rm -r %s; mkdir %s' % (ValgrindTool.VGLOGS_DIR,
ValgrindTool.VGLOGS_DIR)) ValgrindTool.VGLOGS_DIR))
files = self.GetFilesForTool() files = cls.GetFilesForTool()
self._device.PushChangedFiles( device.PushChangedFiles(
[((os.path.join(DIR_SOURCE_ROOT, f), [((os.path.join(DIR_SOURCE_ROOT, f),
os.path.join(ValgrindTool.VG_DIR, os.path.basename(f))) os.path.join(ValgrindTool.VG_DIR, os.path.basename(f)))
for f in files)]) for f in files)])
...@@ -192,7 +194,8 @@ class ValgrindTool(BaseTool): ...@@ -192,7 +194,8 @@ class ValgrindTool(BaseTool):
self._device.RunShellCommand('setprop %s ""' % (prop,)) self._device.RunShellCommand('setprop %s ""' % (prop,))
SetChromeTimeoutScale(self._device, None) SetChromeTimeoutScale(self._device, None)
def GetFilesForTool(self): @staticmethod
def GetFilesForTool():
"""Returns a list of file names for the tool.""" """Returns a list of file names for the tool."""
raise NotImplementedError() raise NotImplementedError()
...@@ -211,7 +214,8 @@ class MemcheckTool(ValgrindTool): ...@@ -211,7 +214,8 @@ class MemcheckTool(ValgrindTool):
def __init__(self, device): def __init__(self, device):
super(MemcheckTool, self).__init__(device) super(MemcheckTool, self).__init__(device)
def GetFilesForTool(self): @staticmethod
def GetFilesForTool():
"""Returns a list of file names for the tool.""" """Returns a list of file names for the tool."""
return ['tools/valgrind/android/vg-chrome-wrapper.sh', return ['tools/valgrind/android/vg-chrome-wrapper.sh',
'tools/valgrind/memcheck/suppressions.txt', 'tools/valgrind/memcheck/suppressions.txt',
...@@ -232,7 +236,8 @@ class TSanTool(ValgrindTool): ...@@ -232,7 +236,8 @@ class TSanTool(ValgrindTool):
def __init__(self, device): def __init__(self, device):
super(TSanTool, self).__init__(device) super(TSanTool, self).__init__(device)
def GetFilesForTool(self): @staticmethod
def GetFilesForTool():
"""Returns a list of file names for the tool.""" """Returns a list of file names for the tool."""
return ['tools/valgrind/android/vg-chrome-wrapper-tsan.sh', return ['tools/valgrind/android/vg-chrome-wrapper-tsan.sh',
'tools/valgrind/tsan/suppressions.txt', 'tools/valgrind/tsan/suppressions.txt',
...@@ -276,3 +281,22 @@ def CreateTool(tool_name, device): ...@@ -276,3 +281,22 @@ def CreateTool(tool_name, device):
print 'Unknown tool %s, available tools: %s' % ( print 'Unknown tool %s, available tools: %s' % (
tool_name, ', '.join(sorted(TOOL_REGISTRY.keys()))) tool_name, ', '.join(sorted(TOOL_REGISTRY.keys())))
sys.exit(1) sys.exit(1)
def PushFilesForTool(tool_name, device):
"""Pushes the files required for |tool_name| to |device|.
Args:
tool_name: Name of the tool to create.
device: A DeviceUtils instance.
"""
if not tool_name:
return
clazz = TOOL_REGISTRY.get(tool_name)
if clazz:
clazz.CopyFiles(device)
else:
print 'Unknown tool %s, available tools: %s' % (
tool_name, ', '.join(sorted(TOOL_REGISTRY.keys())))
sys.exit(1)
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