Commit de004fb2 authored by Behdad Bakhshinategh's avatar Behdad Bakhshinategh Committed by Commit Bot

Revert "Update device directories to allow gtests to run on R"

This reverts commit 1ea229b3.

Reason for revert: https://bugs.chromium.org/p/chromium/issues/detail?id=1097957

Original change's description:
> Update device directories to allow gtests to run on R
> 
> The external storage root path is currently used as the location to
> write test runner output, but this path is no longer writable by apps
> on Android R. Update to use DeviceUtils' GetAppWritablePath() instead
> of GetExternalStoragePath() to support test execution on this version.
> 
> Bug: 1094062
> Change-Id: Ie90c46d4ed0c3e421d83c8d0ae8edee047f2dcac
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2242845
> Reviewed-by: Richard Coles <torne@chromium.org>
> Reviewed-by: John Budorick <jbudorick@chromium.org>
> Commit-Queue: Mike Wittman <wittman@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#780836}

TBR=wittman@chromium.org,torne@chromium.org,jbudorick@chromium.org,hypan@google.com

Change-Id: I39e2858ca7932ff5d79b6ed45391564410caa437
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1094062
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2258118Reviewed-by: default avatarBehdad Bakhshinategh <behdadb@chromium.org>
Commit-Queue: Behdad Bakhshinategh <behdadb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#780910}
parent bb9c2e17
......@@ -4,8 +4,6 @@
package org.chromium.base.test.util;
import android.os.Bundle;
import org.junit.Assert;
import org.chromium.base.PathUtils;
......@@ -18,19 +16,7 @@ import org.chromium.base.annotations.MainDex;
*/
@MainDex
public class UrlUtils {
public static final String EXTRA_ROOT_DIRECTORY =
"org.chromium.base.test.util.UrlUtils.RootDirectory";
private static final String DATA_DIR = "/chrome/test/data/";
private static String sRootDirectory = PathUtils.getExternalStorageDirectory();
/**
* Sets the root directory from state in the bundle.
* @param bundle Bundle containing the intent extras.
*/
public static void setPathsFromBundle(Bundle bundle) {
String rootDirectory = bundle.getString(EXTRA_ROOT_DIRECTORY);
if (rootDirectory != null) sRootDirectory = rootDirectory;
}
/**
* Construct the full path of a test data file.
......@@ -57,7 +43,7 @@ public class UrlUtils {
@CalledByNative
public static String getIsolatedTestRoot() {
try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) {
return sRootDirectory + "/chromium_tests_root";
return PathUtils.getExternalStorageDirectory() + "/chromium_tests_root";
}
}
......
......@@ -40,7 +40,6 @@ _EXTRA_COMMAND_LINE_FLAGS = (
'org.chromium.native_test.NativeTest.CommandLineFlags')
_EXTRA_COVERAGE_DEVICE_FILE = (
'org.chromium.native_test.NativeTest.CoverageDeviceFile')
_EXTRA_ROOT_DIRECTORY = 'org.chromium.base.test.util.UrlUtils.RootDirectory'
_EXTRA_STDOUT_FILE = (
'org.chromium.native_test.NativeTestInstrumentationTestRunner'
'.StdoutFile')
......@@ -137,7 +136,7 @@ def _GetDeviceCoverageDir(device):
Returns:
The directory path on the device.
"""
return posixpath.join(device.GetAppWritablePath(), 'chrome', 'test',
return posixpath.join(device.GetExternalStoragePath(), 'chrome', 'test',
'coverage', 'profraw')
......@@ -180,7 +179,8 @@ class _ApkDelegate(object):
def GetTestDataRoot(self, device):
# pylint: disable=no-self-use
return posixpath.join(device.GetAppWritablePath(), 'chromium_tests_root')
return posixpath.join(device.GetExternalStoragePath(),
'chromium_tests_root')
def Install(self, device):
if self._test_apk_incremental_install_json:
......@@ -200,8 +200,6 @@ class _ApkDelegate(object):
extras = dict(self._extras)
device_api = device.build_version_sdk
extras[_EXTRA_ROOT_DIRECTORY] = device.GetAppWritablePath()
if self._coverage_dir and device_api >= version_codes.LOLLIPOP:
device_coverage_dir = _GetDeviceCoverageDir(device)
extras[_EXTRA_COVERAGE_DEVICE_FILE] = _GetLLVMProfilePath(
......@@ -238,7 +236,7 @@ class _ApkDelegate(object):
# pylint: enable=redefined-variable-type
stdout_file = device_temp_file.DeviceTempFile(
device.adb, dir=device.GetAppWritablePath(), suffix='.gtest_out')
device.adb, dir=device.GetExternalStoragePath(), suffix='.gtest_out')
extras[_EXTRA_STDOUT_FILE] = stdout_file.name
if self._wait_for_java_debugger:
......@@ -346,7 +344,8 @@ class _ExeDelegate(object):
try:
gcov_strip_depth = os.environ['NATIVE_COVERAGE_DEPTH_STRIP']
env['GCOV_PREFIX'] = '%s/gcov' % device.GetAppWritablePath()
external = device.GetExternalStoragePath()
env['GCOV_PREFIX'] = '%s/gcov' % external
env['GCOV_PREFIX_STRIP'] = gcov_strip_depth
except (device_errors.CommandFailedError, KeyError):
pass
......
......@@ -18,7 +18,6 @@ import android.os.Process;
import android.util.SparseArray;
import org.chromium.base.Log;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.test.reporter.TestStatusReceiver;
import java.io.BufferedReader;
......@@ -75,8 +74,6 @@ public class NativeTestInstrumentationTestRunner extends Instrumentation {
if (mNativeTestActivity == null) mNativeTestActivity = DEFAULT_NATIVE_TEST_ACTIVITY;
mTransparentArguments.remove(EXTRA_NATIVE_TEST_ACTIVITY);
UrlUtils.setPathsFromBundle(arguments);
String shardNanoTimeout = arguments.getString(EXTRA_SHARD_NANO_TIMEOUT);
if (shardNanoTimeout != null) mShardNanoTimeout = Long.parseLong(shardNanoTimeout);
mTransparentArguments.remove(EXTRA_SHARD_NANO_TIMEOUT);
......
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