summaryrefslogtreecommitdiffstats
path: root/build/android
diff options
context:
space:
mode:
authorbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-06 13:29:01 +0000
committerbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-06 13:29:01 +0000
commit31e317379b9ffdb16a6eef9c4b5364f5894e1508 (patch)
treef33cedec7a576ce8859646c4621906130122ffd9 /build/android
parentd138f4e9ab391e485b21d981b40b49f4d91f213b (diff)
downloadchromium_src-31e317379b9ffdb16a6eef9c4b5364f5894e1508.zip
chromium_src-31e317379b9ffdb16a6eef9c4b5364f5894e1508.tar.gz
chromium_src-31e317379b9ffdb16a6eef9c4b5364f5894e1508.tar.bz2
Upstream latest changes from build/android/pylib.
- test_result.py cleanup and related dependencies, including fixing run_monkey_test.py - always use sharding for java tests - test package parser BUG=136980 TEST= Review URL: https://chromiumcodereview.appspot.com/10910027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@155182 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/android')
-rw-r--r--build/android/pylib/python_test_base.py14
-rw-r--r--build/android/pylib/run_java_tests.py39
-rw-r--r--build/android/pylib/run_python_tests.py17
-rw-r--r--build/android/pylib/sharded_tests_queue.py1
-rw-r--r--build/android/pylib/test_package.py3
-rw-r--r--build/android/pylib/test_result.py16
-rw-r--r--build/android/pylib/valgrind_tools.py120
-rwxr-xr-xbuild/android/run_monkey_test.py20
8 files changed, 104 insertions, 126 deletions
diff --git a/build/android/pylib/python_test_base.py b/build/android/pylib/python_test_base.py
index 69e5bbec..39b9d27 100644
--- a/build/android/pylib/python_test_base.py
+++ b/build/android/pylib/python_test_base.py
@@ -27,7 +27,7 @@ import android_commands
import apk_info
from run_java_tests import TestRunner
import test_options_parser
-from test_result import SingleTestResult, TestResults, PYTHON
+from test_result import SingleTestResult, TestResults
# aka the parent of com.google.android
@@ -138,16 +138,9 @@ class PythonTestBase(object):
if not log:
log = 'No logging information.'
- short_error_msg = single_result.log.split('\n')[0]
- # err_info is ostensibly for Sponge to consume; it's a short error
- # message and a longer one.
- err_info = (short_error_msg, log)
-
python_result = SingleTestResult(self.qualified_name, start_ms,
duration_ms,
- PYTHON,
- log,
- err_info)
+ log)
# Figure out where the test belonged. There's probably a cleaner way of
# doing this.
@@ -160,8 +153,7 @@ class PythonTestBase(object):
else:
python_result = SingleTestResult(self.qualified_name, start_ms,
- duration_ms,
- PYTHON)
+ duration_ms)
test_results.ok = [python_result]
return test_results
diff --git a/build/android/pylib/run_java_tests.py b/build/android/pylib/run_java_tests.py
index 458f2de..bef6d7a 100644
--- a/build/android/pylib/run_java_tests.py
+++ b/build/android/pylib/run_java_tests.py
@@ -23,8 +23,8 @@ from forwarder import Forwarder
from json_perf_parser import GetAverageRunInfoFromJSONString
from perf_tests_helper import PrintPerfResult
import sharded_tests_queue
-from test_result import JAVA, SingleTestResult, TestResults
-
+from test_result import SingleTestResult, TestResults
+import valgrind_tools
_PERF_TEST_ANNOTATION = 'PerfTest'
@@ -168,10 +168,9 @@ class TestRunner(BaseTestRunner):
self.adb.PushIfNeeded(host_test_files_path,
TestRunner._DEVICE_DATA_DIR)
if self.install_apk:
- # Install -r is not reliable, so uninstall it first.
for apk in self.apks:
- self.adb.Adb().SendCommand('uninstall ' + apk.GetPackageName())
- self.adb.Adb().SendCommand('install ' + apk.GetApkPath())
+ self.adb.ManagedInstall(apk.GetApkPath(),
+ package_name=apk.GetPackageName())
self.tool.CopyFiles()
TestRunner._DEVICE_HAS_TEST_FILES[self.device] = True
@@ -400,11 +399,7 @@ class TestRunner(BaseTestRunner):
def _SetupIndividualTestTimeoutScale(self, test):
timeout_scale = self._GetIndividualTestTimeoutScale(test)
- if timeout_scale == 1:
- value = '""'
- else:
- value = '%f' % timeout_scale
- self.adb.RunShellCommand('setprop chrome.timeout_scale %s' % value)
+ valgrind_tools.SetChromeTimeoutScale(self.adb, timeout_scale)
def _GetIndividualTestTimeoutScale(self, test):
"""Returns the timeout scale for the given |test|."""
@@ -468,12 +463,10 @@ class TestRunner(BaseTestRunner):
log = 'No information.'
if self.screenshot_failures or log.find('INJECT_EVENTS perm') >= 0:
self._TakeScreenshot(test)
- result = (log.split('\n')[0], log)
self.test_results.failed += [SingleTestResult(test, start_date_ms,
- duration_ms, JAVA, log,
- result)]
+ duration_ms, log)]
else:
- result = [SingleTestResult(test, start_date_ms, duration_ms, JAVA)]
+ result = [SingleTestResult(test, start_date_ms, duration_ms)]
self.test_results.ok += result
# Catch exceptions thrown by StartInstrumentation().
# See ../../third_party/android/testrunner/adb_interface.py
@@ -490,8 +483,7 @@ class TestRunner(BaseTestRunner):
message = 'No information.'
self.test_results.crashed += [SingleTestResult(test, start_date_ms,
duration_ms,
- JAVA, message,
- (message, message))]
+ message)]
test_result = None
self.TestTeardown(test, test_result)
return self.test_results
@@ -585,13 +577,10 @@ def DispatchJavaTests(options, apks):
logging.info('Will run: %s', str(tests))
- if (len(attached_devices) > 1 and
- not coverage and
- not options.wait_for_debugger):
- sharder = TestSharder(attached_devices, options, tests, apks)
- test_results = sharder.RunShardedTests()
- else:
- runner = TestRunner(options, attached_devices[0], tests, coverage, 0, apks,
- [])
- test_results = runner.Run()
+ if len(attached_devices) > 1 and (coverage or options.wait_for_debugger):
+ logging.warning('Coverage / debugger can not be sharded, '
+ 'using first available device')
+ attached_devices = attached_devices[:1]
+ sharder = TestSharder(attached_devices, options, tests, apks)
+ test_results = sharder.RunShardedTests()
return test_results
diff --git a/build/android/pylib/run_python_tests.py b/build/android/pylib/run_python_tests.py
index 6556892..0fc1245 100644
--- a/build/android/pylib/run_python_tests.py
+++ b/build/android/pylib/run_python_tests.py
@@ -90,15 +90,14 @@ def DispatchPythonTests(options):
test_files_copier.CopyTestFilesOnce()
# Actually run the tests.
- if (len(attached_devices) > 1 and
- not options.wait_for_debugger):
- logging.debug('Sharding Python tests.')
- sharder = PythonTestSharder(attached_devices, options.shard_retries,
- available_tests)
- test_results = sharder.RunShardedTests()
- else:
- logging.debug('Running Python tests serially.')
- test_results = _RunPythonTests(available_tests, attached_devices[0])
+ if len(attached_devices) > 1 and options.wait_for_debugger:
+ logging.warning('Debugger can not be sharded, '
+ 'using first available device')
+ attached_devices = attached_devices[:1]
+ logging.debug('Running Python tests')
+ sharder = PythonTestSharder(attached_devices, options.shard_retries,
+ available_tests)
+ test_results = sharder.RunShardedTests()
return test_results
diff --git a/build/android/pylib/sharded_tests_queue.py b/build/android/pylib/sharded_tests_queue.py
index d2b3779..9e28e2c 100644
--- a/build/android/pylib/sharded_tests_queue.py
+++ b/build/android/pylib/sharded_tests_queue.py
@@ -23,7 +23,6 @@ class ShardedTestsQueue(object):
_STOP_SENTINEL = 'STOP' # sentinel value for iter()
def __init__(self, num_devices, tests):
- assert num_devices > 1, 'At least two devices must be attached.'
self.num_devices = num_devices
self.tests_queue = multiprocessing.Queue()
for test in tests:
diff --git a/build/android/pylib/test_package.py b/build/android/pylib/test_package.py
index 2afdffd..8f28e02 100644
--- a/build/android/pylib/test_package.py
+++ b/build/android/pylib/test_package.py
@@ -96,6 +96,9 @@ class TestPackage(object):
for test in all_tests:
if not test:
continue
+ if test[0] != ' ' and not test.endswith('.'):
+ # Ignore any lines with unexpected format.
+ continue
if test[0] != ' ' and test.endswith('.'):
current = test
continue
diff --git a/build/android/pylib/test_result.py b/build/android/pylib/test_result.py
index 043cb48..db3a24f 100644
--- a/build/android/pylib/test_result.py
+++ b/build/android/pylib/test_result.py
@@ -13,11 +13,6 @@ import buildbot_report
import constants
-# Language values match constants in Sponge protocol buffer (sponge.proto).
-JAVA = 5
-PYTHON = 7
-
-
class BaseTestResult(object):
"""A single result from a unit test."""
@@ -33,13 +28,10 @@ class SingleTestResult(BaseTestResult):
full_name: Full name of the test.
start_date: Date in milliseconds when the test began running.
dur: Duration of the test run in milliseconds.
- lang: Language of the test (JAVA or PYTHON).
log: An optional string listing any errors.
- error: A tuple of a short error message and a longer version used by Sponge
- if test resulted in a fail or error. An empty tuple implies a pass.
"""
- def __init__(self, full_name, start_date, dur, lang, log='', error=()):
+ def __init__(self, full_name, start_date, dur, log=''):
BaseTestResult.__init__(self, full_name, log)
name_pieces = full_name.rsplit('#')
if len(name_pieces) > 1:
@@ -50,8 +42,6 @@ class SingleTestResult(BaseTestResult):
self.test_name = full_name
self.start_date = start_date
self.dur = dur
- self.error = error
- self.lang = lang
class TestResults(object):
@@ -113,9 +103,7 @@ class TestResults(object):
full_name='PythonWrapper#' + test_name,
start_date=start_date_ms,
dur=duration_ms,
- lang=PYTHON,
- log=log_msg,
- error=(str(exc_type), log_msg))
+ log=(str(exc_type) + ' ' + log_msg))
results = TestResults()
results.failed.append(exc_result)
diff --git a/build/android/pylib/valgrind_tools.py b/build/android/pylib/valgrind_tools.py
index 50cc8f5..810f6be 100644
--- a/build/android/pylib/valgrind_tools.py
+++ b/build/android/pylib/valgrind_tools.py
@@ -27,19 +27,30 @@ import sys
from constants import CHROME_DIR
+def SetChromeTimeoutScale(adb, scale):
+ """Sets the timeout scale in /data/local/tmp/chrome_timeout_scale to scale."""
+ path = '/data/local/tmp/chrome_timeout_scale'
+ if not scale or scale == 1.0:
+ # Delete if scale is None/0.0/1.0 since the default timeout scale is 1.0
+ adb.RunShellCommand('rm %s' % path)
+ else:
+ adb.SetFileContents(path, '%f' % scale)
+
+
class BaseTool(object):
"""A tool that does nothing."""
- def __init__(self, *args, **kwargs):
- pass
-
def GetTestWrapper(self):
"""Returns a string that is to be prepended to the test command line."""
return ''
def GetUtilWrapper(self):
- """Returns a string that is to be prepended to the command line of utility
- processes (forwarder, etc.)"""
+ """Returns the wrapper name for the utilities.
+
+ Returns:
+ A string that is to be prepended to the command line of utility
+ processes (forwarder, etc.).
+ """
return ''
def CopyFiles(self):
@@ -64,7 +75,8 @@ class BaseTool(object):
def NeedsDebugInfo(self):
"""Whether this tool requires debug info.
- Returns True if this tool can not work with stripped binaries.
+ Returns:
+ True if this tool can not work with stripped binaries.
"""
return False
@@ -72,12 +84,12 @@ class BaseTool(object):
class AddressSanitizerTool(BaseTool):
"""AddressSanitizer tool."""
- WRAPPER_PATH = "/system/bin/asanwrapper"
+ WRAPPER_PATH = '/system/bin/asanwrapper'
def __init__(self, adb):
- self.adb = adb
- self.wrap_properties = ['wrap.com.google.android.apps.ch',
- 'wrap.org.chromium.native_test']
+ self._adb = adb
+ self._wrap_properties = ['wrap.com.google.android.apps.ch',
+ 'wrap.org.chromium.native_test']
def CopyFiles(self):
"""Copies ASan tools to the device."""
@@ -86,31 +98,32 @@ class AddressSanitizerTool(BaseTool):
'system/bin/asan/app_process',
'system/bin/linker']
android_product_out = os.environ['ANDROID_PRODUCT_OUT']
- self.adb.MakeSystemFolderWritable()
+ self._adb.MakeSystemFolderWritable()
for f in files:
- self.adb.PushIfNeeded(os.path.join(android_product_out, f),
- os.path.join('/', f))
+ self._adb.PushIfNeeded(os.path.join(android_product_out, f),
+ os.path.join('/', f))
def GetTestWrapper(self):
return AddressSanitizerTool.WRAPPER_PATH
def GetUtilWrapper(self):
- """ AddressSanitizer wrapper must be added to all instrumented binaries,
+ """Returns the wrapper for utilities, such as forwarder.
+
+ AddressSanitizer wrapper must be added to all instrumented binaries,
including forwarder and the like. This can be removed if such binaries
were built without instrumentation. """
return AddressSanitizerTool.WRAPPER_PATH
def SetupEnvironment(self):
- for prop in self.wrap_properties:
- self.adb.RunShellCommand('setprop %s "logwrapper %s"' % (
+ for prop in self._wrap_properties:
+ self._adb.RunShellCommand('setprop %s "logwrapper %s"' % (
prop, self.GetTestWrapper()))
- self.adb.RunShellCommand('setprop chrome.timeout_scale %f' % (
- self.GetTimeoutScale()))
+ SetChromeTimeoutScale(self._adb, self.GetTimeoutScale())
def CleanUpEnvironment(self):
- for prop in self.wrap_properties:
- self.adb.RunShellCommand('setprop %s ""' % (prop,))
- self.adb.RunShellCommand('setprop chrome.timeout_scale ""')
+ for prop in self._wrap_properties:
+ self._adb.RunShellCommand('setprop %s ""' % (prop,))
+ SetChromeTimeoutScale(self._adb, None)
def GetTimeoutScale(self):
# Very slow startup.
@@ -123,38 +136,38 @@ class ValgrindTool(BaseTool):
VG_DIR = '/data/local/tmp/valgrind'
VGLOGS_DIR = '/data/local/tmp/vglogs'
- def __init__(self, adb, renderer=False):
- self.adb = adb
+ def __init__(self, adb):
+ self._adb = adb
# exactly 31 chars, SystemProperties::PROP_NAME_MAX
- self.wrap_properties = ['wrap.com.google.android.apps.ch',
- 'wrap.org.chromium.native_test']
+ self._wrap_properties = ['wrap.com.google.android.apps.ch',
+ 'wrap.org.chromium.native_test']
def CopyFiles(self):
"""Copies Valgrind tools to the device."""
- self.adb.RunShellCommand('rm -r %s; mkdir %s' %
- (ValgrindTool.VG_DIR, ValgrindTool.VG_DIR))
- self.adb.RunShellCommand('rm -r %s; mkdir %s' %
- (ValgrindTool.VGLOGS_DIR, ValgrindTool.VGLOGS_DIR))
+ self._adb.RunShellCommand('rm -r %s; mkdir %s' %
+ (ValgrindTool.VG_DIR, ValgrindTool.VG_DIR))
+ self._adb.RunShellCommand('rm -r %s; mkdir %s' %
+ (ValgrindTool.VGLOGS_DIR,
+ ValgrindTool.VGLOGS_DIR))
files = self.GetFilesForTool()
for f in files:
- self.adb.PushIfNeeded(os.path.join(CHROME_DIR, f),
- os.path.join(ValgrindTool.VG_DIR,
- os.path.basename(f)))
+ self._adb.PushIfNeeded(os.path.join(CHROME_DIR, f),
+ os.path.join(ValgrindTool.VG_DIR,
+ os.path.basename(f)))
def SetupEnvironment(self):
"""Sets up device environment."""
- self.adb.RunShellCommand('chmod 777 /data/local/tmp')
- for prop in self.wrap_properties:
- self.adb.RunShellCommand('setprop %s "logwrapper %s"' % (
+ self._adb.RunShellCommand('chmod 777 /data/local/tmp')
+ for prop in self._wrap_properties:
+ self._adb.RunShellCommand('setprop %s "logwrapper %s"' % (
prop, self.GetTestWrapper()))
- self.adb.RunShellCommand('setprop chrome.timeout_scale %f' % (
- self.GetTimeoutScale()))
+ SetChromeTimeoutScale(self._adb, self.GetTimeoutScale())
def CleanUpEnvironment(self):
"""Cleans up device environment."""
- for prop in self.wrap_properties:
- self.adb.RunShellCommand('setprop %s ""' % (prop,))
- self.adb.RunShellCommand('setprop chrome.timeout_scale ""')
+ for prop in self._wrap_properties:
+ self._adb.RunShellCommand('setprop %s ""' % (prop,))
+ SetChromeTimeoutScale(self._adb, None)
def GetFilesForTool(self):
"""Returns a list of file names for the tool."""
@@ -163,7 +176,8 @@ class ValgrindTool(BaseTool):
def NeedsDebugInfo(self):
"""Whether this tool requires debug info.
- Returns True if this tool can not work with stripped binaries.
+ Returns:
+ True if this tool can not work with stripped binaries.
"""
return True
@@ -171,8 +185,8 @@ class ValgrindTool(BaseTool):
class MemcheckTool(ValgrindTool):
"""Memcheck tool."""
- def __init__(self, adb, renderer=False):
- super(MemcheckTool, self).__init__(adb, renderer)
+ def __init__(self, adb):
+ super(MemcheckTool, self).__init__(adb)
def GetFilesForTool(self):
"""Returns a list of file names for the tool."""
@@ -192,8 +206,8 @@ class MemcheckTool(ValgrindTool):
class TSanTool(ValgrindTool):
"""ThreadSanitizer tool. See http://code.google.com/p/data-race-test ."""
- def __init__(self, adb, renderer=False):
- super(TSanTool, self).__init__(adb, renderer)
+ def __init__(self, adb):
+ super(TSanTool, self).__init__(adb)
def GetFilesForTool(self):
"""Returns a list of file names for the tool."""
@@ -208,15 +222,15 @@ class TSanTool(ValgrindTool):
def GetTimeoutScale(self):
"""Returns a multiplier that should be applied to timeout values."""
- return 30
+ return 30.0
TOOL_REGISTRY = {
- 'memcheck': lambda x: MemcheckTool(x, False),
- 'memcheck-renderer': lambda x: MemcheckTool(x, True),
- 'tsan': lambda x: TSanTool(x, False),
- 'tsan-renderer': lambda x: TSanTool(x, True),
- 'asan': lambda x: AddressSanitizerTool(x)
+ 'memcheck': lambda x: MemcheckTool(x),
+ 'memcheck-renderer': lambda x: MemcheckTool(x),
+ 'tsan': lambda x: TSanTool(x),
+ 'tsan-renderer': lambda x: TSanTool(x),
+ 'asan': lambda x: AddressSanitizerTool(x),
}
@@ -226,6 +240,8 @@ def CreateTool(tool_name, adb):
Args:
tool_name: Name of the tool to create.
adb: ADB interface the tool will use.
+ Returns:
+ A tool for the specified tool_name.
"""
if not tool_name:
return BaseTool()
@@ -235,5 +251,5 @@ def CreateTool(tool_name, adb):
return ctor(adb)
else:
print 'Unknown tool %s, available tools: %s' % (
- tool_name, ', '.join(sorted(TOOL_REGISTRY.keys())))
+ tool_name, ', '.join(sorted(TOOL_REGISTRY.keys())))
sys.exit(1)
diff --git a/build/android/run_monkey_test.py b/build/android/run_monkey_test.py
index 3a89796..ab75915 100755
--- a/build/android/run_monkey_test.py
+++ b/build/android/run_monkey_test.py
@@ -45,8 +45,7 @@ class MonkeyTest(python_test_base.PythonTestBase):
crashed = (not before_pids or not after_pids
or after_pids[0] != before_pids[0])
result = test_result.SingleTestResult(self.qualified_name, start_ms,
- duration_ms, test_result.PYTHON,
- log=output)
+ duration_ms, log=output)
results = test_result.TestResults()
if 'Monkey finished' in output and not crashed:
@@ -69,18 +68,11 @@ def DispatchPythonTests(options):
raise Exception('You have no devices attached or visible!')
# Actually run the tests.
- # TODO(frankf): Test sharder should really be handling the case
- # where only 1 device is attached.
- if len(attached_devices) > 1:
- logging.debug('Sharding Python tests.')
- available_tests *= len(attached_devices)
- sharder = python_test_sharder.PythonTestSharder(
- attached_devices, 1, available_tests)
- result = sharder.RunShardedTests()
- else:
- logging.debug('Running Python tests serially.')
- result = python_test_caller.CallPythonTest(available_tests[0],
- attached_devices[0], 0)
+ logging.debug('Running monkey tests.')
+ available_tests *= len(attached_devices)
+ sharder = python_test_sharder.PythonTestSharder(
+ attached_devices, 1, available_tests)
+ result = sharder.RunShardedTests()
result.LogFull('Monkey', 'Monkey', build_type)
result.PrintAnnotation()