linux-test-project / lcov

LCOV
GNU General Public License v2.0
866 stars 234 forks source link

lcov --no-external behaves incorrectly with 2 or more -d #311

Closed cesaro closed 2 days ago

cesaro commented 3 days ago

A call to

lcov -c -i --no-external -d a/ -d b/ -o out

should generate a trace where the cover points of C files in either a/ or b/ are in out, but currently it discards those in b/.

The following script reproduces the issue:

#!/bin/bash
set -xe

mkdir -p /tmp/bug
cd /tmp/bug

rm -Rf a b out
mkdir a b

echo 'int a (int x) { return x + 1; }' > a/a.c
echo 'int b (int x) { return x + 2;}' > b/b.c

gcc -c --coverage a/a.c -o a/a.o
gcc -c --coverage b/b.c -o b/b.o

lcov -o out -c -i --no-external -d a -d b

The call to lcov at the end explicitly logs that only /tmp/bug/a is an internal directory:

+ lcov -o out -c -i --no-external -d a -d b
Capturing coverage data from a b
geninfo cmd: '/path/to/geninfo a b --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/a
Writing temporary data to /tmp/geninfo_dat9L2R
Scanning a for .gcno files ...
Found 1 graph files in a
Scanning b for .gcno files ...
Found 1 graph files in b
using: chunkSize: 1, nchunks:2, intervalLength:0
Dropping 'external' file '/tmp/bug/b/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

Note that lcov is calling geninfo with the two directories a and b, but the geninfo(1) man page never says that passing more than one folder is possible. geninfo -h does say that passing multiple folder is possible.