From 4dae8e15dd6997d6a78eb01b96eb0151191be3c5 Mon Sep 17 00:00:00 2001 From: neewy Date: Mon, 11 Mar 2019 15:54:47 +0300 Subject: [PATCH 1/2] Remove function signature lines that are never report as hit Signed-off-by: neewy --- .jenkinsci-new/build.groovy | 3 +- .../helpers/remove-function-lines.py | 48 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 .jenkinsci-new/helpers/remove-function-lines.py diff --git a/.jenkinsci-new/build.groovy b/.jenkinsci-new/build.groovy index 8ac859cf60..7dbe0f1bfb 100644 --- a/.jenkinsci-new/build.groovy +++ b/.jenkinsci-new/build.groovy @@ -58,7 +58,8 @@ def initialCoverage(String buildDir) { def postCoverage(buildDir, String cobertura_bin) { sh "cmake --build ${buildDir} --target coverage.info" - sh "python ${cobertura_bin} ${buildDir}/reports/coverage.info -o ${buildDir}/reports/coverage.xml" + sh "python ${sourceTreeDir}/.jenkinsci-new/helpers/remove-function-lines.py ${buildDir}/reports/coverage.info ${buildDir}/reports/cleaned-coverage.info" + sh "python ${cobertura_bin} ${buildDir}/reports/cleaned-coverage.info -o ${buildDir}/reports/coverage.xml" cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: "**/${buildDir}/reports/coverage.xml", conditionalCoverageTargets: '75, 50, 0', failUnhealthy: false, failUnstable: false, lineCoverageTargets: '75, 50, 0', maxNumberOfBuilds: 50, diff --git a/.jenkinsci-new/helpers/remove-function-lines.py b/.jenkinsci-new/helpers/remove-function-lines.py new file mode 100644 index 0000000000..b691f91623 --- /dev/null +++ b/.jenkinsci-new/helpers/remove-function-lines.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 + +# https://github.com/JeremyAgost/lcov-llvm-function-mishit-filter +# https://github.com/linux-test-project/lcov/issues/30 + +import argparse +import subprocess + +def demangle(symbol): + p = subprocess.Popen(['c++filt','-n'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) + return p.communicate(input=symbol.encode())[0].decode().strip() + +def filter_lcov(lines, verbose=False): + defs, srcfile = {}, '' + for line in lines: + if line.startswith('SF:'): + defs = {} + srcfile = line[3:].strip() + elif line.startswith('end_of_record'): + defs = {} + elif line.startswith('FN:'): + lineno, symbol = line[3:].split(',') + if verbose: + defs[lineno] = demangle(symbol) + else: + defs[lineno] = True + elif line.startswith('DA:'): + lineno = line[3:].split(',')[0] + if lineno in defs: + if verbose: + printf('Ignoring: {srcfile}:{lineno}:{defs[lineno]}') + continue + yield line + +def main(): + p = argparse.ArgumentParser() + p.add_argument('input', type=str) + p.add_argument('output', type=str) + p.add_argument('--verbose', '-v', action='store_true') + args = p.parse_args() + with open(args.input, 'r') as fin: + lines = list(fin) + with open(args.output, 'w') as fout: + for line in filter_lcov(lines, verbose=args.verbose): + fout.write(line) + +if __name__ == '__main__': + main() From c785003e6c8a1163eac58bcd1cef457498adf8db Mon Sep 17 00:00:00 2001 From: neewy Date: Mon, 11 Mar 2019 16:42:16 +0300 Subject: [PATCH 2/2] Fix python script path Signed-off-by: neewy --- .jenkinsci-new/build.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jenkinsci-new/build.groovy b/.jenkinsci-new/build.groovy index 7dbe0f1bfb..9dac9e2af5 100644 --- a/.jenkinsci-new/build.groovy +++ b/.jenkinsci-new/build.groovy @@ -58,7 +58,7 @@ def initialCoverage(String buildDir) { def postCoverage(buildDir, String cobertura_bin) { sh "cmake --build ${buildDir} --target coverage.info" - sh "python ${sourceTreeDir}/.jenkinsci-new/helpers/remove-function-lines.py ${buildDir}/reports/coverage.info ${buildDir}/reports/cleaned-coverage.info" + sh "python .jenkinsci-new/helpers/remove-function-lines.py ${buildDir}/reports/coverage.info ${buildDir}/reports/cleaned-coverage.info" sh "python ${cobertura_bin} ${buildDir}/reports/cleaned-coverage.info -o ${buildDir}/reports/coverage.xml" cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: "**/${buildDir}/reports/coverage.xml", conditionalCoverageTargets: '75, 50, 0',