android / android/android-test

CoverageFile generated inside of /sdcard/googletest/internal_use on Android 11

Open
#1,158 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
342
Avg merge
11h 29m
Merged PRs (30d)
2

Description

### Description

When running instrument test with `-e coverageFile /sdcard/coverage.ec` options in adb command, coverage file has generated inside of `/sdcard/googletest/internal_use,` instead of desired path `/sdcard/coverage.ec`

* what I did before testing
* install test-services apk, version 1.4.1-alpha03 (from [maven.google.com](https://maven.google.com/web/index.html?#androidx.test.services:test-services:1.4.1-alpha03))
* adb shell appops set androidx.test.services MANAGE_EXTERNAL_STORAGE allow (according to #1141)

* test adb command: `adb shell am instrument -w -r -e coverage true -e useTestStorageService true -e coverageFile /sdcard/coverage.ec com.example.android.testing.androidjunitrunnersample.test/androidx.test.runner.AndroidJUnitRunner`

* Related logcat
```
2021-10-13 15:33:09.942 28175-28199/com.example.android.testing.androidjunitrunnersample D/TestExecutor: Adding listener androidx.test.internal.runner.listener.CoverageListener
2021-10-13 15:33:19.462 28175-28199/com.example.android.testing.androidjunitrunnersample D/InstrumentationCoverageReporter: Test service is available. Moving the coverage data file to be managed by the storage service.
2021-10-13 15:33:19.462 28175-28199/com.example.android.testing.androidjunitrunnersample D/InstrumentationCoverageReporter: Moving coverage file [/data/user/0/com.example.android.testing.androidjunitrunnersample/files/coverage.ec] to the internal test storage [/sdcard/coverage.ec].
2021-10-13 15:33:19.474 28175-28199/com.example.android.testing.androidjunitrunnersample D/InstrumentationCoverageReporter: Coverage file was generated to /sdcard/coverage.ec
```

### Steps to Reproduce
1. Run instrument test with `-e coverageFile /sdcard/coverage.ec` options
2. check file is exists (adb shell ls /sdcard/ | grep coverage.ec)

### Expected Results
* coverage.ec file should found in /sdcard/

### Actual Results
* coverage.ec file can't found in /sdcard/, but found on /sdcard/googletest/internal_use/sdcard
```
*** android % adb shell ls /sdcard/ | grep coverage.ec
*** android % adb shell ls /sdcard/googletest/internal_use/sdcard | grep coverage.ec
coverage.ec
```

### AndroidX Test and Android OS Versions
* 1.4.0, 1.4.1-alpha03
* Galaxy S21+ Ultra (Android 11)

### Link to a public git repo demonstrating the problem:
* Clone sample (https://github.com/android/testing-samples/tree/main/runner/AndroidJunitRunnerSample) and add `buildTypes.debug.testCoverageEnabled true` in `app/build.gradle`

Contributor guide

Open the contributing guide

Research direction

Start with the InstrumentationCoverageReporter entry point identified in the logcat and reproduce the issue using the AndroidJunitRunnerSample and the provided adb command. Trace how the coverageFile argument is moved through the test storage service, especially the /sdcard path handling. Done means the file is created at /sdcard/coverage.ec rather than under googletest/internal_use/sdcard, with a regression test covering the path.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.