document coverage workflow
- Dominant language
- No language data
- Stars
- 2.3k
- Forks
- 310
- PR merge metrics
- No merged PRs in 30d
Description
#### Expected scenario:
Compile a *.so with ndk and integrate it into the apk. Expect to generate a .gcda file when running the app on Android, and then analyze the code coverage of c++.
#### NDK version: ndk-r10d
#### Ndk compile *.so operation:
Set the compile link parameters as follows:
```
// Android.mk
LOCAL_CFLAGS += -fprofile-arcs -ftest-coverage
LOCAL_CXXFLAGS += -fprofile-arcs -ftest-coverage
LOCAL_LDFLAGS += -lgcov -lm -llog -landroid -lgcc
```
Set the path where .gcda is stored (the path can be written):
```
// Test.cc
Setenv("GCOV_PREFIX", "/data/local/tmp", 1);
Setenv("GCOV_PREFIX_STRIP", "100", 1);
```
The .gcno file is generated normally when compiling and generating so.
Then I integrated *.so into the Android apk.
There is information on the Internet that the program should be completed normally and cannot be killed. So I force __gcov_flush() to be called, and I make sure this function is called.
#### The end result is that the .gcda file cannot be generated after the program is run on an Android phone.
#### So, does ndk support code coverage? If it is supported, where is the problem?
I have nowhere else to find useful information. Looking forward to answering, thank you.
Contributor guide
Research direction
Start by reviewing the Android.mk coverage flags and the Test.cc settings for GCOV_PREFIX, GCOV_PREFIX_STRIP, and __gcov_flush under NDK r10d. Reproduce the APK run on an Android phone and check whether the expected .gcda file is created in /data/local/tmp; done means the file is generated and can be analyzed for C++ coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, cpp
- Domain
- mobile-dev, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100