Skip to content

document coverage workflow #1120

@kong1z

Description

@kong1z

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions