문제

Is it possible to exclude certain functions or lines of code from the gcov coverage analysis. My code contains certain functions that are used for debugging, and are not exercised as part of my test suite. Such functions reduce the coverage percentage reported by gcov. I would like to exclude these functions from the results. If it is not possible via gcov, perhaps it is possible via lcov, but I was not able to figure it out. Your help is appreciated.

도움이 되었습니까?

해결책

I filter out certain source files by running the output of lcov --capture through a simple awk script. The output of lcov --capture has a very simple format and the awk script below filters out source files matching file_pattern. I think it is possible to adapt the script to make it filter functions instead of file names.

BEGIN {
        record=""
}

/^SF/ {
        if ( match ($0, "file_pattern" ) ) {
            doprint = 0
        } else {
            doprint = 1
        }
}

/^end_of_record$/ {
        if ( doprint ) {
            print record $0
        }
        record = ""
        next
}

{
    record=record $0 "\n"
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top