Comments (4)
I'm also hitting this issue. The problem is that --no-external
incorrectly filters out files when they can be accessed via symbolic links.
Here is a simple script that reproduces the problem, in a format that should be easy to adapt for the regression tests, @henry2cox:
#!/bin/bash
set -xe
mkdir -p /tmp/bug
cd /tmp/bug
rm -Rf src src2
mkdir src
ln -s src src2
echo 'int a (int x) { return x + 1; }' > src/a.c
echo 'int b (int x) { return x + 2; }' > src/b.c
gcc -c --coverage src/a.c -o src/a.o
gcc -c --coverage src2/b.c -o src/b.o
lcov -o out -c -i --no-external -d src
You would expect that the call to lcov -c -i
records the coverage of both a.c
and b.c
, but --no-external
is incorrectly dropping b.c
:
+ lcov -o out -c -i --no-external -d src
Capturing coverage data from src
geninfo cmd: '/path/to/geninfo src --output-filename out --initial --no-external'
Found gcov version: 12.3.0
Using intermediate gcov format
geninfo: WARNING: (usage) branch filter enabled but branch coverage not enabled
(use "geninfo --ignore-errors usage,usage ..." to suppress this warning)
Recording 'internal' directories:
/tmp/bug/src
Writing temporary data to /tmp/geninfo_datHcWj
Scanning src for .gcno files ...
Found 2 graph files in src
using: chunkSize: 1, nchunks:2, intervalLength:0
Dropping 'external' file '/tmp/bug/src2/b.c'
Finished processing 2 GCNO files
Excluded data for 1 file due to include/exclude options
Apply filtering..
Finished filter file processing
Finished .info-file creation
Summary coverage rate:
source files: 1
lines.......: 0.0% (0 of 1 line)
functions...: 0.0% (0 of 1 function)
Message summary:
1 warning message:
usage: 1
And this is probably happening because /tmp/bug/src/b.gcno
refers to the path that uses symbolic links:
$ strings /tmp/bug/src/b.gcno
oncg*32B
/tmp/bug
src2/b.c
src2/b.c
src2/b.c
and because lcov --no-external
doesn't canonicalize file path names (see realpath(1)
) before comparing them.
from lcov.
Hi -
Thanks for the testcase.
I actually think there is about an even chance that a user would want to include symlinked out-of-tree files and directories, or would want to exclude them - and an even better chance that (s)he would want to include some and exclude others.
In any case, I updated the man pages to note that --no-external
is a bit of a blunt instrument, and that --include
, --exclude
can provide finer-grained control when --no-external
fails to do what you want - and also added an option (really, re-used an existing option) to select how symlinked directories are treated.
I will push the update shortly.
Henry
from lcov.
fix pushed in 2efc0fb
from lcov.
Closing this issue as I believe it is fixed in commit listed above.
If there is still a problem, please reopen this issue or file a new one.
Please include a testcase and/or recipe to reproduce the problem.
Henry
from lcov.
Related Issues (20)
- Duplicate folder structure (--prefix does not help) HOT 2
- gcov error:std::bad_alloc HOT 8
- lcov fails with gcc 14 HOT 1
- perl2lcov: unexpected data type 'time' HOT 6
- genhtml package removed from PyPI HOT 1
- RPM 2.1-1 does not install on Rocky Linux 8 or Centos7 HOT 1
- Unable to generate gcda file for cc_library_shared module HOT 4
- inconsistent branch coverage summary HOT 1
- Build of example fails on Ubuntu 22.04.4 LTS due to Makefile using SHELL of /bin/sh (softlink to /bin/dash) HOT 1
- Option geninfo_external from a user-provided lcovrc file gets ignored HOT 4
- Incorrect #line directives cause Perl warnings HOT 1
- lcov fails with "(inconsistent) mismatched end line" for googletest code HOT 1
- lcov --no-external behaves incorrectly with 2 or more -d
- path mismatch between diff-file and baseline/current info/dat file HOT 23
- Problems with differential reporting HOT 4
- Possible root causes of geninfo 'mismatched end line for main at start.c' ? HOT 7
- gitdiff should strip a/ b/ prefixes from --- +++ lines HOT 6
- Differences between `coverage lcov` and `py2lcov` for consideration HOT 3
- I see functions as uncovered although they are covered HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lcov.