summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjbudorick <jbudorick@chromium.org>2015-01-13 15:49:28 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-13 23:50:14 +0000
commite6c56015219f5824bf0cad7f69d888f14e693e3e (patch)
treefbb44cb6dd5ba84044b3a2763e9a618151c29493
parent05b83de45a179f95fca6c4c1bf08142f93268451 (diff)
downloadchromium_src-e6c56015219f5824bf0cad7f69d888f14e693e3e.zip
chromium_src-e6c56015219f5824bf0cad7f69d888f14e693e3e.tar.gz
chromium_src-e6c56015219f5824bf0cad7f69d888f14e693e3e.tar.bz2
[Android] Add file-based gtest filtering for gtests on AMP.
BUG=428729 Review URL: https://codereview.chromium.org/810193007 Cr-Commit-Position: refs/heads/master@{#311363}
-rw-r--r--build/android/pylib/gtest/filter/base_unittests_disabled3
-rw-r--r--build/android/pylib/gtest/filter/cc_unittests_disabled5
-rw-r--r--build/android/pylib/remote/device/remote_device_environment.py29
-rw-r--r--build/android/pylib/remote/device/remote_device_gtest_run.py27
-rw-r--r--build/android/pylib/remote/device/remote_device_test_run.py19
-rwxr-xr-xbuild/android/test_runner.py34
-rw-r--r--testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java14
-rw-r--r--testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java28
8 files changed, 119 insertions, 40 deletions
diff --git a/build/android/pylib/gtest/filter/base_unittests_disabled b/build/android/pylib/gtest/filter/base_unittests_disabled
index a64dd57..bf2311d 100644
--- a/build/android/pylib/gtest/filter/base_unittests_disabled
+++ b/build/android/pylib/gtest/filter/base_unittests_disabled
@@ -20,6 +20,9 @@ FieldTrialTest.*
ScopedJavaRefTest.RefCounts
# Death tests are not supported with apks.
*DeathTest*
+FileTest.MemoryCorruption
+MessagePumpLibeventTest.QuitOutsideOfRun
+ScopedFD.ScopedFDCrashesOnCloseFailure
# http://crbug.com/245043
StackContainer.BufferAlignment
diff --git a/build/android/pylib/gtest/filter/cc_unittests_disabled b/build/android/pylib/gtest/filter/cc_unittests_disabled
new file mode 100644
index 0000000..feab5ac
--- /dev/null
+++ b/build/android/pylib/gtest/filter/cc_unittests_disabled
@@ -0,0 +1,5 @@
+# Death tests are not supported with apks.
+BeginFrameObserverMixInTest.OnBeginFrameImplementation
+BeginFrameSourceMixInTest.ObserverManipulation
+BeginFrameSourceMultiplexerTest.SourcesManipulation
+BeginFrameSourceMultiplexerTest.MinimumIntervalNegativeFails
diff --git a/build/android/pylib/remote/device/remote_device_environment.py b/build/android/pylib/remote/device/remote_device_environment.py
index 0e48ee6..caf8a51 100644
--- a/build/android/pylib/remote/device/remote_device_environment.py
+++ b/build/android/pylib/remote/device/remote_device_environment.py
@@ -166,37 +166,42 @@ class RemoteDeviceEnvironment(environment.Environment):
raise remote_device_helper.RemoteDeviceError('No device found.')
@property
+ def collect(self):
+ return self._collect
+
+ @property
def device(self):
return self._device
@property
- def token(self):
- return self._access_token
+ def only_output_failures(self):
+ # TODO(jbudorick): Remove this once b/18981674 is fixed.
+ return True
@property
def results_path(self):
return self._results_path
@property
+ def runner_package(self):
+ return self._runner_package
+
+ @property
def runner_type(self):
return self._runner_type
@property
- def runner_package(self):
- return self._runner_package
+ def timeouts(self):
+ return self._timeouts
@property
- def trigger(self):
- return self._trigger
+ def token(self):
+ return self._access_token
@property
- def collect(self):
- return self._collect
+ def trigger(self):
+ return self._trigger
@property
def verbose_count(self):
return self._verbose_count
-
- @property
- def timeouts(self):
- return self._timeouts
diff --git a/build/android/pylib/remote/device/remote_device_gtest_run.py b/build/android/pylib/remote/device/remote_device_gtest_run.py
index 3a6c447..e5f6990 100644
--- a/build/android/pylib/remote/device/remote_device_gtest_run.py
+++ b/build/android/pylib/remote/device/remote_device_gtest_run.py
@@ -7,6 +7,7 @@
import logging
import os
import sys
+import tempfile
from pylib import constants
from pylib.base import base_test_result
@@ -15,6 +16,14 @@ from pylib.remote.device import remote_device_test_run
from pylib.remote.device import remote_device_helper
+_EXTRA_COMMAND_LINE_FILE = (
+ 'org.chromium.native_test.ChromeNativeTestActivity.CommandLineFile')
+# TODO(jbudorick): Remove this extra when b/18981674 is fixed.
+_EXTRA_ONLY_OUTPUT_FAILURES = (
+ 'org.chromium.native_test.ChromeNativeTestInstrumentationTestRunner.'
+ 'OnlyOutputFailures')
+
+
class RemoteDeviceGtestRun(remote_device_test_run.RemoteDeviceTestRun):
"""Run gtests and uirobot tests on a remote device."""
@@ -43,8 +52,20 @@ class RemoteDeviceGtestRun(remote_device_test_run.RemoteDeviceTestRun):
dummy_app_path = os.path.join(
constants.GetOutDirectory(), 'apks', 'remote_device_dummy.apk')
- self._AmInstrumentTestSetup(dummy_app_path, self._test_instance.apk,
- runner_package)
+ with tempfile.NamedTemporaryFile(suffix='.flags.txt') as flag_file:
+ env_vars = {}
+ filter_string = self._test_instance._GenerateDisabledFilterString(None)
+ if filter_string:
+ flag_file.write('_ --gtest_filter=%s' % filter_string)
+ flag_file.flush()
+ env_vars[_EXTRA_COMMAND_LINE_FILE] = os.path.basename(flag_file.name)
+ self._test_instance._data_deps.append(
+ (os.path.abspath(flag_file.name), None))
+ if self._env.only_output_failures:
+ env_vars[_EXTRA_ONLY_OUTPUT_FAILURES] = None
+ self._AmInstrumentTestSetup(
+ dummy_app_path, self._test_instance.apk, runner_package,
+ environment_variables=env_vars)
_INSTRUMENTATION_STREAM_LEADER = 'INSTRUMENTATION_STATUS: stream='
@@ -62,6 +83,8 @@ class RemoteDeviceGtestRun(remote_device_test_run.RemoteDeviceTestRun):
if l.startswith(self._INSTRUMENTATION_STREAM_LEADER))
results_list = self._test_instance.ParseGTestOutput(output)
results.AddResults(results_list)
+ if self._env.only_output_failures:
+ logging.info('See logcat for more results information.')
if not self._results['results']['pass']:
results.AddResult(base_test_result.BaseTestResult(
'Remote Service detected error.',
diff --git a/build/android/pylib/remote/device/remote_device_test_run.py b/build/android/pylib/remote/device/remote_device_test_run.py
index cdc8777..c77d0b4 100644
--- a/build/android/pylib/remote/device/remote_device_test_run.py
+++ b/build/android/pylib/remote/device/remote_device_test_run.py
@@ -170,8 +170,12 @@ class RemoteDeviceTestRun(test_run.TestRun):
self._results = test_check_res.json()['response']
return self._results['status']
- def _AmInstrumentTestSetup(self, app_path, test_path, runner_package):
+ def _AmInstrumentTestSetup(self, app_path, test_path, runner_package,
+ environment_variables):
config = {'runner': runner_package}
+ if environment_variables:
+ config['environment_vars'] = ','.join(
+ '%s=%s' % (k, v) for k, v in environment_variables.iteritems())
self._app_id = self._UploadAppToDevice(app_path)
@@ -183,11 +187,12 @@ class RemoteDeviceTestRun(test_run.TestRun):
with zipfile.ZipFile(test_with_deps.name, 'w') as zip_file:
zip_file.write(test_path, host_test, zipfile.ZIP_DEFLATED)
for h, _ in data_deps:
- zip_utils.WriteToZipFile(zip_file, h, '.')
if os.path.isdir(h):
+ zip_utils.WriteToZipFile(zip_file, h, '.')
sdcard_files.extend(os.listdir(h))
else:
- sdcard_files.extend(h)
+ zip_utils.WriteToZipFile(zip_file, h, os.path.basename(h))
+ sdcard_files.append(os.path.basename(h))
config['sdcard_files'] = ','.join(sdcard_files)
config['host_test'] = host_test
self._test_id = self._UploadTestToDevice(
@@ -232,7 +237,13 @@ class RemoteDeviceTestRun(test_run.TestRun):
"""
logging.info('Generating config file for test.')
with tempfile.TemporaryFile() as config:
- config_data = ['[appurify]', '[%s]' % runner_type]
+ config_data = [
+ '[appurify]',
+ 'pcap=0',
+ 'profiler=0',
+ 'videocapture=0',
+ '[%s]' % runner_type
+ ]
config_data.extend('%s=%s' % (k, v) for k, v in body.iteritems())
config.write(''.join('%s\n' % l for l in config_data))
config.flush()
diff --git a/build/android/test_runner.py b/build/android/test_runner.py
index 049b1ab..e92f851 100755
--- a/build/android/test_runner.py
+++ b/build/android/test_runner.py
@@ -123,39 +123,39 @@ def AddRemoteDeviceOptions(parser):
group = parser.add_argument_group('Remote Device Options')
group.add_argument('--trigger', default='',
- help=('Only triggers the test if set. Stores test_run_id '
- 'in given file path. '))
+ help=('Only triggers the test if set. Stores test_run_id '
+ 'in given file path. '))
group.add_argument('--collect', default='',
- help=('Only collects the test results if set. '
- 'Gets test_run_id from given file path.'))
+ help=('Only collects the test results if set. '
+ 'Gets test_run_id from given file path.'))
group.add_argument('--remote-device', default='',
- help=('Device type to run test on.'))
+ help='Device type to run test on.')
group.add_argument('--remote-device-os', default='',
- help=('OS to have on the device.'))
+ help='OS to have on the device.')
group.add_argument('--results-path', default='',
- help=('File path to download results to.'))
+ help='File path to download results to.')
group.add_argument('--api-protocol',
- help=('HTTP protocol to use. (http or https)'))
- group.add_argument('--api-address', help=('Address to send HTTP requests.'))
- group.add_argument('--api-port', help=('Port to send HTTP requests to.'))
+ help='HTTP protocol to use. (http or https)')
+ group.add_argument('--api-address', help='Address to send HTTP requests.')
+ group.add_argument('--api-port', help='Port to send HTTP requests to.')
group.add_argument('--runner-type', default='',
- help=('Type of test to run as.'))
+ help='Type of test to run as.')
group.add_argument('--runner-package', default='',
- help=('Package name of test.'))
+ help='Package name of test.')
group.add_argument('--apk-under-test', default='apks/Chrome.apk',
- help=('APK to run tests on.'))
+ help='APK to run tests on.')
api_secret_group = group.add_mutually_exclusive_group()
api_secret_group.add_argument('--api-secret', default='',
- help=('API secret for remote devices.'))
+ help='API secret for remote devices.')
api_secret_group.add_argument('--api-secret-file', default='',
- help=('Path to file that contains API secret.'))
+ help='Path to file that contains API secret.')
api_key_group = group.add_mutually_exclusive_group()
api_key_group.add_argument('--api-key', default='',
- help=('API key for remote devices.'))
+ help='API key for remote devices.')
api_key_group.add_argument('--api-key-file', default='',
- help=('Path to file that contains API key.'))
+ help='Path to file that contains API key.')
def AddDeviceOptions(parser):
diff --git a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
index 42befe5..d476cbc 100644
--- a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
+++ b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestActivity.java
@@ -7,6 +7,7 @@ package org.chromium.native_test;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
+import android.os.Environment;
import android.os.Handler;
import android.util.Log;
@@ -16,6 +17,8 @@ import org.chromium.base.PowerMonitor;
import org.chromium.base.ResourceExtractor;
import org.chromium.base.library_loader.NativeLibraries;
+import java.io.File;
+
/**
* Android's NativeActivity is mostly useful for pure-native code.
* Our tests need to go up to our own java classes, which is not possible using
@@ -75,7 +78,16 @@ public class ChromeNativeTestActivity extends Activity {
if (commandLineFlags == null) commandLineFlags = "";
String commandLineFilePath = getIntent().getStringExtra(EXTRA_COMMAND_LINE_FILE);
- if (commandLineFilePath == null) commandLineFilePath = "";
+ if (commandLineFilePath == null) {
+ commandLineFilePath = "";
+ } else {
+ File commandLineFile = new File(commandLineFilePath);
+ if (!commandLineFile.isAbsolute()) {
+ commandLineFilePath = Environment.getExternalStorageDirectory() + "/"
+ + commandLineFilePath;
+ }
+ Log.i(TAG, "command line file path: " + commandLineFilePath);
+ }
// This directory is used by build/android/pylib/test_package_apk.py.
nativeRunTests(commandLineFlags, commandLineFilePath, getFilesDir().getAbsolutePath(),
diff --git a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java
index a5cf485..43135cc 100644
--- a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java
+++ b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java
@@ -27,9 +27,13 @@ import java.util.regex.Pattern;
* An Instrumentation that runs tests based on ChromeNativeTestActivity.
*/
public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
+ // TODO(jbudorick): Remove this extra when b/18981674 is fixed.
+ public static final String EXTRA_ONLY_OUTPUT_FAILURES =
+ "org.chromium.native_test.ChromeNativeTestInstrumentationTestRunner."
+ + "OnlyOutputFailures";
private static final String TAG = "ChromeNativeTestInstrumentationTestRunner";
- private static final Pattern RE_TEST_OUTPUT = Pattern.compile("\\[ *([^ ]*) *\\] ?([^ ]*) .*");
+ private static final Pattern RE_TEST_OUTPUT = Pattern.compile("\\[ *([^ ]*) *\\] ?([^ ]+) .*");
private static interface ResultsBundleGenerator {
public Bundle generate(Map<String, TestResult> rawResults);
@@ -39,6 +43,7 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
private String mCommandLineFlags;
private Bundle mLogBundle;
private ResultsBundleGenerator mBundleGenerator;
+ private boolean mOnlyOutputFailures;
@Override
public void onCreate(Bundle arguments) {
@@ -46,6 +51,7 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
mCommandLineFlags = arguments.getString(ChromeNativeTestActivity.EXTRA_COMMAND_LINE_FLAGS);
mLogBundle = new Bundle();
mBundleGenerator = new RobotiumBundleGenerator();
+ mOnlyOutputFailures = arguments.containsKey(EXTRA_ONLY_OUTPUT_FAILURES);
start();
}
@@ -117,17 +123,27 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
for (String l = r.readLine(); l != null && !l.equals("<<ScopedMainEntryLogger");
l = r.readLine()) {
Matcher m = RE_TEST_OUTPUT.matcher(l);
+ boolean isFailure = false;
if (m.matches()) {
if (m.group(1).equals("RUN")) {
results.put(m.group(2), TestResult.UNKNOWN);
} else if (m.group(1).equals("FAILED")) {
results.put(m.group(2), TestResult.FAILED);
+ isFailure = true;
+ mLogBundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT, l + "\n");
+ sendStatus(0, mLogBundle);
} else if (m.group(1).equals("OK")) {
results.put(m.group(2), TestResult.PASSED);
}
}
- mLogBundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT, l + "\n");
- sendStatus(0, mLogBundle);
+
+ // TODO(jbudorick): mOnlyOutputFailures is a workaround for b/18981674. Remove it
+ // once that issue is fixed.
+ if (!mOnlyOutputFailures || isFailure) {
+ mLogBundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT, l + "\n");
+ sendStatus(0, mLogBundle);
+ }
+ Log.i(TAG, l);
}
} catch (InterruptedException e) {
Log.e(TAG, "Interrupted while waiting for FIFO file creation: " + e.toString());
@@ -168,6 +184,9 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
++testsPassed;
break;
case FAILED:
+ // TODO(jbudorick): Remove this log message once AMP execution and
+ // results handling has been stabilized.
+ Log.d(TAG, "FAILED: " + entry.getKey());
++testsFailed;
break;
default:
@@ -178,11 +197,12 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation {
}
StringBuilder resultBuilder = new StringBuilder();
- resultBuilder.append("\nOK (" + Integer.toString(testsPassed) + " tests)");
if (testsFailed > 0) {
resultBuilder.append(
"\nFAILURES!!! Tests run: " + Integer.toString(rawResults.size())
+ ", Failures: " + Integer.toString(testsFailed) + ", Errors: 0");
+ } else {
+ resultBuilder.append("\nOK (" + Integer.toString(testsPassed) + " tests)");
}
resultsBundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT,
resultBuilder.toString());