aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-07-09 03:14:08 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-07-09 03:14:08 +0000
commita5af93f792d1002a536f64703da9a614960a4a40 (patch)
treec7e4af4847da2618c6f4c59534de554d186390f2
parentf6e88600d0a86191e8db80b256e70c59899b9332 (diff)
parentfbbc4918392dc5bdb9f303178baf6824d5f3af43 (diff)
downloadtradefederation-android10-mainline-release.tar.gz
Snap for 5713174 from fbbc4918392dc5bdb9f303178baf6824d5f3af43 to qt-aml-releaseandroid-mainline-10.0.0_r3android-mainline-10.0.0_r1android10-mainline-release
Change-Id: Ib7d6ccd39439471c4116c95a6f2cbd3ec9f743c6
-rw-r--r--src/com/android/tradefed/testtype/NativeCodeCoverageListener.java4
-rw-r--r--tests/src/com/android/tradefed/testtype/NativeCodeCoverageListenerTest.java9
2 files changed, 9 insertions, 4 deletions
diff --git a/src/com/android/tradefed/testtype/NativeCodeCoverageListener.java b/src/com/android/tradefed/testtype/NativeCodeCoverageListener.java
index 976c71e54..dca83dbb9 100644
--- a/src/com/android/tradefed/testtype/NativeCodeCoverageListener.java
+++ b/src/com/android/tradefed/testtype/NativeCodeCoverageListener.java
@@ -44,7 +44,7 @@ import java.util.HashMap;
*/
public final class NativeCodeCoverageListener extends ResultForwarder {
- private static final String NATIVE_COVERAGE_DEVICE_PATH = "/data/misc/trace";
+ private static final String NATIVE_COVERAGE_DEVICE_PATH = "/data/misc/trace/proc/self/cwd/out";
private static final String COVERAGE_FILE_LIST_COMMAND =
String.format("find %s -name '*.gcda'", NATIVE_COVERAGE_DEVICE_PATH);
@@ -72,6 +72,8 @@ public final class NativeCodeCoverageListener extends ResultForwarder {
try {
localDir = FileUtil.createTempDir("native_coverage");
+ // Enable abd root on the device, otherwise the list command will fail.
+ verify(mDevice.enableAdbRoot(), "Failed to enable adb root.");
String findResult = mDevice.executeShellCommand(COVERAGE_FILE_LIST_COMMAND);
Path devicePathRoot = Paths.get(NATIVE_COVERAGE_DEVICE_PATH);
diff --git a/tests/src/com/android/tradefed/testtype/NativeCodeCoverageListenerTest.java b/tests/src/com/android/tradefed/testtype/NativeCodeCoverageListenerTest.java
index 11b225022..98d88ebbf 100644
--- a/tests/src/com/android/tradefed/testtype/NativeCodeCoverageListenerTest.java
+++ b/tests/src/com/android/tradefed/testtype/NativeCodeCoverageListenerTest.java
@@ -91,10 +91,12 @@ public class NativeCodeCoverageListenerTest {
@Test
public void test_logsCoverageZip() throws DeviceNotAvailableException, IOException {
// Setup mocks to write the coverage measurement to the file.
+ doReturn(true).when(mMockDevice).enableAdbRoot();
doReturn(
new StringJoiner("\n")
- .add("/data/misc/trace/path/to/coverage.gcda")
- .add("/data/misc/trace/path/to/.hidden/coverage2.gcda")
+ .add("/data/misc/trace/proc/self/cwd/out/path/to/coverage.gcda")
+ .add(
+ "/data/misc/trace/proc/self/cwd/out/path/to/.hidden/coverage2.gcda")
.toString())
.when(mMockDevice)
.executeShellCommand(anyString());
@@ -160,7 +162,8 @@ public class NativeCodeCoverageListenerTest {
@Test
public void testFailure_unableToPullFile() throws DeviceNotAvailableException {
// Setup mocks.
- doReturn("/data/misc/trace/some/path/to/coverage.gcda\n")
+ doReturn(true).when(mMockDevice).enableAdbRoot();
+ doReturn("/data/misc/trace/proc/self/cwd/out/some/path/to/coverage.gcda\n")
.when(mMockDevice)
.executeShellCommand(anyString());
doReturn(false).when(mMockDevice).pullFile(anyString(), any());